Linux驱动PCIE转USB 3.0调试经验

本文深入解析了μPD720202K8-701-BAA-A芯片,该芯片用于将PCIE接口转换为两个USB3.0接口,涵盖了硬件电路设计要点、内核配置、驱动模块细节及调试技巧。文章揭示了在启动过程中关键的打印信息,以及在遇到USB3.0设备识别问题时的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PCIE转USB 3.0芯片

μPD720202K8-701-BAA-A芯片,一个PCIE口转2个USB 3.0,主要用于USB口的扩展;

硬件电路

电路图

电路设计注意事项

RXD需要改为0欧电阻,不要ESD器件,OCI1B需要拉高;

驱动代码

request_firmware内核配置,固件需要拷贝到文件系统的/lib/firmware/;

Device Drivers  --->
	Generic Driver Options  ---> 
	
		[*] Select only drivers that don't need compile-time external firmware                                             
		[*] Prevent firmware from being built                                                                              
		{*} Userspace firmware loading support                                                                             
		[*]   Include in-kernel firmware blobs in kernel binary                                                            
		()    External firmware blobs to build into the kernel binary                                                      
		[*] Fallback user-helper invocation for firmware loading        	

 三个驱动模块:insmod xhci-hcd.ko,xhci-plat-hcd.ko ,xhci-pci.ko;

驱动移植:需要移植xhci-fwdload.c驱动文件;

    leds {
        compatible = "gpio-leds";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpio_led>;

        pcie_pwon {
            label = "PCIE_PWON";
            gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
            default-state = "off";
        };
    };

&iomuxc {
    pinctrl-names = "default";

        pinctrl_pcie0: pcie0grp {
            fsl,pins = <
                MX8MM_IOMUXC_SD2_DATA1_GPIO2_IO16   0xc1
                MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12    0x61
                MX8MM_IOMUXC_SD2_RESET_B_GPIO2_IO19 0x41
            >;
        };

&pcie0{
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_pcie0>;
    reset-gpio = <&gpio2 19 GPIO_ACTIVE_LOW>;
    clkreq-gpio = <&gpio2 12 GPIO_ACTIVE_LOW>;
    power-on-gpio = <&gpio2 16 GPIO_ACTIVE_LOW>;
    ext_osc = <0>;
    status = "okay";
};

启动打印

关键打印信息

[    2.317283] imx6q-pcie 33800000.pcie: 33800000.pcie supply epdev_on not found, using dummy regulator
[    2.326803] OF: PCI: host bridge /pcie@0x33800000 ranges:
[    2.332227] OF: PCI:   No bus range found for /pcie@0x33800000, using [bus 00-ff]
[    2.339720] OF: PCI:    IO 0x1ff80000..0x1ff8ffff -> 0x00000000
[    2.345651] OF: PCI:   MEM 0x18000000..0x1fefffff -> 0x18000000
[    2.352028] imx6q-pcie 33800000.pcie: Initialize PHY with EXT REfCLK!.
[    2.358871] imx6q-pcie 33800000.pcie: PHY Initialization End!.
[    2.365030] imx6q-pcie 33800000.pcie: pcie phy pll is locked.
[    2.423573] imx6q-pcie 33800000.pcie: Link up, Gen2
[    2.429246] imx6q-pcie 33800000.pcie: PCI host bridge to bus 0000:00
[    2.435627] pci_bus 0000:00: root bus resource [bus 00-ff]
[    2.441124] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    2.447311] pci_bus 0000:00: root bus resource [mem 0x18000000-0x1fefffff]
[    2.466200] pci 0000:00:00.0: BAR 0: assigned [mem 0x18000000-0x180fffff 64bit]
[    2.473532] pci 0000:00:00.0: BAR 14: assigned [mem 0x18100000-0x181fffff]
[    2.480425] pci 0000:00:00.0: BAR 6: assigned [mem 0x18200000-0x1820ffff pref]
[    2.487668] pci 0000:01:00.0: BAR 0: assigned [mem 0x18100000-0x18101fff 64bit]
[    2.495033] pci 0000:00:00.0: PCI bridge to [bus 01-ff]
[    2.500274] pci 0000:00:00.0:   bridge window [mem 0x18100000-0x181fffff]
[    2.507499] pcieport 0000:00:00.0: Signaling PME with IRQ 230
[    2.513361] pcieport 0000:00:00.0: AER enabled with IRQ 230
[    2.519025] pci 0000:01:00.0: enabling device (0000 -> 0002)
[    2.525182] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    2.530435] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 3

usb信息

[  169.878429] xhci_hcd 0000:01:00.0: xHCI Host Controller
[  169.883949] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 3
[  170.006893] Can't support > 32 bit dma.
[  170.050672] xhci_hcd 0000:01:00.0: hcc params 0x014051cf hci version 0x100 quirks 0x0000000000000090
[  170.067938] hub 3-0:1.0: USB hub found
[  170.072939] hub 3-0:1.0: 2 ports detected
[  170.079747] xhci_hcd 0000:01:00.0: xHCI Host Controller
[  170.085315] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 4
[  170.092922] xhci_hcd 0000:01:00.0: Host supports USB 3.0  SuperSpeed
[  170.099627] usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
[  170.110073] hub 4-0:1.0: USB hub found
[  170.114140] hub 4-0:1.0: 2 ports detected

插入3.0 U盘打印信息

[  142.761704] usb 4-1: new SuperSpeed USB device number 2 using xhci_hcd
[  142.821223] usb-storage 4-1:1.0: USB Mass Storage device detected
[  142.840700] scsi host0: usb-storage 4-1:1.0
[  143.877959] scsi 0:0:0:0: Direct-Access     Generic  STORAGE DEVICE   1532 PQ: 0 ANSI: 6
[  144.216203] sd 0:0:0:0: [sda] 249737216 512-byte logical blocks: (128 GB/119 GiB)
[  144.225368] sd 0:0:0:0: [sda] Write Protect is off
[  144.231410] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  144.256347]  sda: sda1
[  144.266457] sd 0:0:0:0: [sda] Attached SCSI removable disk

问题调试

USB2.0能识别,USB3.0提示bad cable问题

[  112.208013] usb usb1-port2: Cannot enable. Maybe the USB cable is bad?
[  113.180033] usb usb1-port2: Cannot enable. Maybe the USB cable is bad?
[  113.186621] usb usb1-port2: attempt power cycle
[  114.472025] usb usb1-port2: Cannot enable. Maybe the USB cable is bad?
[  115.444016] usb usb1-port2: Cannot enable. Maybe the USB cable is bad?
[  115.450602] usb usb1-port2: unable to enumerate USB device

 去掉ESD器件解决上面问题;

去掉flash后固件存放位置和启动失败问题

[    1.946229] pci 0000:00:00.0:   bridge window [mem 0x18100000-0x181fffff]
[    1.956527] pcieport 0000:00:00.0: Signaling PME with IRQ 230
[    1.962369] pcieport 0000:00:00.0: AER enabled with IRQ 230
[    1.968016] pci 0000:01:00.0: enabling device (0000 -> 0002)
[    1.974075] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    1.979322] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 3
[    1.986769] pci_bus 0000:01: Falling back to user helper
[   62.538056] pci_bus 0000:01: Falling back to user helper

驱动做成KO模式加载,固件存放对应目录位置解决上面问题;

另外一个USB口不能使用问题,OCI1B需要拉高;

评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值