Skip to contentSkip to conversation

phy: tegra: xusb: t210: add usb3 port fake support

PATCH Superseded Nagarjuna Kristam 3 participants 14 messages Mar 11, 2019 – May 8, 2019

Subsystems (5)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/8 phy: tegra: xusb: t210: add usb3 port fake support

On Tegra210, usb2 only otg/peripheral ports dont work in device mode. They need an assosciated usb3 port to work in device mode. Identify an unused usb3 port and assign it as a fake USB3 port to USB2 only port whose mode is otg/peripheral

Based on work by BH Hsieh <[email protected]>.

---
 drivers/phy/tegra/xusb-tegra210.c | 40 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 29 ++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.h          |  6 ++++++
 3 files changed, 75 insertions(+)
drivers/phy/tegra/xusb-tegra210.c +40 -0
index 4beebcc..48478bc4 100644
@@ -58,6 +58,7 @@
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_SHIFT(x) ((x) * 5)
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(x) (0x7 << ((x) * 5))
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(x, v) (((v) & 0x7) << ((x) * 5))
+#define XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED 0x7
 
 #define XUSB_PADCTL_ELPG_PROGRAM1 0x024
 #define XUSB_PADCTL_ELPG_PROGRAM1_AUX_MUX_LP0_VCORE_DOWN (1 << 31)
@@ -952,6 +953,15 @@ static int tegra210_usb2_phy_power_on(struct phy *phy)
 
 	priv = to_tegra210_xusb_padctl(padctl);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(
+					port->usb3_port_fake, index);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
 	value &= ~((XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_MASK <<
 		    XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT) |
@@ -1086,6 +1096,15 @@ static int tegra210_usb2_phy_power_off(struct phy *phy)
 
 	mutex_lock(&padctl->lock);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(port->usb3_port_fake,
+					XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	if (WARN_ON(pad->enable == 0))
 		goto out;
 
@@ -1784,6 +1803,27 @@ static const struct tegra_xusb_pad_soc * const tegra210_pads[] = {
 
 static int tegra210_usb2_port_enable(struct tegra_xusb_port *port)
 {
+	struct tegra_xusb_usb2_port *usb2 = to_usb2_port(port);
+	struct tegra_xusb_padctl *padctl = port->padctl;
+
+	/* Disable usb3_port_fake usage by default and assign if needed */
+	usb2->usb3_port_fake = -1;
+	if (usb2 && (usb2->mode == USB_DR_MODE_OTG ||
+		    usb2->mode == USB_DR_MODE_PERIPHERAL)) {
+		if (!tegra_xusb_usb3_port_has_companion(padctl, port->index)) {
+			int fake = tegra_xusb_find_unused_usb3_port(padctl);
+
+			if (fake >= 0) {
+				dev_dbg(&port->dev, "Found unused usb3 port: %d\n",
+					 fake);
+				usb2->usb3_port_fake = fake;
+			} else {
+				dev_err(&port->dev, "usb2-%u has neither a companion nor an unused usb3 port to fake it\n",
+					port->index);
+				return -ENODEV;
+			}
+		}
+	}
 	return 0;
 }
 
drivers/phy/tegra/xusb.c +29 -0
index c6178a0..e89746d 100644
@@ -799,6 +799,35 @@ static void __tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl)
 	}
 }
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+						       unsigned int index)
+{
+	unsigned int i;
+	struct tegra_xusb_usb3_port *usb3;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		usb3 = tegra_xusb_find_usb3_port(padctl, i);
+		if (usb3 && usb3->port == index)
+			return true;
+	}
+
+	return false;
+}
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl)
+{
+	struct device_node *np;
+	unsigned int i;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		np = tegra_xusb_find_port_node(padctl, "usb3", i);
+		if (!np || !of_device_is_available(np))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
 static int tegra_xusb_setup_ports(struct tegra_xusb_padctl *padctl)
 {
 	struct tegra_xusb_port *port;
drivers/phy/tegra/xusb.h +6 -0
index 17cc8dc..b263165 100644
@@ -274,6 +274,7 @@ struct tegra_xusb_usb2_port {
 	struct regulator *supply;
 	bool internal;
 	enum usb_dr_mode mode;
+	int usb3_port_fake;
 };
 
 static inline struct tegra_xusb_usb2_port *
@@ -413,6 +414,11 @@ struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
 					     const char *name,
 					     unsigned int index);
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+					unsigned int index);
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl);
+
 #if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
 extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
 #endif
#1 lore raw

PATCH v2 3/8 phy: tegra: xusb: t210: add vbus override support

Tegra XUSB device control driver needs to control vbus override during its operations, add API for the support

---
 drivers/phy/tegra/xusb-tegra210.c | 61 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 28 ++++++++++++++++--
 drivers/phy/tegra/xusb.h          |  2 ++
 include/linux/phy/tegra/xusb.h    |  6 ++--
 4 files changed, 92 insertions(+), 5 deletions(-)
drivers/phy/tegra/xusb-tegra210.c +61 -0
index 48478bc4..be1a870 100644
@@ -73,6 +73,10 @@
 #define XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(x) (1 << (1 + (x)))
 #define XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(x) (1 << (8 + (x)))
 
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(x) (0x080 + (x) * 0x40)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP (1 << 18)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN (1 << 22)
+
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL1(x) (0x084 + (x) * 0x40)
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_SHIFT 7
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_MASK 0x3
@@ -235,6 +239,12 @@
 #define XUSB_PADCTL_UPHY_USB3_PADX_ECTL6(x) (0xa74 + (x) * 0x40)
 #define XUSB_PADCTL_UPHY_USB3_PAD_ECTL6_RX_EQ_CTRL_H_VAL 0xfcf01368
 
+#define XUSB_PADCTL_USB2_VBUS_ID 0xc60
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON (1 << 14)
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT 18
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK 0xf
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING 8
+
 struct tegra210_xusb_fuse_calibration {
 	u32 hs_curr_level[4];
 	u32 hs_term_range_adj;
@@ -2009,6 +2019,55 @@ static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = {
 	.map = tegra210_usb3_port_map,
 };
 
+static int tegra210_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
+					      bool set)
+{
+	u32 reg;
+
+	dev_dbg(padctl->dev, "%s vbus override\n", set ? "set" : "clear");
+
+	reg = padctl_readl(padctl, XUSB_PADCTL_USB2_VBUS_ID);
+	if (set) {
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;
+		reg &= ~(XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK <<
+			   XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT);
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING <<
+			 XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT;
+	} else
+		reg &= ~XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;
+	padctl_writel(padctl, reg, XUSB_PADCTL_USB2_VBUS_ID);
+
+	return 0;
+}
+
+static int tegra210_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_padctl *padctl;
+	struct tegra_xusb_lane *lane;
+	struct device *dev;
+	u32 reg;
+
+	if (!phy)
+		return -ENODEV;
+
+	lane = phy_get_drvdata(phy);
+	padctl = lane->pad->padctl;
+	dev = padctl->dev;
+
+	reg = padctl_readl(padctl,
+				XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(0));
+	dev_dbg(dev, "BATTERY_CHRG_OTGPADX_CTL0(0): 0x%x\n", reg);
+
+	if ((reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP) ||
+	    (reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN)) {
+		dev_dbg(dev, "Toggle vbus\n");
+		tegra210_xusb_padctl_vbus_override(padctl, false);
+		tegra210_xusb_padctl_vbus_override(padctl, true);
+		return 1;
+	}
+	return 0;
+}
+
 static int
 tegra210_xusb_read_fuse_calibration(struct tegra210_xusb_fuse_calibration *fuse)
 {
@@ -2071,6 +2130,8 @@ static const struct tegra_xusb_padctl_ops tegra210_xusb_padctl_ops = {
 	.remove = tegra210_xusb_padctl_remove,
 	.usb3_set_lfps_detect = tegra210_usb3_set_lfps_detect,
 	.hsic_set_idle = tegra210_hsic_set_idle,
+	.vbus_override = tegra210_xusb_padctl_vbus_override,
+	.utmi_port_reset = tegra210_utmi_port_reset,
 };
 
 const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc = {
drivers/phy/tegra/xusb.c +25 -3
index e89746d..bbb839b 100644
@@ -1027,7 +1027,7 @@ int tegra_xusb_padctl_usb3_save_context(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->usb3_save_context)
 		return padctl->soc->ops->usb3_save_context(padctl, port);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_save_context);
 
@@ -1037,7 +1037,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->hsic_set_idle)
 		return padctl->soc->ops->hsic_set_idle(padctl, port, idle);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_hsic_set_idle);
 
