setup-sdhci.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* linux/arch/arm/mach-s5pv210/setup-sdhci.c
  2. *
  3. * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * S5PV210 - Helper functions for settign up SDHCI device(s) (HSMMC)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/mmc/card.h>
  18. #include <linux/mmc/host.h>
  19. #include <plat/regs-sdhci.h>
  20. #include <plat/sdhci.h>
  21. /* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
  22. char *s5pv210_hsmmc_clksrcs[4] = {
  23. [0] = "hsmmc", /* HCLK */
  24. /* [1] = "hsmmc", - duplicate HCLK entry */
  25. [2] = "sclk_mmc", /* mmc_bus */
  26. /* [3] = NULL, - reserved */
  27. };
  28. void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
  29. void __iomem *r,
  30. struct mmc_ios *ios,
  31. struct mmc_card *card)
  32. {
  33. u32 ctrl2, ctrl3;
  34. /* don't need to alter anything according to card-type */
  35. writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA, r + S3C64XX_SDHCI_CONTROL4);
  36. ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
  37. ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
  38. ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
  39. S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
  40. S3C_SDHCI_CTRL2_ENFBCLKRX |
  41. S3C_SDHCI_CTRL2_DFCNT_NONE |
  42. S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
  43. if (ios->clock < 25 * 1000000)
  44. ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
  45. S3C_SDHCI_CTRL3_FCSEL2 |
  46. S3C_SDHCI_CTRL3_FCSEL1 |
  47. S3C_SDHCI_CTRL3_FCSEL0);
  48. else
  49. ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
  50. writel(ctrl2, r + S3C_SDHCI_CONTROL2);
  51. writel(ctrl3, r + S3C_SDHCI_CONTROL3);
  52. }