USB HOST驱动一般都是由芯片厂商维护的,因此,我们仍然只需要配置下DTS即可完成USB HOST驱动的移植。
DTS配置
参考sabresd相关的DTS,在我们的DTS中添加如下内容:
/ { ... regulators { compatible = "simple-bus"; reg_usb_otg_vbus: usb_otg_vbus { compatible = "regulator-fixed"; regulator-name = "usb_otg_vbus"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio3 22 0>; enable-active-high; }; reg_usb_h1_vbus: usb_h1_vbus { compatible = "regulator-fixed"; regulator-name = "usb_h1_vbus"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio1 29 0>; enable-active-high; }; }; ... }; ... &usbh1 { vbus-supply = <®_usb_h1_vbus>; status = "okay"; }; &usbotg { vbus-supply = <®_usb_otg_vbus>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usbotg_2>; disable-over-current; status = "okay"; }; ...添加以上内容后重新编译DTB并烧写到SD。
测试方法
USB HOST移植好之后可以使用USB盘来测试,使用修改好的DTB启动内核,然后将U盘插到tqimx6q的USB口上,在开发板的串口终端会看到驱动枚举到USB设备的Log信息,我这边看到的Log信息如下:
usb 1-1.2: new high-speed USB device number 3 using ci_hdrc usb-storage 1-1.2:1.0: USB Mass Storage device detected scsi0 : usb-storage 1-1.2:1.0 scsi 0:0:0:0: Direct-Access Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 4 sd 0:0:0:0: [sda] 30233588 512-byte logical blocks: (15.4 GB/14.4 GiB) sd 0:0:0:0: [sda] Write Protect is off sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA sda: sda4 sd 0:0:0:0: [sda] Attached SCSI removable disk
相应的设备节点在/dev目录下,一般是以sd开头的,本文的U盘设备节点是sda,对应分区节点是sda4。虽然内核驱动已经识别到了U盘,但是没有自动挂载U盘,因此需要手动挂载U盘:
mount /dev/sda4 /mnt即可将U盘挂在到mnt目录。然后通过cd命令切换到/mnt目录,然后使用ls指令即可查看U盘内的文件:
@tqimx6q #mount /dev/sda4 mnt/ FAT-fs (sda4): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. @tqimx6q #cd mnt/ @tqimx6q mnt#ls DDR??M.txt L3.0.35_4.1.0_130816_source.tar.gz alsa-wm8960.tar.bz2 arch imx6_corec_q1g_cd1.iso imx6_corec_q1g_cd2.iso imx6q jdk-6u45-linux-x64.bin linux-2.6-imx.tar(1).bz2 linux-3.12.10-ti2013.12.01.tgz linux-3.17.2.tgz rootfs rootfs.tgz stunnel.rar synergy-master.zip test ti-sdk-am335x-evm-07.00.00.00-Linux-x86-Install.bin官方默认内核有些驱动是没有配置的,比如USB串口驱动。如果有需要可以通过内核的menuconfig选项进行配置,这里就不多说了。至此,tqimx6q的USB HOST驱动就已经移植好了,有任何疑问可以留言讨论。
本文作者:girlkoo
本文链接:http://blog.csdn.net/girlkoo/article/details/45652209
I.MX6Q(TQIMX6Q/TQE9)学习笔记——新版BSP之USB HOST移植
原文地址:http://blog.csdn.net/girlkoo/article/details/45652209