Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98156
  • 博文数量: 38
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 384
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-06 16:52
文章分类

全部博文(38)

文章存档

2014年(38)

我的朋友

分类: 嵌入式

2014-04-06 17:24:09

1. 在driver/mmc/目录下新建s3c6410-sdhci.c,内容如下

点击(此处)折叠或打开

  1. /*
  2.  * Samsung S3C6410 SD/MMC driver
  3.  * Based on sdhci.c
  4.  * Author: LiQiang E-mail: jxustlq@163.com
  5.  * Licensed under the GPL-2 or later.
  6.  */
  7.  
  8. #include <common.h>
  9. #include <malloc.h>
  10. #include <sdhci.h>
  11. #include <asm/arch/s3c6410.h>

  12. #ifdef CONFIG_MMC_CHANNEL
  13. #define MMC_CHANNEL CONFIG_MMC_CHANNEL
  14. #else
  15. #define    MMC_CHANNEL 0
  16. #endif

  17. #define ELFIN_HSMMC_BASE    0x7C200000
  18. #define MMC_REGS_BASE        (ELFIN_HSMMC_BASE + 0x100000*MMC_CHANNEL)


  19. static void sdhc_set_gpio()
  20. {
  21.     u32 reg;
  22. #if (MMC_CHANNEL == 0)
  23.     reg = readl(GPGCON) & 0xf0000000;
  24.     writel(reg | 0x02222222, GPGCON);

  25.     reg = readl(GPGPUD) & 0xfffff000;
  26.     writel(reg, GPGPUD);
  27. #elif (MMC_CHANNEL == 1)
  28.     writel(0x00222222, GPHCON0);
  29.     writel(0x00000000, GPHCON1);

  30.     reg = readl(GPHPUD) & 0xfffff000;
  31.     writel(reg, GPHPUD);
  32. #else
  33.     printf("#####err: SDMMC channel is not defined!\n");
  34. #endif
  35. }

  36. int s3c_sdhci_init(u32 regbase, u32 max_clk, u32 min_clk, u32 quirks)
  37. {
  38.     struct sdhci_host *host = NULL;
  39.     host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
  40.     if (!host) {
  41.         printf("#####err: sdhci_host malloc fails!\n");
  42.         return 1;
  43.     }
  44.     sdhc_set_gpio();
  45.     host->name = "Samsung Host Controller";
  46.     host->ioaddr = (void *)regbase;
  47.     host->quirks = quirks;


  48.     host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
  49.     if (quirks & SDHCI_QUIRK_REG32_RW)
  50.         host->version = sdhci_readl(host, SDHCI_HOST_VERSION - 2) >> 16;
  51.     else
  52.         host->version = sdhci_readw(host, SDHCI_HOST_VERSION);

  53.     host->host_caps = MMC_MODE_HC;

  54.     add_sdhci(host, max_clk, min_clk);
  55.     return 0;
  56. }



  57. int board_mmc_init(bd_t *bis)
  58. {
  59.     return s3c_sdhci_init(MMC_REGS_BASE, 52000000, 400000, 0);
  60. }

2. 修改driver/mmc/Makefile,添加COBJS-$(CONFIG_S3C6410_SDHCI) += s3c6410_sdhci.o


3.修改driver/mmc/sdhci.c,注释掉167行的mask |= SDHCI_INT_DATA_END;

    在491行sdhci_reset(host, SDHCI_RESET_ALL);之前添加mmc->b_max = 1024;


4.修改include/configs/smdk6410.h,添加

点击(此处)折叠或打开

  1. /*support for mmc*/
  2. #define CONFIG_MMC
  3. #define CONFIG_GENERIC_MMC
  4. #define CONFIG_CMD_MMC
  5. #define CONFIG_SDHCI
  6. #define CONFIG_MMC_SDMA
  7. #define CONFIG_S3C6410_SDHCI

5.重新make all,重新烧录到SD卡,在dnw中输入mmcinfo,显示结果如下





阅读(2265) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~