Jetson Nano OTG USB2 and USB3 DT help

I believe that I need to make some device tree changes to get USB working for our custom board.

We have a single USB “port” (I know overloaded term) that is wired for both USB 2 and USB 3 as Type A. It has USB0 setup for USB 2 and USBSS wired for USB 3.

Because we want OTG support and to be able to manually force it into Host or Device mode we have a microcontroller setting ID to either 1 or 0, and VBUS to either 1 or 0 as well. In Device mode we set ID to 1 and VBUS to 0. For Host mode we set ID to 0 and VBUS to 0.

We also enable HID in the kernel config.

By default we have it in device mode (ID=1 VBUS=0).

If I decompile the device tree I see this:

                ports {

                        usb2-0 {
                                status = "okay";
                                vbus-supply = <0x46>;
                                mode = "otg";
                                nvidia,usb3-port-fake = <3>;
                        };

                        usb2-1 {
                                status = "okay";
                                vbus-supply = <0x47>;
                                mode = "host";
                                linux,phandle = <0xb4>;
                                phandle = <0xb4>;
                        };

                        usb2-2 {
                                status = "okay";
                                vbus-supply = <0x48>;
                                mode = "host";
                        };

                        usb2-3 {
                                status = "disabled";
                        };

                        usb3-0 {
                                status = "okay";
                                nvidia,usb2-companion = <0x1>;
                        };
...

I tried to change nvidia,usb2-companion to <0x0> and remove the nvidia,usb3-port-fake line. I still don’t see a USB device show up when running /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode-start.sh

I am sure there are some more device tree changes that are needed to make this work, could anyone help me out with making USB 2 and 3 work with OTG (with the dynamic Host/Device switch)?

Please refer to the USB porting guide in the developer guide.

I can’t answer, but will suggest that you just look at the micro-OTG port device tree on the dev kit and its carrier board schematic.

I tried to follow the porting guide. We are going for something similar to the example with both ID and VBUS_DET being used to determine the host vs. device. This is the dtsi file I came up with. Does anyone see anything wrong right off the bat?

#include <dt-bindings/platform/t210/t210.h>
#include <dt-bindings/gpio/tegra-gpio.h>
/ {
	vbus_id_extcon: usb_otg {
		compatible = "extcon-gpio-states";
		extcon-gpio,name = "VBUS_ID";
		extcon-gpio,wait-for-gpio-scan = <0>;
		extcon-gpio,cable-states = <0x3 0x0
									0x0 0x2
									0x1 0x2
									0x2 0x1>;
		gpios = <&gpio TEGRA_GPIO(Y, 2) 0
				&gpio TEGRA_GPIO(V, 1) 0>;
		extcon-gpio,out-cable-names =
				<EXTCON_USB EXTCON_USB_HOST EXTCON_NONE>;
		#extcon-cells = <1>;
	};

	xusb_padctl@7009f000 {
		status = "okay";
		pads {
			usb2 {
				status = "okay";
				lanes {
					usb2-0 {
						status = "okay";
						nvidia,function = "xusb";
					};
					usb2-1 {
						status = "disable";
						nvidia,function = "xusb";
					};
					usb2-2 {
						status = "disable";
						nvidia,function = "xusb";
					};
				};
			};
			pcie {
				status = "okay";
				lanes {
					pcie-0 {
						status = "disable";
						nvidia,function = "pcie-x1";
					};
					pcie-1 {
						status = "disable";
						nvidia,function = "pcie-x4";
					};
					pcie-2 {
						status = "disable";
						nvidia,function = "pcie-x4";
					};
					pcie-3 {
						status = "disable";
						nvidia,function = "pcie-x4";
					};
					pcie-4 {
						status = "disable";
						nvidia,function = "pcie-x4";
					};
					pcie-5 {
						status = "disable";
						nvidia,function = "xusb";
					};
					pcie-6 {
						status = "okay";
						nvidia,function = "xusb";
					};
				};
			};
		};

		ports {
			usb2-0 {
				status = "okay";
				mode = "otg";
			};
			usb2-1 {
				status = "disable";
				mode = "host";
			};
			usb2-2 {
				status = "disable";
				mode = "host";
			};
			usb3-0 {
				status = "okay";
				nvidia,usb2-companion = <0>;
			};
		};
	};

	xusb@70090000 {
		phys = <&{/xusb_padctl@7009f000/pads/usb2/lanes/usb2-0}>,
				<&{/xusb_padctl@7009f000/pads/pcie/lanes/pcie-6}>;
		phy-names = "usb2-0", "usb3-0";
		extcon-cables = <&vbus_id_extcon 0>;
		extcon-cable-names = "id";
		#extcon-cells = <1>;
		nvidia,xusb-padctl = <&xusb_padctl>;
		status = "okay";
	};

	xudc@700d0000 {
		phys = <&{/xusb_padctl@7009f000/pads/usb2/lanes/usb2-0}>,
				<&{/xusb_padctl@7009f000/pads/pcie/lanes/pcie-6}>;
		phy-names = "usb2-0", "usb3-0";
		extcon-cables = <&vbus_id_extcon 1>;
	    extcon-cable-names = "vbus";
		#extcon-cells = <1>;
		nvidia,xusb-padctl = <&xusb_padctl>;
		status = "okay";
	};
};

Hi,

How is the status of the dmesg now?

Im still trying to figure out where to put the dtsi file so it overrides what is usually in the dtb. Right now I am not seeing changes for anything in this dtsi.

Hi,

You may need to follow the developer guide to rebuild the dtb and that dtb will include the change you added in dtsi file.

dtsi file is more like a header file that is for other main dts files to include.

yes I am including the dtsi the same as the other ones we have in the kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts file. It doesn’t seem to be taking the changes though as the others. It might be something with my formatting. Will figure it out and then be able to check if anything changed in dmesg.

hi,

You can check /proc/device-tree on your jetson nano after you flash it.

Yes, it doesn’t match. I am also using dtc to decompile it. Would I need to do an overlay in addition to or instead of the .dtsi route? I thought that if I included something it would override the “common” defaults. That is what seems to happen with our other 4 dtsi files.

It was a problem with our staging. We hadn’t been seeing the new DTB file since the morning. I am now trying to figure out another issue since it seems our PinMux files were also being copied wrong.

Once I figure the staging issues out I can get back to this and get the dmesg, hopefully fixing the staging will help fix this.

So I have some updates after we got our staging working again. I set it up so I can manually set both the ID and VBUS lines logic states.

If I set ID=1 and VBUS=1 this shows up in dmesg (Same for USB Key, USB2 wire, and USB3 wire)

[ 1076.400334] extcon-gpio-states usb_otg: Cable state:0, cable id:0
[ 1076.400727] unbalanced disables for vdd-usb-vbus
[ 1076.423875] Workqueue: events tegra_xusb_otg_vbus_work
[ 1076.430330] [<ffffff800849cbac>] tegra210_xusb_padctl_vbus_power_off+0x1b4/0x3d0
[ 1076.430391] [<ffffff800849cfdc>] tegra210_xusb_padctl_otg_vbus_handle+0x74/0xe8
[ 1076.430440] [<ffffff80084960ec>] tegra_xusb_otg_vbus_work+0x5c/0x78
[ 1076.434527] tegra-xusb-padctl 7009f000.xusb_padctl: disable usb2-0 vbus failed -5

If I set ID=0 and VBUS=1 this shows up in dmesg (Same for USB Key, USB2 wire, and USB3 wire)

[ 1247.747147] extcon-gpio-states usb_otg: Cable state:1, cable id:1
[ 1247.751447] unbalanced disables for vdd-usb-vbus
[ 1247.773280] Workqueue: events tegra_xusb_otg_vbus_work
[ 1247.778062] [<ffffff800849cbac>] tegra210_xusb_padctl_vbus_power_off+0x1b4/0x3d0
[ 1247.778068] [<ffffff800849cfdc>] tegra210_xusb_padctl_otg_vbus_handle+0x74/0xe8
[ 1247.778073] [<ffffff80084960ec>] tegra_xusb_otg_vbus_work+0x5c/0x78
[ 1247.778263] tegra-xusb-padctl 7009f000.xusb_padctl: disable usb2-0 vbus failed -5

If I set ID=0 and VBUS=0 this shows up in dmesg with a USB3 cable in:

[ 1412.160139] extcon-gpio-states usb_otg: Cable state:1, cable id:2
[ 1412.160769] tegra-xusb 70090000.xusb: exiting ELPG
[ 1412.165224] unbalanced disables for vdd-usb-vbus
[ 1412.187023] Workqueue: events tegra_xusb_otg_vbus_work
[ 1412.191733] [<ffffff800849cbac>] tegra210_xusb_padctl_vbus_power_off+0x1b4/0x3d0
[ 1412.191737] [<ffffff800849cfdc>] tegra210_xusb_padctl_otg_vbus_handle+0x74/0xe8
[ 1412.191740] [<ffffff80084960ec>] tegra_xusb_otg_vbus_work+0x5c/0x78
[ 1412.191835] tegra-xusb-padctl 7009f000.xusb_padctl: disable usb2-0 vbus failed -5
[ 1412.201653] tegra-xusb 70090000.xusb: Firmware timestamp: 2020-07-31 09:33:12 UTC, Version: 50.26 release
[ 1412.202308] tegra-xusb 70090000.xusb: exiting ELPG done
[ 1412.202462] tegra-xusb 70090000.xusb: Upgrade port 0 to USB3.0
[ 1412.202466] tegra-xusb 70090000.xusb: Upgrade port 1 to USB3.0
[ 1412.219570] usb usb2-port1: config error
[ 1416.295979] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 1420.376447] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
... repeats

