Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

Linux 下 SD 卡驅動移植實作

Linux 對 SD 卡的支持已相當完善,只要按下列步驟修改即可完成初始化。

一、註冊平台設備

在 arch/arm/mach-s3c2440/mach-smdk2440.c 的 platform 結構中加上 &s3c_device_sdi:

static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
&s3c_device_nand,
&s3c_device_sdi, // add here
};

二、設定插拔中斷

編輯 drivers/mmc/host/s3cmci.c 第 1335 行,加入:

host->irq_cd = IRQ_EINT16;
s3c2410_gpio_cfgpin(S3C2410_GPG8, S3C2410_GPG8_EINT16);

注意:中斷管腳需依實際硬體連接圖調整。

三、menuconfig 選項

在 Device Drivers 下選上 MMC/SD/SDIO card support、MMC block device driver,以及 Samsung S3CSD/MMC Card Interface support。若要支援中文,還需在 File systems 中把 FAT 的 Default codepage 由 437 改為 936,並在 Native language support 勾選 Simplified Chinese charset 與 NLS UTF-8。

四、測試掛載

直接掛載:mount -t vfat /dev/mmcblk0 /mnt;若已分區則用 mount -t vfat /dev/mmcblk0p1 /mnt,之後即可讀寫 SD 卡。

Copyright © Linux教程網 All Rights Reserved