platform-imx-dma.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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_SOC_IMX25
  31. struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
  32. imx_imx_sdma_data_entry_single(MX25, 2, "imx25", 1);
  33. #endif /* ifdef CONFIG_SOC_IMX25 */
  34. #ifdef CONFIG_SOC_IMX31
  35. struct imx_imx_sdma_data imx31_imx_sdma_data __initdata =
  36. imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 1);
  37. #endif /* ifdef CONFIG_SOC_IMX31 */
  38. #ifdef CONFIG_SOC_IMX35
  39. struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
  40. imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 1);
  41. #endif /* ifdef CONFIG_SOC_IMX35 */
  42. #ifdef CONFIG_SOC_IMX51
  43. struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
  44. imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 1);
  45. #endif /* ifdef CONFIG_SOC_IMX51 */
  46. #ifdef CONFIG_SOC_IMX53
  47. struct imx_imx_sdma_data imx53_imx_sdma_data __initconst =
  48. imx_imx_sdma_data_entry_single(MX53, 2, "imx53", 0);
  49. #endif /* ifdef CONFIG_SOC_IMX53 */
  50. static struct platform_device __init __maybe_unused *imx_add_imx_sdma(
  51. const struct imx_imx_sdma_data *data)
  52. {
  53. struct resource res[] = {
  54. {
  55. .start = data->iobase,
  56. .end = data->iobase + SZ_16K - 1,
  57. .flags = IORESOURCE_MEM,
  58. }, {
  59. .start = data->irq,
  60. .end = data->irq,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. return imx_add_platform_device("imx-sdma", -1,
  65. res, ARRAY_SIZE(res),
  66. &data->pdata, sizeof(data->pdata));
  67. }
  68. static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
  69. {
  70. return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
  71. }
  72. #ifdef CONFIG_ARCH_MX25
  73. static struct sdma_script_start_addrs addr_imx25 = {
  74. .ap_2_ap_addr = 729,
  75. .uart_2_mcu_addr = 904,
  76. .per_2_app_addr = 1255,
  77. .mcu_2_app_addr = 834,
  78. .uartsh_2_mcu_addr = 1120,
  79. .per_2_shp_addr = 1329,
  80. .mcu_2_shp_addr = 1048,
  81. .ata_2_mcu_addr = 1560,
  82. .mcu_2_ata_addr = 1479,
  83. .app_2_per_addr = 1189,
  84. .app_2_mcu_addr = 770,
  85. .shp_2_per_addr = 1407,
  86. .shp_2_mcu_addr = 979,
  87. };
  88. #endif
  89. #ifdef CONFIG_SOC_IMX31
  90. static struct sdma_script_start_addrs addr_imx31_to1 = {
  91. .per_2_per_addr = 1677,
  92. };
  93. static struct sdma_script_start_addrs addr_imx31_to2 = {
  94. .ap_2_ap_addr = 423,
  95. .ap_2_bp_addr = 829,
  96. .bp_2_ap_addr = 1029,
  97. };
  98. #endif
  99. #ifdef CONFIG_SOC_IMX35
  100. static struct sdma_script_start_addrs addr_imx35_to1 = {
  101. .ap_2_ap_addr = 642,
  102. .uart_2_mcu_addr = 817,
  103. .mcu_2_app_addr = 747,
  104. .uartsh_2_mcu_addr = 1183,
  105. .per_2_shp_addr = 1033,
  106. .mcu_2_shp_addr = 961,
  107. .ata_2_mcu_addr = 1333,
  108. .mcu_2_ata_addr = 1252,
  109. .app_2_mcu_addr = 683,
  110. .shp_2_per_addr = 1111,
  111. .shp_2_mcu_addr = 892,
  112. };
  113. static struct sdma_script_start_addrs addr_imx35_to2 = {
  114. .ap_2_ap_addr = 729,
  115. .uart_2_mcu_addr = 904,
  116. .per_2_app_addr = 1597,
  117. .mcu_2_app_addr = 834,
  118. .uartsh_2_mcu_addr = 1270,
  119. .per_2_shp_addr = 1120,
  120. .mcu_2_shp_addr = 1048,
  121. .ata_2_mcu_addr = 1429,
  122. .mcu_2_ata_addr = 1339,
  123. .app_2_per_addr = 1531,
  124. .app_2_mcu_addr = 770,
  125. .shp_2_per_addr = 1198,
  126. .shp_2_mcu_addr = 979,
  127. };
  128. #endif
  129. #ifdef CONFIG_SOC_IMX51
  130. static struct sdma_script_start_addrs addr_imx51 = {
  131. .ap_2_ap_addr = 642,
  132. .uart_2_mcu_addr = 817,
  133. .mcu_2_app_addr = 747,
  134. .mcu_2_shp_addr = 961,
  135. .ata_2_mcu_addr = 1473,
  136. .mcu_2_ata_addr = 1392,
  137. .app_2_per_addr = 1033,
  138. .app_2_mcu_addr = 683,
  139. .shp_2_per_addr = 1251,
  140. .shp_2_mcu_addr = 892,
  141. };
  142. #endif
  143. #ifdef CONFIG_SOC_IMX53
  144. static struct sdma_script_start_addrs addr_imx53 = {
  145. .ap_2_ap_addr = 642,
  146. .app_2_mcu_addr = 683,
  147. .mcu_2_app_addr = 747,
  148. .uart_2_mcu_addr = 817,
  149. .shp_2_mcu_addr = 891,
  150. .mcu_2_shp_addr = 960,
  151. .uartsh_2_mcu_addr = 1032,
  152. .spdif_2_mcu_addr = 1100,
  153. .mcu_2_spdif_addr = 1134,
  154. .firi_2_mcu_addr = 1193,
  155. .mcu_2_firi_addr = 1290,
  156. };
  157. #endif
  158. static int __init imxXX_add_imx_dma(void)
  159. {
  160. struct platform_device *ret;
  161. #if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
  162. if (cpu_is_mx21() || cpu_is_mx27())
  163. ret = imx_add_imx_dma();
  164. else
  165. #endif
  166. #if defined(CONFIG_SOC_IMX25)
  167. if (cpu_is_mx25()) {
  168. imx25_imx_sdma_data.pdata.script_addrs = &addr_imx25;
  169. ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
  170. } else
  171. #endif
  172. #if defined(CONFIG_SOC_IMX31)
  173. if (cpu_is_mx31()) {
  174. int to_version = mx31_revision() >> 4;
  175. imx31_imx_sdma_data.pdata.to_version = to_version;
  176. if (to_version == 1)
  177. imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to1;
  178. else
  179. imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to2;
  180. ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
  181. } else
  182. #endif
  183. #if defined(CONFIG_SOC_IMX35)
  184. if (cpu_is_mx35()) {
  185. int to_version = mx35_revision() >> 4;
  186. imx35_imx_sdma_data.pdata.to_version = to_version;
  187. if (to_version == 1)
  188. imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to1;
  189. else
  190. imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to2;
  191. ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
  192. } else
  193. #endif
  194. #if defined(CONFIG_SOC_IMX51)
  195. if (cpu_is_mx51()) {
  196. int to_version = mx51_revision() >> 4;
  197. imx51_imx_sdma_data.pdata.to_version = to_version;
  198. imx51_imx_sdma_data.pdata.script_addrs = &addr_imx51;
  199. ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
  200. } else
  201. #endif
  202. #if defined(CONFIG_SOC_IMX53)
  203. if (cpu_is_mx53()) {
  204. imx53_imx_sdma_data.pdata.script_addrs = &addr_imx53;
  205. ret = imx_add_imx_sdma(&imx53_imx_sdma_data);
  206. } else
  207. #endif
  208. ret = ERR_PTR(-ENODEV);
  209. if (IS_ERR(ret))
  210. return PTR_ERR(ret);
  211. return 0;
  212. }
  213. arch_initcall(imxXX_add_imx_dma);