If I set ID=0 and VBUS=0 this shows up in dmesg with a USB2 cable in:

[ 1516.187326] tegra-xusb 70090000.xusb: exiting ELPG
[ 1516.192503] tegra-xusb 70090000.xusb: Firmware timestamp: 2020-07-31 09:33:12 UTC, Version: 50.26 release
[ 1516.193163] tegra-xusb 70090000.xusb: exiting ELPG done
[ 1516.193270] tegra-xusb 70090000.xusb: Upgrade port 0 to USB3.0
[ 1516.193275] tegra-xusb 70090000.xusb: Upgrade port 1 to USB3.0
[ 1518.199705] tegra-xusb 70090000.xusb: entering ELPG
[ 1518.204597] tegra-xusb 70090000.xusb: entering ELPG done

If I set ID=0 and VBUS=0 I successfully can mount a USB drive. This shows up in dmesg with a USB Key in:

[ 1608.071715] tegra-xusb 70090000.xusb: exiting ELPG
[ 1608.073255] tegra-xusb-padctl 7009f000.xusb_padctl: power on UTMI pads 0
[ 1608.077958] tegra-xusb 70090000.xusb: Firmware timestamp: 2020-07-31 09:33:12 UTC, Version: 50.26 release
[ 1608.079781] tegra-xusb 70090000.xusb: exiting ELPG done
[ 1608.081423] usb usb2: usb_suspend_both: status 0
[ 1608.307969] usb 1-1: new high-speed USB device number 4 using tegra-xusb
[ 1608.336232] usb 1-1: New USB device found, idVendor=1221, idProduct=3234
[ 1608.336305] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1608.336352] usb 1-1: Product: USB Disk
[ 1608.336394] usb 1-1: Manufacturer: Flash
[ 1608.336440] usb 1-1: SerialNumber: 37270447F682197019048
[ 1608.341697] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 1608.342101] scsi host0: usb-storage 1-1:1.0

