mv_sdhci.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <common.h>
  2. #include <malloc.h>
  3. #include <sdhci.h>
  4. #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
  5. static struct sdhci_ops mv_ops;
  6. #if defined(CONFIG_SHEEVA_88SV331xV5)
  7. #define SD_CE_ATA_2 0xEA
  8. #define MMC_CARD 0x1000
  9. #define MMC_WIDTH 0x0100
  10. static inline void mv_sdhci_writeb(struct sdhci_host *host, u8 val, int reg)
  11. {
  12. struct mmc *mmc = host->mmc;
  13. u32 ata = (u32)host->ioaddr + SD_CE_ATA_2;
  14. if (!IS_SD(mmc) && reg == SDHCI_HOST_CONTROL) {
  15. if (mmc->bus_width == 8)
  16. writew(readw(ata) | (MMC_CARD | MMC_WIDTH), ata);
  17. else
  18. writew(readw(ata) & ~(MMC_CARD | MMC_WIDTH), ata);
  19. }
  20. writeb(val, host->ioaddr + reg);
  21. }
  22. #else
  23. #define mv_sdhci_writeb NULL
  24. #endif /* CONFIG_SHEEVA_88SV331xV5 */
  25. #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
  26. static char *MVSDH_NAME = "mv_sdh";
  27. int mv_sdh_init(u32 regbase, u32 max_clk, u32 min_clk, u32 quirks)
  28. {
  29. struct sdhci_host *host = NULL;
  30. host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
  31. if (!host) {
  32. printf("sdh_host malloc fail!\n");
  33. return 1;
  34. }
  35. host->name = MVSDH_NAME;
  36. host->ioaddr = (void *)regbase;
  37. host->quirks = quirks;
  38. #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
  39. memset(&mv_ops, 0, sizeof(struct sdhci_ops));
  40. mv_ops.write_b = mv_sdhci_writeb;
  41. host->ops = &mv_ops;
  42. #endif
  43. if (quirks & SDHCI_QUIRK_REG32_RW)
  44. host->version = sdhci_readl(host, SDHCI_HOST_VERSION - 2) >> 16;
  45. else
  46. host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
  47. add_sdhci(host, max_clk, min_clk);
  48. return 0;
  49. }