dma.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /* linux/arch/arm/mach-s5p64x0/dma.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Copyright (C) 2010 Samsung Electronics Co. Ltd.
  7. * Jaswinder Singh <jassi.brar@samsung.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include <linux/dma-mapping.h>
  24. #include <linux/amba/bus.h>
  25. #include <linux/amba/pl330.h>
  26. #include <asm/irq.h>
  27. #include <mach/map.h>
  28. #include <mach/irqs.h>
  29. #include <mach/regs-clock.h>
  30. #include <mach/dma.h>
  31. #include <plat/devs.h>
  32. #include <plat/irqs.h>
  33. static u64 dma_dmamask = DMA_BIT_MASK(32);
  34. struct dma_pl330_peri s5p6440_pdma_peri[22] = {
  35. {
  36. .peri_id = (u8)DMACH_UART0_RX,
  37. .rqtype = DEVTOMEM,
  38. }, {
  39. .peri_id = (u8)DMACH_UART0_TX,
  40. .rqtype = MEMTODEV,
  41. }, {
  42. .peri_id = (u8)DMACH_UART1_RX,
  43. .rqtype = DEVTOMEM,
  44. }, {
  45. .peri_id = (u8)DMACH_UART1_TX,
  46. .rqtype = MEMTODEV,
  47. }, {
  48. .peri_id = (u8)DMACH_UART2_RX,
  49. .rqtype = DEVTOMEM,
  50. }, {
  51. .peri_id = (u8)DMACH_UART2_TX,
  52. .rqtype = MEMTODEV,
  53. }, {
  54. .peri_id = (u8)DMACH_UART3_RX,
  55. .rqtype = DEVTOMEM,
  56. }, {
  57. .peri_id = (u8)DMACH_UART3_TX,
  58. .rqtype = MEMTODEV,
  59. }, {
  60. .peri_id = DMACH_MAX,
  61. }, {
  62. .peri_id = DMACH_MAX,
  63. }, {
  64. .peri_id = (u8)DMACH_PCM0_TX,
  65. .rqtype = MEMTODEV,
  66. }, {
  67. .peri_id = (u8)DMACH_PCM0_RX,
  68. .rqtype = DEVTOMEM,
  69. }, {
  70. .peri_id = (u8)DMACH_I2S0_TX,
  71. .rqtype = MEMTODEV,
  72. }, {
  73. .peri_id = (u8)DMACH_I2S0_RX,
  74. .rqtype = DEVTOMEM,
  75. }, {
  76. .peri_id = (u8)DMACH_SPI0_TX,
  77. .rqtype = MEMTODEV,
  78. }, {
  79. .peri_id = (u8)DMACH_SPI0_RX,
  80. .rqtype = DEVTOMEM,
  81. }, {
  82. .peri_id = (u8)DMACH_MAX,
  83. }, {
  84. .peri_id = (u8)DMACH_MAX,
  85. }, {
  86. .peri_id = (u8)DMACH_MAX,
  87. }, {
  88. .peri_id = (u8)DMACH_MAX,
  89. }, {
  90. .peri_id = (u8)DMACH_SPI1_TX,
  91. .rqtype = MEMTODEV,
  92. }, {
  93. .peri_id = (u8)DMACH_SPI1_RX,
  94. .rqtype = DEVTOMEM,
  95. },
  96. };
  97. struct dma_pl330_platdata s5p6440_pdma_pdata = {
  98. .nr_valid_peri = ARRAY_SIZE(s5p6440_pdma_peri),
  99. .peri = s5p6440_pdma_peri,
  100. };
  101. struct dma_pl330_peri s5p6450_pdma_peri[32] = {
  102. {
  103. .peri_id = (u8)DMACH_UART0_RX,
  104. .rqtype = DEVTOMEM,
  105. }, {
  106. .peri_id = (u8)DMACH_UART0_TX,
  107. .rqtype = MEMTODEV,
  108. }, {
  109. .peri_id = (u8)DMACH_UART1_RX,
  110. .rqtype = DEVTOMEM,
  111. }, {
  112. .peri_id = (u8)DMACH_UART1_TX,
  113. .rqtype = MEMTODEV,
  114. }, {
  115. .peri_id = (u8)DMACH_UART2_RX,
  116. .rqtype = DEVTOMEM,
  117. }, {
  118. .peri_id = (u8)DMACH_UART2_TX,
  119. .rqtype = MEMTODEV,
  120. }, {
  121. .peri_id = (u8)DMACH_UART3_RX,
  122. .rqtype = DEVTOMEM,
  123. }, {
  124. .peri_id = (u8)DMACH_UART3_TX,
  125. .rqtype = MEMTODEV,
  126. }, {
  127. .peri_id = (u8)DMACH_UART4_RX,
  128. .rqtype = DEVTOMEM,
  129. }, {
  130. .peri_id = (u8)DMACH_UART4_TX,
  131. .rqtype = MEMTODEV,
  132. }, {
  133. .peri_id = (u8)DMACH_PCM0_TX,
  134. .rqtype = MEMTODEV,
  135. }, {
  136. .peri_id = (u8)DMACH_PCM0_RX,
  137. .rqtype = DEVTOMEM,
  138. }, {
  139. .peri_id = (u8)DMACH_I2S0_TX,
  140. .rqtype = MEMTODEV,
  141. }, {
  142. .peri_id = (u8)DMACH_I2S0_RX,
  143. .rqtype = DEVTOMEM,
  144. }, {
  145. .peri_id = (u8)DMACH_SPI0_TX,
  146. .rqtype = MEMTODEV,
  147. }, {
  148. .peri_id = (u8)DMACH_SPI0_RX,
  149. .rqtype = DEVTOMEM,
  150. }, {
  151. .peri_id = (u8)DMACH_PCM1_TX,
  152. .rqtype = MEMTODEV,
  153. }, {
  154. .peri_id = (u8)DMACH_PCM1_RX,
  155. .rqtype = DEVTOMEM,
  156. }, {
  157. .peri_id = (u8)DMACH_PCM2_TX,
  158. .rqtype = MEMTODEV,
  159. }, {
  160. .peri_id = (u8)DMACH_PCM2_RX,
  161. .rqtype = DEVTOMEM,
  162. }, {
  163. .peri_id = (u8)DMACH_SPI1_TX,
  164. .rqtype = MEMTODEV,
  165. }, {
  166. .peri_id = (u8)DMACH_SPI1_RX,
  167. .rqtype = DEVTOMEM,
  168. }, {
  169. .peri_id = (u8)DMACH_USI_TX,
  170. .rqtype = MEMTODEV,
  171. }, {
  172. .peri_id = (u8)DMACH_USI_RX,
  173. .rqtype = DEVTOMEM,
  174. }, {
  175. .peri_id = (u8)DMACH_MAX,
  176. }, {
  177. .peri_id = (u8)DMACH_I2S1_TX,
  178. .rqtype = MEMTODEV,
  179. }, {
  180. .peri_id = (u8)DMACH_I2S1_RX,
  181. .rqtype = DEVTOMEM,
  182. }, {
  183. .peri_id = (u8)DMACH_I2S2_TX,
  184. .rqtype = MEMTODEV,
  185. }, {
  186. .peri_id = (u8)DMACH_I2S2_RX,
  187. .rqtype = DEVTOMEM,
  188. }, {
  189. .peri_id = (u8)DMACH_PWM,
  190. }, {
  191. .peri_id = (u8)DMACH_UART5_RX,
  192. .rqtype = DEVTOMEM,
  193. }, {
  194. .peri_id = (u8)DMACH_UART5_TX,
  195. .rqtype = MEMTODEV,
  196. },
  197. };
  198. struct dma_pl330_platdata s5p6450_pdma_pdata = {
  199. .nr_valid_peri = ARRAY_SIZE(s5p6450_pdma_peri),
  200. .peri = s5p6450_pdma_peri,
  201. };
  202. struct amba_device s5p64x0_device_pdma = {
  203. .dev = {
  204. .init_name = "dma-pl330",
  205. .dma_mask = &dma_dmamask,
  206. .coherent_dma_mask = DMA_BIT_MASK(32),
  207. },
  208. .res = {
  209. .start = S5P64X0_PA_PDMA,
  210. .end = S5P64X0_PA_PDMA + SZ_4K,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. .irq = {IRQ_DMA0, NO_IRQ},
  214. .periphid = 0x00041330,
  215. };
  216. static int __init s5p64x0_dma_init(void)
  217. {
  218. unsigned int id = __raw_readl(S5P64X0_SYS_ID) & 0xFF000;
  219. if (id == 0x50000)
  220. s5p64x0_device_pdma.dev.platform_data = &s5p6450_pdma_pdata;
  221. else
  222. s5p64x0_device_pdma.dev.platform_data = &s5p6440_pdma_pdata;
  223. amba_device_register(&s5p64x0_device_pdma, &iomem_resource);
  224. return 0;
  225. }
  226. arch_initcall(s5p64x0_dma_init);