@@ -1048,10 +1048,32 @@ int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 		return padctl->soc->ops->usb3_set_lfps_detect(padctl, port,
 							      enable);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_set_lfps_detect);
 
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+							bool val)
+{
+	if (padctl->soc->ops->vbus_override)
+		return padctl->soc->ops->vbus_override(padctl, val);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_xusb_padctl_set_vbus_override);
+
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
+	struct tegra_xusb_padctl *padctl = lane->pad->padctl;
+
+	if (padctl->soc->ops->utmi_port_reset)
+		return padctl->soc->ops->utmi_port_reset(phy);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_port_reset);
+
 MODULE_AUTHOR("Thierry Reding <[email protected]>");
 MODULE_DESCRIPTION("Tegra XUSB Pad Controller driver");
 MODULE_LICENSE("GPL v2");
drivers/phy/tegra/xusb.h +2 -0
index b263165..9a39b05 100644
@@ -356,6 +356,8 @@ struct tegra_xusb_padctl_ops {
 			     unsigned int index, bool idle);
 	int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl,
 				    unsigned int index, bool enable);
+	int (*vbus_override)(struct tegra_xusb_padctl *padctl, bool set);
+	int (*utmi_port_reset)(struct phy *phy);
 };
 
 struct tegra_xusb_padctl_soc {
include/linux/phy/tegra/xusb.h +4 -2
index 8e1a57a..9b8351c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2016-2019, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -26,5 +26,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 				    unsigned int port, bool idle);
 int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 					   unsigned int port, bool enable);
-
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+					bool val);
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy);
 #endif /* PHY_TEGRA_XUSB_H */
#2 lore raw

PATCH v2 4/8 dt-bindings: usb: Add NVIDIA Tegra XUSB device mode controller binding

Add device-tree binding documentation for the XUSB device mode controller present on tegra210 SoC. This controller supports USB 3.0 specification

Based on work by Andrew Bresticker <[email protected]>.

---
 .../devicetree/bindings/usb/nvidia,tegra-xudc.txt  | 105 +++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +105 -0
new file mode 100644
index 0000000..990655d
@@ -0,0 +1,105 @@
+Device tree binding for NVIDIA Tegra XUSB device mode controller (XUDC)
+=======================================================================
+
+The Tegra XUDC controller supports both USB 2.0 HighSpeed/FullSpeed and
+USB 3.0 SuperSpeed protocols.
+
+Required properties:
+--------------------
+- compatible: For Tegra210, must contain "nvidia,tegra210-xudc".
+- reg: Must contain the base and length of the XUSB device registers, XUSB device
+  PCI Config registers and XUSB device controller registers.
+- interrupts: Must contain the XUSB device interrupt
+- clocks: Must contain an entry for ell clocks used.
+  See ../clock/clock-bindings.txt for details.
+- clock-names: Must include the following entries:
+   - xusb_device
+   - xusb_ss
+   - xusb_ss_src
+   - xusb_hs_src
+   - xusb_fs_src
+- nvidia,xusb-padctl: phandle to the XUSB pad controller that is used to
+  configure the USB pads used by the XUDC controller
+- power-domains: A list of PM domain specifiers that reference each power-domain
+  used by the XUSB device mode controller. This list must comprise of a specifier
+  for the XUSBA and XUSBB power-domains. See ../power/power_domain.txt and
+  ../arm/tegra/nvidia,tegra20-pmc.txt for details.
+- power-domain-names: A list of names that represent each of the specifiers in
+  the 'power-domains' property. Must include 'xusb_ss' and 'xusb_device'
+
+For Tegra210:
+- avddio-usb-supply: PCIe/USB3 analog logic power supply. Must supply 1.05 V.
+- hvdd-usb-supply: USB controller power supply. Must supply 3.3 V.
+- avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V.
+
+- phys: Must contain an entry for each entry in phy-names.
+  See ../phy/phy-bindings.txt for details.
+- extcon-usb: Must contains an extcon-usb entry which detects
+  USB VBUS pin. See ../extcon/extcon-usb-gpio.txt for details.
+
+Optional properties:
+--------------------
+- phy-names: Should include an entry for each PHY used by the controller.
+  Names must be "usb2", and "usb3" if support SuperSpeed device mode.
+  - "usb3" phy, SuperSpeed (SSTX+/SSTX-/SSRX+/SSRX-) data lines
+  - "usb2" phy, USB 2.0 (D+/D-) data lines
+
+Example:
+--------
+	pmc: pmc@7000e400 {
+		compatible = "nvidia,tegra210-pmc";
+		reg = <0x0 0x7000e400 0x0 0x400>;
+		clocks = <&tegra_car TEGRA210_CLK_PCLK>, <&clk32k_in>;
+		clock-names = "pclk", "clk32k_in";
+
+		powergates {
+			pd_xusbss: xusba {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				resets = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				#power-domain-cells = <0>;
+			};
+
+			pd_xusbdev: xusbb {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>;
+				resets = <&tegra_car 95>;
+				#power-domain-cells = <0>;
+			};
+		};
+	};
+
+	xudc@700d0000 {
+		compatible = "nvidia,tegra210-xudc";
+		reg = <0x0 0x700d0000 0x0 0x8000>,
+			<0x0 0x700d8000 0x0 0x1000>,
+			<0x0 0x700d9000 0x0 0x1000>;
+
+		interrupts = <0 44 0x4>;
+
+		clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>,
+			<&tegra_car TEGRA210_CLK_XUSB_SS>,
+			<&tegra_car TEGRA210_CLK_XUSB_SSP_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_HS_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_FS_SRC>;
+		clock-names = "xusb_device", "xusb_ss", "xusb_ss_src",
+			      "xusb_hs_src", "xusb_fs_src";
+
+		power-domains = <&pd_xusbdev>, <&pd_xusbss>;
+		power-domain-names = "xusb_device", "xusb_ss";
+
+		nvidia,xusb-padctl = <&padctl>;
+
+		phys = <&{/padctl@7009f000/pads/usb2/lanes/usb2-0}>;
+		phy-names = "usb2;
+
+		avddio-usb-supply = <&vdd_pex_1v05>;
+		hvdd-usb-supply = <&vdd_3v3_sys>;
+		avdd-pll-utmip-supply = <&vdd_1v8>;
+
+		extcon = <&extcon_usb>;
+	};
+
+	extcon_usb: extcon_vbus {
+		compatible = "linux,extcon-usb-gpio";
+		vbus-gpio = <&gpio TEGRA_GPIO(Z, 0) GPIO_ACTIVE_LOW>;
+	};
+
#3 lore raw

PATCH v2 7/8 usb: gadget: Add UDC driver for tegra XUSB device mode controller

This patch adds UDC driver for tegra XUSB 3.0 device mode controller. XUSB device mode controller support SS, HS and FS modes

Based on work by:
Mark Kuo <[email protected]>
Andrew Bresticker <[email protected]>

---
 drivers/usb/gadget/udc/Kconfig      |   10 +
 drivers/usb/gadget/udc/Makefile     |    1 +
 drivers/usb/gadget/udc/tegra_xudc.c | 3702 +++++++++++++++++++++++++++++++++++
 3 files changed, 3713 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/tegra_xudc.c
drivers/usb/gadget/udc/Kconfig +10 -0
index 0a16cbd..f6f469c 100644
@@ -439,6 +439,16 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_TEGRA_XUDC
+	tristate "NVIDIA Superspeed USB 3.0 Device Controller"
+	depends on ARCH_TEGRA
+	help
+	 Enables TEGRA USB 3.0 device mode controller driver.
+
+	 Say "y" to link the driver statically, or "m" to build a
+	 dynamically linked module called "tegra_xudc" and force all
+	 gadget drivers to also be dynamically linked.
+
 source "drivers/usb/gadget/udc/aspeed-vhub/Kconfig"
 
 #
drivers/usb/gadget/udc/Makefile +1 -0
index 897f648..1c55c96 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_BCM63XX_UDC)	+= bcm63xx_udc.o
 obj-$(CONFIG_USB_FSL_USB2)	+= fsl_usb2_udc.o
 fsl_usb2_udc-y			:= fsl_udc_core.o
 fsl_usb2_udc-$(CONFIG_ARCH_MXC)	+= fsl_mxc_udc.o
+obj-$(CONFIG_USB_TEGRA_XUDC)	+= tegra_xudc.o
 obj-$(CONFIG_USB_M66592)	+= m66592-udc.o
 obj-$(CONFIG_USB_R8A66597)	+= r8a66597-udc.o
 obj-$(CONFIG_USB_RENESAS_USB3)	+= renesas_usb3.o
drivers/usb/gadget/udc/tegra_xudc.c new file +3702 -0

2,977 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH v2 7/8 usb: gadget: Add UDC driver for tegra XUSB device mode controller

Quoted 20 lines · Nagarjuna Kristam

This patch adds UDC driver for tegra XUSB 3.0 device mode controller. XUSB device mode controller support SS, HS and FS modes

Based on work by:
Mark Kuo <[email protected]>
Andrew Bresticker <[email protected]>

---
 drivers/usb/gadget/udc/Kconfig      |   10 +
 drivers/usb/gadget/udc/Makefile     |    1 +
 drivers/usb/gadget/udc/tegra_xudc.c | 3702 +++++++++++++++++++++++++++++++++++
 3 files changed, 3713 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/tegra_xudc.c