If I set ID=1 and VBUS=0 this shows up in dmesg with a USB2 cable:

[ 1782.131710] extcon-gpio-states usb_otg: Cable state:1, cable id:2

If I set ID=1 and VBUS=0 this shows up in dmesg with a USB3 cable:

[ 1940.387706] extcon-gpio-states usb_otg: Cable state:1, cable id:2
[ 1940.388405] tegra-xusb 70090000.xusb: exiting ELPG
[ 1940.393367] tegra-xusb 70090000.xusb: Firmware timestamp: 2020-07-31 09:33:12 UTC, Version: 50.26 release
[ 1940.394049] tegra-xusb 70090000.xusb: exiting ELPG done
[ 1940.394267] tegra-xusb 70090000.xusb: Upgrade port 0 to USB3.0
[ 1940.394277] tegra-xusb 70090000.xusb: Upgrade port 1 to USB3.0
[ 1940.411793] usb usb2-port1: config error
[ 1944.488486] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
...repeats

If I set ID=1 and VBUS=0 and when I plug in a USB key I successfully can find it in lsusb and mount the drive. This is the dmesg:

[ 1978.422599] tegra-xusb 70090000.xusb: exiting ELPG
[ 1978.424668] tegra-xusb-padctl 7009f000.xusb_padctl: power on UTMI pads 0
[ 1978.429701] tegra-xusb 70090000.xusb: Firmware timestamp: 2020-07-31 09:33:12 UTC, Version: 50.26 release
[ 1978.431471] tegra-xusb 70090000.xusb: exiting ELPG done
[ 1978.659697] usb 1-1: new high-speed USB device number 5 using tegra-xusb
[ 1978.682661] usb 1-1: New USB device found, idVendor=1221, idProduct=3234
[ 1978.682732] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1978.682785] usb 1-1: Product: USB Disk
[ 1978.682831] usb 1-1: Manufacturer: Flash
[ 1978.682876] usb 1-1: SerialNumber: 37270447F682197019048
[ 1978.688171] usb-storage 1-1:1.0: USB Mass Storage device detected

