platform-sdhci-esdhc-imx.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 <mach/hardware.h>
  9. #include <mach/devices-common.h>
  10. #include <mach/esdhc.h>
  11. #define imx_sdhci_esdhc_imx_data_entry_single(soc, _id, hwid) \
  12. { \
  13. .id = _id, \
  14. .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
  15. .irq = soc ## _INT_ESDHC ## hwid, \
  16. }
  17. #define imx_sdhci_esdhc_imx_data_entry(soc, id, hwid) \
  18. [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, id, hwid)
  19. #ifdef CONFIG_SOC_IMX25
  20. const struct imx_sdhci_esdhc_imx_data
  21. imx25_sdhci_esdhc_imx_data[] __initconst = {
  22. #define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  23. imx_sdhci_esdhc_imx_data_entry(MX25, _id, _hwid)
  24. imx25_sdhci_esdhc_imx_data_entry(0, 1),
  25. imx25_sdhci_esdhc_imx_data_entry(1, 2),
  26. };
  27. #endif /* ifdef CONFIG_SOC_IMX25 */
  28. #ifdef CONFIG_SOC_IMX35
  29. const struct imx_sdhci_esdhc_imx_data
  30. imx35_sdhci_esdhc_imx_data[] __initconst = {
  31. #define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  32. imx_sdhci_esdhc_imx_data_entry(MX35, _id, _hwid)
  33. imx35_sdhci_esdhc_imx_data_entry(0, 1),
  34. imx35_sdhci_esdhc_imx_data_entry(1, 2),
  35. imx35_sdhci_esdhc_imx_data_entry(2, 3),
  36. };
  37. #endif /* ifdef CONFIG_SOC_IMX35 */
  38. #ifdef CONFIG_SOC_IMX51
  39. const struct imx_sdhci_esdhc_imx_data
  40. imx51_sdhci_esdhc_imx_data[] __initconst = {
  41. #define imx51_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  42. imx_sdhci_esdhc_imx_data_entry(MX51, _id, _hwid)
  43. imx51_sdhci_esdhc_imx_data_entry(0, 1),
  44. imx51_sdhci_esdhc_imx_data_entry(1, 2),
  45. imx51_sdhci_esdhc_imx_data_entry(2, 3),
  46. imx51_sdhci_esdhc_imx_data_entry(3, 4),
  47. };
  48. #endif /* ifdef CONFIG_SOC_IMX51 */
  49. #ifdef CONFIG_SOC_IMX53
  50. const struct imx_sdhci_esdhc_imx_data
  51. imx53_sdhci_esdhc_imx_data[] __initconst = {
  52. #define imx53_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  53. imx_sdhci_esdhc_imx_data_entry(MX53, _id, _hwid)
  54. imx53_sdhci_esdhc_imx_data_entry(0, 1),
  55. imx53_sdhci_esdhc_imx_data_entry(1, 2),
  56. imx53_sdhci_esdhc_imx_data_entry(2, 3),
  57. imx53_sdhci_esdhc_imx_data_entry(3, 4),
  58. };
  59. #endif /* ifdef CONFIG_SOC_IMX53 */
  60. struct platform_device *__init imx_add_sdhci_esdhc_imx(
  61. const struct imx_sdhci_esdhc_imx_data *data,
  62. const struct esdhc_platform_data *pdata)
  63. {
  64. struct resource res[] = {
  65. {
  66. .start = data->iobase,
  67. .end = data->iobase + SZ_16K - 1,
  68. .flags = IORESOURCE_MEM,
  69. }, {
  70. .start = data->irq,
  71. .end = data->irq,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. return imx_add_platform_device("sdhci-esdhc-imx", data->id, res,
  76. ARRAY_SIZE(res), pdata, sizeof(*pdata));
  77. }