platform-imx-dma.c 3.1 KB

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