I can’t seem to get any device to show up on the Host side. I am running the /opt/nvidia/l4t-usb-device-mode scripts. I think USB Host mode is working, but I need help getting USB device mode to work.

I had to swap the ID and VBUS lines, now atleast we match the table to be either in Device Mode or Host Mode. Host Mode seems to work for at least USB keys, but Device mode still shows:

[ 5735.883784] extcon-gpio-states usb_otg: Cable state:1, cable id:1
[ 5735.884445] tegra-xudc-new 700d0000.xudc: vbus state: 1
[ 5735.884548] tegra-xudc-new 700d0000.xudc: exiting ELPG
[ 5735.888742] tegra-xudc-new 700d0000.xudc: exiting ELPG done
[ 5735.888752] tegra-xudc-new 700d0000.xudc: device mode on: 0
[ 5735.888760] tegra-xudc-new 700d0000.xudc: active: 0 => 1
[ 5735.888776] unbalanced disables for vdd-usb-vbus
[ 5735.888809] ------------[ cut here ]------------
[ 5735.893429] WARNING: CPU: 0 PID: 7802 at .../Linux_for_Tegra/sources/kernel/kernel-4.9/drivers/regulator/core.c:2446 _regulator_disable+0xc0/0x198
[ 5735.910514] Modules linked in: bnep fuse zram xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter userspace_alert overlay nvgpu ip_tables x_tables [last unloaded: gpio_bb]

[ 5735.910564] CPU: 0 PID: 7802 Comm: kworker/0:0 Tainted: G        W       4.9.253-tegra #45
[ 5735.910567] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[ 5735.910578] Workqueue: events tegra_xusb_otg_vbus_work
[ 5735.910583] task: ffffffc0f9118000 task.stack: ffffffc0f3ef8000
[ 5735.910587] PC is at _regulator_disable+0xc0/0x198
[ 5735.910591] LR is at _regulator_disable+0xc0/0x198
[ 5735.910594] pc : [<ffffff80086d6d58>] lr : [<ffffff80086d6d58>] pstate: 40400045
[ 5735.910596] sp : ffffffc0f3efbc70
[ 5735.910599] x29: ffffffc0f3efbc70 x28: 0000000000000000
[ 5735.910605] x27: 0000000000000000 x26: ffffffc0fefd4600
[ 5735.910611] x25: ffffff800a0ec000 x24: 0000000000000001
[ 5735.910617] x23: 0000000000000000 x22: 0000000000000000
[ 5735.910623] x21: ffffffc0f95e5868 x20: ffffffc0f95e5800
[ 5735.910629] x19: ffffffc0f95e5800 x18: 0000000000000000
[ 5735.910634] x17: 0000000000000001 x16: 0000000000000007
[ 5735.910640] x15: ffffffffffffffff x14: ffffffc0f589b107
[ 5735.910646] x13: ffffffc0f589b106 x12: 0000000000000000
[ 5735.910651] x11: 0000000000000006 x10: 00000000000004d2
[ 5735.910657] x9 : 0000000000000000 x8 : ffffffc0fefc246c
[ 5735.910663] x7 : 0000000000000000 x6 : 0000000000000001
[ 5735.910668] x5 : 0000000000000000 x4 : ffffffc0fefccbe8
[ 5735.910674] x3 : ffffffc0fefccbe8 x2 : 0000000000000007
[ 5735.910680] x1 : ffffffc0f9118000 x0 : 0000000000000024

[ 5735.910687] ---[ end trace f9064f8896502c20 ]---
[ 5735.915293] Call trace:
[ 5735.915298] [<ffffff80086d6d58>] _regulator_disable+0xc0/0x198
[ 5735.915302] [<ffffff80086d6e80>] regulator_disable+0x50/0x90
[ 5735.915307] [<ffffff800849cbac>] tegra210_xusb_padctl_vbus_power_off+0x1b4/0x3d0
[ 5735.915311] [<ffffff800849cfdc>] tegra210_xusb_padctl_otg_vbus_handle+0x74/0xe8
[ 5735.915315] [<ffffff80084960ec>] tegra_xusb_otg_vbus_work+0x5c/0x78
[ 5735.915320] [<ffffff80080d40ac>] process_one_work+0x1e4/0x4b0
[ 5735.915324] [<ffffff80080d43c8>] worker_thread+0x50/0x4c8
[ 5735.915328] [<ffffff80080db09c>] kthread+0xec/0xf0
[ 5735.915332] [<ffffff80080838a0>] ret_from_fork+0x10/0x30
[ 5735.915575] tegra-xusb-padctl 7009f000.xusb_padctl: disable usb2-0 vbus failed -5

