Loading...
首页专栏正文

nvidia xavier平台无PD控制器USB接口调试

 
1人已赏
free-jdx 发布于 2021-03-16 17:38:25 浏览 3244 点赞 97 收藏 8

1. 前言

问题:

基于nvidia xavier核心板,设计载板,但是USB功能无法使用;

硬件:

OTG连接器使用Micro B VBUS_ID=GPIO30(B55) pin VBUS Detect=GPIO10(A62) 检查了USB端口VBUS pin保持5V在我们携带的板上

咨询nvidia技术人员,说是没有PD控制器,所以需要对dts进行修改调试

2. 参考修改

对于类型A,没有OTG,如果没有PD控制器,需要删除xhci和xudc下的extcon-*属性。

还需要添加一个调节器“vbus-supply”下的xusb_pad_ctl一些usb2端口伴随USB3.0端口。

必须在设备树中编写自己的extcon(如果需要使用OTG)。

vbus_id_extcon: extcon@1 {

compatible = "extcon-gpio-states";
extcon-gpio,name = "VBUS_ID";
extcon-gpio,wait-for-gpio-scan = <0>;
extcon-gpio,cable-states = <0x3 0x0
0x0 0x2
0x1 0x2
0x2 0x1>;
gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(M, 3) 0
&tegra_main_gpio TEGRA194_MAIN_GPIO(Q, 0) 0>;

//GPIO_M3 is VBUS_DETECT pin and GPIO_Q0 is ID pin.
extcon-gpio,out-cable-names = <EXTCON_USB EXTCON_USB_HOST EXTCON_NONE>;
#extcon-cells = <1>;
};

对于extcon节点, 可参考“kernel/kernel-4.9/Documentation/devicetree/bindings/extcon/extcon-gpio-states.txt”

创建这个节点后,在xhci/xudc下的属性节点下面设置

extcon-cables = <&vbus_id_extcon 1>;
    extcon-cable-names = "id";
    #extcon-cells = <1>;

under xudc
 extcon-cables = <&vbus_id_extcon 0>;
    extcon-cable-names = "vbus";
    #extcon-cells = <1>;

注意事项:

(1)extcon-cables: OTG支持。必须包含一个检测USB ID pin的extconcable入口。当extcon线缆状态为0时,OTG端口将转换为主机模式。 (2)xhci必须为“id”,xudc必须为“vbus”。 (3)#extcon-cells: extcon说明符中的单元数。总是应该是1。 如果不需要OTG,删除xhci/xudc下的extcon相关属性

3. dts具体修改