drivers/usb/gadget/udc/Kconfig +0 -0
index 0a16cbd..f6f469c 100644

drivers/usb/gadget/udc/Kconfig config USB_GADGET_XILINX · line 444

Quoted 6 lines
drivers/usb/gadget/udc/Kconfig +3 -0
@@ -439,6 +439,16 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_TEGRA_XUDC
+	tristate "NVIDIA Superspeed USB 3.0 Device Controller"
+	depends on ARCH_TEGRA

no compile_test?

#5 lore raw

PATCH v2 2/8 phy: tegra: xusb: t210: add usb3 port fake support

Quoted 5 lines · Nagarjuna Kristam

On Tegra210, usb2 only otg/peripheral ports dont work in device mode. They need an assosciated usb3 port to work in device mode. Identify an unused usb3 port and assign it as a fake USB3 port to USB2 only port whose mode is otg/peripheral

Quoted 8 lines

Based on work by BH Hsieh <[email protected]>.

---
 drivers/phy/tegra/xusb-tegra210.c | 40 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 29 ++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.h          |  6 ++++++
 3 files changed, 75 insertions(+)

I think this looks a whole lot better than the initial version. One or two minor comments below.

Quoted 59 lines
drivers/phy/tegra/xusb-tegra210.c +30 -0
index 4beebcc..48478bc4 100644
@@ -58,6 +58,7 @@
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_SHIFT(x) ((x) * 5)
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(x) (0x7 << ((x) * 5))
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(x, v) (((v) & 0x7) << ((x) * 5))
+#define XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED 0x7
 
 #define XUSB_PADCTL_ELPG_PROGRAM1 0x024
 #define XUSB_PADCTL_ELPG_PROGRAM1_AUX_MUX_LP0_VCORE_DOWN (1 << 31)
@@ -952,6 +953,15 @@ static int tegra210_usb2_phy_power_on(struct phy *phy)
 
 	priv = to_tegra210_xusb_padctl(padctl);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(
+					port->usb3_port_fake, index);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
 	value &= ~((XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_MASK <<
 		    XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT) |
@@ -1086,6 +1096,15 @@ static int tegra210_usb2_phy_power_off(struct phy *phy)
 
 	mutex_lock(&padctl->lock);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(port->usb3_port_fake,
+					XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	if (WARN_ON(pad->enable == 0))
 		goto out;
 
@@ -1784,6 +1803,27 @@ static const struct tegra_xusb_pad_soc * const tegra210_pads[] = {
 
 static int tegra210_usb2_port_enable(struct tegra_xusb_port *port)
 {
+	struct tegra_xusb_usb2_port *usb2 = to_usb2_port(port);
+	struct tegra_xusb_padctl *padctl = port->padctl;
+
+	/* Disable usb3_port_fake usage by default and assign if needed */
+	usb2->usb3_port_fake = -1;
+	if (usb2 && (usb2->mode == USB_DR_MODE_OTG ||
+		    usb2->mode == USB_DR_MODE_PERIPHERAL)) {
+		if (!tegra_xusb_usb3_port_has_companion(padctl, port->index)) {
+			int fake = tegra_xusb_find_unused_usb3_port(padctl);
+
+			if (fake >= 0) {

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_pad_soc * const tegra210_pads[] = { · line 1826

Quoted 10 lines
drivers/phy/tegra/xusb-tegra210.c +10 -0
+				dev_dbg(&port->dev, "Found unused usb3 port: %d\n",
+					 fake);
+				usb2->usb3_port_fake = fake;
+			} else {
+				dev_err(&port->dev, "usb2-%u has neither a companion nor an unused usb3 port to fake it\n",
+					port->index);
+				return -ENODEV;
+			}
+		}
+	}

Generally it's preferable to check for errors and deal with success in the regular code path. So the above would be:

			if (fake < 0) {
				dev_err(...);
				return -ENODEV;
			}

			dev_dbg(...);
			...

Also, the error message is slightly redundant because &port->dev will already output the usb2-%u part. Also, perhaps try to make that message a little shorter. Something like:

	dev_err(&port->dev, "no unused USB3 ports available\n");

Also, I don't think this is the right place to do this. There's really no way for the ->enable() callbacks to fail. Or at least failures will be ignored, so there's no chance for the driver to do anything about the failure. It also looks somewhat tacked on.

But how about if we do this as part of tegra_xusb_usb3_port_parse_dt() or tegra_xusb_add_usb3_port() already? The former is where we read the USB2 companion port index from DT so we know exactly which USB2 port to associate with a given USB3 port. So in the latter we could iterate over the USB2 ports (which have already been set up) and establish a backlink to the USB3 companion.

Something like this, in tegra_xusb_add_usb3_port():

	struct tegra_xusb_usb2_port *companion;

	for (i = 0; i < padctl->soc->ports.usb2.count; i++) {
		companion = tegra_xusb_find_usb2_port(padctl, i);
		if (!companion)
			continue;

		if (companion->base.index == usb3->port) {
			companion->port = index;
			break;
		}
	}

Then, as part of tegra_xusb_setup_ports() we could add functionality to hook up a fake port if no companion is available, much like you're doing above. Perhaps we should introduce a new ->setup() callback to the port ops to encapsulate this, or perhaps add a flag to tegra_xusb_padctl_soc that is set to true on SoC generations that need the fake USB3 port.

Thierry

Quoted 70 lines
drivers/phy/tegra/xusb-tegra210.c +0 -0
 	return 0;
 }
 
drivers/phy/tegra/xusb.c +29 -0
index c6178a0..e89746d 100644
@@ -799,6 +799,35 @@ static void __tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl)
 	}
 }
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+						       unsigned int index)
+{
+	unsigned int i;
+	struct tegra_xusb_usb3_port *usb3;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		usb3 = tegra_xusb_find_usb3_port(padctl, i);
+		if (usb3 && usb3->port == index)
+			return true;
+	}
+
+	return false;
+}
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl)
+{
+	struct device_node *np;
+	unsigned int i;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		np = tegra_xusb_find_port_node(padctl, "usb3", i);
+		if (!np || !of_device_is_available(np))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
 static int tegra_xusb_setup_ports(struct tegra_xusb_padctl *padctl)
 {
 	struct tegra_xusb_port *port;
drivers/phy/tegra/xusb.h +6 -0
index 17cc8dc..b263165 100644
@@ -274,6 +274,7 @@ struct tegra_xusb_usb2_port {
 	struct regulator *supply;
 	bool internal;
 	enum usb_dr_mode mode;
+	int usb3_port_fake;
 };
 
 static inline struct tegra_xusb_usb2_port *
@@ -413,6 +414,11 @@ struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
 					     const char *name,
 					     unsigned int index);
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+					unsigned int index);
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl);
+
 #if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
 extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
 #endif
Signature · 1 line
2.7.4
#6 lore raw
Quoted 99 lines · Thierry Reding
Quoted 5 lines · Nagarjuna Kristam

On Tegra210, usb2 only otg/peripheral ports dont work in device mode. They need an assosciated usb3 port to work in device mode. Identify an unused usb3 port and assign it as a fake USB3 port to USB2 only port whose mode is otg/peripheral

Quoted 8 lines

Based on work by BH Hsieh <[email protected]>.

---
 drivers/phy/tegra/xusb-tegra210.c | 40 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 29 ++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.h          |  6 ++++++
 3 files changed, 75 insertions(+)

I think this looks a whole lot better than the initial version. One or two minor comments below.

Quoted 59 lines
drivers/phy/tegra/xusb-tegra210.c +30 -0
index 4beebcc..48478bc4 100644
@@ -58,6 +58,7 @@
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_SHIFT(x) ((x) * 5)
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(x) (0x7 << ((x) * 5))
 #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(x, v) (((v) & 0x7) << ((x) * 5))
+#define XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED 0x7
 
 #define XUSB_PADCTL_ELPG_PROGRAM1 0x024
 #define XUSB_PADCTL_ELPG_PROGRAM1_AUX_MUX_LP0_VCORE_DOWN (1 << 31)
