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>
26 #include <plat/regs-serial.h>
27 #include <mach/regs-gpio.h>
28 #include <plat/regs-ac97.h>
29 #include <mach/regs-mem.h>
30 #include <mach/regs-lcd.h>
31 #include <mach/regs-sdi.h>
32 #include <plat/regs-s3c2412-iis.h>
33 #include <plat/regs-iis.h>
34 #include <plat/regs-spi.h>
36 #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
38 static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
41 .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
42 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0),
46 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
47 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1),
51 .channels = MAP(S3C2412_DMAREQSEL_SDI),
52 .channels_rx = MAP(S3C2412_DMAREQSEL_SDI),
53 .hw_addr.to = S3C2410_PA_SDI + S3C2410_SDIDATA,
54 .hw_addr.from = S3C2410_PA_SDI + S3C2410_SDIDATA,
58 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
59 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX),
60 .hw_addr.to = S3C2410_PA_SPI + S3C2410_SPTDAT,
61 .hw_addr.from = S3C2410_PA_SPI + S3C2410_SPRDAT,
65 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
66 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX),
67 .hw_addr.to = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPTDAT,
68 .hw_addr.from = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPRDAT,
72 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
73 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0),
74 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
75 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
79 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
80 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0),
81 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
82 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
86 .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
87 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0),
88 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
89 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
91 [DMACH_UART0_SRC2] = {
93 .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
94 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1),
95 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
96 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
98 [DMACH_UART1_SRC2] = {
100 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
101 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1),
102 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
103 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
105 [DMACH_UART2_SRC2] = {
107 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
108 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1),
109 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
110 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
114 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
115 .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER),
119 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
120 .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX),
121 .hw_addr.from = S3C2410_PA_IIS + S3C2412_IISRXD,
125 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
126 .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX),
127 .hw_addr.to = S3C2410_PA_IIS + S3C2412_IISTXD,
131 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
132 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1),
136 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
137 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2),
141 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
142 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3),
146 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
147 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4),
151 static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan,
152 struct s3c24xx_dma_map *map,
153 enum s3c2410_dmasrc dir)
157 if (dir == S3C2410_DMASRC_HW)
158 chsel = map->channels_rx[0];
160 chsel = map->channels[0];
162 chsel &= ~DMA_CH_VALID;
163 chsel |= S3C2412_DMAREQSEL_HW;
165 writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL);
168 static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
169 struct s3c24xx_dma_map *map)
171 s3c2412_dma_direction(chan, map, chan->source);
174 static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
175 .select = s3c2412_dma_select,
176 .direction = s3c2412_dma_direction,
178 .map = s3c2412_dma_mappings,
179 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
182 static int __init s3c2412_dma_add(struct sys_device *sysdev)
185 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
188 static struct sysdev_driver s3c2412_dma_driver = {
189 .add = s3c2412_dma_add,
192 static int __init s3c2412_dma_init(void)
194 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver);
197 arch_initcall(s3c2412_dma_init);