setup-sdhci.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* linux/arch/arm/mach-exynos4/setup-sdhci.c
  2. *
  3. * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * EXYNOS4 - 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. /* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
  21. char *exynos4_hsmmc_clksrcs[4] = {
  22. [0] = NULL,
  23. [1] = NULL,
  24. [2] = "sclk_mmc", /* mmc_bus */
  25. [3] = NULL,
  26. };
  27. void exynos4_setup_sdhci_cfg_card(struct platform_device *dev, void __iomem *r,
  28. struct mmc_ios *ios, struct mmc_card *card)
  29. {
  30. u32 ctrl2, ctrl3;
  31. /* don't need to alter anything acording to card-type */
  32. ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
  33. /* select base clock source to HCLK */
  34. ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
  35. /*
  36. * clear async mode, enable conflict mask, rx feedback ctrl, SD
  37. * clk hold and no use debounce count
  38. */
  39. ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
  40. S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
  41. S3C_SDHCI_CTRL2_ENFBCLKRX |
  42. S3C_SDHCI_CTRL2_DFCNT_NONE |
  43. S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
  44. /* Tx and Rx feedback clock delay control */
  45. if (ios->clock < 25 * 1000000)
  46. ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
  47. S3C_SDHCI_CTRL3_FCSEL2 |
  48. S3C_SDHCI_CTRL3_FCSEL1 |
  49. S3C_SDHCI_CTRL3_FCSEL0);
  50. else
  51. ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
  52. writel(ctrl2, r + S3C_SDHCI_CONTROL2);
  53. writel(ctrl3, r + S3C_SDHCI_CONTROL3);
  54. }