I am very close. I am going to post the dtsi up to this point for anyone who is struggling with the same:

#include <dt-bindings/platform/t210/t210.h>
#include <dt-bindings/gpio/tegra-gpio.h>

/ {
	vbus_id_extcon: usb_otg {
		compatible = "extcon-gpio-states";
		extcon-gpio,name = "VBUS_ID";
		extcon-gpio,wait-for-gpio-scan = <10>;
		extcon-gpio,cable-states = <0x3 0x0
									0x0 0x2
									0x1 0x2
									0x2 0x1>;
		gpios = <&gpio TEGRA_GPIO(V, 1) 0
				&gpio TEGRA_GPIO(Y, 2) 0>;
		extcon-gpio,out-cable-names =
				<EXTCON_USB EXTCON_USB_HOST EXTCON_NONE>;
		#extcon-cells = <1>;
		cable-connected-on-boot = <1>
	};

	xusb_padctl@7009f000 {
		status = "okay";
		pads {
			usb2 {
				status = "okay";
				lanes {
					usb2-0 {
						status = "okay";
						nvidia,function = "xusb";
					};
					usb2-1 {
						status = "disable";
						nvidia,function = "xusb";
					};
					usb2-2 {
						status = "disable";
						nvidia,function = "xusb";
					};
				};
			};

			pcie {
				status = "okay";

				lanes {
					pcie-1 {
						status = "disable";
					};
					pcie-2 {
						status = "disable";
					};
					pcie-3 {
						status = "disable";
					};
					pcie-4 {
						status = "disable";
					};
					pcie-5 {
						status = "disable";
					};
					pcie-6 {
						status = "okay";
						nvidia,function = "xusb";
					};
				};
			};
		};

		ports {
			usb2-0 {
				status = "okay";
				mode = "otg";
				/delete-property/ nvidia,usb3-port-fake;
			};
			usb2-1 {
				status = "disable";
				mode = "host";
			};
			usb2-2 {
				status = "disable";
				mode = "host";
			};
			usb3-0 {
				status = "okay";
				nvidia,usb2-companion = <0>;
			};
		};
	};

	xusb@70090000 {
		phys = <&{/xusb_padctl@7009f000/pads/usb2/lanes/usb2-0}>,
				<&{/xusb_padctl@7009f000/pads/pcie/lanes/pcie-6}>;
		phy-names = "usb2-0", "usb3-0";
		extcon-cables = <&vbus_id_extcon 1>;
		extcon-cable-names = "id";
		#extcon-cells = <1>;
		nvidia,xusb-padctl = <&xusb_padctl>;
		status = "okay";
	};

	xudc@700d0000 {
		phys = <&{/xusb_padctl@7009f000/pads/usb2/lanes/usb2-0}>,
				<&{/xusb_padctl@7009f000/pads/pcie/lanes/pcie-6}>;
		phy-names = "usb2", "usb3";
		extcon-cables = <&vbus_id_extcon 0>;
	    extcon-cable-names = "vbus";
		#extcon-cells = <1>;
		nvidia,xusb-padctl = <&xusb_padctl>;
		status = "okay";
	};

	xotg {
		status = "okay";
		phys = <&{/xusb_padctl@7009f000/pads/usb2/lanes/usb2-0}>,
				<&{/xusb_padctl@7009f000/pads/pcie/lanes/pcie-6}>;
		phy-names = "otg-usb2", "otg-usb3";
 	};
};

I am able to see a USB Key show up in host mode (ID low and VBUS high) and the default nv-l4t-usb-device-mode device show up on my laptop when I plug in a USB2 cable in device mode (ID high and VBUS low).

However, if I try and plug in a USB3 external HD in host mode nothing shows up, though I hear the HD start to spin. Also if I use a USB3 cable in device mode my laptop can tell there is some sort of device connected but it can’t figure out what type of device it is so it fails to setup the ethernet connection.

EDIT:
this is the message I see when connecting the jetson custom board to my laptop with a USB3 cable:
The device ‘NVIDIA Linux for Tegra’ was unable to connect to its ideal host controller. An attempt will be made to connect this device to the best available host controller. This might result in undefined behavior for this device.

@WWWang, incase you haven’t seen the updates on this for a while.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

  1. Sorry that I didn’t see the post and you also tagged the wrong person…

  2. Please share your schematic, full dts converted from dtb and also the latest dmesg.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.