You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IMX6UL+Kernel5.15.91平台USB OTG功能异常求助

i.MX6 + Kernel 5.15.91 USB OTG模式切换失败问题求助

我正在使用Yocto构建基于i.MX6芯片、Kernel 5.15.91的定制系统,但USB OTG功能始终无法正常工作。通过以下设备树配置可使其进入Device Mode,但无法切换至Host Mode:

/ {
    regulators {
        compatible = "simple-bus";
        #address-cells = <1>;
        #size-cells = <0>;

        reg_usb_otg1_vbus: regulator@2 {
            compatible = "regulator-fixed";
            reg = <2>;
            regulator-name = "usb_otg1_vbus";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
            regulator-min-microvolt = <5000000>;
            regulator-max-microvolt = <5000000>;
            gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
            enable-active-high;
            status = "okay";
        };
    };
};

&usbotg1 {
    dr_mode = "otg";
    status = "okay";
    disable-over-current;
    vbus-supply = <&reg_usb_otg1_vbus>;
};

&iomuxc {
    pinctrl_usb_otg1_vbus: usbotg1 {
        fsl,pins = <
            MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08  0x000000b9
        >;
    };
};

但只要添加任何与OTG模式切换相关的配置,功能就完全失效,以下是尝试的几种配置及结果:

添加usb-role-switch配置后失效

&usbotg1 {
    dr_mode = "otg";
    status = "okay";
    usb-role-switch;
    disable-over-current;
    vbus-supply = <&reg_usb_otg1_vbus>;
};

= 失败

添加带ID引脚的extcon配置后失效

/ {
    regulators {
        compatible = "simple-bus";
        #address-cells = <1>;
        #size-cells = <0>;

        reg_usb_otg1_vbus: regulator@2 {
            compatible = "regulator-fixed";
            reg = <2>;
            regulator-name = "usb_otg1_vbus";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
            regulator-min-microvolt = <5000000>;
            regulator-max-microvolt = <5000000>;
            gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
            enable-active-high;
            status = "okay";
        };
    };

    extcon_usb: extcon_iddig {
        compatible = "linux,extcon-usb-gpio";
        id-gpio = <&gpio1 00 GPIO_ACTIVE_LOW>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usbotg1>;
    };
};

&usbotg1 {
    dr_mode = "otg";
    status = "okay";
    disable-over-current;
    vbus-supply = <&reg_usb_otg1_vbus>;

    extcon = <&extcon_usb>;
};

&iomuxc {
    pinctrl_usbotg1: usbotg1_id {
        fsl,pins = <
            MX6UL_PAD_GPIO1_IO00__GPIO1_IO00    0x0001b020 /* ID Pin */
        >;
    };

    pinctrl_usb_otg1_vbus: usbotg1 {
        fsl,pins = <
            MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08  0x000000b9
        >;
    };
};

= 失败

结合PTN5110驱动使用端点配置后失效

/ {
    regulators {
        compatible = "simple-bus";
        #address-cells = <1>;
        #size-cells = <0>;
        
        reg_usb_otg1_vbus: regulator@2 {
            compatible = "regulator-fixed";
            reg = <2>;
            regulator-name = "usb_otg1_vbus";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
            regulator-min-microvolt = <5000000>;
            regulator-max-microvolt = <5000000>;
            gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
            status = "okay";
        };
    };
};

&usbotg1 {
    dr_mode = "otg";
    status = "okay";
    disable-over-current;
    vbus-supply = <&reg_usb_otg1_vbus>;

    port {
        usb1_drd_sw: endpoint {
            remote-endpoint = <&typec1_dr_sw>;
        };
    };
};

&i2c4 {
    clock-frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c4>;
    status = "okay";

    usb_pd: ptn5110@50 {
        compatible = "nxp,ptn5110";
        reg = <0x50>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usb_pd>;
        interrupt-parent = <&gpio5>;
        interrupts = <5 IRQ_TYPE_LEVEL_LOW>;
        wakeup-source;

        port {
            typec1_dr_sw: endpoint {
                remote-endpoint = <&usb1_drd_sw>;
            };
        };

        usb_con: connector {
            compatible = "usb-c-connector";
            label = "USB-C";
            data-role = "dual";
            power-role = "dual";
            try-power-role = "source";
            source-pdos = <PDO_FIXED(VSAFE5V, 2000, PDO_FIXED_USB_COMM | PDO_FIXED_DUAL_ROLE)>;
            sink-pdos = <PDO_FIXED(VSAFE5V, 2000, PDO_FIXED_USB_COMM | PDO_FIXED_DUAL_ROLE)
                                     /*PDO_FIXED(VSAFE5V, 3000, 0)
                                       PDO_FIXED(9000, 3000, 0)*/
                                     PDO_FIXED(12000, 3000, 0)
                                     PDO_FIXED(20000, 3000, 0)>;
            op-sink-microwatt = <10000000>;

            /*vbus-supply = <&reg_usb_otg1_vbus>;*/
            /*id-gpios = <&gpio1 00 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;*/
        };
    };
};

&iomuxc {
    pinctrl_i2c4: i2c4grp {
        fsl,pins = <
            MX6UL_PAD_UART2_TX_DATA__I2C4_SCL   0x4001b8b0
            MX6UL_PAD_UART2_RX_DATA__I2C4_SDA   0x4001b8b0
        >;
    };

    pinctrl_usb_pd: usbpdgrp {
        fsl,pins = <
            MX6UL_PAD_SNVS_TAMPER5__GPIO5_IO05      0x0001b020 /* Alert Interrupt */
            MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09      0x0001b020 /* Fault Interrupt */

            MX6UL_PAD_GPIO1_IO00__GPIO1_IO00    0x0001b020 /* ID Pin */
        >;
    };

    pinctrl_usb_otg1_vbus: usbotg1 {
        fsl,pins = <
            MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08  0x000000b9
        >;
    };
};

= 失败

我尝试了所有能想到的配置组合,但均未奏效。希望有熟悉设备树的技术人员能提供帮助,我们可商讨相应报酬。

内容的提问来源于stack exchange,提问作者LokleLama

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 20:42:37