@@ -952,6 +953,15 @@ static int tegra210_usb2_phy_power_on(struct phy *phy)
 
 	priv = to_tegra210_xusb_padctl(padctl);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(
+					port->usb3_port_fake, index);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
 	value &= ~((XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_MASK <<
 		    XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT) |
@@ -1086,6 +1096,15 @@ static int tegra210_usb2_phy_power_off(struct phy *phy)
 
 	mutex_lock(&padctl->lock);
 
+	if (port->usb3_port_fake != -1) {
+		value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
+		value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(
+					port->usb3_port_fake);
+		value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(port->usb3_port_fake,
+					XUSB_PADCTL_SS_PORT_MAP_PORT_DISABLED);
+		padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
+	}
+
 	if (WARN_ON(pad->enable == 0))
 		goto out;
 
@@ -1784,6 +1803,27 @@ static const struct tegra_xusb_pad_soc * const tegra210_pads[] = {
 
 static int tegra210_usb2_port_enable(struct tegra_xusb_port *port)
 {
+	struct tegra_xusb_usb2_port *usb2 = to_usb2_port(port);
+	struct tegra_xusb_padctl *padctl = port->padctl;
+
+	/* Disable usb3_port_fake usage by default and assign if needed */
+	usb2->usb3_port_fake = -1;
+	if (usb2 && (usb2->mode == USB_DR_MODE_OTG ||
+		    usb2->mode == USB_DR_MODE_PERIPHERAL)) {
+		if (!tegra_xusb_usb3_port_has_companion(padctl, port->index)) {
+			int fake = tegra_xusb_find_unused_usb3_port(padctl);
+
+			if (fake >= 0) {

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_pad_soc * const tegra210_pads[] = { · line 1826

Quoted 10 lines
drivers/phy/tegra/xusb-tegra210.c +10 -0
+				dev_dbg(&port->dev, "Found unused usb3 port: %d\n",
+					 fake);
+				usb2->usb3_port_fake = fake;
+			} else {
+				dev_err(&port->dev, "usb2-%u has neither a companion nor an unused usb3 port to fake it\n",
+					port->index);
+				return -ENODEV;
+			}
+		}
+	}

Generally it's preferable to check for errors and deal with success in the regular code path. So the above would be:

			if (fake < 0) {
				dev_err(...);
				return -ENODEV;
			}

			dev_dbg(...);
			...
Quoted 6 lines

Also, the error message is slightly redundant because &port->dev will already output the usb2-%u part. Also, perhaps try to make that message a little shorter. Something like:

	dev_err(&port->dev, "no unused USB3 ports available\n");

Will update accordingly

Quoted 5 lines

Also, I don't think this is the right place to do this. There's really no way for the ->enable() callbacks to fail. Or at least failures will be ignored, so there's no chance for the driver to do anything about the failure. It also looks somewhat tacked on.

Quoted 7 lines

But how about if we do this as part of tegra_xusb_usb3_port_parse_dt() or tegra_xusb_add_usb3_port() already? The former is where we read the USB2 companion port index from DT so we know exactly which USB2 port to associate with a given USB3 port. So in the latter we could iterate over the USB2 ports (which have already been set up) and establish a backlink to the USB3 companion.

Ok, instead of doing in ->enable(), will move the logic currently inside ->enable() to a separate function called from tegra_xusb_setup_ports(). This will get executed under soc flag need_fake_usb3_support, which will be set only in t210 soc data.

Quoted 15 lines

Something like this, in tegra_xusb_add_usb3_port():

	struct tegra_xusb_usb2_port *companion;

	for (i = 0; i < padctl->soc->ports.usb2.count; i++) {
		companion = tegra_xusb_find_usb2_port(padctl, i);
		if (!companion)
			continue;

		if (companion->base.index == usb3->port) {
			companion->port = index;
			break;
		}
	}
Quoted 7 lines

Then, as part of tegra_xusb_setup_ports() we could add functionality to hook up a fake port if no companion is available, much like you're doing above. Perhaps we should introduce a new ->setup() callback to the port ops to encapsulate this, or perhaps add a flag to tegra_xusb_padctl_soc that is set to true on SoC generations that need the fake USB3 port.

Thierry

I believe adding usb3 port index data to usb2 port data structure is not needed. Logic inside current ->enable() [which will be moved based on soc data feature flag] takes care of the needs.

- Nagarjuna

Quoted 71 lines
Quoted 71 lines
drivers/phy/tegra/xusb-tegra210.c +0 -0
 	return 0;
 }
 
drivers/phy/tegra/xusb.c +29 -0
index c6178a0..e89746d 100644
@@ -799,6 +799,35 @@ static void __tegra_xusb_remove_ports(struct tegra_xusb_padctl *padctl)
 	}
 }
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+						       unsigned int index)
+{
+	unsigned int i;
+	struct tegra_xusb_usb3_port *usb3;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		usb3 = tegra_xusb_find_usb3_port(padctl, i);
+		if (usb3 && usb3->port == index)
+			return true;
+	}
+
+	return false;
+}
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl)
+{
+	struct device_node *np;
+	unsigned int i;
+
+	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
+		np = tegra_xusb_find_port_node(padctl, "usb3", i);
+		if (!np || !of_device_is_available(np))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
 static int tegra_xusb_setup_ports(struct tegra_xusb_padctl *padctl)
 {
 	struct tegra_xusb_port *port;
drivers/phy/tegra/xusb.h +6 -0
index 17cc8dc..b263165 100644
@@ -274,6 +274,7 @@ struct tegra_xusb_usb2_port {
 	struct regulator *supply;
 	bool internal;
 	enum usb_dr_mode mode;
+	int usb3_port_fake;
 };
 
 static inline struct tegra_xusb_usb2_port *
@@ -413,6 +414,11 @@ struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
 					     const char *name,
 					     unsigned int index);
 
+bool tegra_xusb_usb3_port_has_companion(struct tegra_xusb_padctl *padctl,
+					unsigned int index);
+
+int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl);
+
 #if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
 extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
 #endif
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 3/8 phy: tegra: xusb: t210: add vbus override support

Quoted 40 lines · Nagarjuna Kristam

Tegra XUSB device control driver needs to control vbus override during its operations, add API for the support

---
 drivers/phy/tegra/xusb-tegra210.c | 61 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 28 ++++++++++++++++--
 drivers/phy/tegra/xusb.h          |  2 ++
 include/linux/phy/tegra/xusb.h    |  6 ++--
 4 files changed, 92 insertions(+), 5 deletions(-)
drivers/phy/tegra/xusb-tegra210.c +10 -0
index 48478bc4..be1a870 100644
@@ -73,6 +73,10 @@
 #define XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(x) (1 << (1 + (x)))
 #define XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(x) (1 << (8 + (x)))
 
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(x) (0x080 + (x) * 0x40)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP (1 << 18)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN (1 << 22)
+
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL1(x) (0x084 + (x) * 0x40)
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_SHIFT 7
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_MASK 0x3
@@ -235,6 +239,12 @@
 #define XUSB_PADCTL_UPHY_USB3_PADX_ECTL6(x) (0xa74 + (x) * 0x40)
 #define XUSB_PADCTL_UPHY_USB3_PAD_ECTL6_RX_EQ_CTRL_H_VAL 0xfcf01368
 
+#define XUSB_PADCTL_USB2_VBUS_ID 0xc60
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON (1 << 14)
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT 18
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK 0xf
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING 8
+
 struct tegra210_xusb_fuse_calibration {
 	u32 hs_curr_level[4];
 	u32 hs_term_range_adj;

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2023

Quoted 5 lines
drivers/phy/tegra/xusb-tegra210.c +2 -0
@@ -2009,6 +2019,55 @@ static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = {
 	.map = tegra210_usb3_port_map,
 };
 
+static int tegra210_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
+					      bool set)

I think "status" would perhaps be somewhat more meaningful.

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2025

Quoted 2 lines
drivers/phy/tegra/xusb-tegra210.c +2 -0
+{
+	u32 reg;

The rest of the driver uses "u32 value". It'd be good to be consistent.

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2037

Quoted 12 lines
drivers/phy/tegra/xusb-tegra210.c +12 -0
+
+	dev_dbg(padctl->dev, "%s vbus override\n", set ? "set" : "clear");
+
+	reg = padctl_readl(padctl, XUSB_PADCTL_USB2_VBUS_ID);
+	if (set) {
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;
+		reg &= ~(XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK <<
+			   XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT);
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING <<
+			 XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT;
+	} else
+		reg &= ~XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;

This could use some blank lines to separate blocks and make it more readable.

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2048

Quoted 11 lines
drivers/phy/tegra/xusb-tegra210.c +11 -0
+	padctl_writel(padctl, reg, XUSB_PADCTL_USB2_VBUS_ID);
+
+	return 0;
+}
+
+static int tegra210_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_padctl *padctl;
+	struct tegra_xusb_lane *lane;
+	struct device *dev;
+	u32 reg;

u32 value

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2051

Quoted 3 lines
drivers/phy/tegra/xusb-tegra210.c +3 -0
+
+	if (!phy)
+		return -ENODEV;

When would this happen?

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2058

Quoted 7 lines
drivers/phy/tegra/xusb-tegra210.c +7 -0
+
+	lane = phy_get_drvdata(phy);
+	padctl = lane->pad->padctl;
+	dev = padctl->dev;
+
+	reg = padctl_readl(padctl,
+				XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(0));

Usually subsequent lines are indented so that they align with the first argument of the first line.

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2059

Quoted 1 line
drivers/phy/tegra/xusb-tegra210.c +1 -0
+	dev_dbg(dev, "BATTERY_CHRG_OTGPADX_CTL0(0): 0x%x\n", reg);

You can use %#x to avoid having to explicitly provide the 0x prefix. Also, is this really useful for debugging? We could add trace support to this driver (to padctl_readl() and padctl_writel() for example) to allow for more flexible tracing of register programming sequences.

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2063

