2022-11-02 13:38:17

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 0/6] arm64: dts: verdin-imx8mp: usb dual-role switching et. al.

From: Marcel Ziswiler <[email protected]>


This series is an assortment of USB dual-role specific commits as
follows:

Improvement of pinctrl for vbus-supplies:
As we are using two fixed regulators for Verdin USB_1_EN (SODIMM 155)
and Verdin USB_2_EN (SODIMM 185), those should be muxed as GPIOs rather
than OTG_PWR.

Removal of USB_2 over-current detection disabling:
The disable-over-current property is only applicable for the
ci-hdrc-usb2 and dwc2 drivers while the i.MX 8M Plus integrates dwc3
IP. Therefore remove this property which does not really serve any
purpose here.

Addition of USB_1 over-current detection:
Add Verdin USB_1 over-current detection functionality via Verdin
USB_1_OC# (SODIMM 157) being active-low and removing its previous
gpio_hog3 mapping.

Disabling of USB port power controls:
Disable port power control on Verdin USB_1/2 as we use regular
fixed-regulators with Verdin USB_1/2_EN as enable GPIOs.

Addition of GPIO USB-B connector:
Add GPIO USB-B connector (gpio-usb-b-connector) functionality using
Verdin USB_1_ID.

Marking USB_2 as permanently attached:
As both Dahlia and the Verdin Development Board have on-carrier
permanently attached USB hubs mark Verdin USB_2 as such.

Note:
Currently, I am still seeing a rare race condition of sorts when booting
the system with Verdin USB_1 as a host port with a USB memory stick
plugged in. This exact patch series applied on top of NXP's latest
downstream 5.15.52_2.1.0 release (together with backporting a few more
dwc3-specific patches) actually makes this same use case work very
reliably. However, NXP also keeps further downstream-only patches which
I plan to further investigate and hopefully upstream a proper fix for
soon.


Marcel Ziswiler (6):
arm64: dts: verdin-imx8mp: improve pinctrl for vbus-supplies
arm64: dts: verdin-imx8mp: remove usb_2 over-current detection
disabling
arm64: dts: verdin-imx8mp: add usb_1 over-current detection
arm64: dts: verdin-imx8mp: disable usb port power control
arm64: dts: verdin-imx8mp: add gpio usb-b connector
arm64: dts: verdin-imx8mp: dahlia: mark usb_2 permanently attached

.../dts/freescale/imx8mp-verdin-dahlia.dtsi | 1 +
.../boot/dts/freescale/imx8mp-verdin.dtsi | 40 ++++++++++++++-----
2 files changed, 32 insertions(+), 9 deletions(-)

--
2.36.1



2022-11-02 14:01:01

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 1/6] arm64: dts: verdin-imx8mp: improve pinctrl for vbus-supplies

From: Marcel Ziswiler <[email protected]>

As we are using two fixed regulators for Verdin USB_1_EN (SODIMM 155)
and Verdin USB_2_EN (SODIMM 185), those should be muxed as GPIOs rather
than OTG_PWR.

Signed-off-by: Marcel Ziswiler <[email protected]>
---

arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
index cc3b0725ce06..97e88440a251 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
@@ -1221,7 +1221,7 @@ pinctrl_uart4: uart4grp {

pinctrl_usb1_vbus: usb1vbusgrp {
fsl,pins =
- <MX8MP_IOMUXC_GPIO1_IO12__USB1_OTG_PWR 0x19>; /* SODIMM 155 */
+ <MX8MP_IOMUXC_GPIO1_IO12__GPIO1_IO12 0x106>; /* SODIMM 155 */
};

/* USB_1_ID */
@@ -1232,7 +1232,7 @@ pinctrl_usb_1_id: usb1idgrp {

pinctrl_usb2_vbus: usb2vbusgrp {
fsl,pins =
- <MX8MP_IOMUXC_GPIO1_IO14__USB2_OTG_PWR 0x19>; /* SODIMM 185 */
+ <MX8MP_IOMUXC_GPIO1_IO14__GPIO1_IO14 0x106>; /* SODIMM 185 */
};

/* On-module Wi-Fi */
--
2.36.1


2022-11-02 14:01:01

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 3/6] arm64: dts: verdin-imx8mp: add usb_1 over-current detection

From: Marcel Ziswiler <[email protected]>

Add Verdin USB_1 over-current detection functionality via Verdin
USB_1_OC# (SODIMM 157) being active-low and removing its previous
gpio_hog3 mapping.

Signed-off-by: Marcel Ziswiler <[email protected]>
---

arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
index 57cddf1bf6b3..85af2875fb70 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
@@ -807,6 +807,12 @@ &uart4 {
};

/* Verdin USB_1 */
+&usb3_0 {
+ fsl,over-current-active-low;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usb_1_oc_n>;
+};
+
&usb3_phy0 {
vbus-supply = <&reg_usb1_vbus>;
};
@@ -816,7 +822,6 @@ &usb_dwc3_0 {
dr_mode = "otg";
hnp-disable;
maximum-speed = "high-speed";
- over-current-active-low;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_1_id>;
srp-disable;
@@ -1045,7 +1050,6 @@ pinctrl_gpio_hog2: gpiohog2grp {

pinctrl_gpio_hog3: gpiohog3grp {
fsl,pins =
- <MX8MP_IOMUXC_GPIO1_IO13__GPIO1_IO13 0x1c4>, /* SODIMM 157 */
/* CSI_1_MCLK */
<MX8MP_IOMUXC_GPIO1_IO15__GPIO1_IO15 0x1c4>; /* SODIMM 91 */
};
@@ -1229,6 +1233,12 @@ pinctrl_usb_1_id: usb1idgrp {
<MX8MP_IOMUXC_SD1_RESET_B__GPIO2_IO10 0x1c4>; /* SODIMM 161 */
};

+ /* USB_1_OC# */
+ pinctrl_usb_1_oc_n: usb1ocngrp {
+ fsl,pins =
+ <MX8MP_IOMUXC_GPIO1_IO13__USB1_OTG_OC 0x1c4>; /* SODIMM 157 */
+ };
+
pinctrl_usb2_vbus: usb2vbusgrp {
fsl,pins =
<MX8MP_IOMUXC_GPIO1_IO14__GPIO1_IO14 0x106>; /* SODIMM 185 */
--
2.36.1


2022-11-02 14:02:08

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 5/6] arm64: dts: verdin-imx8mp: add gpio usb-b connector

From: Marcel Ziswiler <[email protected]>

Add GPIO USB-B connector (gpio-usb-b-connector) functionality using
Verdin USB_1_ID.

Signed-off-by: Marcel Ziswiler <[email protected]>
---

.../boot/dts/freescale/imx8mp-verdin.dtsi | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
index 795e02df9f29..6a1890a4b5d8 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
@@ -814,18 +814,26 @@ &usb3_0 {
pinctrl-0 = <&pinctrl_usb_1_oc_n>;
};

-&usb3_phy0 {
- vbus-supply = <&reg_usb1_vbus>;
-};
-
&usb_dwc3_0 {
+ /* dual role only, not full featured OTG */
adp-disable;
dr_mode = "otg";
hnp-disable;
maximum-speed = "high-speed";
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_usb_1_id>;
+ role-switch-default-mode = "peripheral";
srp-disable;
+ usb-role-switch;
+
+ connector {
+ compatible = "gpio-usb-b-connector", "usb-b-connector";
+ id-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
+ label = "Type-C";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usb_1_id>;
+ self-powered;
+ type = "micro";
+ vbus-supply = <&reg_usb1_vbus>;
+ };
};

/* Verdin USB_2 */
--
2.36.1


2022-11-02 14:02:10

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 4/6] arm64: dts: verdin-imx8mp: disable usb port power control

From: Marcel Ziswiler <[email protected]>

Disable port power control on Verdin USB_1/2 as we use regular
fixed-regulators with Verdin USB_1/2_EN as enable GPIOs.

Signed-off-by: Marcel Ziswiler <[email protected]>
---

arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
index 85af2875fb70..795e02df9f29 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
@@ -808,6 +808,7 @@ &uart4 {

/* Verdin USB_1 */
&usb3_0 {
+ fsl,disable-port-power-control;
fsl,over-current-active-low;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_1_oc_n>;
@@ -828,6 +829,10 @@ &usb_dwc3_0 {
};

/* Verdin USB_2 */
+&usb3_1 {
+ fsl,disable-port-power-control;
+};
+
&usb3_phy1 {
vbus-supply = <&reg_usb2_vbus>;
};
--
2.36.1


2022-11-02 14:11:50

by Marcel Ziswiler

[permalink] [raw]
Subject: [PATCH v1 6/6] arm64: dts: verdin-imx8mp: dahlia: mark usb_2 permanently attached

From: Marcel Ziswiler <[email protected]>

As both Dahlia and the Verdin Development Board have on-carrier
permanently attached USB hubs mark Verdin USB_2 as such.

Signed-off-by: Marcel Ziswiler <[email protected]>

---

arch/arm64/boot/dts/freescale/imx8mp-verdin-dahlia.dtsi | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp-verdin-dahlia.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-verdin-dahlia.dtsi
index 4b8f86f63081..80db1ad7c230 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-verdin-dahlia.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp-verdin-dahlia.dtsi
@@ -116,6 +116,7 @@ &usb3_phy0 {

/* Verdin USB_2 */
&usb3_1 {
+ fsl,permanently-attached;
status = "okay";
};

--
2.36.1


2022-11-11 05:59:31

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH v1 0/6] arm64: dts: verdin-imx8mp: usb dual-role switching et. al.

On Wed, Nov 02, 2022 at 02:11:57PM +0100, Marcel Ziswiler wrote:
> From: Marcel Ziswiler <[email protected]>
>
>
> This series is an assortment of USB dual-role specific commits as
> follows:
>
> Improvement of pinctrl for vbus-supplies:
> As we are using two fixed regulators for Verdin USB_1_EN (SODIMM 155)
> and Verdin USB_2_EN (SODIMM 185), those should be muxed as GPIOs rather
> than OTG_PWR.
>
> Removal of USB_2 over-current detection disabling:
> The disable-over-current property is only applicable for the
> ci-hdrc-usb2 and dwc2 drivers while the i.MX 8M Plus integrates dwc3
> IP. Therefore remove this property which does not really serve any
> purpose here.
>
> Addition of USB_1 over-current detection:
> Add Verdin USB_1 over-current detection functionality via Verdin
> USB_1_OC# (SODIMM 157) being active-low and removing its previous
> gpio_hog3 mapping.
>
> Disabling of USB port power controls:
> Disable port power control on Verdin USB_1/2 as we use regular
> fixed-regulators with Verdin USB_1/2_EN as enable GPIOs.
>
> Addition of GPIO USB-B connector:
> Add GPIO USB-B connector (gpio-usb-b-connector) functionality using
> Verdin USB_1_ID.
>
> Marking USB_2 as permanently attached:
> As both Dahlia and the Verdin Development Board have on-carrier
> permanently attached USB hubs mark Verdin USB_2 as such.
>
> Note:
> Currently, I am still seeing a rare race condition of sorts when booting
> the system with Verdin USB_1 as a host port with a USB memory stick
> plugged in. This exact patch series applied on top of NXP's latest
> downstream 5.15.52_2.1.0 release (together with backporting a few more
> dwc3-specific patches) actually makes this same use case work very
> reliably. However, NXP also keeps further downstream-only patches which
> I plan to further investigate and hopefully upstream a proper fix for
> soon.

Thanks for the noting!

>
>
> Marcel Ziswiler (6):
> arm64: dts: verdin-imx8mp: improve pinctrl for vbus-supplies
> arm64: dts: verdin-imx8mp: remove usb_2 over-current detection
> disabling
> arm64: dts: verdin-imx8mp: add usb_1 over-current detection
> arm64: dts: verdin-imx8mp: disable usb port power control
> arm64: dts: verdin-imx8mp: add gpio usb-b connector
> arm64: dts: verdin-imx8mp: dahlia: mark usb_2 permanently attached

Applied all, thanks!