Hello,
we designed a custom board with an USB B Port (device mode) and an USB A Port (host mode) connected to the same pins on the SOM.
The ID pin is floating and not connected to the SOM.
We want to switch between host and device mode only by detecting VBUS on the USB B Port.
Our hardware team designed the schematics so that the USB_OTG_VBUS is only connected to the device port.
In case USB_OTG_VBUS is high, the controller must be switched to device mode. If USB_OTG_VBUS is low, the controller must be switched to host mode.
I’ve found the part of the device tree which is responsible for this, but I do not know what to change, so that host mode is activated when the USB_OTG_VBUS is low.
external-connection {
vbus_id_extcon: extcon@1 {
compatible = "extcon-gpio-states";
reg = <0x1>;
extcon-gpio,name = "VBUS";
extcon-gpio,cable-states = <
0x0 0x1
0x1 0x0>;
gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Z, 1) 0>;
extcon-gpio,out-cable-names = <EXTCON_USB EXTCON_USB_HOST EXTCON_NONE>;
wakeup-source;
#extcon-cells = <1>;
};
};
GPIO00 is the pin where our VBUS Signal is pulling up USB_OTG_VBUS, so the GPIO(Z,1) seems to be correct already.
tegra_xudc: xudc@3550000 {
#if TEGRA_XUSB_DT_VERSION < DT_VERSION_3
extcon-cables = <&vbus_id_extcon 0>;
extcon-cable-names = "vbus";
#extcon-cells = <1>;
#endif
phys = <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-0}>;
#if TEGRA_XUSB_DT_VERSION >= DT_VERSION_3
phy-names = "usb2-0";
#else
phy-names = "usb2";
#endif
nvidia,xusb-padctl = <&xusb_padctl>;
nvidia,boost_cpu_freq = <1200>;
status = "okay";
};
Device mode seems to be configured correctly as it is activated when vbus is connected?
tegra_xhci: xhci@3610000 {
#if TEGRA_XUSB_DT_VERSION < DT_VERSION_3
extcon-cables = <&vbus_id_extcon 1>;
extcon-cable-names = "id";
#extcon-cells = <1>;
#endif
phys = <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-0}>,
<&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-1}>,
<&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-2}>,
<&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-2}>;
phy-names = "usb2-0", "usb2-1", "usb2-2", "usb3-2";
nvidia,xusb-padctl = <&xusb_padctl>;
status = "okay";
};
Host mode seems to be incorrect as it relies on the ID pin, what do I need to change here, so that it is activated when USB_OTG_VBUS is low? I could write vbus there, but how do I change it to enable the port when being low?