前言:
解决usb虚拟u盘无法probe驱动的问题--Apple的学习笔记之前已经玩了下usb,但是我认为方便不正确,我是通过对比tisdk的打印信息来找线索,对usb文件夹中的c文件含义并不是很清楚。所以今天来一次相对正式方法来学习。之前直接编译入内核,这次改成模块加载方式。
一,usb子系统结构
1,底层控制器+phy驱动(通过设备树可以看到usb分为5个匹配项)
modprobe musb_am335x(注册usb设备)
modprobe phy-am335x(注册usb控制器和phy)
modprobe musb_dsps(驱动,用来匹配底层设备)
2,usb总线协议
modprobe usbcore(注册总线及协议)
3,上层应用协议(串口,虚拟网卡,u盘等)
modprobe udc-core(上层协议的中间件)
二,过程中的问题
通过添加模块的方法居然无法创建/sys/class/udc下面的设备
解决方法:
设备树搜索,发现musb_am335x.c是需要被调用的,否则无法匹配设备树。但是我对比.config将y改成M的呀,都没有搜索到CONFIG_USB_MUSB_AM335X_CHILD呀?原来CONFIG_USB_MUSB_AM335X_CHILD是tristate属性的,所以被隐藏了。由于我之前CONFIG_USB_MUSB_DSPS选择为y,所以CONFIG_USB_MUSB_AM335X_CHILD就自动变成y。
- 添加modprobe musb_am335x后能创建musb-hdrc.0的设备。
三,关于musb-hdrc设备匹配的理解
因为现在设备树用多,所以任何的匹配我都会去dts中找,所以我搜索musb-hdrc,没有搜索到。那么只能去分析代码。后来发现
dsps_probe->platform_device_alloc("musb-hdrc"...)所以关于musb-hdrc的匹配是通过driver_match_device函数中的dev.name来匹配的。
image.png
四,最后成功
只要musb-hdrc.0能创建出来,usb虚拟U盘就能成功。
Welcome to Buildroot
buildroot login: root
# modprobe musb_am335x
# modprobe phy-am335x
[ 21.566063] am335x-phy-driver 47401300.usb-phy: GPIO lookup for consumer reset
[ 21.573584] am335x-phy-driver 47401300.usb-phy: using device tree for GPIO lookup
[ 21.581152] of_get_named_gpiod_flags: can't parse 'reset-gpios' property of node '/ocp/usb@47400000/usb-phy@47401300[0]'
[ 21.592151] of_get_named_gpiod_flags: can't parse 'reset-gpio' property of node '/ocp/usb@47400000/usb-phy@47401300[0]'
[ 21.603026] am335x-phy-driver 47401300.usb-phy: using lookup tables for GPIO lookup
[ 21.610725] am335x-phy-driver 47401300.usb-phy: No GPIO consumer reset found
[ 21.617835] am335x-phy-driver 47401300.usb-phy: GPIO lookup for consumer vbus-detect
[ 21.625640] am335x-phy-driver 47401300.usb-phy: using device tree for GPIO lookup
[ 21.633202] of_get_named_gpiod_flags: can't parse 'vbus-detect-gpios' property of node '/ocp/usb@47400000/usb-phy@47401300[0]'
[ 21.644686] of_get_named_gpiod_flags: can't parse 'vbus-detect-gpio' property of node '/ocp/usb@47400000/usb-phy@47401300[0]'
[ 21.656072] am335x-phy-driver 47401300.usb-phy: using lookup tables for GPIO lookup
[ 21.663788] am335x-phy-driver 47401300.usb-phy: No GPIO consumer vbus-detect found
[ 21.671535] am335x-phy-driver 47401300.usb-phy: 47401300.usb-phy supply vcc not found, using dummy regulator
[ 21.686799] am335x-phy-driver 47401b00.usb-phy: GPIO lookup for consumer reset
[ 21.694279] am335x-phy-driver 47401b00.usb-phy: using device tree for GPIO lookup
[ 21.701845] of_get_named_gpiod_flags: can't parse 'reset-gpios' property of node '/ocp/usb@47400000/usb-phy@47401b00[0]'
[ 21.712863] of_get_named_gpiod_flags: can't parse 'reset-gpio' property of node '/ocp/usb@47400000/usb-phy@47401b00[0]'
[ 21.723742] am335x-phy-driver 47401b00.usb-phy: using lookup tables for GPIO lookup
[ 21.731442] am335x-phy-driver 47401b00.usb-phy: No GPIO consumer reset found
[ 21.738556] am335x-phy-driver 47401b00.usb-phy: GPIO lookup for consumer vbus-detect
[ 21.746364] am335x-phy-driver 47401b00.usb-phy: using device tree for GPIO lookup
[ 21.753930] of_get_named_gpiod_flags: can't parse 'vbus-detect-gpios' property of node '/ocp/usb@47400000/usb-phy@47401b00[0]'
[ 21.765420] of_get_named_gpiod_flags: can't parse 'vbus-detect-gpio' property of node '/ocp/usb@47400000/usb-phy@47401b00[0]'
[ 21.776809] am335x-phy-driver 47401b00.usb-phy: using lookup tables for GPIO lookup
[ 21.784529] am335x-phy-driver 47401b00.usb-phy: No GPIO consumer vbus-detect found
[ 21.792274] am335x-phy-driver 47401b00.usb-phy: 47401b00.usb-phy supply vcc not found, using dummy regulator
# modprobe usbcore
[ 28.904523] usbcore: registered new interface driver usbfs
[ 28.910148] usbcore: registered new interface driver hub
[ 28.915736] usbcore: registered new device driver usb
# modprobe musb_hdrc
# modprobe udc-core
# modprobe musb_dsps
[ 42.281548] musb-dsps 47401400.usb: VBUS irq 59 configured
[ 42.288197] go musb_probe
[ 42.290896] go musb_init_controller
[ 42.299794] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[ 42.310442] musb-hdrc: MHDRC RTL version 2.0
[ 42.314764] musb-hdrc: setup fifo_mode 4
[ 42.318722] musb-hdrc: 28/31 max ep, 16384/16384 memory
[ 42.324334] musb->port_mode is 2
[ 42.324340] go musb_gadget_setup
[ 42.330860] go usb_add_gadget_udc
[ 42.334243] go usb_add_gadget_udc_release
[ 42.339802] go musb_probe
[ 42.342502] go musb_init_controller
[ 42.351315] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[ 42.361956] musb-hdrc: MHDRC RTL version 2.0
[ 42.366275] musb-hdrc: setup fifo_mode 4
[ 42.370231] musb-hdrc: 28/31 max ep, 16384/16384 memory
# ls /sys/class/udc
musb-hdrc.0
# lsmod
Module Size Used by Not tainted
musb_dsps 20480 0
musb_hdrc 86016 1 musb_dsps
udc_core 40960 1 musb_hdrc
usbcore 200704 0
phy_am335x 16384 2
phy_am335x_control 16384 1 phy_am335x
phy_generic 16384 1 phy_am335x
usb_common 16384 5 musb_dsps,musb_hdrc,udc_core,usbcore,phy_am335x
musb_am335x 16384 0 [permanent]
#
网友评论