1. under ucsi_ccg 
        ucsi_ccg: ucsi_ccg@8 {
-            status = "okay";
+           status = "disabled";

2. under xusb_padctl@3520000, make sure mode is set to "host" and usb3 ports need its companion usb2 port.
    xusb_padctl: xusb_padctl@3520000 {
......
        ports {
            usb2-0 {
               mode = "host";
               status = "okay";
            };
            usb3-0 {
        status = "okay";
        nvidia,usb2-companion = <0x0>; //it means the port is coupled with usb2-0
        };
        };

3. add regulator for vbus-supply
//I don't know how is your hw design this part. You need to add those regulators for them.

+        vdd_usb20_5v0: regulator@115 {
+            compatible = "regulator-fixed";
+            reg = <115>;
+            regulator-name = "vdd-usb20-5v0";
+            regulator-min-microvolt = <5000000>;
+            regulator-max-microvolt = <5000000>;
+            enable-active-high;
+            gpio = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Z, 1) 0>;
+            vin-supply = <&battery_reg>;
+        };

        ports {
            usb2-0 {
-                vbus-supply = <&battery_reg>;
+                vbus-supply = <&vdd_usb20_5v0>;
            };

4.  remove all "extcon*" property under xhci@3610000 and xudc@3550000.

4. 修改后完整dts如下

/ {
    nvidia,dtsfilename = __FILE__;
    nvidia,dtbbuildtime = __DATE__, __TIME__;
    nvidia,fastboot-usb-vid = <0x0955>;
    nvidia,fastboot-usb-pid = <0xee1e>;

    model = "jetson-xavier";
    compatible = "nvidia,jetson-xavier", "nvidia,tegra194";

    chosen {
        bootargs ="console=ttyTCU0,115200";
        board-has-eeprom;
    };

    firmware {
        android {
            compatible = "android,firmware";
            hardware = "jetson-xavier";
            fstab {
                compatible = "android,fstab";
                vendor {
                    compatible = "android,vendor";
                    dev = "/dev/block/platform/3460000.sdhci/by-name/vendor";
                    type = "ext4";
                    mnt_flags = "ro";
                    fsmgr_flags = "wait";
                };
                odm {
                    compatible = "android,odm";
                    dev = "/dev/block/platform/3460000.sdhci/by-name/odm";
                    type = "ext4";
                    mnt_flags = "ro";
                    fsmgr_flags = "wait";
                };
            };
        };
    };

    arm64_ras {
        status = "okay";
    };

    carmel_ras {
        status = "okay";
    };

    spi@3270000 {
        status = "disabled";
    };

    spi@3300000 {
        status = "disabled";
    };

    pmc@c370000 {
        nvidia,invert-interrupt;
    };

    i2c@c240000 {
        ucsi_ccg: ucsi_ccg@8 {
            status = "disabled";
            typec-extcon {
                typec_port0: port-0 {
                    status = "okay";
                    #extcon-cells = <1>;
                };
                typec_port1: port-1 {
                    status = "okay";
                    #extcon-cells = <1>;
                };
            };
            typec-pd {
                typec_pd: pd {
                    status = "okay";
                    #extcon-cells = <1>;
                };
            };
        };
    };

#if TEGRA_XUSB_PADCONTROL_VERSION >= DT_VERSION_2

    xusb_padctl: xusb_padctl@3520000 {
        status = "okay";

        pads {
            usb2 {
                lanes {
                    usb2-0 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                    usb2-1 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                    usb2-2 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                    usb2-3 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                };
            };
            usb3 {
                lanes {
                    usb3-0 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                    usb3-2 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                    usb3-3 {
                        nvidia,function = "xusb";
                        status = "okay";
                    };
                };
            };
        };

        ports {
            usb2-0 {
                mode = "host";
                //vbus-supply = <&battery_reg>;
                status = "okay";
            };
            usb2-1 {
                mode = "host";
                status = "okay";
            };
            usb2-2 {
                mode = "host";
                status = "okay";
            };
            usb2-3 {
                mode = "host";
                status = "okay";
            };
            usb3-0 {
                nvidia,usb2-companion = <0x0>;
                status = "okay";
            };
            usb3-2 {
                nvidia,usb2-companion = <0>;
                status = "okay";
            };
            usb3-3 {
                nvidia,usb2-companion = <3>;
                nvidia,usb3-gen1-only= <1>;
                status = "okay";
            };
        };
    };
#endif

    tegra_xudc: xudc@3550000 {
        /*extcon-cables = <&typec_port0 0>;
        extcon-cable-names = "vbus";
        #extcon-cells = <1>;*/
#if TEGRA_XUSB_PADCONTROL_VERSION >= DT_VERSION_2
        phys = <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-0}>,
            <&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-2}>;
        phy-names = "usb2", "usb3";
        nvidia,xusb-padctl = <&xusb_padctl>;
#endif
        status = "okay";
    };

    tegra_xhci: xhci@3610000 {
        /*extcon-cables = <&typec_port0 1>;
        extcon-cable-names = "id";
        #extcon-cells = <1>;*/
#if TEGRA_XUSB_PADCONTROL_VERSION >= DT_VERSION_2
        phys = <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-0}>,
            <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-1}>,
            <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-3}>,
            <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-2}>,
            <&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-2}>,
            <&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-0}>,
            <&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-3}>;
        phy-names = "usb2-0", "usb2-1", "usb2-3", "usb2-2",
            "usb3-2", "usb3-0", "usb3-3";
        nvidia,xusb-padctl = <&xusb_padctl>;
#endif
        status = "okay";
    };

    arm-pmu {
        status = "okay";
    };

    power-domain {
        status = "disabled";
    };

    interrupt-controller {
        status = "disabled";
    };

    mods-simple-bus {
        status = "disabled";
    };

    eeprom-manager {
        status = "disabled";
    };

    cpuidle {
        compatible = "nvidia,tegra19x-cpuidle";
        status = "okay";
    };

    thermal-zones {
        status = "disabled";
    };

    reserved-memory {
        ramoops_carveout {
            status = "okay";
        };
    };

    mttcan@c310000 {
        status = "okay";
    };

    mttcan@c320000 {
        status = "okay";
    };

    serial@3110000 {
        status = "okay";
    };

    pwm@32c0000 {
        status = "okay";
    };

    pwm@32f0000 {
        status = "okay";
    };

    i2c@31e0000 {
        pinctrl-names = "default";
        pinctrl-0 = <&dpaux_default>;
        bmi160@69 {
            compatible = "bmi,bmi160";
            reg = <0x69>;
            accelerometer_matrix    = [01 00 00 00 01 00 00 00 01];
            gyroscope_matrix        = [01 00 00 00 01 00 00 00 01];
            status = "okay";
        };
    };

    host1x {
        dpaux@155F0000 {
            status = "okay";
            compatible = "nvidia,tegra194-dpaux3-padctl";
            /delete-property/ power-domains;
            dpaux_default: pinmux@0 {
                dpaux3_pins {
                    pins = "dpaux3-3";
                    function = "i2c";
                };
            };
        };
    };

    hardwood {
        compatible = "nvidia,denver-hardwood";
        interrupts = <0 24 0x4>;
    };

    ufshci@2450000 {
        nvidia,enable-hs-mode;
    };
};
/*
&head0 {
    extcon-cables = <&typec_port0 2 &typec_port1 2>;
    extcon-cable-names = "typec0", "typec1";
    #extcon-cells = <1>;
};

&head1 {
    extcon-cables = <&typec_port0 2 &typec_port1 2>;
    extcon-cable-names = "typec0", "typec1";
    #extcon-cells = <1>;
};

&head2 {
    extcon-cables = <&typec_port0 2 &typec_port1 2>;
    extcon-cable-names = "typec0", "typec1";
    #extcon-cells = <1>;
};
*/
&sor0 {
    nvidia,typec-port = /bits/ 8 <0>;
};

