基于tiny4412的Linux内核移植 -- SD卡驱动移植
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于tiny4412的Linux内核移植 -- SD卡驱动移植相关的知识,希望对你有一定的参考价值。
作者信息
作者: 彭东林
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)
基于tiny4412的Linux内核移植 -- MMA7660驱动移植(九-2)基于tiny4412的Linux内核移植 -- PWM子系统学习
基于tiny4412的Linux内核移植 -- PWM子系统学习