How works USBC_VBUS_DET

Good morning,
I have some doubts about how to use USBC line, and how to configure Device Tree to use it correctly.

I work with:

  • imx6ull trdx module;
  • colibri evaluation v3 board;
  • our custom carrier board;
  • Linux BSP 5.6
  • Kernel 5.4-2.3

In our custom carrier board we need to use both USBH and USBC lines.
USBH is connected to a usb-hub, while USBC is directly connected to a usb socket because we need to read /save data on a simple usb-stick.

From datasheet I understood that USBC can be used in both USB Host and USB Client modes, but, because we connect a usb-stick, we are working with USB Host mode. Correct?

For that reason I disabled

extcon_usbc_det

node in my Device Tree, to use that pin as standard GPIO.
Problem is that, doing that, I cannot access anymore my usb-stick. I have to maintain it enabled.

extcon_usbc_det uses GPIO5.02 as id-gpio (check imx6ull-colibri-eval-v3.dtsi)

	extcon_usbc_det: usbc_det {
		compatible = "linux,extcon-usb-gpio";
		debounce = <25>;
		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
	};

Can someone explain to me why I need to leave that pin with default function? because explanation in datasheet it is not clear to me.
Because the datasheet (page 36) reports that pin Sodimm 137 std function is: USB Client Cable
Detect. But we are using it as host.

Thanks.
Riccardo

Hello @RiccardoC_DLK ,

you can find information in our colibri ref guide page 18.

If you need more help we can set up a video Call.

Best Regards,

Matthias

Thank you Matthias, but it is not clear to me sorry.
I have already read Design Guide, but I can’t figure it how pin 137 works.

On our carrier board we connected pin (sodimm) 137 to a led, because initiatially we wanted to use it as GPIO.
For USB port type A we are using pin 143 and 145 only. What we noticed it that I can’t detect a usb key if I disable ‘extcon_usbc_det’ node in DeviceTree.
If I enable it again, the module is able to detect the usbkey.
How can be possibile?

Attached you can find our schematic, where VBUS is not connected to any Toradex pin. You see we are using only USBC_P and USBC_N pins. GPIO133 is for OverCurrent detection.

Thanks.
Riccardo.

USB_C port can be used either as USB host or USB device. The Colibri iMX6ULL module does not support true OTG, but the interface can be configured as host or client. Due to compatibility with other Colibri modules, the current evaluation board and the other Toradex carrier board do not use the USB OTG ID pin to detect whether a Type A or Type B cable is plugged in. Instead, the VBUS is used for detecting the Host or Client mode.
2.3.2.2 USB 2.0 OTG Schematic Example
If no cable is plugged into the Micro-AB jack, the port is configured to host mode and the 5V
power output (VCC_USB2 in the schematic below) is disabled. If a Micro-B is plugged in (ID pin is
floating on such plugs), the VCC_USB2 comes from the cable since the system gets plugged into a
host. With help of the voltage divider, the USB_C_DET signal gets around 3.3V. This signalizes the
module that it has been connected to a host and need to switch to client mode.

From Colibri iMX6ULL datasheet:
137 USB Client CableDetect,SPDIF_OUT SNVS_TAMPER2 gpio5.IO[2]
Use this pin to detect if VBUS is present (5V USB supply). Please note that this pin is only
3.3V tolerant
Even though this is just a regular GPIO, it is recommended to use this one to be compatible with the Toradex BSP

So if you define extcon_usbc_det node USB_C can be used as a host or as device depending on level on GPIO pin gpio5 2 . And to make it enumerate USB stick properly gpio 5 2 (pin 137) must be LOW. When extcon_usbc_det node is not present USB_C is always configured as USB host and able enumerate your USB stick no matter what pin 137 level is.

@alex.tx,

I don’t know what you mean by true OTG, perhaps dedicated real ID pin function instead of GPIO, but Colibri iMMX6ULL USB_C can be used as OTG. On Iris V1.1 it works well, the same as with other Colibries. USB role has to be set to “otg” in device tree, which is already so by default.

Yes, on Iris 1.1 ID pin (shorted to GND) controls power flow from Iris to flash drive connected to USB micro. USB_C_DET detects connection as slave to USB host. This seems being enough to work as OTG without any additional manipulations in DT or sysfs.

Regards,
Edward

We don’t have a dedicated DT for the Iris board. Could you please let me know which DT you are using for the board? I’m doubtful that USB_C will support dual role without the extcon_usbc_det node in the DT you are using.

Colibri iMX6ULL + Iris 1.1 is supported since long ago. At least in this git I see DT files for Iris, even for fresh EMMC variant:

dts « boot « arm « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Ok and it has the extcon_usbc_det node . So you still need to have an additional manipulations in DT to make USB_C dual role works.

@RiccardoC_DLK

Thank you for your feedback. What Alex posted should answer your questions.
I will check internally if we have to add something to our ref. design guide to make it more clear.
If you want we can set up a call and go over your schematic.

Best Regards,

Matthias

Thank you both.
From what I understood so, usbc port needs the ID pin (sodimm 137) to switch between client and host mode.
And because we need it as a Host, we can leave it unconnected (or shorted to ground).
Correct?

You need either connect it ground or remove extcon_usbc_det node from you Device Tree. In last case you can use pin 137 as a regular GPIO

1 Like

I tried adding these lines in my Device Tree but it seems nothing happens.

&extcon_usbc_det {
	status = "disabled";
};

Usb-key is never detected.
Should I instead declaring another id-gpio ?

This is classic code into device tree. should I change id-gpio line?

	extcon_usbc_det: usbc_det {
		compatible = "linux,extcon-usb-gpio";
		debounce = <25>;
		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
	};

In this case status has no effect. You should instead delete extcon property

&usbotg1 {
     /delete-property/ extcon;
};

hello @RiccardoC_DLK,

have you been successful with the device tree modification?

Matthias Gohlke

Hello Matthias,

I think yes, with this modifications in my .dts file:

  1. I deleted usbc-det node;
  2. I changed extcon_usbc_det node;
  3. I set usbotg1 as host, deleting also extcon;
  4. I change sodim 137 function.
/ {
    /delete-node/usbc-det;			// usbc-det
};

&extcon_usbc_det {
	compatible = "linux,extcon-usb-gpio";
	debounce = <25>;
	id-gpio = < >;
	pinctrl-names = "default";
};

&usbotg1 {
	dr_mode = "host";
	/delete-property/ extcon;
};

&iomuxc {
    imx6ull-colibri {
        pinctrl_gpio1: gpio1-grp {
            fsl,pins = <
                MX6UL_PAD_SNVS_TAMPER2__GPIO5_IO02	0x3038  /* SODIMM 137 */ /*100kOhm pulldown */
            >;
        };
    };
};

That way I am able to use USBC line as host to read a usb-key without needing an id-detection pin (which is normally sodimm137).

Hello @RiccardoC_DLK,

I see you have another ticket SoM flashing with Toradex Easy Installer through usb device and usb_c line
I will answer there. The problem is related.

Best Regards,

Matthias