blob: ba0591e71f329aff73ae383c3549f22d17390507 [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/mach-s3c2412/dma.c
Ben Dooks34348012006-09-18 23:52:03 +01002 *
Ben Dooksc16f7bd2006-12-17 20:05:21 +01003 * Copyright (c) 2006 Simtec Electronics
Ben Dooks34348012006-09-18 23:52:03 +01004 * 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
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/sysdev.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010018#include <linux/serial_core.h>
Russell Kingfced80c2008-09-06 12:10:45 +010019#include <linux/io.h>
Ben Dooks34348012006-09-18 23:52:03 +010020
21#include <asm/dma.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/dma.h>
Ben Dooks34348012006-09-18 23:52:03 +010023
Ben Dooksd5120ae2008-10-07 23:09:51 +010024#include <plat/dma.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010025#include <plat/cpu.h>
Ben Dooks34348012006-09-18 23:52:03 +010026
Ben Dooksa2b7ba92008-10-07 22:26:09 +010027#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/regs-gpio.h>
Ben Dooks06cfa552007-07-22 16:23:02 +010029#include <asm/plat-s3c/regs-ac97.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/regs-mem.h>
31#include <mach/regs-lcd.h>
32#include <mach/regs-sdi.h>
Ben Dooksd45c30c2007-12-23 03:09:40 +010033#include <asm/plat-s3c24xx/regs-s3c2412-iis.h>
Ben Dooks06cfa552007-07-22 16:23:02 +010034#include <asm/plat-s3c24xx/regs-iis.h>
35#include <asm/plat-s3c24xx/regs-spi.h>
Ben Dooks34348012006-09-18 23:52:03 +010036
37#define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
38
39static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
40 [DMACH_XD0] = {
41 .name = "xdreq0",
42 .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooksc6709e82008-01-28 13:01:20 +010043 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooks34348012006-09-18 23:52:03 +010044 },
45 [DMACH_XD1] = {
46 .name = "xdreq1",
47 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooksc6709e82008-01-28 13:01:20 +010048 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooks34348012006-09-18 23:52:03 +010049 },
50 [DMACH_SDI] = {
51 .name = "sdi",
52 .channels = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooksc6709e82008-01-28 13:01:20 +010053 .channels_rx = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooksd45c30c2007-12-23 03:09:40 +010054 .hw_addr.to = S3C2410_PA_SDI + S3C2410_SDIDATA,
55 .hw_addr.from = S3C2410_PA_SDI + S3C2410_SDIDATA,
Ben Dooks34348012006-09-18 23:52:03 +010056 },
57 [DMACH_SPI0] = {
58 .name = "spi0",
59 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010060 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX),
Ben Dooks34348012006-09-18 23:52:03 +010061 .hw_addr.to = S3C2410_PA_SPI + S3C2410_SPTDAT,
62 .hw_addr.from = S3C2410_PA_SPI + S3C2410_SPRDAT,
63 },
64 [DMACH_SPI1] = {
65 .name = "spi1",
66 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010067 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX),
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +010068 .hw_addr.to = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPTDAT,
69 .hw_addr.from = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPRDAT,
Ben Dooks34348012006-09-18 23:52:03 +010070 },
71 [DMACH_UART0] = {
72 .name = "uart0",
73 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010074 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooks34348012006-09-18 23:52:03 +010075 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
76 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
77 },
78 [DMACH_UART1] = {
79 .name = "uart1",
80 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010081 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooks34348012006-09-18 23:52:03 +010082 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
83 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
84 },
85 [DMACH_UART2] = {
86 .name = "uart2",
87 .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010088 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooks34348012006-09-18 23:52:03 +010089 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
90 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
91 },
92 [DMACH_UART0_SRC2] = {
93 .name = "uart0",
94 .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010095 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooks34348012006-09-18 23:52:03 +010096 .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH,
97 .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH,
98 },
99 [DMACH_UART1_SRC2] = {
100 .name = "uart1",
101 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooksc6709e82008-01-28 13:01:20 +0100102 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooks34348012006-09-18 23:52:03 +0100103 .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH,
104 .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH,
105 },
106 [DMACH_UART2_SRC2] = {
107 .name = "uart2",
108 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooksc6709e82008-01-28 13:01:20 +0100109 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooks34348012006-09-18 23:52:03 +0100110 .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH,
111 .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH,
112 },
113 [DMACH_TIMER] = {
114 .name = "timer",
115 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooksc6709e82008-01-28 13:01:20 +0100116 .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooks34348012006-09-18 23:52:03 +0100117 },
118 [DMACH_I2S_IN] = {
119 .name = "i2s-sdi",
120 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooksc6709e82008-01-28 13:01:20 +0100121 .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooksd45c30c2007-12-23 03:09:40 +0100122 .hw_addr.from = S3C2410_PA_IIS + S3C2412_IISRXD,
Ben Dooks34348012006-09-18 23:52:03 +0100123 },
124 [DMACH_I2S_OUT] = {
125 .name = "i2s-sdo",
126 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooksc6709e82008-01-28 13:01:20 +0100127 .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooksd45c30c2007-12-23 03:09:40 +0100128 .hw_addr.to = S3C2410_PA_IIS + S3C2412_IISTXD,
Ben Dooks34348012006-09-18 23:52:03 +0100129 },
130 [DMACH_USB_EP1] = {
131 .name = "usb-ep1",
132 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooksc6709e82008-01-28 13:01:20 +0100133 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooks34348012006-09-18 23:52:03 +0100134 },
135 [DMACH_USB_EP2] = {
136 .name = "usb-ep2",
137 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooksc6709e82008-01-28 13:01:20 +0100138 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooks34348012006-09-18 23:52:03 +0100139 },
140 [DMACH_USB_EP3] = {
141 .name = "usb-ep3",
142 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooksc6709e82008-01-28 13:01:20 +0100143 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooks34348012006-09-18 23:52:03 +0100144 },
145 [DMACH_USB_EP4] = {
146 .name = "usb-ep4",
147 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooksc6709e82008-01-28 13:01:20 +0100148 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooks34348012006-09-18 23:52:03 +0100149 },
150};
151
Ben Dooksc6709e82008-01-28 13:01:20 +0100152static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan,
153 struct s3c24xx_dma_map *map,
154 enum s3c2410_dmasrc dir)
155{
156 unsigned long chsel;
157
158 if (dir == S3C2410_DMASRC_HW)
159 chsel = map->channels_rx[0];
160 else
161 chsel = map->channels[0];
162
163 chsel &= ~DMA_CH_VALID;
164 chsel |= S3C2412_DMAREQSEL_HW;
165
166 writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL);
167}
168
Ben Dooks34348012006-09-18 23:52:03 +0100169static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
170 struct s3c24xx_dma_map *map)
171{
Ben Dooksc6709e82008-01-28 13:01:20 +0100172 s3c2412_dma_direction(chan, map, chan->source);
Ben Dooks34348012006-09-18 23:52:03 +0100173}
174
175static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
176 .select = s3c2412_dma_select,
Ben Dooksc6709e82008-01-28 13:01:20 +0100177 .direction = s3c2412_dma_direction,
Ben Dooks34348012006-09-18 23:52:03 +0100178 .dcon_mask = 0,
179 .map = s3c2412_dma_mappings,
180 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
181};
182
Krzysztof Heltf2c10d62007-09-04 17:19:33 +0100183static int __init s3c2412_dma_add(struct sys_device *sysdev)
Ben Dooks34348012006-09-18 23:52:03 +0100184{
Ben Dooks48adbcf2007-02-17 15:37:14 +0100185 s3c2410_dma_init();
Ben Dooks34348012006-09-18 23:52:03 +0100186 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
187}
188
189static struct sysdev_driver s3c2412_dma_driver = {
190 .add = s3c2412_dma_add,
191};
192
193static int __init s3c2412_dma_init(void)
194{
195 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver);
196}
197
198arch_initcall(s3c2412_dma_init);