dma-s3c2443.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* linux/arch/arm/mach-s3c2443/dma.c
  2. *
  3. * Copyright (c) 2007 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2443 DMA selection
  7. *
  8. * http://armlinux.simtec.co.uk/
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/device.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/io.h>
  19. #include <mach/dma.h>
  20. #include <plat/dma-s3c24xx.h>
  21. #include <plat/cpu.h>
  22. #include <plat/regs-serial.h>
  23. #include <mach/regs-gpio.h>
  24. #include <plat/regs-ac97.h>
  25. #include <plat/regs-dma.h>
  26. #include <mach/regs-mem.h>
  27. #include <mach/regs-lcd.h>
  28. #include <mach/regs-sdi.h>
  29. #include <plat/regs-iis.h>
  30. #include <plat/regs-spi.h>
  31. #define MAP(x) { \
  32. [0] = (x) | DMA_CH_VALID, \
  33. [1] = (x) | DMA_CH_VALID, \
  34. [2] = (x) | DMA_CH_VALID, \
  35. [3] = (x) | DMA_CH_VALID, \
  36. [4] = (x) | DMA_CH_VALID, \
  37. [5] = (x) | DMA_CH_VALID, \
  38. }
  39. static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
  40. [DMACH_XD0] = {
  41. .name = "xdreq0",
  42. .channels = MAP(S3C2443_DMAREQSEL_XDREQ0),
  43. },
  44. [DMACH_XD1] = {
  45. .name = "xdreq1",
  46. .channels = MAP(S3C2443_DMAREQSEL_XDREQ1),
  47. },
  48. [DMACH_SDI] = { /* only on S3C2443 */
  49. .name = "sdi",
  50. .channels = MAP(S3C2443_DMAREQSEL_SDI),
  51. },
  52. [DMACH_SPI0] = {
  53. .name = "spi0",
  54. .channels = MAP(S3C2443_DMAREQSEL_SPI0TX),
  55. },
  56. [DMACH_SPI1] = { /* only on S3C2443/S3C2450 */
  57. .name = "spi1",
  58. .channels = MAP(S3C2443_DMAREQSEL_SPI1TX),
  59. },
  60. [DMACH_UART0] = {
  61. .name = "uart0",
  62. .channels = MAP(S3C2443_DMAREQSEL_UART0_0),
  63. },
  64. [DMACH_UART1] = {
  65. .name = "uart1",
  66. .channels = MAP(S3C2443_DMAREQSEL_UART1_0),
  67. },
  68. [DMACH_UART2] = {
  69. .name = "uart2",
  70. .channels = MAP(S3C2443_DMAREQSEL_UART2_0),
  71. },
  72. [DMACH_UART3] = {
  73. .name = "uart3",
  74. .channels = MAP(S3C2443_DMAREQSEL_UART3_0),
  75. },
  76. [DMACH_UART0_SRC2] = {
  77. .name = "uart0",
  78. .channels = MAP(S3C2443_DMAREQSEL_UART0_1),
  79. },
  80. [DMACH_UART1_SRC2] = {
  81. .name = "uart1",
  82. .channels = MAP(S3C2443_DMAREQSEL_UART1_1),
  83. },
  84. [DMACH_UART2_SRC2] = {
  85. .name = "uart2",
  86. .channels = MAP(S3C2443_DMAREQSEL_UART2_1),
  87. },
  88. [DMACH_UART3_SRC2] = {
  89. .name = "uart3",
  90. .channels = MAP(S3C2443_DMAREQSEL_UART3_1),
  91. },
  92. [DMACH_TIMER] = {
  93. .name = "timer",
  94. .channels = MAP(S3C2443_DMAREQSEL_TIMER),
  95. },
  96. [DMACH_I2S_IN] = {
  97. .name = "i2s-sdi",
  98. .channels = MAP(S3C2443_DMAREQSEL_I2SRX),
  99. },
  100. [DMACH_I2S_OUT] = {
  101. .name = "i2s-sdo",
  102. .channels = MAP(S3C2443_DMAREQSEL_I2STX),
  103. },
  104. [DMACH_PCM_IN] = {
  105. .name = "pcm-in",
  106. .channels = MAP(S3C2443_DMAREQSEL_PCMIN),
  107. },
  108. [DMACH_PCM_OUT] = {
  109. .name = "pcm-out",
  110. .channels = MAP(S3C2443_DMAREQSEL_PCMOUT),
  111. },
  112. [DMACH_MIC_IN] = {
  113. .name = "mic-in",
  114. .channels = MAP(S3C2443_DMAREQSEL_MICIN),
  115. },
  116. };
  117. static void s3c2443_dma_select(struct s3c2410_dma_chan *chan,
  118. struct s3c24xx_dma_map *map)
  119. {
  120. writel(map->channels[0] | S3C2443_DMAREQSEL_HW,
  121. chan->regs + S3C2443_DMA_DMAREQSEL);
  122. }
  123. static struct s3c24xx_dma_selection __initdata s3c2443_dma_sel = {
  124. .select = s3c2443_dma_select,
  125. .dcon_mask = 0,
  126. .map = s3c2443_dma_mappings,
  127. .map_size = ARRAY_SIZE(s3c2443_dma_mappings),
  128. };
  129. static int __init s3c2443_dma_add(struct device *dev,
  130. struct subsys_interface *sif)
  131. {
  132. s3c24xx_dma_init(6, IRQ_S3C2443_DMA0, 0x100);
  133. return s3c24xx_dma_init_map(&s3c2443_dma_sel);
  134. }
  135. #ifdef CONFIG_CPU_S3C2416
  136. /* S3C2416 DMA contains the same selection table as the S3C2443 */
  137. static struct subsys_interface s3c2416_dma_interface = {
  138. .name = "s3c2416_dma",
  139. .subsys = &s3c2416_subsys,
  140. .add_dev = s3c2443_dma_add,
  141. };
  142. static int __init s3c2416_dma_init(void)
  143. {
  144. return subsys_interface_register(&s3c2416_dma_interface);
  145. }
  146. arch_initcall(s3c2416_dma_init);
  147. #endif
  148. #ifdef CONFIG_CPU_S3C2443
  149. static struct subsys_interface s3c2443_dma_interface = {
  150. .name = "s3c2443_dma",
  151. .subsys = &s3c2443_subsys,
  152. .add_dev = s3c2443_dma_add,
  153. };
  154. static int __init s3c2443_dma_init(void)
  155. {
  156. return subsys_interface_register(&s3c2443_dma_interface);
  157. }
  158. arch_initcall(s3c2443_dma_init);
  159. #endif