platform-sdhci-esdhc-imx.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2010 Pengutronix, Wolfram Sang <w.sang@pengutronix.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU General Public License version 2 as published by the
  6. * Free Software Foundation.
  7. */
  8. #include <linux/platform_data/mmc-esdhc-imx.h>
  9. #include "../hardware.h"
  10. #include "devices-common.h"
  11. #define imx_sdhci_esdhc_imx_data_entry_single(soc, _devid, _id, hwid) \
  12. { \
  13. .devid = _devid, \
  14. .id = _id, \
  15. .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
  16. .irq = soc ## _INT_ESDHC ## hwid, \
  17. }
  18. #define imx_sdhci_esdhc_imx_data_entry(soc, devid, id, hwid) \
  19. [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)
  20. #ifdef CONFIG_SOC_IMX25
  21. const struct imx_sdhci_esdhc_imx_data
  22. imx25_sdhci_esdhc_imx_data[] __initconst = {
  23. #define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  24. imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid)
  25. imx25_sdhci_esdhc_imx_data_entry(0, 1),
  26. imx25_sdhci_esdhc_imx_data_entry(1, 2),
  27. };
  28. #endif /* ifdef CONFIG_SOC_IMX25 */
  29. #ifdef CONFIG_SOC_IMX35
  30. const struct imx_sdhci_esdhc_imx_data
  31. imx35_sdhci_esdhc_imx_data[] __initconst = {
  32. #define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  33. imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)
  34. imx35_sdhci_esdhc_imx_data_entry(0, 1),
  35. imx35_sdhci_esdhc_imx_data_entry(1, 2),
  36. imx35_sdhci_esdhc_imx_data_entry(2, 3),
  37. };
  38. #endif /* ifdef CONFIG_SOC_IMX35 */
  39. #ifdef CONFIG_SOC_IMX51
  40. const struct imx_sdhci_esdhc_imx_data
  41. imx51_sdhci_esdhc_imx_data[] __initconst = {
  42. #define imx51_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  43. imx_sdhci_esdhc_imx_data_entry(MX51, "sdhci-esdhc-imx51", _id, _hwid)
  44. imx51_sdhci_esdhc_imx_data_entry(0, 1),
  45. imx51_sdhci_esdhc_imx_data_entry(1, 2),
  46. imx51_sdhci_esdhc_imx_data_entry(2, 3),
  47. imx51_sdhci_esdhc_imx_data_entry(3, 4),
  48. };
  49. #endif /* ifdef CONFIG_SOC_IMX51 */
  50. #ifdef CONFIG_SOC_IMX53
  51. const struct imx_sdhci_esdhc_imx_data
  52. imx53_sdhci_esdhc_imx_data[] __initconst = {
  53. #define imx53_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  54. imx_sdhci_esdhc_imx_data_entry(MX53, "sdhci-esdhc-imx53", _id, _hwid)
  55. imx53_sdhci_esdhc_imx_data_entry(0, 1),
  56. imx53_sdhci_esdhc_imx_data_entry(1, 2),
  57. imx53_sdhci_esdhc_imx_data_entry(2, 3),
  58. imx53_sdhci_esdhc_imx_data_entry(3, 4),
  59. };
  60. #endif /* ifdef CONFIG_SOC_IMX53 */
  61. static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
  62. .wp_type = ESDHC_WP_NONE,
  63. .cd_type = ESDHC_CD_NONE,
  64. };
  65. struct platform_device *__init imx_add_sdhci_esdhc_imx(
  66. const struct imx_sdhci_esdhc_imx_data *data,
  67. const struct esdhc_platform_data *pdata)
  68. {
  69. struct resource res[] = {
  70. {
  71. .start = data->iobase,
  72. .end = data->iobase + SZ_16K - 1,
  73. .flags = IORESOURCE_MEM,
  74. }, {
  75. .start = data->irq,
  76. .end = data->irq,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. /*
  81. * If machine does not provide pdata, use the default one
  82. * which means no WP/CD support
  83. */
  84. if (!pdata)
  85. pdata = &default_esdhc_pdata;
  86. return imx_add_platform_device(data->devid, data->id, res,
  87. ARRAY_SIZE(res), pdata, sizeof(*pdata));
  88. }