Quoted 4 lines
drivers/phy/tegra/xusb-tegra210.c +4 -0
+
+	if ((reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP) ||
+	    (reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN)) {
+		dev_dbg(dev, "Toggle vbus\n");

This one is pretty redundant because the function calls below each already output something to that effect.

Quoted 42 lines
drivers/phy/tegra/xusb-tegra210.c +9 -0
+		tegra210_xusb_padctl_vbus_override(padctl, false);
+		tegra210_xusb_padctl_vbus_override(padctl, true);
+		return 1;
+	}
+	return 0;
+}
+
 static int
 tegra210_xusb_read_fuse_calibration(struct tegra210_xusb_fuse_calibration *fuse)
 {
@@ -2071,6 +2130,8 @@ static const struct tegra_xusb_padctl_ops tegra210_xusb_padctl_ops = {
 	.remove = tegra210_xusb_padctl_remove,
 	.usb3_set_lfps_detect = tegra210_usb3_set_lfps_detect,
 	.hsic_set_idle = tegra210_hsic_set_idle,
+	.vbus_override = tegra210_xusb_padctl_vbus_override,
+	.utmi_port_reset = tegra210_utmi_port_reset,
 };
 
 const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc = {
drivers/phy/tegra/xusb.c +2 -2
index e89746d..bbb839b 100644
@@ -1027,7 +1027,7 @@ int tegra_xusb_padctl_usb3_save_context(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->usb3_save_context)
 		return padctl->soc->ops->usb3_save_context(padctl, port);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_save_context);
 
@@ -1037,7 +1037,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->hsic_set_idle)
 		return padctl->soc->ops->hsic_set_idle(padctl, port, idle);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_hsic_set_idle);
 

drivers/phy/tegra/xusb.c int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl, · line 1053

Quoted 7 lines
drivers/phy/tegra/xusb.c +1 -1
@@ -1048,10 +1048,32 @@ int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 		return padctl->soc->ops->usb3_set_lfps_detect(padctl, port,
 							      enable);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_set_lfps_detect);

I think these changes should be a separate patch.

Thierry

Quoted 62 lines
drivers/phy/tegra/xusb.c +22 -0
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+							bool val)
+{
+	if (padctl->soc->ops->vbus_override)
+		return padctl->soc->ops->vbus_override(padctl, val);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_xusb_padctl_set_vbus_override);
+
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
+	struct tegra_xusb_padctl *padctl = lane->pad->padctl;
+
+	if (padctl->soc->ops->utmi_port_reset)
+		return padctl->soc->ops->utmi_port_reset(phy);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_port_reset);
+
 MODULE_AUTHOR("Thierry Reding <[email protected]>");
 MODULE_DESCRIPTION("Tegra XUSB Pad Controller driver");
 MODULE_LICENSE("GPL v2");
drivers/phy/tegra/xusb.h +2 -0
index b263165..9a39b05 100644
@@ -356,6 +356,8 @@ struct tegra_xusb_padctl_ops {
 			     unsigned int index, bool idle);
 	int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl,
 				    unsigned int index, bool enable);
+	int (*vbus_override)(struct tegra_xusb_padctl *padctl, bool set);
+	int (*utmi_port_reset)(struct phy *phy);
 };
 
 struct tegra_xusb_padctl_soc {
include/linux/phy/tegra/xusb.h +4 -2
index 8e1a57a..9b8351c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2016-2019, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -26,5 +26,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 				    unsigned int port, bool idle);
 int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 					   unsigned int port, bool enable);
-
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+					bool val);
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy);
 #endif /* PHY_TEGRA_XUSB_H */
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH V2 3/8] phy: tegra: xusb: t210: add vbus override support

Quoted 44 lines · Thierry Reding
Quoted 43 lines · Nagarjuna Kristam

Tegra XUSB device control driver needs to control vbus override during its operations, add API for the support

---
 drivers/phy/tegra/xusb-tegra210.c | 61 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          | 28 ++++++++++++++++--
 drivers/phy/tegra/xusb.h          |  2 ++
 include/linux/phy/tegra/xusb.h    |  6 ++--
 4 files changed, 92 insertions(+), 5 deletions(-)
drivers/phy/tegra/xusb-tegra210.c +10 -0
index 48478bc4..be1a870 100644
@@ -73,6 +73,10 @@
 #define XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(x) (1 << (1 + (x)))
 #define XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(x) (1 << (8 + (x)))
 
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(x) (0x080 + (x) * 0x40)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP (1 << 18)
+#define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN (1 << 22)
+
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL1(x) (0x084 + (x) * 0x40)
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_SHIFT 7
 #define XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL1_VREG_LEV_MASK 0x3
@@ -235,6 +239,12 @@
 #define XUSB_PADCTL_UPHY_USB3_PADX_ECTL6(x) (0xa74 + (x) * 0x40)
 #define XUSB_PADCTL_UPHY_USB3_PAD_ECTL6_RX_EQ_CTRL_H_VAL 0xfcf01368
 
+#define XUSB_PADCTL_USB2_VBUS_ID 0xc60
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON (1 << 14)
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT 18
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK 0xf
+#define XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING 8
+
 struct tegra210_xusb_fuse_calibration {
 	u32 hs_curr_level[4];
 	u32 hs_term_range_adj;
@@ -2009,6 +2019,55 @@ static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = {
 	.map = tegra210_usb3_port_map,
 };
 
Quoted 5 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2023

Quoted 2 lines
drivers/phy/tegra/xusb-tegra210.c +2 -0
+static int tegra210_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
+					      bool set)

I think "status" would perhaps be somewhat more meaningful.

Will update accordingly

Quoted 5 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2025

Quoted 2 lines
drivers/phy/tegra/xusb-tegra210.c +2 -0
+{
+	u32 reg;

The rest of the driver uses "u32 value". It'd be good to be consistent.

Will sync with rest of code as suggested.

Quoted 7 lines
Quoted 7 lines
drivers/phy/tegra/xusb-tegra210.c +7 -0
+
+	dev_dbg(padctl->dev, "%s vbus override\n", set ? "set" : "clear");
+
+	reg = padctl_readl(padctl, XUSB_PADCTL_USB2_VBUS_ID);
+	if (set) {
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;
+		reg &= ~(XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_MASK <<
Quoted 9 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2037

Quoted 5 lines
drivers/phy/tegra/xusb-tegra210.c +5 -0
+			   XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT);
+		reg |= XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_FLOATING <<
+			 XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_SHIFT;
+	} else
+		reg &= ~XUSB_PADCTL_USB2_VBUS_ID_OVERRIDE_VBUS_ON;

This could use some blank lines to separate blocks and make it more readable.

will update accordingly

Quoted 5 lines
Quoted 5 lines
drivers/phy/tegra/xusb-tegra210.c +5 -0
+	padctl_writel(padctl, reg, XUSB_PADCTL_USB2_VBUS_ID);
+
+	return 0;
+}
+
Quoted 9 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2048

Quoted 6 lines
drivers/phy/tegra/xusb-tegra210.c +6 -0
+static int tegra210_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_padctl *padctl;
+	struct tegra_xusb_lane *lane;
+	struct device *dev;
+	u32 reg;

u32 value

will do

Quoted 6 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2051

Quoted 3 lines
drivers/phy/tegra/xusb-tegra210.c +3 -0
+
+	if (!phy)
+		return -ENODEV;

When would this happen?

Added this as safety check, if caller class with null. But in current code flow this won't happen, it can be removed.

Quoted 11 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2058

Quoted 7 lines
drivers/phy/tegra/xusb-tegra210.c +7 -0
+
+	lane = phy_get_drvdata(phy);
+	padctl = lane->pad->padctl;
+	dev = padctl->dev;
+
+	reg = padctl_readl(padctl,
+				XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPADX_CTL0(0));

Usually subsequent lines are indented so that they align with the first argument of the first line.

will do

Quoted 7 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2059

Quoted 1 line
drivers/phy/tegra/xusb-tegra210.c +1 -0
+	dev_dbg(dev, "BATTERY_CHRG_OTGPADX_CTL0(0): 0x%x\n", reg);

You can use %#x to avoid having to explicitly provide the 0x prefix. Also, is this really useful for debugging? We could add trace support to this driver (to padctl_readl() and padctl_writel() for example) to allow for more flexible tracing of register programming sequences.

will remove the debug log

Quoted 8 lines

