USB接口是现在计算机系统中通用的一种接口,这里介绍USB控制器驱动的移植,以U盘驱动为例。 FS4412通过usb hub芯片将一个usb口扩展为多个接口如图:
所以为了能够使用usb口接入usb设备还需要移植usb hub驱动。
设备树添加内容:$ vim arch/arm/boot/dts/exynos4412-fs4412.dts
添加如下内容:
usbphy: usbphy@125B0000 {
#address-cells = < 1>;
#size-cells = < 1>;
compatible = "samsung,exynos4x12-usb2phy";
reg = < 0x125B0000 0x100>;
ranges;
clocks = < &clock 2>, < &clock 305>;
clock-names = "xusbxti", "otg";
usbphy-sys {
reg = < 0x10020704 0x8 0x1001021c 0x4>;
};
};
ehci@12580000 {
status = "okay";
usbphy = < &usbphy>;
};
usb3503@08 {
compatible = "smsc,usb3503";
reg = < 0x08 0x4>;
connect-gpios = < &gpm3 3 1>;
intn-gpios = < &gpx2 3 1>;
reset-gpios = < &gpm2 4 1>;
initial-mode = < 1>;
};
usbphy相关内容参考:Documentation/devicetree/bindings/usb/samsung-usbphy.txt
usb hub芯片几个关键管脚连接如下:
所以:
USB3503_RESET 对应 GPM2_4
USB3503_CONNECT 对应 GPM3_3
HUB_INT_N 对应 GPX2_3
所以
usb3503@08 {
compatible = "smsc,usb3503";
reg = < 0x08 0x4>;
connect-gpios = < &gpm3 3 1>;
intn-gpios = < &gpx2 3 1>;
reset-gpios = < &gpm2 4 1>;
initial-mode = < 1>;
};
参考内容:Documentation/devicetree/bindings/usb/usb3503.txt
配置内核:
make menuconfig
Device Drivers --->
[*] USB support --->
<*> EHCI HCD (USB 2.0) support
<*> EHCI support for Samsung S5P/EXYNOS SoC Series
<*> USB Mass Storage support
<*> USB3503 HSIC to USB20 Driver
USB Physical Layer drivers --->
<*> Samsung USB 2.0 PHY controller Driver
SCSI device support --->
<*> SCSI device support
<*> SCSI disk support
<*> SCSI generic support
File systems --->
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
(437) Default codepage for FAT
(iso8859-1) Default iocharset for FAT
-*- Native language support --->
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
<*> ASCII (United States)
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
<*> NLS UTF-8
重新编译内核,插入U盘看到如下内容表示移植成功:
[ 72.695000] usb 1-3.2: USB disconnect, device number 3
[ 74.435000] usb 1-3.2: new high-speed USB device number 4 using exynos-ehci
[ 74.555000] usb-storage 1-3.2:1.0: USB Mass Storage device detected
[ 74.560000] scsi1 : usb-storage 1-3.2:1.0
[ 75.645000] scsi 1:0:0:0: Direct-Access Kingston DataTraveler 160 PMAP PQ: 0 ANSI: 4
[ 75.660000] sd 1:0:0:0: Attached scsi generic sg0 type 0
[ 76.695000] sd 1:0:0:0: [sda] 15556608 512-byte logical blocks: (7.96 GB/7.41 GiB)
[ 76.700000] sd 1:0:0:0: [sda] Write Protect is off
[ 76.705000] sd 1:0:0:0: [sda] No Caching mode page found
[ 76.710000] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 76.725000] sd 1:0:0:0: [sda] No Caching mode page found
[ 76.730000] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 76.760000] sda: sda1 (sda是设备名 sda1是分区名)
[ 76.770000] sd 1:0:0:0: [sda] No Caching mode page found
[ 76.770000] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 76.780000] sd 1:0:0:0: [sda] Attached SCSI removable disk
然后执行如下操作
# mount -t vfat /dev/sda1 /mnt
# ls