基于tiny4412的Linux内核移植 -- eMMC驱动移植(六)

作者信息

作者: 彭东林

邮箱:[email protected]

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的Linux内核移植 -- eMMC驱动移植(六)_第1张图片

 

基于tiny4412的Linux内核移植 -- eMMC驱动移植(六)_第2张图片

 从上图看到,tiny4412上exynos4412与eMMC传输数据的总线宽度是8位,使用的控制器是Mobile Storage Host,占用了SDMMC0和SDMMC1的资源,即SDMMC0和SDMMC1的引脚被复用为SD_4功能。具体信息请参考Exynos4412的用户手册的 第23节Mobile Storage Host:

基于tiny4412的Linux内核移植 -- eMMC驱动移植(六)_第3张图片

 二、修改设备树

这部分我参考了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

你可能感兴趣的:(基于tiny4412的Linux内核移植 -- eMMC驱动移植(六))