linux-3.9.7 sdhci 驱动移植 基于QT210

一、配置内核

Device Drivers--->MMC/SD/SDIO card support -->

-->Secure Digital Host Controller Interface support

-->SDHCI support on Samsung S3C SoC

linux-3.9.7 sdhci 驱动移植 基于QT210_第1张图片


二、

1、在mach-smdkv210.c中添加头文件

#include


2、添加平台数据

#ifdef CONFIG_S3C_DEV_HSMMC
static struct s3c_sdhci_platdata smdkc110_hsmmc0_pdata __initdata = {
        .cd_type                = S3C_SDHCI_CD_INTERNAL,
        
#if defined(CONFIG_S5PV210_SD_CH0_8BIT)
        .max_width              = 8,
        .host_caps              = MMC_CAP_8_BIT_DATA,
#endif
}; 
#endif
3、在函数static void __init smdkv210_machine_init(void)设置平台设备

#ifdef CONFIG_S3C_DEV_HSMMC
        s3c_sdhci0_set_platdata(&smdkc110_hsmmc0_pdata);
#endif

三、编译运行

sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdhci s3c-sdhci.0: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.0: clock source 2: mmc_busclk.2 (47785714 Hz)
mmc0: SDHCI controller on samsung-hsmmc [s3c-sdhci.0] using ADMA
s3c-sdhci s3c-sdhci.1: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.1: clock source 2: mmc_busclk.2 (47785714 Hz)
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT ARM
Modules linked in:
CPU: 0    Not tainted  (3.9.7 #37)
PC is at wake_up_process+0x4/0x40
LR is at sdhci_irq+0x390/0x78c
pc : []    lr : []    psr: 60000193
sp : df849c60  ip : 00010000  fp : c0505e33
r10: 00000000  r9 : c04ed6e4  r8 : 00000000
r7 : 00000001  r6 : 00000000  r5 : 00000100  r4 : df9d2000
r3 : 00000000  r2 : 00010000  r1 : 20000193  r0 : 00000000
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5387d  Table: 20004019  DAC: 00000015
Process swapper (pid: 1, stack limit = 0xdf848238)
Stack: (0xdf849c60 to 0xdf84a000)
9c60: df9d2000 00000100 c0505e33 c02dd420 df849ce8 df9d2370 c0505718 c0042628
9c80: 00000000 df801180 000000d0 dfa94780 c04ed6cc 00000000 00000000 0000005a
9ca0: c04ed6e4 c04ed67c c0505e33 c0067074 c095e030 df801180 60000113 c04ed67c
9cc0: c04ed6cc dfa94780 00000000 c054fec0 00000000 c03aad88 c0452efc c0067210
9ce0: c04ed67c c04ed6cc 00000000 c00691d8 c04f7924 0000005a 00000000 c0066a00
9d00: 000000d0 c0014720 c054fee8 df849d30 00000001 c0008538 c0220188 20000113
9d20: ffffffff df849d64 000008b5 c0013440 df816250 00000d80 00000000 00000000
9d40: df801480 00000001 df816000 000008b4 000008b5 00000000 c03aad88 c0452efc
9d60: 00000000 df849d7c 00000000 c0220188 20000113 ffffffff df849dc8 c00a11c0
9d80: df9d3010 00000001 c045fc68 df8197c0 00000000 c02239c4 df849dc8 dfa95040
9da0: 00000000 df849dc8 dfa94f80 00000001 00000000 c00fbf0c df849dcc 00000000
9dc0: 00000004 c00fa5b8 df935f80 df9d3008 df9d3010 c04e48c0 00000000 c0553fdc
9de0: c050041c 00000004 00000000 c0276d44 c04ed760 00000000 dfa94d50 a0000113
9e00: df9d3340 c02dd090 0000005b df9d3000 df9d3000 df9d3008 df9d33f4 df9d3408
9e20: dfa94c90 00000004 df9d34d0 c02cdea8 df9d3340 df9d3000 00000000 c02de034
9e40: dfa94c40 df9d3340 c04e48b0 df9d3340 c04e48c0 0000005b df9d34c0 c02dee04
9e60: 02d926f2 c00fbf0c 0000005b 00000000 5f636d6d 63737562 332e6b6c 00000000
9e80: c0554008 c0554000 c0554008 c04e48f4 c04e48c0 c050084c c04d2104 c04ac164
9ea0: 00000000 c0279f50 c0279f3c c0278f10 00000000 c04e48c0 c050084c c04e48f4
9ec0: 00000000 c04c2314 c04ac164 c027911c c050084c c0279090 df849ee0 c027782c
9ee0: df803878 df90be40 00000000 c050084c c04fd858 df91b100 00000000 c0278798
9f00: c042ea78 c050084c c050084c c0505f00 df848000 00000000 c04c2314 c027941c
9f20: 00000000 c04c99cc c0505f00 df848000 00000000 c04c2314 c04ac164 c00085e8
9f40: c045e43c c048cb08 00000006 00000006 c04e7670 c04c99c8 00000006 c04c99cc
9f60: 00000006 c04c99ac c0505f00 0000007c c04ac164 c04ac8f0 00000006 00000006
9f80: c04ac164 c004566c 00000000 c0389064 00000000 00000000 00000000 00000000
9fa0: 00000000 c038906c 00000000 c00138d8 00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 bebfffdb bdfe7f17
Code: e28bd000 e8bd0800 eaffffc0 e92d4830 (e5903000)
---[ end trace 0e5af1bea14335f2 ]---
Kernel panic - not syncing: Fatal exception in interrupt

根据函数调用关系

sdhci_irq--->mmc_signal_sdio_irq--->

static inline void mmc_signal_sdio_irq(struct mmc_host *host)
{
	host->ops->enable_sdio_irq(host, 0);
	host->sdio_irq_pending = true;
	wake_up_process(host->sdio_irq_thread);
}
打log发现sdio_irq_thread是个空指针

但是一直不明白为什么其他型号没有这个问题

只好注释掉这个wake_up_process

同时发现网上有人提到过这个问题

https://groups.google.com/forum/#!msg/linux.kernel/0qRjyAz70uc/AGaFj906W54J

修改如下

static inline void mmc_signal_sdio_irq(struct mmc_host *host)
{
	host->ops->enable_sdio_irq(host, 0);
	host->sdio_irq_pending = true;
    if (host->sdio_irq_thread)                 
		wake_up_process(host->sdio_irq_thread); 
}

sd卡可以识别

正常的log如下

sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdhci s3c-sdhci.0: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.0: clock source 2: mmc_busclk.2 (47785714 Hz)
mmc0: SDHCI controller on samsung-hsmmc [s3c-sdhci.0] using ADMA
s3c-sdhci s3c-sdhci.1: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.1: clock source 2: mmc_busclk.2 (47785714 Hz)
mmc0: new high speed SD card at address 1234
mmcblk0: mmc0:1234 SA02G 1.81 GiB
 mmcblk0: p1 p2 p3
mmc1: SDHCI controller on samsung-hsmmc [s3c-sdhci.1] using ADMA
s3c-sdhci s3c-sdhci.2: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.2: clock source 2: mmc_busclk.2 (80000000 Hz)
mmc2: SDHCI controller on samsung-hsmmc [s3c-sdhci.2] using ADMA
s3c-sdhci s3c-sdhci.3: clock source 0: mmc_busclk.0 (133800000 Hz)
s3c-sdhci s3c-sdhci.3: clock source 2: mmc_busclk.2 (80000000 Hz)
mmc3: SDHCI controller on samsung-hsmmc [s3c-sdhci.3] using ADMA

以后继续分析 中断产生,sdio_irq_thread却是空指针的原因。




你可能感兴趣的:(Linux-驱动移植,Linux)