Skip to contentSkip to conversation

ARM: dts: colibri-imx6ull: Enable dual-role switching

PATCH Superseded Philippe Schenker 5 participants 5 messages Nov 2, 2022 – Nov 11, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: dts: colibri-imx6ull: Enable dual-role switching

From: Philippe Schenker <[email protected]>

The Colibri standard provides a GPIO called USBC_DET to switch from USB Host to USB Device and back. The Colibri iMX6ULL does have the SoC ball USB_OTG1_VBUS connected in series with a capacitor to ground.

This means that we need to provide to the extcon framework VBUS and ID events using the single GPIO we have. The Extcon USB GPIO driver does use id-gpio also for VBUS event, as in our case where vbus-gpio is absent.

---

 arch/arm/boot/dts/imx6ull-colibri.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/imx6ull-colibri.dtsi +8 -0
index 577a424b0e1d..feb1fcd9a684 100644
@@ -24,6 +24,13 @@ backlight: backlight {
 		status = "okay";
 	};
 
+	extcon_usbc_det: usbc-det {
+		compatible = "linux,extcon-usb-gpio";
+		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>; /* SODIMM 137 / USBC_DET */
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		pinctrl-names = "default";
@@ -275,6 +282,7 @@ &uart5 {
 /* Colibri USBC */
 &usbotg1 {
 	dr_mode = "otg";
+	extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;
 	srp-disable;
 	hnp-disable;
 	adp-disable;
Signature · 1 line
2.38.1
#1 lore raw

Hi Philippe,

Am Mittwoch, 2. November 2022, 16:52:26 CET schrieb Philippe Schenker:

Quoted 24 lines

From: Philippe Schenker <[email protected]>

The Colibri standard provides a GPIO called USBC_DET to switch from USB Host to USB Device and back. The Colibri iMX6ULL does have the SoC ball USB_OTG1_VBUS connected in series with a capacitor to ground.

This means that we need to provide to the extcon framework VBUS and ID events using the single GPIO we have. The Extcon USB GPIO driver does use id-gpio also for VBUS event, as in our case where vbus-gpio is absent.

---

 arch/arm/boot/dts/imx6ull-colibri.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6ull-colibri.dtsi index 577a424b0e1d..feb1fcd9a684 100644

arch/arm/boot/dts/imx6ull-colibri.dtsi backlight: backlight { · line 29

Quoted 6 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +3 -0
@@ -24,6 +24,13 @@ backlight: backlight {
 		status = "okay";
 	};
 
+	extcon_usbc_det: usbc-det {
+		compatible = "linux,extcon-usb-gpio";
+		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>; /* SODIMM 137 / 

USBC_DET */

arch/arm/boot/dts/imx6ull-colibri.dtsi &uart5 { · line 285

Quoted 12 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +5 -0
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		pinctrl-names = "default";
@@ -275,6 +282,7 @@ &uart5 {
 /* Colibri USBC */
 &usbotg1 {
 	dr_mode = "otg";
+	extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;

How came you up with this double entries? Is there some documentation you need two phandles?
I have a problem on imx8mm (same USB host controller) where on USB device mode no device is attached on host side. I fixed it by using usb-role-switch instead [1].
But it also works on imx8mm using extcon with two phandles instead of just one.

Regards,
Alexander

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/
[email protected]/

Quoted 3 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +0 -0
 	srp-disable;
 	hnp-disable;
 	adp-disable;
#2 lore raw
Quoted 34 lines · Alexander Stein

Hi Philippe,

Am Mittwoch, 2. November 2022, 16:52:26 CET schrieb Philippe Schenker:

Quoted 24 lines

From: Philippe Schenker <[email protected]>

The Colibri standard provides a GPIO called USBC_DET to switch from USB Host to USB Device and back. The Colibri iMX6ULL does have the SoC ball USB_OTG1_VBUS connected in series with a capacitor to ground.

This means that we need to provide to the extcon framework VBUS and ID events using the single GPIO we have. The Extcon USB GPIO driver does use id-gpio also for VBUS event, as in our case where vbus-gpio is absent.

---

 arch/arm/boot/dts/imx6ull-colibri.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6ull-colibri.dtsi index 577a424b0e1d..feb1fcd9a684 100644

arch/arm/boot/dts/imx6ull-colibri.dtsi backlight: backlight { · line 29

Quoted 6 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +3 -0
@@ -24,6 +24,13 @@ backlight: backlight {
 		status = "okay";
 	};
 
+	extcon_usbc_det: usbc-det {
+		compatible = "linux,extcon-usb-gpio";
+		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>; /* SODIMM 137 / 

USBC_DET */

Quoted 15 lines

arch/arm/boot/dts/imx6ull-colibri.dtsi &uart5 { · line 285

Quoted 12 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +5 -0
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		pinctrl-names = "default";
@@ -275,6 +282,7 @@ &uart5 {
 /* Colibri USBC */
 &usbotg1 {
 	dr_mode = "otg";
+	extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;

How came you up with this double entries? Is there some documentation you need two phandles?

extcon-usb-gpio provides both vbus/otg_id with a single handle, however the integration in chipidea is somehow weird, the first entry is supposed to be used to read the vbus, the second one to read the otg_id.

So if you need to read both you really need to have the handle twice ...

Francesco

#3 lore raw
Quoted 59 lines · Francesco Dolcini
Quoted 41 lines · Alexander Stein

Hi Philippe,

Am Mittwoch, 2. November 2022, 16:52:26 CET schrieb Philippe Schenker:

Quoted 35 lines

From: Philippe Schenker <[email protected]>

The Colibri standard provides a GPIO called USBC_DET to switch from
USB Host to USB Device and back. The Colibri iMX6ULL does have the SoC
ball USB_OTG1_VBUS connected in series with a capacitor to ground.

This means that we need to provide to the extcon framework VBUS and ID
events using the single GPIO we have. The Extcon USB GPIO driver does
use id-gpio also for VBUS event, as in our case where vbus-gpio is absent.

---

 arch/arm/boot/dts/imx6ull-colibri.dtsi | 8 ++++++++

 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6ull-colibri.dtsi index
577a424b0e1d..feb1fcd9a684
100644

arch/arm/boot/dts/imx6ull-colibri.dtsi +3 -0
@@ -24,6 +24,13 @@ backlight: backlight {
                 status = "okay";
         };
 
+       extcon_usbc_det: usbc-det {
+               compatible = "linux,extcon-usb-gpio";
+               id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>; /* SODIMM
Quoted 1 line

137 /

USBC_DET */

Quoted 16 lines

arch/arm/boot/dts/imx6ull-colibri.dtsi &uart5 { · line 285

Quoted 12 lines

+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_snvs_usbc_det>; +       };
+
        gpio-keys {
                compatible = "gpio-keys"; pinctrl-names = "default";

arch/arm/boot/dts/imx6ull-colibri.dtsi +1 -0
@@ -275,6 +282,7 @@ &uart5 {
  /* Colibri USBC */
  &usbotg1 {
         dr_mode = "otg";
+       extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;

How came you up with this double entries? Is there some documentation you need
two phandles?

Quoted 8 lines

extcon-usb-gpio provides both vbus/otg_id with a single handle, however
the integration in chipidea is somehow weird, the first entry is supposed to be
used to read the vbus, the second one to read the otg_id.

So if you need to read both you really need to have the handle twice
...

Thanks for the suggestion Alex and Francesco for answering. I cannot add much more, we tried a lot back and forth due to the really special hardware-design this solution was the best we found for the colibri- imx6ull.

Regards,
Philippe

Quoted 3 lines

Francesco

#4 lore raw
In reply to Francesco Dolcini
Quoted 51 lines · Francesco Dolcini
Quoted 34 lines · Alexander Stein

Hi Philippe,

Am Mittwoch, 2. November 2022, 16:52:26 CET schrieb Philippe Schenker:

Quoted 24 lines

From: Philippe Schenker <[email protected]>

The Colibri standard provides a GPIO called USBC_DET to switch from USB Host to USB Device and back. The Colibri iMX6ULL does have the SoC ball USB_OTG1_VBUS connected in series with a capacitor to ground.

This means that we need to provide to the extcon framework VBUS and ID events using the single GPIO we have. The Extcon USB GPIO driver does use id-gpio also for VBUS event, as in our case where vbus-gpio is absent.

---

 arch/arm/boot/dts/imx6ull-colibri.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6ull-colibri.dtsi index 577a424b0e1d..feb1fcd9a684 100644

arch/arm/boot/dts/imx6ull-colibri.dtsi backlight: backlight { · line 29

Quoted 6 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +3 -0
@@ -24,6 +24,13 @@ backlight: backlight {
 		status = "okay";
 	};
 
+	extcon_usbc_det: usbc-det {
+		compatible = "linux,extcon-usb-gpio";
+		id-gpio = <&gpio5 2 GPIO_ACTIVE_HIGH>; /* SODIMM 137 / 

USBC_DET */

Quoted 15 lines

arch/arm/boot/dts/imx6ull-colibri.dtsi &uart5 { · line 285

Quoted 12 lines
arch/arm/boot/dts/imx6ull-colibri.dtsi +5 -0
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_snvs_usbc_det>;
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		pinctrl-names = "default";
@@ -275,6 +282,7 @@ &uart5 {
 /* Colibri USBC */
 &usbotg1 {
 	dr_mode = "otg";
+	extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;

How came you up with this double entries? Is there some documentation you need two phandles?

Quoted 5 lines

extcon-usb-gpio provides both vbus/otg_id with a single handle, however the integration in chipidea is somehow weird, the first entry is supposed to be used to read the vbus, the second one to read the otg_id.

So if you need to read both you really need to have the handle twice ...

Thanks for the input, Francesco!

Philippe,

Do you consider to use usb-role-switch as suggested by Alexander, considering the weirdness of how chipidea driver supports extcon-usb-gpio?

Shawn