drivers/phy/tegra/xusb-tegra210.c static const struct tegra_xusb_port_ops tegra210_usb3_port_ops = { · line 2063

Quoted 4 lines
drivers/phy/tegra/xusb-tegra210.c +4 -0
+
+	if ((reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIP) ||
+	    (reg & XUSB_PADCTL_USB2_BATTERY_CHRG_OTGPAD_CTL0_ZIN)) {
+		dev_dbg(dev, "Toggle vbus\n");

This one is pretty redundant because the function calls below each already output something to that effect.

will remove

Quoted 45 lines
Quoted 45 lines
drivers/phy/tegra/xusb-tegra210.c +9 -0
+		tegra210_xusb_padctl_vbus_override(padctl, false);
+		tegra210_xusb_padctl_vbus_override(padctl, true);
+		return 1;
+	}
+	return 0;
+}
+
 static int
 tegra210_xusb_read_fuse_calibration(struct tegra210_xusb_fuse_calibration *fuse)
 {
@@ -2071,6 +2130,8 @@ static const struct tegra_xusb_padctl_ops tegra210_xusb_padctl_ops = {
 	.remove = tegra210_xusb_padctl_remove,
 	.usb3_set_lfps_detect = tegra210_usb3_set_lfps_detect,
 	.hsic_set_idle = tegra210_hsic_set_idle,
+	.vbus_override = tegra210_xusb_padctl_vbus_override,
+	.utmi_port_reset = tegra210_utmi_port_reset,
 };
 
 const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc = {
drivers/phy/tegra/xusb.c +2 -2
index e89746d..bbb839b 100644
@@ -1027,7 +1027,7 @@ int tegra_xusb_padctl_usb3_save_context(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->usb3_save_context)
 		return padctl->soc->ops->usb3_save_context(padctl, port);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_save_context);
 
@@ -1037,7 +1037,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 	if (padctl->soc->ops->hsic_set_idle)
 		return padctl->soc->ops->hsic_set_idle(padctl, port, idle);
 
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_hsic_set_idle);
 
@@ -1048,10 +1048,32 @@ int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 		return padctl->soc->ops->usb3_set_lfps_detect(padctl, port,
 							      enable);
 
Quoted 9 lines

drivers/phy/tegra/xusb.c int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl, · line 1053

Quoted 4 lines
drivers/phy/tegra/xusb.c +1 -1
-	return -ENOSYS;
+	return -ENOTSUPP;
 }
 EXPORT_SYMBOL_GPL(tegra_xusb_padctl_usb3_set_lfps_detect);

I think these changes should be a separate patch.

Thierry

will remove from current patch

-Nagarjuna

Quoted 62 lines
Quoted 62 lines
drivers/phy/tegra/xusb.c +22 -0
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+							bool val)
+{
+	if (padctl->soc->ops->vbus_override)
+		return padctl->soc->ops->vbus_override(padctl, val);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_xusb_padctl_set_vbus_override);
+
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy)
+{
+	struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
+	struct tegra_xusb_padctl *padctl = lane->pad->padctl;
+
+	if (padctl->soc->ops->utmi_port_reset)
+		return padctl->soc->ops->utmi_port_reset(phy);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_port_reset);
+
 MODULE_AUTHOR("Thierry Reding <[email protected]>");
 MODULE_DESCRIPTION("Tegra XUSB Pad Controller driver");
 MODULE_LICENSE("GPL v2");
drivers/phy/tegra/xusb.h +2 -0
index b263165..9a39b05 100644
@@ -356,6 +356,8 @@ struct tegra_xusb_padctl_ops {
 			     unsigned int index, bool idle);
 	int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl,
 				    unsigned int index, bool enable);
+	int (*vbus_override)(struct tegra_xusb_padctl *padctl, bool set);
+	int (*utmi_port_reset)(struct phy *phy);
 };
 
 struct tegra_xusb_padctl_soc {
include/linux/phy/tegra/xusb.h +4 -2
index 8e1a57a..9b8351c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2016-2019, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -26,5 +26,7 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xusb_padctl *padctl,
 				    unsigned int port, bool idle);
 int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padctl,
 					   unsigned int port, bool enable);
-
+int tegra_xusb_padctl_set_vbus_override(struct tegra_xusb_padctl *padctl,
+					bool val);
+int tegra_phy_xusb_utmi_port_reset(struct phy *phy);
 #endif /* PHY_TEGRA_XUSB_H */
Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 4/8 dt-bindings: usb: Add NVIDIA Tegra XUSB device mode controller binding

Quoted 2 lines · Nagarjuna Kristam

Add device-tree binding documentation for the XUSB device mode controller present on tegra210 SoC. This controller supports USB 3.0 specification

Tegra210, please. "... supports the USB 3.0 ...". Also end sentences with a fullstop.

Quoted 18 lines

Based on work by Andrew Bresticker <[email protected]>.

---
 .../devicetree/bindings/usb/nvidia,tegra-xudc.txt  | 105 +++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +3 -0
new file mode 100644
index 0000000..990655d
@@ -0,0 +1,105 @@
+Device tree binding for NVIDIA Tegra XUSB device mode controller (XUDC)
+=======================================================================
+

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +10 -0
+The Tegra XUDC controller supports both USB 2.0 HighSpeed/FullSpeed and
+USB 3.0 SuperSpeed protocols.
+
+Required properties:
+--------------------
+- compatible: For Tegra210, must contain "nvidia,tegra210-xudc".
+- reg: Must contain the base and length of the XUSB device registers, XUSB device
+  PCI Config registers and XUSB device controller registers.
+- interrupts: Must contain the XUSB device interrupt
+- clocks: Must contain an entry for ell clocks used.

s/ell/all/

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 20

Quoted 7 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +7 -0
+  See ../clock/clock-bindings.txt for details.
+- clock-names: Must include the following entries:
+   - xusb_device
+   - xusb_ss
+   - xusb_ss_src
+   - xusb_hs_src
+   - xusb_fs_src

It'd be good to explain what each of these are.

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 33

Quoted 13 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +13 -0
+- nvidia,xusb-padctl: phandle to the XUSB pad controller that is used to
+  configure the USB pads used by the XUDC controller
+- power-domains: A list of PM domain specifiers that reference each power-domain
+  used by the XUSB device mode controller. This list must comprise of a specifier
+  for the XUSBA and XUSBB power-domains. See ../power/power_domain.txt and
+  ../arm/tegra/nvidia,tegra20-pmc.txt for details.
+- power-domain-names: A list of names that represent each of the specifiers in
+  the 'power-domains' property. Must include 'xusb_ss' and 'xusb_device'
+
+For Tegra210:
+- avddio-usb-supply: PCIe/USB3 analog logic power supply. Must supply 1.05 V.
+- hvdd-usb-supply: USB controller power supply. Must supply 3.3 V.
+- avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V.

My understanding is that this last supply is really needed for the XUSB pad controller to bring up the PLL. In fact, I've just moved the same supply to the XUSB pad controller from the XUSB controller for all of the supported boards because having this in the XUSB controller would fail under some circumstances.

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 37

Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +4 -0
+
+- phys: Must contain an entry for each entry in phy-names.
+  See ../phy/phy-bindings.txt for details.
+- extcon-usb: Must contains an extcon-usb entry which detects

In the example below, this is simply "extcon".

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 45

Quoted 8 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +8 -0
+  USB VBUS pin. See ../extcon/extcon-usb-gpio.txt for details.
+
+Optional properties:
+--------------------
+- phy-names: Should include an entry for each PHY used by the controller.
+  Names must be "usb2", and "usb3" if support SuperSpeed device mode.
+  - "usb3" phy, SuperSpeed (SSTX+/SSTX-/SSRX+/SSRX-) data lines
+  - "usb2" phy, USB 2.0 (D+/D-) data lines

Why are these optional? phys is required and references phy-names explicitly, so I think that effectively makes these phy-names required as well.

Quoted 21 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +21 -0
+
+Example:
+--------
+	pmc: pmc@7000e400 {
+		compatible = "nvidia,tegra210-pmc";
+		reg = <0x0 0x7000e400 0x0 0x400>;
+		clocks = <&tegra_car TEGRA210_CLK_PCLK>, <&clk32k_in>;
+		clock-names = "pclk", "clk32k_in";
+
+		powergates {
+			pd_xusbss: xusba {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				resets = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				#power-domain-cells = <0>;
+			};
+
+			pd_xusbdev: xusbb {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>;
+				resets = <&tegra_car 95>;
+				#power-domain-cells = <0>;
+			};

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 76

Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +10 -0
+		};
+	};
+
+	xudc@700d0000 {
+		compatible = "nvidia,tegra210-xudc";
+		reg = <0x0 0x700d0000 0x0 0x8000>,
+			<0x0 0x700d8000 0x0 0x1000>,
+			<0x0 0x700d9000 0x0 0x1000>;
+
+		interrupts = <0 44 0x4>;

This should use symbolic names defined in the following includes:

dt-bindings/interrupt-controller/irq.h dt-bindings/interrupt-controller/arm-gic.h

Thierry

Quoted 32 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +29 -0
+
+		clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>,
+			<&tegra_car TEGRA210_CLK_XUSB_SS>,
+			<&tegra_car TEGRA210_CLK_XUSB_SSP_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_HS_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_FS_SRC>;
+		clock-names = "xusb_device", "xusb_ss", "xusb_ss_src",
+			      "xusb_hs_src", "xusb_fs_src";
+
+		power-domains = <&pd_xusbdev>, <&pd_xusbss>;
+		power-domain-names = "xusb_device", "xusb_ss";
+
+		nvidia,xusb-padctl = <&padctl>;
+
+		phys = <&{/padctl@7009f000/pads/usb2/lanes/usb2-0}>;
+		phy-names = "usb2;
+
+		avddio-usb-supply = <&vdd_pex_1v05>;
+		hvdd-usb-supply = <&vdd_3v3_sys>;
+		avdd-pll-utmip-supply = <&vdd_1v8>;
+
+		extcon = <&extcon_usb>;
+	};
+
+	extcon_usb: extcon_vbus {
+		compatible = "linux,extcon-usb-gpio";
+		vbus-gpio = <&gpio TEGRA_GPIO(Z, 0) GPIO_ACTIVE_LOW>;
+	};
+
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 4/8 dt-bindings: usb: Add NVIDIA Tegra XUSB device mode controller binding

