m68knommu: move ColdFire pit.c to its own coldfire directory
[wrt350n-kernel.git] / arch / arm / mach-s3c2412 / dma.c
blob1dd8649935662383989c81cc6d90fea834152390
1 /* linux/arch/arm/mach-s3c2412/dma.c
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * S3C2412 DMA selection
8 * http://armlinux.simtec.co.uk/
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.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/sysdev.h>
18 #include <linux/serial_core.h>
20 #include <asm/dma.h>
21 #include <asm/arch/dma.h>
22 #include <asm/io.h>
24 #include <asm/plat-s3c24xx/dma.h>
25 #include <asm/plat-s3c24xx/cpu.h>
27 #include <asm/plat-s3c/regs-serial.h>
28 #include <asm/arch/regs-gpio.h>
29 #include <asm/plat-s3c/regs-ac97.h>
30 #include <asm/arch/regs-mem.h>
31 #include <asm/arch/regs-lcd.h>
32 #include <asm/arch/regs-sdi.h>
33 #include <asm/plat-s3c24xx/regs-s3c2412-iis.h>
34 #include <asm/plat-s3c24xx/regs-iis.h>
35 #include <asm/plat-s3c24xx/regs-spi.h>
37 #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
39 static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
40 [DMACH_XD0] = {
41 .name = "xdreq0",
42 .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
43 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0),
45 [DMACH_XD1] = {
46 .name = "xdreq1",
47 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
48 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1),
50 [DMACH_SDI] = {
51 .name = "sdi",
52 .channels = MAP(S3C2412_DMAREQSEL_SDI),
53 .channels_rx = MAP(S3C2412_DMAREQSEL_SDI),
54 .hw_addr.to = S3C2410_PA_SDI + S3C2410_SDIDATA,
55 .hw_addr.from = S3C2410_PA_SDI + S3C2410_SDIDATA,
57 [DMACH_SPI0] = {
58 .name = "spi0",
59 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
60 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX),
61 .hw_addr.to = S3C2410_PA_SPI + S3C2410_SPTDAT,
62 .hw_addr.from = S3C2410_PA_SPI + S3C2410_SPRDAT,
64 [DMACH_SPI1] = {
65 .name = "spi1",
66 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
67 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX),
68 .hw_addr.to = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPTDAT,
69 .hw_addr.from = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPRDAT,
71 [DMACH_UART0] = {
72 .name = "uart0",
73 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
74 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0),
75 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
76 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
78 [DMACH_UART1] = {
79 .name = "uart1",
80 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
81 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0),
82 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
83 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
85 [DMACH_UART2] = {
86 .name = "uart2",
87 .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
88 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0),
89 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
90 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
92 [DMACH_UART0_SRC2] = {
93 .name = "uart0",
94 .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
95 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1),
96 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
97 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
99 [DMACH_UART1_SRC2] = {
100 .name = "uart1",
101 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
102 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1),
103 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
104 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
106 [DMACH_UART2_SRC2] = {
107 .name = "uart2",
108 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
109 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1),
110 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
111 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
113 [DMACH_TIMER] = {
114 .name = "timer",
115 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
116 .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER),
118 [DMACH_I2S_IN] = {
119 .name = "i2s-sdi",
120 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
121 .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX),
122 .hw_addr.from = S3C2410_PA_IIS + S3C2412_IISRXD,
124 [DMACH_I2S_OUT] = {
125 .name = "i2s-sdo",
126 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
127 .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX),
128 .hw_addr.to = S3C2410_PA_IIS + S3C2412_IISTXD,
130 [DMACH_USB_EP1] = {
131 .name = "usb-ep1",
132 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
133 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1),
135 [DMACH_USB_EP2] = {
136 .name = "usb-ep2",
137 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
138 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2),
140 [DMACH_USB_EP3] = {
141 .name = "usb-ep3",
142 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
143 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3),
145 [DMACH_USB_EP4] = {
146 .name = "usb-ep4",
147 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
148 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4),
152 static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan,
153 struct s3c24xx_dma_map *map,
154 enum s3c2410_dmasrc dir)
156 unsigned long chsel;
158 if (dir == S3C2410_DMASRC_HW)
159 chsel = map->channels_rx[0];
160 else
161 chsel = map->channels[0];
163 chsel &= ~DMA_CH_VALID;
164 chsel |= S3C2412_DMAREQSEL_HW;
166 writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL);
169 static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
170 struct s3c24xx_dma_map *map)
172 s3c2412_dma_direction(chan, map, chan->source);
175 static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
176 .select = s3c2412_dma_select,
177 .direction = s3c2412_dma_direction,
178 .dcon_mask = 0,
179 .map = s3c2412_dma_mappings,
180 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
183 static int __init s3c2412_dma_add(struct sys_device *sysdev)
185 s3c2410_dma_init();
186 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
189 static struct sysdev_driver s3c2412_dma_driver = {
190 .add = s3c2412_dma_add,
193 static int __init s3c2412_dma_init(void)
195 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver);
198 arch_initcall(s3c2412_dma_init);