platform-mxs-mmc.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2010 Pengutronix
  3. * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
  4. *
  5. * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License version 2 as published by the
  9. * Free Software Foundation.
  10. */
  11. #include <linux/compiler.h>
  12. #include <linux/err.h>
  13. #include <linux/init.h>
  14. #include <mach/mx23.h>
  15. #include <mach/mx28.h>
  16. #include <mach/devices-common.h>
  17. #define mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid) \
  18. { \
  19. .devid = _devid, \
  20. .id = _id, \
  21. .iobase = soc ## _SSP ## hwid ## _BASE_ADDR, \
  22. .dma = soc ## _DMA_SSP ## hwid, \
  23. .irq_err = soc ## _INT_SSP ## hwid ## _ERROR, \
  24. .irq_dma = soc ## _INT_SSP ## hwid ## _DMA, \
  25. }
  26. #define mxs_mxs_mmc_data_entry(soc, _devid, _id, hwid) \
  27. [_id] = mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)
  28. #ifdef CONFIG_SOC_IMX23
  29. const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
  30. mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 0, 1),
  31. mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 1, 2),
  32. };
  33. #endif
  34. #ifdef CONFIG_SOC_IMX28
  35. const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
  36. mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 0, 0),
  37. mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 1, 1),
  38. mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 2, 2),
  39. mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 3, 3),
  40. };
  41. #endif
  42. struct platform_device *__init mxs_add_mxs_mmc(
  43. const struct mxs_mxs_mmc_data *data,
  44. const struct mxs_mmc_platform_data *pdata)
  45. {
  46. struct resource res[] = {
  47. {
  48. .start = data->iobase,
  49. .end = data->iobase + SZ_8K - 1,
  50. .flags = IORESOURCE_MEM,
  51. }, {
  52. .start = data->dma,
  53. .end = data->dma,
  54. .flags = IORESOURCE_DMA,
  55. }, {
  56. .start = data->irq_err,
  57. .end = data->irq_err,
  58. .flags = IORESOURCE_IRQ,
  59. }, {
  60. .start = data->irq_dma,
  61. .end = data->irq_dma,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. };
  65. return mxs_add_platform_device(data->devid, data->id,
  66. res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
  67. }