ST意法半导体
直播中

张飞雄

7年用户 985经验值
私信 关注
[问答]

无法让USB主机正常工作是我做错了什么吗?

我无法让 USB 正常工作。我正在使用定制板,但我知道 USB 可以工作,因为如果我使用交付的图像 (MyIR) 启动板,USB 可以工作。我正在使用带有 5.10 内核的 buildroot 和来自 bootlin git 的 linux 内核配置。
在 TF-A 中,我启用了 CLK_USBPHY_HSE 和 CLK_USBPHY_USBPHY。
内核设备树:
  • &usbh_ehci {
  •         phys = <&usbphyc_port0>;
  •         phy-names = "usb";
  •         status = "okay";
  • };
  • &usbh_ohci {
  •            phys = <&usbphyc_port0>;
  •         phy-names = "usb";
  •         status = "okay";
  • };
  • &usbotg_hs {
  •         compatible = "st,STM32mp15-hsotg", "snps,dwc2";
  •         phys = <&usbphyc_port1 0>;
  •         phy-names = "usb2-phy";
  •         dr_mode = "host";
  •         status = "okay";
  • };
  • &usbphyc {
  •         status = "okay";
  • };
  • &usbphyc_port0 {
  •         phy-supply = <&vdd_usb>;
  •         st,phy-tuning = <&usb_phy_tuning>;
  • };
  • &usbphyc_port1 {
  •         phy-supply = <&vdd_usb>;
  •         st,phy-tuning = <&usb_phy_tuning>;
  • };
内核引导日志(我启用了 dwc2 调试)
  • # dmesg | grep -i usb
  • [    0.114896] usbcore: registered new interface driver usbfs
  • [    0.114983] usbcore: registered new interface driver hub
  • [    0.115069] usbcore: registered new device driver usb
  • [    1.743100] usb33: supplied by vdd_usb
  • [    1.791657] pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB Ethernet driver
  • [    1.791754] usbcore: registered new interface driver pegasus
  • [    1.791852] usbcore: registered new interface driver asix
  • [    1.791915] usbcore: registered new interface driver ax88179_178a
  • [    1.791976] usbcore: registered new interface driver cdc_ether
  • [    1.792055] usbcore: registered new interface driver smsc75xx
  • [    1.792133] usbcore: registered new interface driver smsc95xx
  • [    1.792193] usbcore: registered new interface driver net1080
  • [    1.792264] usbcore: registered new interface driver cdc_subset
  • [    1.792325] usbcore: registered new interface driver zaurus
  • [    1.792413] usbcore: registered new interface driver cdc_ncm
  • [    1.793050] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 7975fc9b
  • [    1.793872] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
  • [    1.794375] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  • [    1.795291] usbcore: registered new interface driver usb-storage
  • [    1.807092] usbcore: registered new interface driver usbhid
  • [    1.807108] usbhid: USB HID core driver
  • [    1.866395] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 3bad9e35
  • [    3.243027] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 474d4785
  • [    3.376990] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 13a1f023
  • [    3.385604] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 1c356f89
  • [    3.462241] dwc2 49000000.usb-otg: mapped PA 49000000 to VA 46c345d1
  • [    3.640278] dwc2 49000000.usb-otg: mapped PA 49000000 to VA cdf58676
