Skip to contentSkip to conversation

usb: chipidea: Add support for Tegra20 through Tegra124

RFC In review Thierry Reding 3 participants 10 messages May 26, 2016 – May 27, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover usb: chipidea: Add support for Tegra20 through Tegra124

From: Thierry Reding <[email protected]>

All Tegra SoC generations from Tegra20 through Tegra124 have a ChipIdea USB device controller. This set of patches adds very rudimentary support for it to the existing ChipIdea driver and enables them on the set of boards that I could easily test on.

I'm sending this out as RFC because I'm not sure yet how to merge this. While the driver seems to work fine (tested by exporting a USB driver or eMMC via the mass storage function) I don't yet understand how to make the driver switch between host and device modes dynamically. It might be useful to get this merged before, but I'd like to have some feedback on this, because doing so would mean that we need to use device mode on the devices where it's enabled and can't use the USBD port in host mode.

Thierry

Thierry Reding (5):
usb: chipidea: Add support for Tegra20/30/114/124
ARM: tegra: Enable UDC on TrimSlice
ARM: tegra: Enable UDC on Beaver
ARM: tegra: Enable UDC on Dalmore
ARM: tegra: Enable UDC on Jetson TK1

 arch/arm/boot/dts/tegra114-dalmore.dts    |  11 +++
 arch/arm/boot/dts/tegra124-jetson-tk1.dts |  13 +++-
 arch/arm/boot/dts/tegra20-trimslice.dts   |   3 +
 arch/arm/boot/dts/tegra30-beaver.dts      |  11 +++
 drivers/usb/chipidea/Makefile             |   1 +
 drivers/usb/chipidea/ci_hdrc_tegra.c      | 109 ++++++++++++++++++++++++++++++
 6 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/chipidea/ci_hdrc_tegra.c
Signature · 1 line
2.8.3
#1 lore raw

RFC 1/5 usb: chipidea: Add support for Tegra20/30/114/124

From: Thierry Reding <[email protected]>

All of these Tegra SoC generations have a ChipIdea UDC IP block that can be used for device mode communication with a host. Implement rudimentary support that doesn't allow switching between host and device modes.

---
 drivers/usb/chipidea/Makefile        |   1 +
 drivers/usb/chipidea/ci_hdrc_tegra.c | 109 +++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)
 create mode 100644 drivers/usb/chipidea/ci_hdrc_tegra.c
drivers/usb/chipidea/Makefile +1 -0
index 518e445476c3..3532df6561d9 100644
@@ -10,6 +10,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM)		+= otg_fsm.o
 obj-$(CONFIG_USB_CHIPIDEA)	+= ci_hdrc_usb2.o
 obj-$(CONFIG_USB_CHIPIDEA)	+= ci_hdrc_msm.o
 obj-$(CONFIG_USB_CHIPIDEA)	+= ci_hdrc_zevio.o
+obj-$(CONFIG_USB_CHIPIDEA)	+= ci_hdrc_tegra.o
 
 obj-$(CONFIG_USB_CHIPIDEA_PCI)	+= ci_hdrc_pci.o
 
drivers/usb/chipidea/ci_hdrc_tegra.c new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.8.3
#2 lore raw

Re: [RFC 1/5] usb: chipidea: Add support for Tegra20/30/114/124

Quoted 5 lines · Thierry Reding

From: Thierry Reding <[email protected]>

All of these Tegra SoC generations have a ChipIdea UDC IP block that can be used for device mode communication with a host. Implement rudimentary support that doesn't allow switching between host and device modes.

Are you sure this is correct for Tegra20? I ask because for the /host/ mode driver, there's a "has_hostpc" flag which is set to false for Tegra20 and true for all other SoCs. In the U-Boot device mode driver (if not in the kernel driver; I didn't check), there's a concept of "has hostpc" too. I might expect that flag to be set the same way for both drivers. That said, I /think/ the host and device HW are unrelated, so it's possible has_hostpc might be set differently for them. Unfortunately, we haven't enabled the device mode driver for any Tegra20 system in U-Boot so I can't tell whether we should enable has_hostpc for Tegra20's device mode driver.

Still, if this code works then I guess it's likely correct...

#3 lore raw

Re: [RFC 1/5] usb: chipidea: Add support for Tegra20/30/114/124

Quoted 18 lines · Stephen Warren
Quoted 5 lines · Thierry Reding

From: Thierry Reding <[email protected]>

All of these Tegra SoC generations have a ChipIdea UDC IP block that can be used for device mode communication with a host. Implement rudimentary support that doesn't allow switching between host and device modes.

Are you sure this is correct for Tegra20? I ask because for the /host/ mode driver, there's a "has_hostpc" flag which is set to false for Tegra20 and true for all other SoCs. In the U-Boot device mode driver (if not in the kernel driver; I didn't check), there's a concept of "has hostpc" too. I might expect that flag to be set the same way for both drivers. That said, I /think/ the host and device HW are unrelated, so it's possible has_hostpc might be set differently for them. Unfortunately, we haven't enabled the device mode driver for any Tegra20 system in U-Boot so I can't tell whether we should enable has_hostpc for Tegra20's device mode driver.

Quoted 1 line

Still, if this code works then I guess it's likely correct...

On the other hand, it looks like the kernel device mode driver might auto-detect this; in core.c:hw_device_init(), I see:

        reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
                __ffs(HCCPARAMS_LEN);
        ci->hw_bank.lpm  = reg;

... and in host.c:host_start(), I see:

	ehci->has_hostpc = ci->hw_bank.lpm;
#4 lore raw

