dma-s3c2412.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* linux/arch/arm/mach-s3c2412/dma.c
  2. *
  3. * Copyright (c) 2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2412 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-dma.h>
  25. #include <mach/regs-lcd.h>
  26. #include <plat/regs-spi.h>
  27. #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
  28. static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
  29. [DMACH_XD0] = {
  30. .name = "xdreq0",
  31. .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
  32. },
  33. [DMACH_XD1] = {
  34. .name = "xdreq1",
  35. .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
  36. },
  37. [DMACH_SDI] = {
  38. .name = "sdi",
  39. .channels = MAP(S3C2412_DMAREQSEL_SDI),
  40. },
  41. [DMACH_SPI0_RX] = {
  42. .name = "spi0-rx",
  43. .channels = MAP(S3C2412_DMAREQSEL_SPI0RX),
  44. },
  45. [DMACH_SPI0_TX] = {
  46. .name = "spi0-tx",
  47. .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
  48. },
  49. [DMACH_SPI1_RX] = {
  50. .name = "spi1-rx",
  51. .channels = MAP(S3C2412_DMAREQSEL_SPI1RX),
  52. },
  53. [DMACH_SPI1_TX] = {
  54. .name = "spi1-tx",
  55. .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
  56. },
  57. [DMACH_UART0] = {
  58. .name = "uart0",
  59. .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
  60. },
  61. [DMACH_UART1] = {
  62. .name = "uart1",
  63. .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
  64. },
  65. [DMACH_UART2] = {
  66. .name = "uart2",
  67. .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
  68. },
  69. [DMACH_UART0_SRC2] = {
  70. .name = "uart0",
  71. .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
  72. },
  73. [DMACH_UART1_SRC2] = {
  74. .name = "uart1",
  75. .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
  76. },
  77. [DMACH_UART2_SRC2] = {
  78. .name = "uart2",
  79. .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
  80. },
  81. [DMACH_TIMER] = {
  82. .name = "timer",
  83. .channels = MAP(S3C2412_DMAREQSEL_TIMER),
  84. },
  85. [DMACH_I2S_IN] = {
  86. .name = "i2s-sdi",
  87. .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
  88. },
  89. [DMACH_I2S_OUT] = {
  90. .name = "i2s-sdo",
  91. .channels = MAP(S3C2412_DMAREQSEL_I2STX),
  92. },
  93. [DMACH_USB_EP1] = {
  94. .name = "usb-ep1",
  95. .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
  96. },
  97. [DMACH_USB_EP2] = {
  98. .name = "usb-ep2",
  99. .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
  100. },
  101. [DMACH_USB_EP3] = {
  102. .name = "usb-ep3",
  103. .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
  104. },
  105. [DMACH_USB_EP4] = {
  106. .name = "usb-ep4",
  107. .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
  108. },
  109. };
  110. static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
  111. struct s3c24xx_dma_map *map)
  112. {
  113. unsigned long chsel = map->channels[0] & (~DMA_CH_VALID);
  114. writel(chsel | S3C2412_DMAREQSEL_HW,
  115. chan->regs + S3C2412_DMA_DMAREQSEL);
  116. }
  117. static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
  118. .select = s3c2412_dma_select,
  119. .dcon_mask = 0,
  120. .map = s3c2412_dma_mappings,
  121. .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
  122. };
  123. static int __init s3c2412_dma_add(struct device *dev,
  124. struct subsys_interface *sif)
  125. {
  126. s3c2410_dma_init();
  127. return s3c24xx_dma_init_map(&s3c2412_dma_sel);
  128. }
  129. static struct subsys_interface s3c2412_dma_interface = {
  130. .name = "s3c2412_dma",
  131. .subsys = &s3c2412_subsys,
  132. .add_dev = s3c2412_dma_add,
  133. };
  134. static int __init s3c2412_dma_init(void)
  135. {
  136. return subsys_interface_register(&s3c2412_dma_interface);
  137. }
  138. arch_initcall(s3c2412_dma_init);