&sor1 {
    nvidia,typec-port = /bits/ 8 <1>;
};

#if LINUX_VERSION >= 414
#include <tegra194-linux-4.14.dtsi>
#endif

5. 调试记录

修改完后,系统一直报错,如下:

[  468.481055] usb usb2-port4: cannot disable (err = -32)
[  469.968830] tegra-xusb 3610000.xhci: Cannot set link state.
[  469.969036] usb usb2-port4: cannot disable (err = -32)
[  469.969195] tegra-xusb 3610000.xhci: Cannot set link state.
[  469.969313] usb usb2-port4: cannot disable (err = -32)
[  472.313439] usb 2-4: Device not responding to setup address.
[  472.521413] usb 2-4: Device not responding to setup address.
[  472.728640] usb 2-4: device not accepting address 66, error -71
[  472.728848] tegra-xusb 3610000.xhci: Cannot set link state.
[  472.728994] usb usb2-port4: cannot disable (err = -32)

[  474.216900] tegra-xusb 3610000.xhci: Cannot set link state.
[  474.217099] usb usb2-port4: cannot disable (err = -32)
[  474.217261] tegra-xusb 3610000.xhci: Cannot set link state.
[  474.217378] usb usb2-port4: cannot disable (err = -32)

nvidia@jetson-0424418058605:~$ [  476.561449] usb 2-4: Device not responding to setup address.
[  476.769406] usb 2-4: Device not responding to setup address.
[  476.976634] usb 2-4: device not accepting address 68, error -71
[  476.976859] tegra-xusb 3610000.xhci: Cannot set link state.
[  476.977018] usb usb2-port4: cannot disable (err = -32)

nvidia@jetson-0424418058605:~$ [  478.464874] tegra-xusb 3610000.xhci: Cannot set link state.
[  478.465153] usb usb2-port4: cannot disable (err = -32)
[  478.465334] tegra-xusb 3610000.xhci: Cannot set link state.
[  478.465456] usb usb2-port4: cannot disable (err = -32)

查看usb设备信息

nvidia@jetson-0424218031082:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 005: ID 1c4f:000e SiGma Micro Genius KB-120 Keyboard
Bus 001 Device 004: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 002: ID 8564:4100 Transcend Information, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
nvidia@jetson-0424218031082:~$
nvidia@jetson-0424218031082:~$
nvidia@jetson-0424218031082:~$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=tegra-xusb/4p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=tegra-xusb/4p, 480M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 2: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 2: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 3: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 3: Dev 3, If 1, Class=Wireless, Driver=btusb, 12M
nvidia@jetson-0424218031082:~$

6. 调试方法

这里包含xhci日志的完整内核消息,可以方便进一步调试

echo ‘module usbcore +p’ > /sys/kernel/debug/dynamic_debug/control
echo ‘module xhci_hcd +p’ > /sys/kernel/debug/dynamic_debug/control
echo 8 > /proc/sys/kernel/printk

7. 修改usb2-companion

通过进一步排查发现是如下设置出现问题

usb3-0 {
                nvidia,usb2-companion = <0x0>;
                status = "okay";
            };
            usb3-2 {
                nvidia,usb2-companion = <0>;
                status = "okay";
                    };

这里表示usb3-0和usb3-2都使用相同的usb2-0端口0; 与实际硬件是不符合的

修改如下:

                     usb3-0 {
                                nvidia,usb2-companion = <0x0>;
                                status = "okay";
                        };
                        usb3-2 {
                                nvidia,usb2-companion = <1>;
                                status = "okay";
                        };
                        usb3-3 {
                                nvidia,usb2-companion = <3>;
                                nvidia,usb3-gen1-only= <1>;
                                status = "okay";
                        };

至此调过PD控制器, USB接口可正常使用

*本文仅代表作者观点,不代表易百纳技术社区立场。系作者授权易百纳技术社区发表,未经许可不得转载。

精彩评论

内容存在敏感词
打赏
打赏作者
free-jdx
您的支持将鼓励我继续创作!
金额:
¥1 ¥5 ¥10 ¥50 ¥100
支付方式:
微信支付
支付宝支付
微信支付
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

易百纳技术社区
确定要删除此文章、专栏、评论吗?
确定
取消
易百纳技术社区