platform-sdhci-esdhc-imx.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_IMX35
  21. const struct imx_sdhci_esdhc_imx_data
  22. imx35_sdhci_esdhc_imx_data[] __initconst = {
  23. #define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
  24. imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)
  25. imx35_sdhci_esdhc_imx_data_entry(0, 1),
  26. imx35_sdhci_esdhc_imx_data_entry(1, 2),
  27. imx35_sdhci_esdhc_imx_data_entry(2, 3),
  28. };
  29. #endif /* ifdef CONFIG_SOC_IMX35 */
  30. static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
  31. .wp_type = ESDHC_WP_NONE,
  32. .cd_type = ESDHC_CD_NONE,
  33. };
  34. struct platform_device *__init imx_add_sdhci_esdhc_imx(
  35. const struct imx_sdhci_esdhc_imx_data *data,
  36. const struct esdhc_platform_data *pdata)
  37. {
  38. struct resource res[] = {
  39. {
  40. .start = data->iobase,
  41. .end = data->iobase + SZ_16K - 1,
  42. .flags = IORESOURCE_MEM,
  43. }, {
  44. .start = data->irq,
  45. .end = data->irq,
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. /*
  50. * If machine does not provide pdata, use the default one
  51. * which means no WP/CD support
  52. */
  53. if (!pdata)
  54. pdata = &default_esdhc_pdata;
  55. return imx_add_platform_device_dmamask(data->devid, data->id, res,
  56. ARRAY_SIZE(res), pdata, sizeof(*pdata),
  57. DMA_BIT_MASK(32));
  58. }