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