基于tiny4412的Linux内核移植 -- SD卡驱动移植(五)

作者信息

作者: 彭东林

邮箱:pengdonglin137@163.com

QQ:405728433

平台简介

开发板:tiny4412ADK + S700 + 4GB Flash

要移植的内核版本:Linux-4.4.0 (支持device tree)

u-boot版本:友善之臂自带的 U-Boot 2010.12 (为支持uImage启动,做了少许改动)

busybox版本:busybox 1.25

SD卡:Kingston SDHC 4GB

交叉编译工具链: arm-none-linux-gnueabi-gcc

      (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29))

概述

    移植SD卡比较简单,但是刚开始的时候也出现了不少问题,关键是设置设备树的修改、对regulator的理解以及sdcard检测过程。

移植

    下面是tiny4412关于sd卡部分的原理图:

底板:

技术分享

核心板:

技术分享

从原理图可以看出,tiny4412用的MMC控制器是SDMMC2。一共用到了7个引脚,在之前的移植中我们将sdhc2给disabled了:

arch/arm/boot/dts/exynos4412-tiny4412.dts:

&sdhci_2 {
    bus-width = <4>;
    pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
    pinctrl-names = "default";
    status = "disabled";
};

其中princtrl-0后的作用是设置用到的GPIO的复用功能,这几个标号是在arch/arm/boot/dts/exynos4x12-pinctrl.dtsi中定义的:

sd2_clk: sd2-clk {
    samsung,pins = "gpk2-0";
    samsung,pin-function = <2>;
    samsung,pin-pud = <0>;
    samsung,pin-drv = <3>;
};
 
sd2_cmd: sd2-cmd {
    samsung,pins = "gpk2-1";
    samsung,pin-function = <2>;
    samsung,pin-pud = <0>;
    samsung,pin-drv = <3>;
};
 
sd2_cd: sd2-cd {
    samsung,pins = "gpk2-2";
    samsung,pin-function = <2>;
    samsung,pin-pud = <3>;
    samsung,pin-drv = <3>;
};
 
sd2_bus4: sd2-bus-width4 {
    samsung,pins = "gpk2-3", "gpk2-4", "gpk2-5", "gpk2-6";
    samsung,pin-function = <2>;
    samsung,pin-pud = <3>;
    samsung,pin-drv = <3>;
};

这样只是设置了这几个GPIO的复用功能,并不用在驱动程序中申请这几个GPIO资源,因为这几个引脚已经不是作为普通的GPIO使用了。但是如果直接将sdhc2使能的话:

--- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
+++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
@@ -86,7 +86,7 @@
        bus-width = <4>;
        pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
        pinctrl-names = "default";
