[U-Boot] [PATCH v3 1/1] colibri_imx7: migrate usb to driver model

Migrate USB to Driver Model (CONFIG_DM_USB=y).
Acked-by: Marcel Ziswiler marcel.ziswiler@toradex.com Tested-by: Marcel Ziswiler marcel.ziswiler@toradex.com Signed-off-by: Igor Opaniuk igor.opaniuk@toradex.com ---
v3: - re-order usb nodes and add additional comments, as suggested by Marcel
v2: - Drop vbus-supply property for usbotg1 node, as on Colibri the turning on of the USB host power is actually done purely in hardware based on the cable detect pin
arch/arm/dts/imx7-colibri-emmc.dts | 38 +++++++++++++++++++++++++ arch/arm/dts/imx7-colibri-rawnand.dts | 41 +++++++++++++++++++++++++++ configs/colibri_imx7_defconfig | 1 + configs/colibri_imx7_emmc_defconfig | 1 + 4 files changed, 81 insertions(+)
diff --git a/arch/arm/dts/imx7-colibri-emmc.dts b/arch/arm/dts/imx7-colibri-emmc.dts index efd600091d..8265d6ff15 100644 --- a/arch/arm/dts/imx7-colibri-emmc.dts +++ b/arch/arm/dts/imx7-colibri-emmc.dts @@ -13,11 +13,30 @@ aliases { mmc0 = &usdhc3; mmc1 = &usdhc1; + usb0 = &usbotg1; /* required for ums */ };
chosen { stdout-path = &uart1; }; + + reg_5v0: regulator-5v0 { + compatible = "regulator-fixed"; + regulator-name = "5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + reg_usbh_vbus: regulator-usbh-vbus { + compatible = "regulator-fixed"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usbh_reg>; + regulator-name = "VCC_USB[1-4]"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio4 7 GPIO_ACTIVE_LOW>; + vin-supply = <®_5v0>; + }; };
&usdhc3 { @@ -44,4 +63,23 @@ MX7D_PAD_SD3_STROBE__SD3_STROBE 0x19 >; }; + + pinctrl_usbh_reg: gpio-usbh-vbus { + fsl,pins = < + MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14 + >; + }; +}; + +/* Colibri USBC */ +&usbotg1 { + dr_mode = "host"; + status = "okay"; +}; + +/* Colibri USBH */ +&usbotg2 { + dr_mode = "host"; + vbus-supply = <®_usbh_vbus>; + status = "okay"; }; diff --git a/arch/arm/dts/imx7-colibri-rawnand.dts b/arch/arm/dts/imx7-colibri-rawnand.dts index 4eb86fb011..b8d798765f 100644 --- a/arch/arm/dts/imx7-colibri-rawnand.dts +++ b/arch/arm/dts/imx7-colibri-rawnand.dts @@ -13,6 +13,28 @@ chosen { stdout-path = &uart1; }; + + aliases { + usb0 = &usbotg1; /* required for ums */ + }; + + reg_5v0: regulator-5v0 { + compatible = "regulator-fixed"; + regulator-name = "5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + reg_usbh_vbus: regulator-usbh-vbus { + compatible = "regulator-fixed"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usbh_reg>; + regulator-name = "VCC_USB[1-4]"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio4 7 GPIO_ACTIVE_LOW>; + vin-supply = <®_5v0>; + }; };
&gpmi { @@ -43,4 +65,23 @@ MX7D_PAD_SD3_DATA7__NAND_DATA07 0x71 >; }; + + pinctrl_usbh_reg: gpio-usbh-vbus { + fsl,pins = < + MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14 + >; + }; +}; + +/* Colibri USBC */t +&usbotg1 { + dr_mode = "host"; + status = "okay"; +}; + +/* Colibri USBH */ +&usbotg2 { + dr_mode = "host"; + vbus-supply = <®_usbh_vbus>; + status = "okay"; }; diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig index 7a52361a2a..43af825d5c 100644 --- a/configs/colibri_imx7_defconfig +++ b/configs/colibri_imx7_defconfig @@ -62,6 +62,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX7=y CONFIG_DM_PMIC=y CONFIG_PMIC_RN5T567=y +CONFIG_DM_USB=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_GADGET=y diff --git a/configs/colibri_imx7_emmc_defconfig b/configs/colibri_imx7_emmc_defconfig index 5e2a204a88..beec2704c5 100644 --- a/configs/colibri_imx7_emmc_defconfig +++ b/configs/colibri_imx7_emmc_defconfig @@ -64,3 +64,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_VIDEO=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_USB=y

