pl080.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. struct pl08x_platform_data s3c64xx_dma0_plat_data = {
  113. .memcpy_channel = {
  114. .bus_id = "memcpy",
  115. .cctl_memcpy =
  116. (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
  117. PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
  118. PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
  119. PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
  120. PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
  121. PL080_CONTROL_PROT_SYS),
  122. },
  123. .lli_buses = PL08X_AHB1,
  124. .mem_buses = PL08X_AHB1,
  125. .get_xfer_signal = pl08x_get_xfer_signal,
  126. .put_xfer_signal = pl08x_put_xfer_signal,
  127. .slave_channels = s3c64xx_dma0_info,
  128. .num_slave_channels = ARRAY_SIZE(s3c64xx_dma0_info),
  129. };
  130. static AMBA_AHB_DEVICE(s3c64xx_dma0, "dma-pl080s.0", 0,
  131. 0x75000000, {IRQ_DMA0}, &s3c64xx_dma0_plat_data);
  132. /*
  133. * DMA1
  134. */
  135. static struct pl08x_channel_data s3c64xx_dma1_info[] = {
  136. {
  137. .bus_id = "pcm1_tx",
  138. .min_signal = 0,
  139. .max_signal = 0,
  140. .periph_buses = PL08X_AHB2,
  141. }, {
  142. .bus_id = "pcm1_rx",
  143. .min_signal = 1,
  144. .max_signal = 1,
  145. .periph_buses = PL08X_AHB2,
  146. }, {
  147. .bus_id = "i2s1_tx",
  148. .min_signal = 2,
  149. .max_signal = 2,
  150. .periph_buses = PL08X_AHB2,
  151. }, {
  152. .bus_id = "i2s1_rx",
  153. .min_signal = 3,
  154. .max_signal = 3,
  155. .periph_buses = PL08X_AHB2,
  156. }, {
  157. .bus_id = "spi1_tx",
  158. .min_signal = 4,
  159. .max_signal = 4,
  160. .periph_buses = PL08X_AHB2,
  161. }, {
  162. .bus_id = "spi1_rx",
  163. .min_signal = 5,
  164. .max_signal = 5,
  165. .periph_buses = PL08X_AHB2,
  166. }, {
  167. .bus_id = "ac97_out",
  168. .min_signal = 6,
  169. .max_signal = 6,
  170. .periph_buses = PL08X_AHB2,
  171. }, {
  172. .bus_id = "ac97_in",
  173. .min_signal = 7,
  174. .max_signal = 7,
  175. .periph_buses = PL08X_AHB2,
  176. }, {
  177. .bus_id = "ac97_mic",
  178. .min_signal = 8,
  179. .max_signal = 8,
  180. .periph_buses = PL08X_AHB2,
  181. }, {
  182. .bus_id = "pwm",
  183. .min_signal = 9,
  184. .max_signal = 9,
  185. .periph_buses = PL08X_AHB2,
  186. }, {
  187. .bus_id = "irda",
  188. .min_signal = 10,
  189. .max_signal = 10,
  190. .periph_buses = PL08X_AHB2,
  191. }, {
  192. .bus_id = "external",
  193. .min_signal = 11,
  194. .max_signal = 11,
  195. .periph_buses = PL08X_AHB2,
  196. },
  197. };
  198. struct pl08x_platform_data s3c64xx_dma1_plat_data = {
  199. .memcpy_channel = {
  200. .bus_id = "memcpy",
  201. .cctl_memcpy =
  202. (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
  203. PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
  204. PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
  205. PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
  206. PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
  207. PL080_CONTROL_PROT_SYS),
  208. },
  209. .lli_buses = PL08X_AHB1,
  210. .mem_buses = PL08X_AHB1,
  211. .get_xfer_signal = pl08x_get_xfer_signal,
  212. .put_xfer_signal = pl08x_put_xfer_signal,
  213. .slave_channels = s3c64xx_dma1_info,
  214. .num_slave_channels = ARRAY_SIZE(s3c64xx_dma1_info),
  215. };
  216. static AMBA_AHB_DEVICE(s3c64xx_dma1, "dma-pl080s.1", 0,
  217. 0x75100000, {IRQ_DMA1}, &s3c64xx_dma1_plat_data);
  218. static int __init s3c64xx_pl080_init(void)
  219. {
  220. if (!soc_is_s3c64xx())
  221. return 0;
  222. /* Set all DMA configuration to be DMA, not SDMA */
  223. writel(0xffffff, S3C64XX_SDMA_SEL);
  224. if (of_have_populated_dt())
  225. return 0;
  226. amba_device_register(&s3c64xx_dma0_device, &iomem_resource);
  227. amba_device_register(&s3c64xx_dma1_device, &iomem_resource);
  228. return 0;
  229. }
  230. arch_initcall(s3c64xx_pl080_init);