Quoted 46 lines · Thierry Reding
Quoted 2 lines · Nagarjuna Kristam

Add device-tree binding documentation for the XUSB device mode controller present on tegra210 SoC. This controller supports USB 3.0 specification

Tegra210, please. "... supports the USB 3.0 ...". Also end sentences with a fullstop.

Quoted 18 lines

Based on work by Andrew Bresticker <[email protected]>.

---
 .../devicetree/bindings/usb/nvidia,tegra-xudc.txt  | 105 +++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +3 -0
new file mode 100644
index 0000000..990655d
@@ -0,0 +1,105 @@
+Device tree binding for NVIDIA Tegra XUSB device mode controller (XUDC)
+=======================================================================
+

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +10 -0
+The Tegra XUDC controller supports both USB 2.0 HighSpeed/FullSpeed and
+USB 3.0 SuperSpeed protocols.
+
+Required properties:
+--------------------
+- compatible: For Tegra210, must contain "nvidia,tegra210-xudc".
+- reg: Must contain the base and length of the XUSB device registers, XUSB device
+  PCI Config registers and XUSB device controller registers.
+- interrupts: Must contain the XUSB device interrupt
+- clocks: Must contain an entry for ell clocks used.

s/ell/all/

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 20

Quoted 7 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +7 -0
+  See ../clock/clock-bindings.txt for details.
+- clock-names: Must include the following entries:
+   - xusb_device
+   - xusb_ss
+   - xusb_ss_src
+   - xusb_hs_src
+   - xusb_fs_src
Quoted 1 line

It'd be good to explain what each of these are.

Perhaps we should also drop the xusb_ prefix here. That's already implied by this being the XUDC controller bindings.

Quoted 9 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 28

Quoted 9 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +8 -0
+- nvidia,xusb-padctl: phandle to the XUSB pad controller that is used to
+  configure the USB pads used by the XUDC controller
+- power-domains: A list of PM domain specifiers that reference each power-domain
+  used by the XUSB device mode controller. This list must comprise of a specifier
+  for the XUSBA and XUSBB power-domains. See ../power/power_domain.txt and
+  ../arm/tegra/nvidia,tegra20-pmc.txt for details.
+- power-domain-names: A list of names that represent each of the specifiers in
+  the 'power-domains' property. Must include 'xusb_ss' and 'xusb_device'

Same here, I'd drop the xusb_ prefix. I think the "device" power domain is also usually referred to as "XUSB_DEV", so perhaps make that "dev" instead?

Thierry

Quoted 103 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 33

Quoted 5 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +5 -0
+
+For Tegra210:
+- avddio-usb-supply: PCIe/USB3 analog logic power supply. Must supply 1.05 V.
+- hvdd-usb-supply: USB controller power supply. Must supply 3.3 V.
+- avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V.

My understanding is that this last supply is really needed for the XUSB pad controller to bring up the PLL. In fact, I've just moved the same supply to the XUSB pad controller from the XUSB controller for all of the supported boards because having this in the XUSB controller would fail under some circumstances.

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 37

Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +4 -0
+
+- phys: Must contain an entry for each entry in phy-names.
+  See ../phy/phy-bindings.txt for details.
+- extcon-usb: Must contains an extcon-usb entry which detects

In the example below, this is simply "extcon".

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 45

Quoted 8 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +8 -0
+  USB VBUS pin. See ../extcon/extcon-usb-gpio.txt for details.
+
+Optional properties:
+--------------------
+- phy-names: Should include an entry for each PHY used by the controller.
+  Names must be "usb2", and "usb3" if support SuperSpeed device mode.
+  - "usb3" phy, SuperSpeed (SSTX+/SSTX-/SSRX+/SSRX-) data lines
+  - "usb2" phy, USB 2.0 (D+/D-) data lines

Why are these optional? phys is required and references phy-names explicitly, so I think that effectively makes these phy-names required as well.

Quoted 21 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +21 -0
+
+Example:
+--------
+	pmc: pmc@7000e400 {
+		compatible = "nvidia,tegra210-pmc";
+		reg = <0x0 0x7000e400 0x0 0x400>;
+		clocks = <&tegra_car TEGRA210_CLK_PCLK>, <&clk32k_in>;
+		clock-names = "pclk", "clk32k_in";
+
+		powergates {
+			pd_xusbss: xusba {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				resets = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				#power-domain-cells = <0>;
+			};
+
+			pd_xusbdev: xusbb {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>;
+				resets = <&tegra_car 95>;
+				#power-domain-cells = <0>;
+			};

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 76

Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +10 -0
+		};
+	};
+
+	xudc@700d0000 {
+		compatible = "nvidia,tegra210-xudc";
+		reg = <0x0 0x700d0000 0x0 0x8000>,
+			<0x0 0x700d8000 0x0 0x1000>,
+			<0x0 0x700d9000 0x0 0x1000>;
+
+		interrupts = <0 44 0x4>;

This should use symbolic names defined in the following includes:

dt-bindings/interrupt-controller/irq.h dt-bindings/interrupt-controller/arm-gic.h

Thierry

Quoted 32 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +29 -0
+
+		clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>,
+			<&tegra_car TEGRA210_CLK_XUSB_SS>,
+			<&tegra_car TEGRA210_CLK_XUSB_SSP_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_HS_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_FS_SRC>;
+		clock-names = "xusb_device", "xusb_ss", "xusb_ss_src",
+			      "xusb_hs_src", "xusb_fs_src";
+
+		power-domains = <&pd_xusbdev>, <&pd_xusbss>;
+		power-domain-names = "xusb_device", "xusb_ss";
+
+		nvidia,xusb-padctl = <&padctl>;
+
+		phys = <&{/padctl@7009f000/pads/usb2/lanes/usb2-0}>;
+		phy-names = "usb2;
+
+		avddio-usb-supply = <&vdd_pex_1v05>;
+		hvdd-usb-supply = <&vdd_3v3_sys>;
+		avdd-pll-utmip-supply = <&vdd_1v8>;
+
+		extcon = <&extcon_usb>;
+	};
+
+	extcon_usb: extcon_vbus {
+		compatible = "linux,extcon-usb-gpio";
+		vbus-gpio = <&gpio TEGRA_GPIO(Z, 0) GPIO_ACTIVE_LOW>;
+	};
+
Signature · 1 line
2.7.4
#11 lore raw

Re: [PATCH V2 4/8] dt-bindings: usb: Add NVIDIA Tegra XUSB device mode controller binding

Quoted 8 lines · Thierry Reding
Quoted 7 lines · Thierry Reding
Quoted 2 lines · Nagarjuna Kristam

Add device-tree binding documentation for the XUSB device mode controller present on tegra210 SoC. This controller supports USB 3.0 specification

Tegra210, please. "... supports the USB 3.0 ...". Also end sentences with a fullstop.

Will update

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

Based on work by Andrew Bresticker <[email protected]>.

---
 .../devicetree/bindings/usb/nvidia,tegra-xudc.txt  | 105 +++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +8 -0
new file mode 100644
index 0000000..990655d
@@ -0,0 +1,105 @@
+Device tree binding for NVIDIA Tegra XUSB device mode controller (XUDC)
+=======================================================================
+
+The Tegra XUDC controller supports both USB 2.0 HighSpeed/FullSpeed and
+USB 3.0 SuperSpeed protocols.
+
+Required properties:
+--------------------
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 13

Quoted 5 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +5 -0
+- compatible: For Tegra210, must contain "nvidia,tegra210-xudc".
+- reg: Must contain the base and length of the XUSB device registers, XUSB device
+  PCI Config registers and XUSB device controller registers.
+- interrupts: Must contain the XUSB device interrupt
+- clocks: Must contain an entry for ell clocks used.

s/ell/all/

will do

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +7 -0
+  See ../clock/clock-bindings.txt for details.
+- clock-names: Must include the following entries:
+   - xusb_device
+   - xusb_ss
+   - xusb_ss_src
+   - xusb_hs_src
+   - xusb_fs_src
Quoted 5 lines
Quoted 1 line

It'd be good to explain what each of these are.

Perhaps we should also drop the xusb_ prefix here. That's already implied by this being the XUDC controller bindings.

