platform-imx-dma.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (C) 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 <linux/compiler.h>
  10. #include <linux/err.h>
  11. #include <linux/init.h>
  12. #include <mach/hardware.h>
  13. #include <mach/devices-common.h>
  14. #include <mach/sdma.h>
  15. struct imx_imx_sdma_data {
  16. resource_size_t iobase;
  17. resource_size_t irq;
  18. struct sdma_platform_data pdata;
  19. };
  20. #define imx_imx_sdma_data_entry_single(soc, _sdma_version, _cpu_name, _to_version)\
  21. { \
  22. .iobase = soc ## _SDMA ## _BASE_ADDR, \
  23. .irq = soc ## _INT_SDMA, \
  24. .pdata = { \
  25. .sdma_version = _sdma_version, \
  26. .cpu_name = _cpu_name, \
  27. .to_version = _to_version, \
  28. }, \
  29. }
  30. #ifdef CONFIG_ARCH_MX25
  31. const struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
  32. imx_imx_sdma_data_entry_single(MX25, 1, "imx25", 0);
  33. #endif /* ifdef CONFIG_ARCH_MX25 */
  34. #ifdef CONFIG_ARCH_MX31
  35. struct imx_imx_sdma_data imx31_imx_sdma_data __initdata =
  36. imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 0);
  37. #endif /* ifdef CONFIG_ARCH_MX31 */
  38. #ifdef CONFIG_ARCH_MX35
  39. struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
  40. imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 0);
  41. #endif /* ifdef CONFIG_ARCH_MX35 */
  42. #ifdef CONFIG_ARCH_MX51
  43. const struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
  44. imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 0);
  45. #endif /* ifdef CONFIG_ARCH_MX51 */
  46. static struct platform_device __init __maybe_unused *imx_add_imx_sdma(
  47. const struct imx_imx_sdma_data *data)
  48. {
  49. struct resource res[] = {
  50. {
  51. .start = data->iobase,
  52. .end = data->iobase + SZ_4K - 1,
  53. .flags = IORESOURCE_MEM,
  54. }, {
  55. .start = data->irq,
  56. .end = data->irq,
  57. .flags = IORESOURCE_IRQ,
  58. },
  59. };
  60. return imx_add_platform_device("imx-sdma", -1,
  61. res, ARRAY_SIZE(res),
  62. &data->pdata, sizeof(data->pdata));
  63. }
  64. static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
  65. {
  66. return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
  67. }
  68. static int __init imxXX_add_imx_dma(void)
  69. {
  70. struct platform_device *ret;
  71. #if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
  72. if (cpu_is_mx21() || cpu_is_mx27())
  73. ret = imx_add_imx_dma();
  74. else
  75. #endif
  76. #if defined(CONFIG_ARCH_MX25)
  77. if (cpu_is_mx25())
  78. ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
  79. else
  80. #endif
  81. #if defined(CONFIG_ARCH_MX31)
  82. if (cpu_is_mx31()) {
  83. imx31_imx_sdma_data.pdata.to_version = mx31_revision() >> 4;
  84. ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
  85. } else
  86. #endif
  87. #if defined(CONFIG_ARCH_MX35)
  88. if (cpu_is_mx35()) {
  89. imx35_imx_sdma_data.pdata.to_version = mx35_revision() >> 4;
  90. ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
  91. } else
  92. #endif
  93. #if defined(CONFIG_ARCH_MX51)
  94. if (cpu_is_mx51())
  95. ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
  96. else
  97. #endif
  98. ret = ERR_PTR(-ENODEV);
  99. if (IS_ERR(ret))
  100. return PTR_ERR(ret);
  101. return 0;
  102. }
  103. arch_initcall(imxXX_add_imx_dma);