pl080.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * Samsung's S3C64XX generic DMA support using amba-pl08x driver.
  3. *
  4. * Copyright (c) 2013 Tomasz Figa <tomasz.figa@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/amba/bus.h>
  12. #include <linux/amba/pl080.h>
  13. #include <linux/amba/pl08x.h>
  14. #include <linux/of.h>
  15. #include <plat/cpu.h>
  16. #include <mach/irqs.h>
  17. #include <mach/map.h>
  18. #include "regs-sys.h"
  19. static int pl08x_get_xfer_signal(const struct pl08x_channel_data *cd)
  20. {
  21. return cd->min_signal;
  22. }
  23. static void pl08x_put_xfer_signal(const struct pl08x_channel_data *cd, int ch)
  24. {
  25. }
  26. /*
  27. * DMA0
  28. */
  29. static struct pl08x_channel_data s3c64xx_dma0_info[] = {
  30. {
  31. .bus_id = "uart0_tx",
  32. .min_signal = 0,
  33. .max_signal = 0,
  34. .periph_buses = PL08X_AHB2,
  35. }, {
  36. .bus_id = "uart0_rx",
  37. .min_signal = 1,
  38. .max_signal = 1,
  39. .periph_buses = PL08X_AHB2,
  40. }, {
  41. .bus_id = "uart1_tx",
  42. .min_signal = 2,
  43. .max_signal = 2,
  44. .periph_buses = PL08X_AHB2,
  45. }, {
  46. .bus_id = "uart1_rx",
  47. .min_signal = 3,
  48. .max_signal = 3,
  49. .periph_buses = PL08X_AHB2,
  50. }, {
  51. .bus_id = "uart2_tx",
  52. .min_signal = 4,
  53. .max_signal = 4,
  54. .periph_buses = PL08X_AHB2,
  55. }, {
  56. .bus_id = "uart2_rx",
  57. .min_signal = 5,
  58. .max_signal = 5,
  59. .periph_buses = PL08X_AHB2,
  60. }, {
  61. .bus_id = "uart3_tx",
  62. .min_signal = 6,
  63. .max_signal = 6,
  64. .periph_buses = PL08X_AHB2,
  65. }, {
  66. .bus_id = "uart3_rx",
  67. .min_signal = 7,
  68. .max_signal = 7,
  69. .periph_buses = PL08X_AHB2,
  70. }, {
  71. .bus_id = "pcm0_tx",
  72. .min_signal = 8,
  73. .max_signal = 8,
  74. .periph_buses = PL08X_AHB2,
  75. }, {
  76. .bus_id = "pcm0_rx",
  77. .min_signal = 9,
  78. .max_signal = 9,
  79. .periph_buses = PL08X_AHB2,
  80. }, {
  81. .bus_id = "i2s0_tx",
  82. .min_signal = 10,
  83. .max_signal = 10,
  84. .periph_buses = PL08X_AHB2,
  85. }, {
  86. .bus_id = "i2s0_rx",
  87. .min_signal = 11,
  88. .max_signal = 11,
  89. .periph_buses = PL08X_AHB2,
  90. }, {
  91. .bus_id = "spi0_tx",
  92. .min_signal = 12,
  93. .max_signal = 12,
  94. .periph_buses = PL08X_AHB2,
  95. }, {
  96. .bus_id = "spi0_rx",
  97. .min_signal = 13,
  98. .max_signal = 13,
  99. .periph_buses = PL08X_AHB2,
  100. }, {
  101. .bus_id = "i2s2_tx",
  102. .min_signal = 14,
  103. .max_signal = 14,
  104. .periph_buses = PL08X_AHB2,
  105. }, {
  106. .bus_id = "i2s2_rx",
  107. .min_signal = 15,
  108. .max_signal = 15,
  109. .periph_buses = PL08X_AHB2,
  110. }
  111. };
  112. static const struct dma_slave_map s3c64xx_dma0_slave_map[] = {
  113. { "s3c6400-uart.0", "tx", &s3c64xx_dma0_info[0] },
  114. { "s3c6400-uart.0", "rx", &s3c64xx_dma0_info[1] },
  115. { "s3c6400-uart.1", "tx", &s3c64xx_dma0_info[2] },
  116. { "s3c6400-uart.1", "rx", &s3c64xx_dma0_info[3] },
  117. { "s3c6400-uart.2", "tx", &s3c64xx_dma0_info[4] },
  118. { "s3c6400-uart.2", "rx", &s3c64xx_dma0_info[5] },
  119. { "s3c6400-uart.3", "tx", &s3c64xx_dma0_info[6] },
  120. { "s3c6400-uart.3", "rx", &s3c64xx_dma0_info[7] },
  121. { "samsung-pcm.0", "tx", &s3c64xx_dma0_info[8] },
  122. { "samsung-pcm.0", "rx", &s3c64xx_dma0_info[9] },
  123. { "samsung-i2s.0", "tx", &s3c64xx_dma0_info[10] },
  124. { "samsung-i2s.0", "rx", &s3c64xx_dma0_info[11] },
  125. { "s3c6410-spi.0", "tx", &s3c64xx_dma0_info[12] },
  126. { "s3c6410-spi.0", "rx", &s3c64xx_dma0_info[13] },
  127. { "samsung-i2s.2", "tx", &s3c64xx_dma0_info[14] },
  128. { "samsung-i2s.2", "rx", &s3c64xx_dma0_info[15] },
  129. };
  130. struct pl08x_platform_data s3c64xx_dma0_plat_data = {
  131. .memcpy_channel = {
  132. .bus_id = "memcpy",
  133. .cctl_memcpy =
  134. (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
  135. PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
  136. PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
  137. PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
  138. PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
  139. PL080_CONTROL_PROT_SYS),
  140. },
  141. .lli_buses = PL08X_AHB1,
  142. .mem_buses = PL08X_AHB1,
  143. .get_xfer_signal = pl08x_get_xfer_signal,
  144. .put_xfer_signal = pl08x_put_xfer_signal,
  145. .slave_channels = s3c64xx_dma0_info,
  146. .num_slave_channels = ARRAY_SIZE(s3c64xx_dma0_info),
  147. .slave_map = s3c64xx_dma0_slave_map,
  148. .slave_map_len = ARRAY_SIZE(s3c64xx_dma0_slave_map),
  149. };
  150. static AMBA_AHB_DEVICE(s3c64xx_dma0, "dma-pl080s.0", 0,
  151. 0x75000000, {IRQ_DMA0}, &s3c64xx_dma0_plat_data);
  152. /*
  153. * DMA1
  154. */
  155. static struct pl08x_channel_data s3c64xx_dma1_info[] = {
  156. {
  157. .bus_id = "pcm1_tx",
  158. .min_signal = 0,
  159. .max_signal = 0,
  160. .periph_buses = PL08X_AHB2,
  161. }, {
  162. .bus_id = "pcm1_rx",
  163. .min_signal = 1,
  164. .max_signal = 1,
  165. .periph_buses = PL08X_AHB2,
  166. }, {
  167. .bus_id = "i2s1_tx",
  168. .min_signal = 2,
  169. .max_signal = 2,
  170. .periph_buses = PL08X_AHB2,
  171. }, {
  172. .bus_id = "i2s1_rx",
  173. .min_signal = 3,
  174. .max_signal = 3,
  175. .periph_buses = PL08X_AHB2,
  176. }, {
  177. .bus_id = "spi1_tx",
  178. .min_signal = 4,
  179. .max_signal = 4,
  180. .periph_buses = PL08X_AHB2,
  181. }, {
  182. .bus_id = "spi1_rx",
  183. .min_signal = 5,
  184. .max_signal = 5,
  185. .periph_buses = PL08X_AHB2,
  186. }, {
  187. .bus_id = "ac97_out",
  188. .min_signal = 6,
  189. .max_signal = 6,
  190. .periph_buses = PL08X_AHB2,
  191. }, {
  192. .bus_id = "ac97_in",
  193. .min_signal = 7,
  194. .max_signal = 7,
  195. .periph_buses = PL08X_AHB2,
  196. }, {
  197. .bus_id = "ac97_mic",
  198. .min_signal = 8,
  199. .max_signal = 8,
  200. .periph_buses = PL08X_AHB2,
  201. }, {
  202. .bus_id = "pwm",
  203. .min_signal = 9,
  204. .max_signal = 9,
  205. .periph_buses = PL08X_AHB2,
  206. }, {
  207. .bus_id = "irda",
  208. .min_signal = 10,
  209. .max_signal = 10,
  210. .periph_buses = PL08X_AHB2,
  211. }, {
  212. .bus_id = "external",
  213. .min_signal = 11,
  214. .max_signal = 11,
  215. .periph_buses = PL08X_AHB2,
  216. },
  217. };
  218. static const struct dma_slave_map s3c64xx_dma1_slave_map[] = {
  219. { "samsung-pcm.1", "tx", &s3c64xx_dma1_info[0] },
  220. { "samsung-pcm.1", "rx", &s3c64xx_dma1_info[1] },
  221. { "samsung-i2s.1", "tx", &s3c64xx_dma1_info[2] },
  222. { "samsung-i2s.1", "rx", &s3c64xx_dma1_info[3] },
  223. { "s3c6410-spi.1", "tx", &s3c64xx_dma1_info[4] },
  224. { "s3c6410-spi.1", "rx", &s3c64xx_dma1_info[5] },
  225. };
  226. struct pl08x_platform_data s3c64xx_dma1_plat_data = {
  227. .memcpy_channel = {
  228. .bus_id = "memcpy",
  229. .cctl_memcpy =
  230. (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
  231. PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
  232. PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
  233. PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
  234. PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
  235. PL080_CONTROL_PROT_SYS),
  236. },
  237. .lli_buses = PL08X_AHB1,
  238. .mem_buses = PL08X_AHB1,
  239. .get_xfer_signal = pl08x_get_xfer_signal,
  240. .put_xfer_signal = pl08x_put_xfer_signal,
  241. .slave_channels = s3c64xx_dma1_info,
  242. .num_slave_channels = ARRAY_SIZE(s3c64xx_dma1_info),
  243. .slave_map = s3c64xx_dma1_slave_map,
  244. .slave_map_len = ARRAY_SIZE(s3c64xx_dma1_slave_map),
  245. };
  246. static AMBA_AHB_DEVICE(s3c64xx_dma1, "dma-pl080s.1", 0,
  247. 0x75100000, {IRQ_DMA1}, &s3c64xx_dma1_plat_data);
  248. static int __init s3c64xx_pl080_init(void)
  249. {
  250. if (!soc_is_s3c64xx())
  251. return 0;
  252. /* Set all DMA configuration to be DMA, not SDMA */
  253. writel(0xffffff, S3C64XX_SDMA_SEL);
  254. if (of_have_populated_dt())
  255. return 0;
  256. amba_device_register(&s3c64xx_dma0_device, &iomem_resource);
  257. amba_device_register(&s3c64xx_dma1_device, &iomem_resource);
  258. return 0;
  259. }
  260. arch_initcall(s3c64xx_pl080_init);