On Wed, Apr 17, 2019 at 12:21 PM Igor Opaniuk igor.opaniuk@toradex.com wrote:
Migrate USB to Driver Model (CONFIG_DM_USB=y).
Acked-by: Marcel Ziswiler marcel.ziswiler@toradex.com Tested-by: Marcel Ziswiler marcel.ziswiler@toradex.com Signed-off-by: Igor Opaniuk igor.opaniuk@toradex.com
v3:
- re-order usb nodes and add additional comments, as suggested by Marcel
v2:
- Drop vbus-supply property for usbotg1 node, as on Colibri the turning
on of the USB host power is actually done purely in hardware based on the cable detect pin
arch/arm/dts/imx7-colibri-emmc.dts | 38 +++++++++++++++++++++++++ arch/arm/dts/imx7-colibri-rawnand.dts | 41 +++++++++++++++++++++++++++ configs/colibri_imx7_defconfig | 1 + configs/colibri_imx7_emmc_defconfig | 1 + 4 files changed, 81 insertions(+)
diff --git a/arch/arm/dts/imx7-colibri-emmc.dts b/arch/arm/dts/imx7-colibri-emmc.dts index efd600091d..8265d6ff15 100644 --- a/arch/arm/dts/imx7-colibri-emmc.dts +++ b/arch/arm/dts/imx7-colibri-emmc.dts @@ -13,11 +13,30 @@ aliases { mmc0 = &usdhc3; mmc1 = &usdhc1;
usb0 = &usbotg1; /* required for ums */ }; chosen { stdout-path = &uart1; };
reg_5v0: regulator-5v0 {
compatible = "regulator-fixed";
regulator-name = "5V";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
};
reg_usbh_vbus: regulator-usbh-vbus {
compatible = "regulator-fixed";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbh_reg>;
regulator-name = "VCC_USB[1-4]";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio4 7 GPIO_ACTIVE_LOW>;
vin-supply = <®_5v0>;
};
};
&usdhc3 { @@ -44,4 +63,23 @@ MX7D_PAD_SD3_STROBE__SD3_STROBE 0x19 >; };
pinctrl_usbh_reg: gpio-usbh-vbus {
fsl,pins = <
MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
>;
};
+};
+/* Colibri USBC */ +&usbotg1 {
dr_mode = "host";
status = "okay";
+};
+/* Colibri USBH */ +&usbotg2 {
dr_mode = "host";
vbus-supply = <®_usbh_vbus>;
status = "okay";
}; diff --git a/arch/arm/dts/imx7-colibri-rawnand.dts b/arch/arm/dts/imx7-colibri-rawnand.dts index 4eb86fb011..b8d798765f 100644 --- a/arch/arm/dts/imx7-colibri-rawnand.dts +++ b/arch/arm/dts/imx7-colibri-rawnand.dts @@ -13,6 +13,28 @@ chosen { stdout-path = &uart1; };
aliases {
usb0 = &usbotg1; /* required for ums */
};
reg_5v0: regulator-5v0 {
compatible = "regulator-fixed";
regulator-name = "5V";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
};
reg_usbh_vbus: regulator-usbh-vbus {
compatible = "regulator-fixed";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbh_reg>;
regulator-name = "VCC_USB[1-4]";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio4 7 GPIO_ACTIVE_LOW>;
vin-supply = <®_5v0>;
};
};
&gpmi { @@ -43,4 +65,23 @@ MX7D_PAD_SD3_DATA7__NAND_DATA07 0x71 >; };
pinctrl_usbh_reg: gpio-usbh-vbus {
fsl,pins = <
MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
>;
};
+};
+/* Colibri USBC */t +&usbotg1 {
dr_mode = "host";
status = "okay";
+};
+/* Colibri USBH */ +&usbotg2 {
dr_mode = "host";
vbus-supply = <®_usbh_vbus>;
status = "okay";
}; diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig index 7a52361a2a..43af825d5c 100644 --- a/configs/colibri_imx7_defconfig +++ b/configs/colibri_imx7_defconfig @@ -62,6 +62,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX7=y CONFIG_DM_PMIC=y CONFIG_PMIC_RN5T567=y +CONFIG_DM_USB=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_GADGET=y diff --git a/configs/colibri_imx7_emmc_defconfig b/configs/colibri_imx7_emmc_defconfig index 5e2a204a88..beec2704c5 100644 --- a/configs/colibri_imx7_emmc_defconfig +++ b/configs/colibri_imx7_emmc_defconfig @@ -64,3 +64,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_VIDEO=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_DM_USB=y
2.17.1
Hi Stefano,
All comments/issues were addressed (I've added both Acked-by and Reviewed-by tags from Marcel) in v3, is there any objections from your side regarding applying this patch?
Thanks

Hi Igor,
On Wed, Apr 17, 2019 at 6:21 AM Igor Opaniuk igor.opaniuk@toradex.com wrote:
+/* Colibri USBC */ +&usbotg1 {
dr_mode = "host";
Since usbotg1 is used for UMS, this should be dr_mode = "otg" or dr_mode="peripheral", right?

On Mon, May 6, 2019 at 4:20 PM Fabio Estevam festevam@gmail.com wrote:
Hi Igor,
On Wed, Apr 17, 2019 at 6:21 AM Igor Opaniuk igor.opaniuk@toradex.com wrote:
+/* Colibri USBC */ +&usbotg1 {
dr_mode = "host";
Since usbotg1 is used for UMS, this should be dr_mode = "otg" or dr_mode="peripheral", right? _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Hi Fabio,
usbotg1 on Colibri iMX7 can function in both host/otg modes. In case if dr_mode = "otg" is specified it obviously won't be enumerated during usb start invocation. For ums command actually it doesn't matter what mode is specified in the device tree, as you explicitly specify usb controller to be used during invocation (usage: ums <USB_controller> [<devtype>] <dev[:part]>)

Hi Fabio
On Mon, 2019-05-06 at 10:20 -0300, Fabio Estevam wrote:
Hi Igor,
On Wed, Apr 17, 2019 at 6:21 AM Igor Opaniuk < igor.opaniuk@toradex.com> wrote:
+/* Colibri USBC */ +&usbotg1 {
dr_mode = "host";
Since usbotg1 is used for UMS, this should be dr_mode = "otg" or dr_mode="peripheral", right?
No, I believe the gadget stack currently does not look at this at all while the host stack refuses to bind/load if it is not set to host. Whether or not this is a good idea and/or would need fixing at various other places remains to be seen I guess.
Cheers
Marcel

Hi Marcel and Igor,
On Mon, May 6, 2019 at 10:30 AM Marcel Ziswiler marcel.ziswiler@toradex.com wrote:
No, I believe the gadget stack currently does not look at this at all while the host stack refuses to bind/load if it is not set to host. Whether or not this is a good idea and/or would need fixing at various other places remains to be seen I guess.
I think it is a bit strange to describe the USB otg port as "host" in the devicetree if it really works in peripheral mode.
By the way, we don't see this issue with imx7s-warp.dts, nor imx7d-pico.dtsi.

On Mon, 2019-05-06 at 10:40 -0300, Fabio Estevam wrote:
Hi Marcel and Igor,
On Mon, May 6, 2019 at 10:30 AM Marcel Ziswiler marcel.ziswiler@toradex.com wrote:
No, I believe the gadget stack currently does not look at this at all while the host stack refuses to bind/load if it is not set to host. Whether or not this is a good idea and/or would need fixing at various other places remains to be seen I guess.
I think it is a bit strange to describe the USB otg port as "host" in the devicetree if it really works in peripheral mode.
No, on Colibri iMX7 one may really use it either in host or peripheral mode. This is especially important on the solo variant which has only that one single USB OTG port.
By the way, we don't see this issue with imx7s-warp.dts, nor imx7d- pico.dtsi.
Just to be crystal clear what we are talking about: On those two one may also use the USB OTG port either as host (e.g. doing usb start; ls usb 0:1 etc.) or peripheral (e.g. doing ums 0 mmc 0), right?
participants (3)
-
Fabio Estevam
-
Igor Opaniuk
-
Marcel Ziswiler