我其实对SD卡的操作不是很熟悉,所以移植的肯定有问题,在随机赠送的Kingston 4G的SD卡上可以进行读写,但是我换了张2G的SD卡,就不行了,原因暂时先不找了,等熟悉了SD卡的操作再看看,哪位大侠知道怎么移植的一定要告诉我,不胜感激。
1.include/configs/smdkv210.h +94
#define CONFIG_GENERIC_MMC #define CONFIG_MMC #define CONFIG_SDHCI #define CONFIG_S5P_SDHCI #define CONFIG_CMD_MMC2.在board/samsung/smdkv210/smdkc100.c添加
int board_mmc_init (bd_t *bis) { //printf ("haha\n"); #define GPG0CON (*(volatile unsigned int *)0xE02001A0) #define GPG0DRV (*(volatile unsigned int *)0xE02001AC) #define GPG3CON (*(volatile unsigned int *)0xE0200200) #define CLK_DIV4 (*(volatile unsigned int *)0xE0100310) #define CLK_SRC4 (*(volatile unsigned int *)0xE0100210) #define MOUTMMC (50000000) /* 50MHz */ unsigned long clk_src, clk_div, mpll, div; //初始化MMC0 MM3管脚,4bit模式 GPG0CON = (0x2<<0)|(0x2<<4)|(0x2<<8)|(0x2<<12)|(0x2<<16)|(0x2<<20)|(0x2<<24); GPG3CON = (0x2<<0)|(0x2<<4)|(0x2<<8)|(0x2<<12)|(0x2<<16)|(0x2<<20)|(0x2<<24); //GPG0DRV = 0x3fdf; //初始化SD时钟 clk_src = CLK_SRC4; clk_src &= ~((0xf << 12) | 0xf); clk_src |= (0x6 << 12) | 0x6; mpll = get_pll_clk(MPLL); div = ((mpll + MOUTMMC) / MOUTMMC) - 1; clk_div = CLK_DIV4; clk_div &= ~((0xf << 12) | 0xf); clk_div |= (div << 12) | div; CLK_SRC4 = clk_src; CLK_DIV4 = clk_div; return s5p_sdhci_init(0xEB000000, 0, 4)|s5p_sdhci_init(0xEB300000, 1, 4); }3.修改drivers/mmc/sdhci.c +133
/* Wait max 10 ms */ timeout = 10; #if 0 sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS); mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT; /* We shouldn't wait for data inihibit for stop commands, even though they might use busy signaling */ if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) mask &= ~SDHCI_DATA_INHIBIT; #endif /* * PRNSTS * CMDINHDAT[1] : Command Inhibit (DAT) * CMDINHCMD[0] : Command Inhibit (CMD) */ mask = (1 << 0); if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY)) mask |= (1 << 1); /* * We shouldn't wait for data inihibit for stop commands, even * though they might use busy signaling */ if (data) mask &= ~(1 << 1); //mask = 1; //printf ("mask: %08x\n read: %08x\n", mask, sdhci_readl(host, SDHCI_PRESENT_STATE)); while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) { if (timeout == 0) { printf("Controller never released inhibit bit(s).\n"); return COMM_ERR; } timeout--; udelay(1000); }4.修改drivers/mmc/mmc.c把sd_change_freq中的最后两个returne err; 给屏蔽掉
//if (err) //return err;5.make,使用命令烧入SD卡里,启动开发板