RFC 2/5 ARM: tegra: Enable UDC on TrimSlice

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Override the compatible string of the first USB controller to enable device mode.

---
 arch/arm/boot/dts/tegra20-trimslice.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boot/dts/tegra20-trimslice.dts +3 -0
index 4a035f74043a..5496f3dc089c 100644
@@ -336,11 +336,14 @@
 	};
 
 	usb@c5000000 {
+		compatible = "nvidia,tegra20-udc";
 		status = "okay";
+		dr_mode = "otg";
 	};
 
 	usb-phy@c5000000 {
 		status = "okay";
+		dr_mode = "otg";
 		vbus-supply = <&vbus_reg>;
 	};
 
Signature · 1 line
2.8.3
#5 lore raw

RFC 3/5 ARM: tegra: Enable UDC on Beaver

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Override the compatible string of the first USB controller to enable device mode.

---
 arch/arm/boot/dts/tegra30-beaver.dts | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/tegra30-beaver.dts +11 -0
index 4ea3ecc10934..5f32bcd96fbc 100644
@@ -1935,6 +1935,17 @@
 		non-removable;
 	};
 
+	usb@7d000000 {
+		compatible = "nvidia,tegra30-udc";
+		status = "okay";
+		dr_mode = "otg";
+	};
+
+	usb-phy@7d000000 {
+		status = "okay";
+		dr_mode = "otg";
+	};
+
 	usb@7d004000 {
 		status = "okay";
 	};
Signature · 1 line
2.8.3
#6 lore raw

RFC 4/5 ARM: tegra: Enable UDC on Dalmore

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Override the compatible string of the first USB controller to enable device mode.

---
 arch/arm/boot/dts/tegra114-dalmore.dts | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/tegra114-dalmore.dts +11 -0
index c970bf65c74c..53d664f718ff 100644
@@ -1122,6 +1122,17 @@
 		non-removable;
 	};
 
+	usb@7d000000 {
+		compatible = "nvidia,tegra114-udc";
+		status = "okay";
+		dr_mode = "otg";
+	};
+
+	usb-phy@7d000000 {
+		status = "okay";
+		dr_mode = "otg";
+	};
+
 	usb@7d008000 {
 		status = "okay";
 	};
Signature · 1 line
2.8.3
#7 lore raw

Re: [RFC 4/5] ARM: tegra: Enable UDC on Dalmore

Quoted 19 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Override the compatible string of the first USB controller to enable device mode.

---
 arch/arm/boot/dts/tegra114-dalmore.dts | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/tegra114-dalmore.dts +1 -0
index c970bf65c74c..53d664f718ff 100644
@@ -1122,6 +1122,17 @@
 		non-removable;
 	};
 
+	usb@7d000000 {

arch/arm/boot/dts/tegra114-dalmore.dts line 1135

Quoted 10 lines
arch/arm/boot/dts/tegra114-dalmore.dts +10 -0
+		compatible = "nvidia,tegra114-udc";
+		status = "okay";
+		dr_mode = "otg";
+	};
+
+	usb-phy@7d000000 {
+		status = "okay";
+		dr_mode = "otg";
+	};
+

It is a USB PHY node, you don't need to set dr_mode for it.

Signature · 2 lines
Best Regards,
Peter Chen
#8 lore raw

RFC 5/5 ARM: tegra: Enable UDC on Jetson TK1

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Override the compatible string of the first USB controller to enable device mode.

---
 arch/arm/boot/dts/tegra124-jetson-tk1.dts | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra124-jetson-tk1.dts +12 -1
index 941f36263c8f..30e92cc85b86 100644
@@ -1726,7 +1726,7 @@
 
 				lanes {
 					usb2-0 {
-						nvidia,function = "xusb";
+						nvidia,function = "snps";
 						status = "okay";
 					};
 
@@ -1833,6 +1833,17 @@
 		};
 	};
 
+	usb@0,7d000000 {
+		compatible = "nvidia,tegra124-udc";
+		status = "okay";
+		dr_mode = "otg";
+	};
+
+	usb-phy@0,7d000000 {
+		status = "okay";
+		dr_mode = "otg";
+	};
+
 	/* mini-PCIe USB */
 	usb@0,7d004000 {
 		status = "okay";
Signature · 1 line
2.8.3
#9 lore raw
In reply to Thierry Reding
Quoted 7 lines · Thierry Reding

From: Thierry Reding <[email protected]>

All Tegra SoC generations from Tegra20 through Tegra124 have a ChipIdea USB device controller. This set of patches adds very rudimentary support for it to the existing ChipIdea driver and enables them on the set of boards that I could easily test on.

Quoted 8 lines

I'm sending this out as RFC because I'm not sure yet how to merge this. While the driver seems to work fine (tested by exporting a USB driver or eMMC via the mass storage function) I don't yet understand how to make the driver switch between host and device modes dynamically. It might be useful to get this merged before, but I'd like to have some feedback on this, because doing so would mean that we need to use device mode on the devices where it's enabled and can't use the USBD port in host mode.

Chipidea driver supports many ways to switch between host and device mode. It can support switching with/without disconnecting cable.

Most of cases need to disconnect cable (Micro-AB) to switch between host and device mode, I just take this as an example:

Using ID pin which is at Micro-B receptacle on the board to determine host (ID = 0) or device (ID = 1 )mode.

- ID pin connects to CPU, and ID interrupt and value can be get through register OTGSC.
- ID pin does not connect to CPU, and there is a dedicated GPIO for ID.

Signature · 2 lines
Best Regards,
Peter Chen