内核版本:linux-2.6.32.2 实验平台:mini2440
1. 添加平台设备私有数据定义
static struct s3c24xx_mci_pdata mini2440_mmc_cfg = {
.gpio_detect = S3C2410_GPG(8),
.gpio_wprotect = S3C2410_GPH(8),
.set_power = NULL,
.ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34,
};
在plat-s3c24xx/devs.h中sd卡主控制器的平台设备已经定义好了的,只需要定义一组上面的平台设备私有数据就可以了,然后需要将私有数据赋值给平台设备:s3c_device_sdi.dev.platform_data = &mini2440_mmc_cfg;
只需要将平台设备添加到mini2440_devices这个数组里面:
static struct platform_device *mini2440_devices[] __initdata = {
/* ... */
&s3c_device_sdi,
/* ... */
};
最后别忘了添加两个头文件:#include <linux/mmc/host.h>
#include <plat/mci.h>
linux-2.6.32.2中s3c2440的sd卡驱动已经很完善了,只需要稍作一点修改:
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index 99b74a3..0c3c229 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -22,6 +22,7 @@
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/delay.h>
#include <mach/dma.h>
@@ -494,6 +495,8 @@ static void pio_tasklet(unsigned long data)
s3cmci_disable_irq(host, true);
+ udelay(50);
+
if (host->pio_active == XFER_WRITE)
do_pio_write(host);
4. 内核配置
Device Drivers ---> [*] MMC/SD/SDIO card support ---> [*] MMC block device driver <*> Secure Digital Host Controller Interface support <*> Samsung S3C SD/MMC Card Interface support