这是来自原始图像:
  • 0.309427] USB33: supplied by regulator-dummy
  • [    0.313788] usbcore: registered new interface driver usbfs
  • [    0.313872] usbcore: registered new interface driver hub
  • [    0.314020] usbcore: registered new device driver usb
  • [    0.442943] stm32-usbphyc 5a006000.usbphyc: Linked as a consumer to regulator.5
  • [    0.443071] stm32-usbphyc 5a006000.usbphyc: Linked as a consumer to regulator.6
  • [    0.443197] stm32-usbphyc 5a006000.usbphyc: Linked as a consumer to regulator.3
  • [    0.443805] stm32-usbphyc 5a006000.usbphyc: registered rev:1.0
  • [    1.783244] pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB Ethernet driver
  • [    1.790785] usbcore: registered new interface driver pegasus
  • [    1.796362] usbcore: registered new interface driver asix
  • [    1.801796] usbcore: registered new interface driver ax88179_178a
  • [    1.807882] usbcore: registered new interface driver cdc_ether
  • [    1.813689] usbcore: registered new interface driver smsc75xx
  • [    1.819497] usbcore: registered new interface driver smsc95xx
  • [    1.825172] usbcore: registered new interface driver net1080
  • [    1.830875] usbcore: registered new interface driver cdc_subset
  • [    1.836760] usbcore: registered new interface driver zaurus
  • [    1.842426] usbcore: registered new interface driver cdc_ncm
  • [    1.848662] dwc2 49000000.usb-otg: 49000000.usb-otg supply vusb_d not found, using dummy regulator
  • [    1.857041] dwc2 49000000.usb-otg: Linked as a consumer to regulator.0
  • [    1.863539] dwc2 49000000.usb-otg: 49000000.usb-otg supply vusb_a not found, using dummy regulator
  • [    1.998801] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
  • [    2.009595] ehci-platform 5800d000.usbh-ehci: EHCI Host Controller
  • [    2.015330] ehci-platform 5800d000.usbh-ehci: new USB bus registered, assigned bus number 1
  • [    2.024135] ehci-platform 5800d000.usbh-ehci: irq 64, io mem 0x5800d000
  • [    2.057519] ehci-platform 5800d000.usbh-ehci: USB 2.0 started, EHCI 1.00
  • [    2.064088] hub 1-0:1.0: USB hub found
  • [    2.071964] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  • [    2.082427] ohci-platform 5800c000.usbh-ohci: Generic Platform OHCI controller
  • [    2.089247] ohci-platform 5800c000.usbh-ohci: new USB bus registered, assigned bus number 2
  • [    2.097907] ohci-platform 5800c000.usbh-ohci: irq 63, io mem 0x5800c000
  • [    2.172746] hub 2-0:1.0: USB hub found
  • [    2.180840] usbcore: registered new interface driver cdc_acm
  • [    2.185045] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
  • [    2.193286] usbcore: registered new interface driver usb-storage
  • [    2.199289] usbcore: registered new interface driver option
  • [    2.204697] usbserial: USB Serial support registered for GSM modem (1-port)
  • [    2.437543] usb 1-1: new high-speed USB device number 2 using ehci-platform
  • [    2.501578] usbcore: registered new interface driver usbhid
  • [    2.505770] usbhid: USB HID core driver
  • [    2.641447] usb-storage 1-1:1.0: USB Mass Storage device detected
  • [    2.689908] scsi host0: usb-storage 1-1:1.0
  • [    2.818748] dwc2 49000000.usb-otg: 49000000.usb-otg supply vusb_d not found, using dummy regulator
  • [    2.826938] dwc2 49000000.usb-otg: 49000000.usb-otg supply vusb_a not found, using dummy regulator
  • [    2.967633] dwc2 49000000.usb-otg: EPs: 9, dedicated fifos, 952 entries in SPRAM
  • [    2.974629] dwc2 49000000.usb-otg: DWC OTG Controller
  • [    2.978747] dwc2 49000000.usb-otg: new USB bus registered, assigned bus number 3
  • [    2.986093] dwc2 49000000.usb-otg: irq 51, io mem 0x49000000
  • [    2.993025] hub 3-0:1.0: USB hub found
  • [    8.708645] usbcore: registered new interface driver uas
  • [   18.015529] usb0: HOST MAC 60:0c:41:e6:65:40
  • [   18.022923] usb0: MAC 8e:a1:99:df:67:b5
  • [   18.025355] dwc2 49000000.usb-otg: bound driver configfs-gadget
  • [   18.208866] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
我还尝试了原始设备树配置(这是针对内核 4.19 的),它也不适用于 5.10:
  • &i2c4 {
  •         pinctrl-names = "default", "sleep";
  •         pinctrl-0 = <&i2c4_pins_a>;
  •         pinctrl-1 = <&i2c4_pins_sleep_a>;
  •         i2c-scl-rising-time-ns = <185>;
  •         i2c-scl-falling-time-ns = <20>;
  •         clock-frequency = <400000>;
  •         status = "okay";
  •         /* spare dmas for other usage */
  •         /delete-property/dmas;
  •         /delete-property/dma-names;
  •         stusb1600@28 {
  •                 compatible = "st,stusb1600";
  •                 reg = <0x28>;
  •                 interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
  •                 interrupt-parent = <&gpiog>;
  •                 pinctrl-names = "default";
  •                 pinctrl-0 = <&stusb1600_pins_a>;
  •                 status = "okay";
  •                 vdd-supply = <&vin>;
  •                 connector {
  •                         compatible = "usb-c-connector";
  •                         label = "USB-C";
  •                         power-role = "dual";
  •                         power-opmode = "default";
  •                         port {
  •                                 con_usbotg_hs_ep: endpoint {
  •                                         remote-endpoint = <&usbotg_hs_ep>;
  •                                 };
  •                         };
  •                 };
  •         };
  • };
  • /*usb host*/
  • &usbh_ehci {
  •         phys = <&usbphyc_port0>;
  •         phy-names = "usb";
  •         status = "okay";
  • };
  • /*USB*/
  • &usbh_ohci {
  •    phys = <&usbphyc_port0>;
  •    phy-names = "usb";
  •    status = "okay";
  • };
  • /*otg*/
  • &usbotg_hs {
  •         phys = <&usbphyc_port1 0>;
  •         phy-names = "usb2-phy";
  •         usb-role-switch;
  •         status = "okay";
  •         port {
  •                 usbotg_hs_ep: endpoint {
  •                         remote-endpoint = <&con_usbotg_hs_ep>;
  •                 };
  •         };
  • };
  • &usbphyc {
  •         status = "okay";
  • };
  • &usbphyc_port0 {
  •         phy-supply = <&vdd_usb>;
  •         st,phy-tuning = <&usb_phy_tuning>;
  • };
  • &usbphyc_port1 {
  •         phy-supply = <&vdd_usb>;
  •         st,phy-tuning = <&usb_phy_tuning>;
  • };
但我只想让 USB 主机工作,所以我真的不需要 USB-C 的东西。知道我做错了什么吗?


回帖(1)

王耀昱

2022-12-2 14:16:47
所以终于开始工作了。我不得不添加pinctrl。


  • &usbotg_hs {
  •         pinctrl-0 = <&usbotg_fs_dp_dm_pins_a>;
  •         pinctrl-names = "default";
  •         phys = <&usbphyc_port1 0>;
  •         phy-names = "usb2-phy";
  •         dr_mode = "host";

  •         status = "okay";
  • };

在我见过的任何示例中都没有真正做到这一点。这通常在哪里完成?当我只配置 USB 主机时,甚至 CubeMX 也不会在任何地方添加它。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分