platform-spi_imx.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2009-2010 Pengutronix
  3. * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU General Public License version 2 as published by the
  7. * Free Software Foundation.
  8. */
  9. #include "../hardware.h"
  10. #include "devices-common.h"
  11. #define imx_spi_imx_data_entry_single(soc, type, _devid, _id, hwid, _size) \
  12. { \
  13. .devid = _devid, \
  14. .id = _id, \
  15. .iobase = soc ## _ ## type ## hwid ## _BASE_ADDR, \
  16. .iosize = _size, \
  17. .irq = soc ## _INT_ ## type ## hwid, \
  18. }
  19. #define imx_spi_imx_data_entry(soc, type, devid, id, hwid, size) \
  20. [id] = imx_spi_imx_data_entry_single(soc, type, devid, id, hwid, size)
  21. #ifdef CONFIG_SOC_IMX21
  22. const struct imx_spi_imx_data imx21_cspi_data[] __initconst = {
  23. #define imx21_cspi_data_entry(_id, _hwid) \
  24. imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K)
  25. imx21_cspi_data_entry(0, 1),
  26. imx21_cspi_data_entry(1, 2),
  27. };
  28. #endif
  29. #ifdef CONFIG_SOC_IMX27
  30. const struct imx_spi_imx_data imx27_cspi_data[] __initconst = {
  31. #define imx27_cspi_data_entry(_id, _hwid) \
  32. imx_spi_imx_data_entry(MX27, CSPI, "imx27-cspi", _id, _hwid, SZ_4K)
  33. imx27_cspi_data_entry(0, 1),
  34. imx27_cspi_data_entry(1, 2),
  35. imx27_cspi_data_entry(2, 3),
  36. };
  37. #endif /* ifdef CONFIG_SOC_IMX27 */
  38. #ifdef CONFIG_SOC_IMX31
  39. const struct imx_spi_imx_data imx31_cspi_data[] __initconst = {
  40. #define imx31_cspi_data_entry(_id, _hwid) \
  41. imx_spi_imx_data_entry(MX31, CSPI, "imx31-cspi", _id, _hwid, SZ_4K)
  42. imx31_cspi_data_entry(0, 1),
  43. imx31_cspi_data_entry(1, 2),
  44. imx31_cspi_data_entry(2, 3),
  45. };
  46. #endif /* ifdef CONFIG_SOC_IMX31 */
  47. #ifdef CONFIG_SOC_IMX35
  48. const struct imx_spi_imx_data imx35_cspi_data[] __initconst = {
  49. #define imx35_cspi_data_entry(_id, _hwid) \
  50. imx_spi_imx_data_entry(MX35, CSPI, "imx35-cspi", _id, _hwid, SZ_4K)
  51. imx35_cspi_data_entry(0, 1),
  52. imx35_cspi_data_entry(1, 2),
  53. };
  54. #endif /* ifdef CONFIG_SOC_IMX35 */
  55. struct platform_device *__init imx_add_spi_imx(
  56. const struct imx_spi_imx_data *data,
  57. const struct spi_imx_master *pdata)
  58. {
  59. struct resource res[] = {
  60. {
  61. .start = data->iobase,
  62. .end = data->iobase + data->iosize - 1,
  63. .flags = IORESOURCE_MEM,
  64. }, {
  65. .start = data->irq,
  66. .end = data->irq,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. return imx_add_platform_device(data->devid, data->id,
  71. res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
  72. }