Personal tools

Using USB OTG dual role on SpaceSOM-8Mplus

From SomLabs Wiki

Revision as of 16:29, 14 December 2023 by KrzysztofChojnowski (talk | contribs) (Created page with "{{PageHeader|Using USB OTG dual role on SpaceSOM-8Mplus}} According to the ''i.MX 8M Plus Applications Processor Datasheet'' it is not possible to use USBx ID pins for USB OT...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Using USB OTG dual role on SpaceSOM-8Mplus


According to the i.MX 8M Plus Applications Processor Datasheet it is not possible to use USBx ID pins for USB OTG role selection. Both USB interfaces ID pins are marked as DNU (do not use), so hardware role selection is not supported. There is a workaround in which any GPIO pin is used as ID function. The original ID/DNU pins do not have alternate GPIO function so may not serve this purpose at all.

In order to use GPIO pin as ID the following changes in device tree are required. In this example pin GPIO1_IO14 is used as power enable signal, and GPIO1_IO01 is used for ID function.

/ {
        // Entries in the main dts node.

        // New regulator for USB power on in host mode.
        reg_usb_otg1_vbus: regulator@2 {
                compatible = "regulator-fixed";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_usb1_pwr>;
                regulator-name = "usb_otg1_vbus";
                regulator-min-microvolt = <5000000>;
                regulator-max-microvolt = <5000000>;
                gpio = <&gpio1 14 GPIO_ACTIVE_HIGH>;
                enable-active-high;
        };

        // Additional connector for ID pin definition.
        extcon_usb: extcon_iddig {
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_usb1_id>;
                compatible = "linux,extcon-usb-gpio";
                id-gpio = <&gpio1 1 GPIO_ACTIVE_HIGH>;
        };
};

&iomuxc {
        // Entries in the IO multiplexer node.

        // GPIO for regulator.
        pinctrl_usb1_pwr: usb1pwr {
                fsl,pins = <
                        MX8MP_IOMUXC_GPIO1_IO14__GPIO1_IO14             0x19
                >;
        };

        // GPIO for USB ID.
        pinctrl_usb1_id: usb1id {
                fsl,pins = <
                        MX8MP_IOMUXC_GPIO1_IO01__GPIO1_IO01             0x140
                >;
        };
};

// USB PHY configuration including regulator.
&usb3_phy1 {
        fsl,phy-tx-preemp-amp-tune = <3>;
        fsl,phy-tx-vref-tune = <0xb>;
        vbus-supply = <&reg_usb_otg1_vbus>;
        status = "okay";
};

&usb3_1 {
        status = "okay";
};

// USB DWC3 with OTG and additional connector.
&usb_dwc3_1 {
        dr_mode = "otg";
        extcon = <&extcon_usb>;
        status = "okay";
};

The kernel image should also contain the linux,extcon-usb-gpio driver enabled in config:

CONFIG_EXTCON_USB_GPIO=y
NXP Partner ST Partner Renesas Partner