xusb_ prefix is added to be in sync with USB host driver. considering that this file already for XUSB hardware, it can be removed.
Will add details and remove xusb_ prefix.

Quoted 10 lines
Quoted 9 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 28

Quoted 9 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +8 -0
+- nvidia,xusb-padctl: phandle to the XUSB pad controller that is used to
+  configure the USB pads used by the XUDC controller
+- power-domains: A list of PM domain specifiers that reference each power-domain
+  used by the XUSB device mode controller. This list must comprise of a specifier
+  for the XUSBA and XUSBB power-domains. See ../power/power_domain.txt and
+  ../arm/tegra/nvidia,tegra20-pmc.txt for details.
+- power-domain-names: A list of names that represent each of the specifiers in
+  the 'power-domains' property. Must include 'xusb_ss' and 'xusb_device'
Quoted 6 lines

Same here, I'd drop the xusb_ prefix. I think the "device" power domain is also usually referred to as "XUSB_DEV", so perhaps make that "dev" instead?

Thierry

will update accordingly. and apply event at clocks naming for "device" to "dev".

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +4 -0
+
+For Tegra210:
+- avddio-usb-supply: PCIe/USB3 analog logic power supply. Must supply 1.05 V.
+- hvdd-usb-supply: USB controller power supply. Must supply 3.3 V.
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 33

Quoted 1 line
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +1 -0
+- avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V.

My understanding is that this last supply is really needed for the XUSB pad controller to bring up the PLL. In fact, I've just moved the same supply to the XUSB pad controller from the XUSB controller for all of the supported boards because having this in the XUSB controller would fail under some circumstances.

Will remove avdd-pll-utmip-supply from xudc driver, as its now part of padctl

Quoted 7 lines
Quoted 7 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 37

Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +4 -0
+
+- phys: Must contain an entry for each entry in phy-names.
+  See ../phy/phy-bindings.txt for details.
+- extcon-usb: Must contains an extcon-usb entry which detects

In the example below, this is simply "extcon".

yes, its extcon only, will update accordingly.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +5 -0
+  USB VBUS pin. See ../extcon/extcon-usb-gpio.txt for details.
+
+Optional properties:
+--------------------
+- phy-names: Should include an entry for each PHY used by the controller.
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 45

Quoted 3 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +3 -0
+  Names must be "usb2", and "usb3" if support SuperSpeed device mode.
+  - "usb3" phy, SuperSpeed (SSTX+/SSTX-/SSRX+/SSRX-) data lines
+  - "usb2" phy, USB 2.0 (D+/D-) data lines

Why are these optional? phys is required and references phy-names explicitly, so I think that effectively makes these phy-names required as well.

Reason being is SS mode is optional, but not usb 2.0 or earlier and hence added in optional, but considering phys and phy-names goes together, will move this section to required.

Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +21 -0
+
+Example:
+--------
+	pmc: pmc@7000e400 {
+		compatible = "nvidia,tegra210-pmc";
+		reg = <0x0 0x7000e400 0x0 0x400>;
+		clocks = <&tegra_car TEGRA210_CLK_PCLK>, <&clk32k_in>;
+		clock-names = "pclk", "clk32k_in";
+
+		powergates {
+			pd_xusbss: xusba {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				resets = <&tegra_car TEGRA210_CLK_XUSB_SS>;
+				#power-domain-cells = <0>;
+			};
+
+			pd_xusbdev: xusbb {
+				clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>;
+				resets = <&tegra_car 95>;
+				#power-domain-cells = <0>;
+			};

Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt line 76

Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +10 -0
+		};
+	};
+
+	xudc@700d0000 {
+		compatible = "nvidia,tegra210-xudc";
+		reg = <0x0 0x700d0000 0x0 0x8000>,
+			<0x0 0x700d8000 0x0 0x1000>,
+			<0x0 0x700d9000 0x0 0x1000>;
+
+		interrupts = <0 44 0x4>;

This should use symbolic names defined in the following includes:

Quoted 5 lines
Quoted 5 lines

dt-bindings/interrupt-controller/irq.h dt-bindings/interrupt-controller/arm-gic.h

Thierry

will update with corresponding macros.

-Nagarjuna

Quoted 34 lines
Quoted 32 lines
Quoted 32 lines
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.txt new file +29 -0
+
+		clocks = <&tegra_car TEGRA210_CLK_XUSB_DEV>,
+			<&tegra_car TEGRA210_CLK_XUSB_SS>,
+			<&tegra_car TEGRA210_CLK_XUSB_SSP_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_HS_SRC>,
+			<&tegra_car TEGRA210_CLK_XUSB_FS_SRC>;
+		clock-names = "xusb_device", "xusb_ss", "xusb_ss_src",
+			      "xusb_hs_src", "xusb_fs_src";
+
+		power-domains = <&pd_xusbdev>, <&pd_xusbss>;
+		power-domain-names = "xusb_device", "xusb_ss";
+
+		nvidia,xusb-padctl = <&padctl>;
+
+		phys = <&{/padctl@7009f000/pads/usb2/lanes/usb2-0}>;
+		phy-names = "usb2;
+
+		avddio-usb-supply = <&vdd_pex_1v05>;
+		hvdd-usb-supply = <&vdd_3v3_sys>;
+		avdd-pll-utmip-supply = <&vdd_1v8>;
+
+		extcon = <&extcon_usb>;
+	};
+
+	extcon_usb: extcon_vbus {
+		compatible = "linux,extcon-usb-gpio";
+		vbus-gpio = <&gpio TEGRA_GPIO(Z, 0) GPIO_ACTIVE_LOW>;
+	};
+
Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 7/8 usb: gadget: Add UDC driver for tegra XUSB device mode controller

Quoted 25 lines · Felipe Balbi
Quoted 23 lines · Nagarjuna Kristam

This patch adds UDC driver for tegra XUSB 3.0 device mode controller. XUSB device mode controller support SS, HS and FS modes

Based on work by:
Mark Kuo <[email protected]>
Andrew Bresticker <[email protected]>

---
 drivers/usb/gadget/udc/Kconfig      |   10 +
 drivers/usb/gadget/udc/Makefile     |    1 +
 drivers/usb/gadget/udc/tegra_xudc.c | 3702 +++++++++++++++++++++++++++++++++++
 3 files changed, 3713 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/tegra_xudc.c
drivers/usb/gadget/udc/Kconfig +0 -0
index 0a16cbd..f6f469c 100644
@@ -439,6 +439,16 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
Quoted 5 lines

drivers/usb/gadget/udc/Kconfig config USB_GADGET_XILINX · line 444

Quoted 3 lines
drivers/usb/gadget/udc/Kconfig +3 -0
+config USB_TEGRA_XUDC
+	tristate "NVIDIA Superspeed USB 3.0 Device Controller"
+	depends on ARCH_TEGRA

no compile_test?

That's not possible right now. The driver depends on functions that don't have dummy implementations to support COMPILE_TEST. I suppose that's something that we could change, but does it need to be part of this initial submission?

On that note:

Nagarjuna, I think we have PHY_TEGRA_XUSB as at least one other dependency. Without that the driver could be enabled but fail to link because of the missing implementations that that driver would've provided.

Thierry

#13 lore raw

Re: [PATCH V2 7/8] usb: gadget: Add UDC driver for tegra XUSB device mode controller

Quoted 37 lines · Thierry Reding
Quoted 25 lines · Felipe Balbi
Quoted 23 lines · Nagarjuna Kristam

This patch adds UDC driver for tegra XUSB 3.0 device mode controller. XUSB device mode controller support SS, HS and FS modes

Based on work by:
Mark Kuo <[email protected]>
Andrew Bresticker <[email protected]>

---
 drivers/usb/gadget/udc/Kconfig      |   10 +
 drivers/usb/gadget/udc/Makefile     |    1 +
 drivers/usb/gadget/udc/tegra_xudc.c | 3702 +++++++++++++++++++++++++++++++++++
 3 files changed, 3713 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/tegra_xudc.c
drivers/usb/gadget/udc/Kconfig +0 -0
index 0a16cbd..f6f469c 100644
@@ -439,6 +439,16 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
Quoted 5 lines

drivers/usb/gadget/udc/Kconfig config USB_GADGET_XILINX · line 444

Quoted 3 lines
drivers/usb/gadget/udc/Kconfig +3 -0
+config USB_TEGRA_XUDC
+	tristate "NVIDIA Superspeed USB 3.0 Device Controller"
+	depends on ARCH_TEGRA

no compile_test?

That's not possible right now. The driver depends on functions that don't have dummy implementations to support COMPILE_TEST. I suppose that's something that we could change, but does it need to be part of this initial submission?

Quoted 7 lines

On that note:

Nagarjuna, I think we have PHY_TEGRA_XUSB as at least one other dependency. Without that the driver could be enabled but fail to link because of the missing implementations that that driver would've provided.

Yes. Will add PHY_TEGRA_XUSB as dependecy for funtional dependency too.

- Nagarjuna

Quoted 2 lines

Thierry