-       status = "disabled";
+       status = "okay";
 };
 
 &serial_0 {

内核在启动时会崩溃,信息如下:

   1: [    2.228406] sdhci: Secure Digital Host Controller Interface driver
   2: [    2.233751] sdhci: Copyright(c) Pierre Ossman
   3: [    2.238350] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (100000000 Hz)
   4: [    2.245838] s3c-sdhci 12530000.sdhci: No vmmc regulator found
   5: [    2.251358] s3c-sdhci 12530000.sdhci: No vqmmc regulator found
   6: [    2.257480] ------------[ cut here ]------------
   7: [    2.261686] kernel BUG at drivers/mmc/host/sdhci.c:1304!
   8: [    2.266981] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
   9: [    2.272796] Modules linked in:
  10: [    2.275836] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.0-gbd7378b-dirty #33
  11: [    2.283038] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
  12: [    2.289115] task: ef078000 ti: ef080000 task.ti: ef080000
  13: [    2.294500] PC is at sdhci_do_set_ios+0x564/0x5e0
  14: [    2.299189] LR is at arm_heavy_mb+0x1c/0x38
  15: [    2.303351] pc : [<c0406f38>]    lr : [<c00198b0>]    psr: 80000093
  16: [    2.303351] sp : ef081cc8  ip : 00000200  fp : 00000001
  17: [    2.314807] r10: 00000003  r9 : ef30e800  r8 : 60000013
  18: [    2.320015] r7 : ef30e800  r6 : ef30ec98  r5 : ef30ea34  r4 : ef30eb80
  19: [    2.326525] r3 : 00000001  r2 : 75004180  r1 : 00000000  r0 : ef30eb80
  20: [    2.333036] Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
  21: [    2.340240] Control: 10c5387d  Table: 4000404a  DAC: 00000051
  22: [    2.345969] Process swapper/0 (pid: 1, stack limit = 0xef080210)
  23: [    2.351958] Stack: (0xef081cc8 to 0xef082000)
  24: [    2.356300] 1cc0:                   00000000 ef30eb80 00000043 c02d30e8 c02d30e8 00000004
  25: [    2.364460] 1ce0: c0058b5c ef080000 ef1a6ebc c0407168 ef1a6e10 ef1a6e80 c02d30e8 c02d3114
  26: [    2.372619] 1d00: 00000004 c02d465c ef1a6e10 c0852100 c086ea10 c02d46b0 00000000 ef1a6e10
  27: [    2.380778] 1d20: c0852100 c02d54fc eeca0fa0 c00f2934 00000188 eeca0fa0 ef078000 60000013
  28: [    2.388937] 1d40: ef1a6e80 ef1a6e10 ef1a6e80 00000004 60000013 00000000 00000002 ef30ea80
  29: [    2.397096] 1d60: 00000000 c02d56c8 00000000 ef30e800 ef30ea24 60000013 ef080000 c03eff80
  30: [    2.405256] 1d80: eec0b7b8 00000000 ef078000 c0044ee8 00000100 00000200 eec0b6b4 ef30e800
  31: [    2.413415] 1da0: ef30ed2c ef30eb80 ef30e800 00000000 00000200 00000000 ef30ed18 c03f2fd8
  32: [    2.421574] 1dc0: ef30e800 c03f41ac 00000000 c0407ba4 ef264300 ef30eb80 00000808 ef30e800
  33: [    2.429733] 1de0: ef7d3488 00000000 00000000 c03f3dd4 00000000 ef30eb80 00000004 ef1a6e10
  34: [    2.437893] 1e00: ef1a6e00 ef30edec 00000001 ef264110 00000000 c0408be8 05f5e100 c087a810
  35: [    2.446052] 1e20: ef17df50 c087a8a4 5f636d6d 63737562 332e6b6c ee9d9600 00000001 ef1a6e10
  36: [    2.454211] 1e40: fffffffe fffffdfb c087a810 c087a810 00000000 c081683c c0816848 c02ce238
  37: [    2.462370] 1e60: c02ce1e8 ef1a6e10 c08d942c c088e410 00000000 c02cc634 c087a810 ef1a6e44
  38: [    2.470529] 1e80: c088e338 ef1a6e10 c087a810 ef1a6e44 c088e338 00000000 00000000 c02cc8d4
  39: [    2.478688] 1ea0: 00000000 c087a810 c02cc848 c02ca7d4 ef003274 ef17b7c0 c087a810 eebf6f00
  40: [    2.486848] 1ec0: c086ebc8 c02cbb48 c0755dc0 c087a810 c087a810 c0855520 ef267240 c089c000
  41: [    2.495007] 1ee0: c08023cc c02cd0cc c087a7fc c0855520 c0855520 c00097a0 ef15eb00 c0598680
  42: [    2.503166] 1f00: 00000025 0000c000 ef078000 60000013 efffca92 c05aba2c 000000c0 c003da88
  43: [    2.511325] 1f20: 00000001 00000003 c0746c3c c07b1804 00000000 c088c6b8 00000006 00000006
  44: [    2.519484] 1f40: c0858ec8 c0849e3c c084a108 00000006 c089c000 c089c000 c07e35b0 000000c0
  45: [    2.527643] 1f60: c081683c c07e3dec 00000006 00000006 00000000 c07e35b0 ef078000 c0042518
  46: [    2.535802] 1f80: 000000a2 00000000 c058e6c8 00000000 00000000 00000000 00000000 00000000
  47: [    2.543962] 1fa0: 00000000 c058e6d0 00000000 c0010338 00000000 00000000 00000000 00000000
  48: [    2.552121] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  49: [    2.560280] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 dffffefb f5fbff7f
  50: [    2.568447] [<c0406f38>] (sdhci_do_set_ios) from [<c0407168>] (sdhci_runtime_resume_host+0x60/0x114)
  51: [    2.577557] [<c0407168>] (sdhci_runtime_resume_host) from [<c02d3114>] (pm_generic_runtime_resume+0x2c/0x38)
  52: [    2.587366] [<c02d3114>] (pm_generic_runtime_resume) from [<c02d465c>] (__rpm_callback+0x2c/0x60)
  53: [    2.596216] [<c02d465c>] (__rpm_callback) from [<c02d46b0>] (rpm_callback+0x20/0x80)
  54: [    2.603942] [<c02d46b0>] (rpm_callback) from [<c02d54fc>] (rpm_resume+0x3ac/0x52c)
  55: [    2.611493] [<c02d54fc>] (rpm_resume) from [<c02d56c8>] (__pm_runtime_resume+0x4c/0x64)
  56: [    2.619482] [<c02d56c8>] (__pm_runtime_resume) from [<c03eff80>] (__mmc_claim_host+0x190/0x19c)
  57: [    2.628161] [<c03eff80>] (__mmc_claim_host) from [<c03f2fd8>] (mmc_start_host+0x38/0x98)
  58: [    2.636232] [<c03f2fd8>] (mmc_start_host) from [<c03f41ac>] (mmc_add_host+0x58/0x7c)
  59: [    2.643957] [<c03f41ac>] (mmc_add_host) from [<c0407ba4>] (sdhci_add_host+0x988/0xe80)
  60: [    2.651855] [<c0407ba4>] (sdhci_add_host) from [<c0408be8>] (sdhci_s3c_probe+0x4a8/0x548)
  61: [    2.660016] [<c0408be8>] (sdhci_s3c_probe) from [<c02ce238>] (platform_drv_probe+0x50/0xac)
  62: [    2.668348] [<c02ce238>] (platform_drv_probe) from [<c02cc634>] (driver_probe_device+0x240/0x454)
  63: [    2.677200] [<c02cc634>] (driver_probe_device) from [<c02cc8d4>] (__driver_attach+0x8c/0x90)
  64: [    2.685626] [<c02cc8d4>] (__driver_attach) from [<c02ca7d4>] (bus_for_each_dev+0x60/0x94)
  65: [    2.693780] [<c02ca7d4>] (bus_for_each_dev) from [<c02cbb48>] (bus_add_driver+0x1b8/0x26c)
  66: [    2.702025] [<c02cbb48>] (bus_add_driver) from [<c02cd0cc>] (driver_register+0x78/0xf8)
  67: [    2.710012] [<c02cd0cc>] (driver_register) from [<c00097a0>] (do_one_initcall+0xbc/0x1f4)
  68: [    2.718176] [<c00097a0>] (do_one_initcall) from [<c07e3dec>] (kernel_init_freeable+0x158/0x1f8)
  69: [    2.726855] [<c07e3dec>] (kernel_init_freeable) from [<c058e6d0>] (kernel_init+0x8/0xf0)
  70: [    2.734927] [<c058e6d0>] (kernel_init) from [<c0010338>] (ret_from_fork+0x14/0x3c)
  71: [    2.742474] Code: e3510000 05991010 ebf24b35 eaffff77 (e7f001f2) 
  72: [    2.748557] ---[ end trace 6068c23e2cfdffe9 ]---
  73: [    2.753149] note: swapper/0[1] exited with preempt_count 1
  74: [    2.758738] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
  75: [    2.758738] 
  76: [    2.767732] CPU1: stopping
  77: [    2.770423] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D         4.4.0-gbd7378b-dirty #33
  78: [    2.778840] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
  79: [    2.784927] [<c0016fc0>] (unwind_backtrace) from [<c0013ab8>] (show_stack+0x10/0x14)
  80: [    2.792652] [<c0013ab8>] (show_stack) from [<c01fa9d8>] (dump_stack+0x80/0xc0)
  81: [    2.799851] [<c01fa9d8>] (dump_stack) from [<c0016030>] (handle_IPI+0x1ac/0x1c0)
  82: [    2.807227] [<c0016030>] (handle_IPI) from [<c00094d0>] (gic_handle_irq+0x90/0x94)
  83: [    2.814778] [<c00094d0>] (gic_handle_irq) from [<c0014594>] (__irq_svc+0x54/0x90)
  84: [    2.822240] Exception stack(0xef0aff88 to 0xef0affd0)
  85: [    2.827277] ff80:                   00000001 00000000 ef0affe0 c001c860 c05977c8 00000000
  86: [    2.835437] ffa0: 00000000 c084e3c0 c08524b4 c084b2e4 ef0ae000 c08524bc 00000001 ef0affd8
  87: [    2.843594] ffc0: c0010da8 c0010dac 60000013 ffffffff
  88: [    2.848631] [<c0014594>] (__irq_svc) from [<c0010dac>] (arch_cpu_idle+0x38/0x3c)
  89: [    2.856015] [<c0010dac>] (arch_cpu_idle) from [<c0059018>] (cpu_startup_entry+0x1b0/0x26c)
  90: [    2.864256] [<c0059018>] (cpu_startup_entry) from [<4000956c>] (0x4000956c)
  91: [    2.871196] CPU3: stopping
  92: [    2.873888] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G      D         4.4.0-gbd7378b-dirty #33
  93: [    2.882305] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
  94: [    2.888389] [<c0016fc0>] (unwind_backtrace) from [<c0013ab8>] (show_stack+0x10/0x14)
  95: [    2.896113] [<c0013ab8>] (show_stack) from [<c01fa9d8>] (dump_stack+0x80/0xc0)
  96: [    2.903315] [<c01fa9d8>] (dump_stack) from [<c0016030>] (handle_IPI+0x1ac/0x1c0)
  97: [    2.910692] [<c0016030>] (handle_IPI) from [<c00094d0>] (gic_handle_irq+0x90/0x94)
  98: [    2.918243] [<c00094d0>] (gic_handle_irq) from [<c0014594>] (__irq_svc+0x54/0x90)
  99: [    2.925706] Exception stack(0xef0b3f88 to 0xef0b3fd0)
 100: [    2.930743] 3f80:                   00000001 00000000 ef0b3fe0 c001c860 c05977c8 00000000
 101: [    2.938902] 3fa0: 00000000 c084e3c0 c08524b4 c084b2e4 ef0b2000 c08524bc 00000001 ef0b3fd8
 102: [    2.947060] 3fc0: c0010da8 c0010dac 60000013 ffffffff
 103: [    2.952096] [<c0014594>] (__irq_svc) from [<c0010dac>] (arch_cpu_idle+0x38/0x3c)
 104: [    2.959476] [<c0010dac>] (arch_cpu_idle) from [<c0059018>] (cpu_startup_entry+0x1b0/0x26c)
 105: [    2.967720] [<c0059018>] (cpu_startup_entry) from [<4000956c>] (0x4000956c)
 106: [    2.974661] CPU2: stopping
 107: [    2.977354] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G      D         4.4.0-gbd7378b-dirty #33
 108: [    2.985771] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
 109: [    2.991854] [<c0016fc0>] (unwind_backtrace) from [<c0013ab8>] (show_stack+0x10/0x14)
 110: [    2.999578] [<c0013ab8>] (show_stack) from [<c01fa9d8>] (dump_stack+0x80/0xc0)
 111: [    3.006781] [<c01fa9d8>] (dump_stack) from [<c0016030>] (handle_IPI+0x1ac/0x1c0)
 112: [    3.014158] [<c0016030>] (handle_IPI) from [<c00094d0>] (gic_handle_irq+0x90/0x94)
 113: [    3.021709] [<c00094d0>] (gic_handle_irq) from [<c0014594>] (__irq_svc+0x54/0x90)
 114: [    3.029171] Exception stack(0xef0b1f88 to 0xef0b1fd0)
 115: [    3.034208] 1f80:                   00000001 00000000 ef0b1fe0 c001c860 c05977c8 00000000
 116: [    3.042368] 1fa0: 00000000 c084e3c0 c08524b4 c084b2e4 ef0b0000 c08524bc 00000001 ef0b1fd8
 117: [    3.050525] 1fc0: c0010da8 c0010dac 60000013 ffffffff
 118: [    3.055562] [<c0014594>] (__irq_svc) from [<c0010dac>] (arch_cpu_idle+0x38/0x3c)
 119: [    3.062942] [<c0010dac>] (arch_cpu_idle) from [<c0059018>] (cpu_startup_entry+0x1b0/0x26c)
 120: [    3.071185] [<c0059018>] (cpu_startup_entry) from [<4000956c>] (0x4000956c)
 121: [    3.078130] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
 122: [    3.078130] 

在第4和第5行可以看到:

[    2.245838] s3c-sdhci 12530000.sdhci: No vmmc regulator found
[    2.251358] s3c-sdhci 12530000.sdhci: No vqmmc regulator found

再结合打印出的栈信息,可以确定就是vmmc或者vqmmc导致的,这两个是关于regulator的,但是从开发板的原理图上看到,sdcard这部分的供电完全在设计原理图时就固定死了,根本不需要什么regulator,但是经过分析drivers/mmc/host/sdhci-s3c.c文件中host的注册过程,还必须设置regulator信息,通过对比其他平台的设备树文件(主要是:arch/arm/boot/dts/exynos4412-origen.dts和arch/arm/boot/dts/exynos4412-trats2.dts),我对设备树文件进行了如下修改:

   1: diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   2: index 69a0d5d..b82e303 100644
   3: --- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
   4: +++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   5: @@ -75,7 +75,21 @@
   6:          compatible = "smsc,usb4640";
   7:          reset-gpios = <&gpm2 4 GPIO_ACTIVE_LOW>;
   8:          initial-mode = <USB4640_MODE_HUB>;
   9: -    };
  10: +    };
  11: +
  12: +    regulators {
  13: +        compatible = "simple-bus";
  14: +        #address-cells = <1>;
  15: +        #size-cells = <0>;
  16: +
  17: +        mmc_reg: regulator@0{
  18: +            compatible = "regulator-fixed";
  19: +            reg = <0>;
  20: +            regulator-name = "VMEM_VDD_2.8V";
  21: +            regulator-min-microvolt = <2800000>;
  22: +            regulator-max-microvolt = <2800000>;
  23: +        };
  24: +    };
  25:  };
  26:  
  27:  &rtc {
  28: @@ -86,7 +100,10 @@
  29:      bus-width = <4>;
  30:      pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
  31:      pinctrl-names = "default";
  32: -    status = "disabled";
  33: +    vmmc-supply = <&mmc_reg>;
  34: +    cd-gpios = <&gpk2 2 GPIO_ACTIVE_HIGH>;
  35: +    cd-inverted;
  36: +    status = "okay";
  37:  };
  38:  
  39:  &serial_0 {

在参考文件arch/arm/boot/dts/exynos4412-origen.dts中的mmc_reg配置中:

   1: regulators {
   2:     compatible = "simple-bus";
   3:     #address-cells = <1>;
   4:     #size-cells = <0>;
   5:  
   6:     mmc_reg: regulator@0 {
   7:         compatible = "regulator-fixed";
   8:         reg = <0>;
   9:         regulator-name = "VMEM_VDD_2.8V";
  10:         regulator-min-microvolt = <2800000>;
  11:         regulator-max-microvolt = <2800000>;
  12:         gpio = <&gpx1 1 GPIO_ACTIVE_HIGH>;
  13:         enable-active-high;
  14:     };
  15: };

    可以看到,还配置有gpio资源(应该是用于控制板子上的某个LDO芯片的开关,刚开始测试的时候发现,如果也给tiny4412配置上gpio的话,在插入sdcard会,这个gpio电平会拉高,当拔出sdcard后,这个gpio的电平会被拉低,证明了我的猜想。感觉tiny4412做的有点不好的是板子上没有PMIC,因此不利于学习电源管理,因为一般的手机或者平板产品上都是有PMIC的),但是我们的tiny4412并不需要,所以我把gpio配置删去了,这里的电压2800000不要乱动,尽管对于tiny4412没什么用,但是如果设置不当,在内核启动log中会打印错误信息。

    还要说明的一点是:

   1: cd-gpios = <&gpk2 2 GPIO_ACTIVE_HIGH>;
   2: cd-inverted;

cd-gpios用于设置sdcard插入拔出检测引脚,从原理图中也可tiny4412使用的是GPIOK2_2,如果这里单独设置了检测引脚,就可以把

pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;

改为

pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4>;

即删除对sdcard检测引脚的功能复用的设置,此时的patch如下:

   1: diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   2: index 69a0d5d..bd823eb 100644
   3: --- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
   4: +++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   5: @@ -75,7 +75,21 @@
   6:          compatible = "smsc,usb4640";
   7:          reset-gpios = <&gpm2 4 GPIO_ACTIVE_LOW>;
   8:          initial-mode = <USB4640_MODE_HUB>;
   9: -    };
  10: +    };
  11: +
  12: +    regulators {
  13: +        compatible = "simple-bus";
  14: +        #address-cells = <1>;
  15: +        #size-cells = <0>;
  16: +
  17: +        mmc_reg: regulator@0{
  18: +            compatible = "regulator-fixed";
  19: +            reg = <0>;
  20: +            regulator-name = "VMEM_VDD_2.8V";
  21: +            regulator-min-microvolt = <2800000>;
  22: +            regulator-max-microvolt = <2800000>;
  23: +        };
  24: +    };
  25:  };
  26:  
  27:  &rtc {
  28: @@ -84,9 +98,12 @@
  29:  
  30:  &sdhci_2 {
  31:      bus-width = <4>;
  32: -    pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
  33: +    pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4>;
  34:      pinctrl-names = "default";
  35: -    status = "disabled";
  36: +    vmmc-supply = <&mmc_reg>;
  37: +    cd-gpios = <&gpk2 2 GPIO_ACTIVE_HIGH>;
  38: +    cd-inverted;
  39: +    status = "okay";
  40:  };
  41:  
  42:  &serial_0 {

在测试时发现,如果不单独设置sdcard的检测引脚的话,在发生sdcard插拔动作时,Linux系统并不能识别到,不知道是不是控制器驱动的问题,这个得以后看看,此时的patch如下:

   1: diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   2: index 69a0d5d..ad8b2ba 100644
   3: --- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
   4: +++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
   5: @@ -75,7 +75,21 @@
   6:          compatible = "smsc,usb4640";
   7:          reset-gpios = <&gpm2 4 GPIO_ACTIVE_LOW>;
   8:          initial-mode = <USB4640_MODE_HUB>;
   9: -    };
  10: +    };
  11: +
  12: +    regulators {
  13: +        compatible = "simple-bus";
  14: +        #address-cells = <1>;
  15: +        #size-cells = <0>;
  16: +
  17: +        mmc_reg: regulator@0{
  18: +            compatible = "regulator-fixed";
  19: +            reg = <0>;
  20: +            regulator-name = "VMEM_VDD_2.8V";
  21: +            regulator-min-microvolt = <2800000>;
  22: +            regulator-max-microvolt = <2800000>;
  23: +        };
  24: +    };
  25:  };
  26:  
  27:  &rtc {
  28: @@ -86,7 +100,8 @@
  29:      bus-width = <4>;
  30:      pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
  31:      pinctrl-names = "default";
  32: -    status = "disabled";
  33: +    vmmc-supply = <&mmc_reg>;
  34: +    status = "okay";
  35:  };
  36:  
  37:  &serial_0 {

可以参考文件:

Documentation/devicetree/bindings/mmc/samsung-sdhci.txt

Documentation/devicetree/bindings/mmc/mmc.txt

下面是Linux启动时检测到sdcard的log:

   1: [    2.238481] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (100000000 Hz)
   2: [    2.245749] s3c-sdhci 12530000.sdhci: Got CD GPIO
   3: [    2.250721] s3c-sdhci 12530000.sdhci: No vqmmc regulator found
   4: [    2.285341] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
   5: [    2.285548] Synopsys Designware Multimedia Card Interface Driver
   6: [    2.287669] usbcore: registered new interface driver usbhid
   7: [    2.287723] usbhid: USB HID core driver
   8: [    2.290841] NET: Registered protocol family 10
   9: [    2.291451] sit: IPv6 over IPv4 tunneling driver
  10: [    2.295264] NET: Registered protocol family 17
  11: [    2.299165] NET: Registered protocol family 15
  12: [    2.303746] Registering SWP/SWPB emulation handler
  13: [    2.309720] hctosys: unable to open rtc device (rtc0)
  14: [    2.325428] ALSA device list:
  15: [    2.325464]   No soundcards found.
  16: [    2.326127] RAMDISK: gzip image found at block 0
  17: [    2.360265] usb 2-2: new high-speed USB device number 2 using exynos-ehci
  18: [    2.468324] EXT4-fs (ram0): mounted filesystem witdered data mode. Opts: (null)
  19: [    2.468418] VFS: Mounted root (ext4 filesystem) on device 1:0.
  20: [    2.468545] devtmpfs: mounted
  21: [    2.468819] Freeing unused kernel memory: 436K (c07e3000 - c0850000)
  22: [    2.490598] usb 2-2: New USB device found, idVendor=0424, idProduct=2640
  23: [    2.490671] usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
  24: [    2.491880] hub 2-2:1.0: USB hub found
  25: [    2.492094] hub 2-2:1.0: 3 ports detected
  26: [    2.519078] mmc0: new high speed SDHC card at address b368
  27: [    2.524690] mmcblk0: mmc0:b368 SMI   3.71 GiB 
  28: [    2.526964]  mmcblk0: p1

 

代码已经上传到github上了:

git clone https://github.com/pengdonglin137/linux-4.4_tiny4412.git -b port_to_tiny4412
文章来自:http://www.cnblogs.com/pengdonglin137/p/5159032.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3