作者信息
作者: 彭東林
QQ:405728433
平臺簡介
開發板:tiny4412ADK + S700 + 4GB Flash
要移植的內核版本:Linux-4.4.0 (支持device tree)
u-boot版本:友善之臂自帶的 U-Boot 2010.12 (為支持uImage啟動,做了少許改動)
busybox版本:busybox 1.25
eMMC:KLMxGxFE3x-x00x
交叉編譯工具鏈: arm-none-linux-gnueabi-gcc
(gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29))
概述
eMMC驅動在內核中也已經支持好了,代碼在:drivers/mmc/host/dw_mmc-exynos.c,我們要做的就是修改設備樹配置文件。
移植
一、原理圖
eMMC這部分電路都在核心板上:
從上圖看到,tiny4412上exynos4412與eMMC傳輸數據的匯流排寬度是8位,使用的控制器是Mobile Storage Host,占用了SDMMC0和SDMMC1的資源,即SDMMC0和SDMMC1的引腳被覆用為SD_4功能。具體信息請參考Exynos4412的用戶手冊的 第23節Mobile Storage Host:
二、修改設備樹
這部分我參考了arch/arm/boot/dts/exynos4412-trats2.dts,對arch/arm/boot/dts/exynos4412-tiny4412.dts做瞭如下修改:
diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos4412-tiny4412.dts
index bd823eb..585cab7 100644
--- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
+++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
@@ -106,6 +106,23 @@
status = "okay";
};
+&mshc_0 {
+ num-slots = <1>;
+ broken-cd;
+ non-removable;
+ card-detect-delay = <200>;
+ vmmc-supply = <&mmc_reg>;
+ clock-frequency = <400000000>;
+ samsung,dw-mshc-ciu-div = <0>;
+ samsung,dw-mshc-sdr-timing = <2 3>;
+ samsung,dw-mshc-ddr-timing = <1 2>;
+ pinctrl-0 = <&sd4_clk &sd4_cmd &sd4_bus4 &sd4_bus8>;
+ pinctrl-names = "default";
+ status = "okay";
+ bus-width = <8>;
+ cap-mmc-highspeed;
+};
+
&serial_0 {
status = "okay";
};
實際測試時發現不設置vmmc-supply也可以正常工作,上面的這些參數我直接從arch/arm/boot/dts/exynos4412-trats2.dts拷貝過來的,沒有做任何改動,其中mshc0是在arch/arm/boot/dts/exynos4x12.dtsi定義的:
mshc_0: mmc@12550000 {
compatible = "samsung,exynos4412-dw-mshc";
reg = <0x12550000 0x1000>;
interrupts = <0 77 0>;
#address-cells = <1>;
#size-cells = <0>;
fifo-depth = <0x80>;
clocks = <&clock CLK_SDMMC4>, <&clock CLK_SCLK_MMC4>;
clock-names = "biu", "ciu";
status = "disabled";
};
三、測試
下麵是啟動log:
1: [ 2.286502] dwmmc_exynos 12550000.mmc: IDMAC supports 32-bit address mode.
2: [ 2.286613] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
3: [ 2.289979] dwmmc_exynos 12550000.mmc: Version ID is 240a
4: [ 2.295396] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 89,32 bit host data width,128 deep fifo
5: [ 2.304812] dwmmc_exynos 12550000.mmc: No vqmmc regulator found
6: [ 2.340643] dwmmc_exynos 12550000.mmc: 1 slots initialized
7: [ 2.341935] usbcore: registered new interface driver usbhid
8: [ 2.341991] usbhid: USB HID core driver
9: [ 2.344435] NET: Registered protocol family 10
10: [ 2.345015] sit: IPv6 over IPv4 tunneling driver
11: [ 2.345497] NET: Registered protocol family 17
12: [ 2.346734] NET: Registered protocol family 15
13: [ 2.351355] Registering SWP/SWPB emulation handler
14: [ 2.357490] hctosys: unable to open rtc device (rtc0)
15: [ 2.365652] usb 2-2: new high-speed USB device number 2 using exynos-ehci
16: [ 2.380409] ALSA device list:
17: [ 2.380451] No soundcards found.
18: [ 2.381460] RAMDISK: gzip image found at block 0
19: [ 2.383346] mmc1: MAN_BKOPS_EN bit is not set
20: [ 2.384095] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
21: [ 2.392918] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
22: [ 2.402558] mmc1: new DDR MMC card at address 0001
23: [ 2.407922] mmcblk0: mmc1:0001 M4G1YC 3.64 GiB
24: [ 2.412049] mmcblk0boot0: mmc1:0001 M4G1YC partition 1 2.00 MiB
25: [ 2.417930] mmcblk0boot1: mmc1:0001 M4G1YC partition 2 2.00 MiB
26: [ 2.424030] mmcblk0rpmb: mmc1:0001 M4G1YC partition 3 128 KiB
27: [ 2.430169] mmcblk0: p1 p2 p3 p4
查看一下:
1: [root@tiny4412 ]# ls /dev/mmcblk* -l
2: brw-rw---- 1 0 0 179, 0 Jan 1 00:00 /dev/mmcblk0
3: brw-rw---- 1 0 0 179, 16 Jan 1 00:00 /dev/mmcblk0boot0
4: brw-rw---- 1 0 0 179, 32 Jan 1 00:00 /dev/mmcblk0boot1
5: brw-rw---- 1 0 0 179, 1 Jan 1 00:00 /dev/mmcblk0p1
6: brw-rw---- 1 0 0 179, 2 Jan 1 00:00 /dev/mmcblk0p2
7: brw-rw---- 1 0 0 179, 3 Jan 1 00:00 /dev/mmcblk0p3
8: brw-rw---- 1 0 0 179, 4 Jan 1 00:00 /dev/mmcblk0p4
9: brw-rw---- 1 0 0 179, 48 Jan 1 00:00 /dev/mmcblk0rpmb
10: brw-rw---- 1 0 0 179, 64 Jan 1 00:00 /dev/mmcblk1
11: brw-rw---- 1 0 0 179, 65 Jan 1 00:00 /dev/mmcblk1p1
其中mmcblk1是我們的sdcard,mmcblk0是核心板上的eMMC。 我在eMMC中燒寫的是Android系統,可以看到Android系統有7個分區,下麵我們掛載一個分區看看:
1: [root@tiny4412 ]# mount -t ext4 /dev/mmcblk0p2 /mnt
2: [ 287.710063] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
3: [root@tiny4412 ]# ls /mnt/
4: addon.d build.prop fonts lost+found tts xbin
5: app busybox framework media usr
6: bin etc lib priv-app vendor
代碼我已經上傳到了github上:
git clone https://github.com/pengdonglin137/linux-4.4_tiny4412.git -b port_to_tiny4412