platform-sdhci-esdhc-imx.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2010 Pengutronix, Wolfram Sang <kernel@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. static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
  40. .wp_type = ESDHC_WP_NONE,
  41. .cd_type = ESDHC_CD_NONE,
  42. };
  43. struct platform_device *__init imx_add_sdhci_esdhc_imx(
  44. const struct imx_sdhci_esdhc_imx_data *data,
  45. const struct esdhc_platform_data *pdata)
  46. {
  47. struct resource res[] = {
  48. {
  49. .start = data->iobase,
  50. .end = data->iobase + SZ_16K - 1,
  51. .flags = IORESOURCE_MEM,
  52. }, {
  53. .start = data->irq,
  54. .end = data->irq,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. /*
  59. * If machine does not provide pdata, use the default one
  60. * which means no WP/CD support
  61. */
  62. if (!pdata)
  63. pdata = &default_esdhc_pdata;
  64. return imx_add_platform_device_dmamask(data->devid, data->id, res,
  65. ARRAY_SIZE(res), pdata, sizeof(*pdata),
  66. DMA_BIT_MASK(32));
  67. }