Skip to contentSkip to conversation

colibri_imx7: migrate usb to driver model

PATCH Superseded Igor Opaniuk 2 participants 3 messages Apr 15, 2019 – Apr 17, 2019

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 colibri_imx7: migrate usb to driver model

Migrate USB to Driver Model (CONFIG_DM_USB=y).

---

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    | 36 +++++++++++++++++++++++++
 arch/arm/dts/imx7-colibri-rawnand.dts | 39 +++++++++++++++++++++++++++
 configs/colibri_imx7_defconfig        |  1 +
 configs/colibri_imx7_emmc_defconfig   |  1 +
 4 files changed, 77 insertions(+)
arch/arm/dts/imx7-colibri-emmc.dts +36 -0
index efd600091d..371c680025 100644
@@ -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 = <&reg_5v0>;
+	};
 };
 
 &usdhc3 {
@@ -44,4 +63,21 @@
 			MX7D_PAD_SD3_STROBE__SD3_STROBE         0x19
 		>;
 	};
+
+	pinctrl_usbh_reg: gpio-usbh-vbus {
+		fsl,pins = <
+			MX7D_PAD_UART3_CTS_B__GPIO4_IO7	0x14
+		>;
+	};
+};
+
+&usbotg2 {
+	dr_mode = "host";
+	vbus-supply = <&reg_usbh_vbus>;
+	status = "okay";
+};
+
+&usbotg1 {
+	dr_mode = "host";
+	status = "okay";
 };
arch/arm/dts/imx7-colibri-rawnand.dts +39 -0
index 4eb86fb011..69a9c6a914 100644
@@ -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 = <&reg_5v0>;
+	};
 };
 
 &gpmi {
@@ -43,4 +65,21 @@
 			MX7D_PAD_SD3_DATA7__NAND_DATA07		0x71
 		>;
 	};
+
+	pinctrl_usbh_reg: gpio-usbh-vbus {
+		fsl,pins = <
+			MX7D_PAD_UART3_CTS_B__GPIO4_IO7	0x14
+		>;
+	};
+};
+
+&usbotg2 {
+	dr_mode = "host";
+	vbus-supply = <&reg_usbh_vbus>;
+	status = "okay";
+};
+
+&usbotg1 {
+	dr_mode = "host";
+	status = "okay";
 };
configs/colibri_imx7_defconfig +1 -0
index 7a52361a2a..43af825d5c 100644
@@ -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
configs/colibri_imx7_emmc_defconfig +1 -0
index 5e2a204a88..beec2704c5 100644
@@ -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
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 colibri_imx7: migrate usb to driver model

As Max Krummenacher asked before, tested also Colibri iMX7S NAND version, everything works fine (USB1 is reported as unavailable by the driver):
USB0 can be still used in both host/OTG modes.

Colibri iMX7 # usb reset
resetting USB...

USB0:   USB EHCI 1.00
USB1:   Port not available.

scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Colibri iMX7 # usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
| u-boot EHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 500mA)

         T1204020000702

Same for UMS:

Colibri iMX7 # ums 0 mmc 0
UMS: LUN 0, dev 0, hwpart 0, sector 0x0, count 0x1dacc00 USB EHCI 1.00

Quoted 154 lines · Igor Opaniuk

Migrate USB to Driver Model (CONFIG_DM_USB=y).

---

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    | 36 +++++++++++++++++++++++++
 arch/arm/dts/imx7-colibri-rawnand.dts | 39 +++++++++++++++++++++++++++
 configs/colibri_imx7_defconfig        |  1 +
 configs/colibri_imx7_emmc_defconfig   |  1 +
 4 files changed, 77 insertions(+)
arch/arm/dts/imx7-colibri-emmc.dts +36 -0
index efd600091d..371c680025 100644
@@ -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 = <&reg_5v0>;
+       };
 };
 
 &usdhc3 {
@@ -44,4 +63,21 @@
                        MX7D_PAD_SD3_STROBE__SD3_STROBE         0x19
                >;
        };
+
+       pinctrl_usbh_reg: gpio-usbh-vbus {
+               fsl,pins = <
+                       MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
+               >;
+       };
+};
+
+&usbotg2 {
+       dr_mode = "host";
+       vbus-supply = <&reg_usbh_vbus>;
+       status = "okay";
+};
+
+&usbotg1 {
+       dr_mode = "host";
+       status = "okay";
 };
arch/arm/dts/imx7-colibri-rawnand.dts +39 -0
index 4eb86fb011..69a9c6a914 100644
@@ -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 = <&reg_5v0>;
+       };
 };
 
 &gpmi {
@@ -43,4 +65,21 @@
                        MX7D_PAD_SD3_DATA7__NAND_DATA07         0x71
                >;
        };
+
+       pinctrl_usbh_reg: gpio-usbh-vbus {
+               fsl,pins = <
+                       MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
+               >;
+       };
+};
+
+&usbotg2 {
+       dr_mode = "host";
+       vbus-supply = <&reg_usbh_vbus>;
+       status = "okay";
+};
+
+&usbotg1 {
+       dr_mode = "host";
+       status = "okay";
 };
configs/colibri_imx7_defconfig +1 -0
index 7a52361a2a..43af825d5c 100644
@@ -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
configs/colibri_imx7_emmc_defconfig +1 -1
index 5e2a204a88..beec2704c5 100644
@@ -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

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Senior Development Engineer,
Igor Opaniuk

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 48
00 (main line)
#2 lore raw

PATCH v2 1/1 colibri_imx7: migrate usb to driver model

Perfect, thanks Igor.

The most minor little nitpick: I would order otg1, otg2 and maybe add some comment about what exact USB ports in the Colibri pin muxing each of those actually is. With that:

Quoted 201 lines · Igor Opaniuk

As Max Krummenacher asked before, tested also Colibri iMX7S NAND version, everything works fine (USB1 is reported as unavailable by the driver):
USB0 can be still used in both host/OTG modes.

Colibri iMX7 # usb reset
resetting USB...

USB0:   USB EHCI 1.00
USB1:   Port not available.

scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Colibri iMX7 # usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
| u-boot EHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 500mA)

        T1204020000702

Same for UMS:

Colibri iMX7 # ums 0 mmc 0
UMS: LUN 0, dev 0, hwpart 0, sector 0x0, count 0x1dacc00 USB EHCI 1.00

Quoted 9 lines · Igor Opaniuk

Migrate USB to Driver Model (CONFIG_DM_USB=y).

---

v2:
- Drop vbus-supply property for usbotg1 node, as on Colibri the

turning

Quoted 5 lines

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    | 36 +++++++++++++++++++++++++
 arch/arm/dts/imx7-colibri-rawnand.dts | 39

+++++++++++++++++++++++++++

Review

Quoted 5 lines
 configs/colibri_imx7_defconfig        |  1 +
 configs/colibri_imx7_emmc_defconfig   |  1 +
 4 files changed, 77 insertions(+)
(quoted diff) +0 -0

b/arch/arm/dts/imx7-colibri-emmc.dts

Review

Quoted 57 lines

index efd600091d..371c680025 100644

arch/arm/dts/imx7-colibri-emmc.dts +36 -0
@@ -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 = <&reg_5v0>;
+       };
 };
 
 &usdhc3 {
@@ -44,4 +63,21 @@
                        MX7D_PAD_SD3_STROBE__SD3_STROBE         0x19
                >;
        };
+
+       pinctrl_usbh_reg: gpio-usbh-vbus {
+               fsl,pins = <
+                       MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
+               >;
+       };
+};
+
+&usbotg2 {
+       dr_mode = "host";
+       vbus-supply = <&reg_usbh_vbus>;
+       status = "okay";
+};
+
+&usbotg1 {
+       dr_mode = "host";
+       status = "okay";
 };
(quoted diff) +0 -0

b/arch/arm/dts/imx7-colibri-rawnand.dts

Review

Quoted 55 lines

index 4eb86fb011..69a9c6a914 100644

arch/arm/dts/imx7-colibri-rawnand.dts +39 -0
@@ -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 = <&reg_5v0>;
+       };
 };
 
 &gpmi {
@@ -43,4 +65,21 @@
                        MX7D_PAD_SD3_DATA7__NAND_DATA07         0x71
                >;
        };
+
+       pinctrl_usbh_reg: gpio-usbh-vbus {
+               fsl,pins = <
+                       MX7D_PAD_UART3_CTS_B__GPIO4_IO7 0x14
+               >;
+       };
+};
+
+&usbotg2 {
+       dr_mode = "host";
+       vbus-supply = <&reg_usbh_vbus>;
+       status = "okay";
+};
+
+&usbotg1 {
+       dr_mode = "host";
+       status = "okay";
 };
(quoted diff) +0 -0

b/configs/colibri_imx7_defconfig

Review

Quoted 12 lines

index 7a52361a2a..43af825d5c 100644

configs/colibri_imx7_defconfig +1 -0
@@ -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
(quoted diff) +0 -0

b/configs/colibri_imx7_emmc_defconfig

Quoted 11 lines

index 5e2a204a88..beec2704c5 100644

configs/colibri_imx7_emmc_defconfig +1 -1
@@ -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

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Senior Development Engineer,
Igor Opaniuk

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 48
00 (main line)
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.