blob: 38472ac920ff16b13b2ae21c0e82e010dd4311a6 [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>
Kay Sievers4a858cf2011-12-21 16:01:38 -080017#include <linux/device.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
Russell Kinga09e64f2008-08-05 16:14:15 +010021#include <mach/dma.h>
Ben Dooks34348012006-09-18 23:52:03 +010022
Ben Dooks992426b2010-02-20 23:01:33 +000023#include <plat/dma-s3c24xx.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010024#include <plat/cpu.h>
Ben Dooks34348012006-09-18 23:52:03 +010025
Ben Dooksa2b7ba92008-10-07 22:26:09 +010026#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/regs-gpio.h>
Ben Dooksf74c95c2008-10-30 10:14:36 +000028#include <plat/regs-ac97.h>
Ben Dooks44dc9402009-03-19 15:02:35 +000029#include <plat/regs-dma.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 Dooks8150bc82009-03-04 00:49:26 +000033#include <plat/regs-iis.h>
Ben Dooks13622702008-10-30 10:14:38 +000034#include <plat/regs-spi.h>
Ben Dooks34348012006-09-18 23:52:03 +010035
36#define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
37
38static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
39 [DMACH_XD0] = {
40 .name = "xdreq0",
41 .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooksc6709e82008-01-28 13:01:20 +010042 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooks34348012006-09-18 23:52:03 +010043 },
44 [DMACH_XD1] = {
45 .name = "xdreq1",
46 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooksc6709e82008-01-28 13:01:20 +010047 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooks34348012006-09-18 23:52:03 +010048 },
49 [DMACH_SDI] = {
50 .name = "sdi",
51 .channels = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooksc6709e82008-01-28 13:01:20 +010052 .channels_rx = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooks34348012006-09-18 23:52:03 +010053 },
54 [DMACH_SPI0] = {
55 .name = "spi0",
56 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010057 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX),
Ben Dooks34348012006-09-18 23:52:03 +010058 },
59 [DMACH_SPI1] = {
60 .name = "spi1",
61 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010062 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX),
Ben Dooks34348012006-09-18 23:52:03 +010063 },
64 [DMACH_UART0] = {
65 .name = "uart0",
66 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010067 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooks34348012006-09-18 23:52:03 +010068 },
69 [DMACH_UART1] = {
70 .name = "uart1",
71 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010072 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooks34348012006-09-18 23:52:03 +010073 },
74 [DMACH_UART2] = {
75 .name = "uart2",
76 .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010077 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooks34348012006-09-18 23:52:03 +010078 },
79 [DMACH_UART0_SRC2] = {
80 .name = "uart0",
81 .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010082 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooks34348012006-09-18 23:52:03 +010083 },
84 [DMACH_UART1_SRC2] = {
85 .name = "uart1",
86 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010087 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooks34348012006-09-18 23:52:03 +010088 },
89 [DMACH_UART2_SRC2] = {
90 .name = "uart2",
91 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010092 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooks34348012006-09-18 23:52:03 +010093 },
94 [DMACH_TIMER] = {
95 .name = "timer",
96 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooksc6709e82008-01-28 13:01:20 +010097 .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooks34348012006-09-18 23:52:03 +010098 },
99 [DMACH_I2S_IN] = {
100 .name = "i2s-sdi",
101 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooksc6709e82008-01-28 13:01:20 +0100102 .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooks34348012006-09-18 23:52:03 +0100103 },
104 [DMACH_I2S_OUT] = {
105 .name = "i2s-sdo",
106 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooksc6709e82008-01-28 13:01:20 +0100107 .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooks34348012006-09-18 23:52:03 +0100108 },
109 [DMACH_USB_EP1] = {
110 .name = "usb-ep1",
111 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooksc6709e82008-01-28 13:01:20 +0100112 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooks34348012006-09-18 23:52:03 +0100113 },
114 [DMACH_USB_EP2] = {
115 .name = "usb-ep2",
116 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooksc6709e82008-01-28 13:01:20 +0100117 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooks34348012006-09-18 23:52:03 +0100118 },
119 [DMACH_USB_EP3] = {
120 .name = "usb-ep3",
121 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooksc6709e82008-01-28 13:01:20 +0100122 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooks34348012006-09-18 23:52:03 +0100123 },
124 [DMACH_USB_EP4] = {
125 .name = "usb-ep4",
126 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooksc6709e82008-01-28 13:01:20 +0100127 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooks34348012006-09-18 23:52:03 +0100128 },
129};
130
Ben Dooksc6709e82008-01-28 13:01:20 +0100131static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan,
132 struct s3c24xx_dma_map *map,
Boojin Kim51ddf312011-09-02 09:44:44 +0900133 enum dma_data_direction dir)
Ben Dooksc6709e82008-01-28 13:01:20 +0100134{
135 unsigned long chsel;
136
Boojin Kim51ddf312011-09-02 09:44:44 +0900137 if (dir == DMA_FROM_DEVICE)
Ben Dooksc6709e82008-01-28 13:01:20 +0100138 chsel = map->channels_rx[0];
139 else
140 chsel = map->channels[0];
141
142 chsel &= ~DMA_CH_VALID;
143 chsel |= S3C2412_DMAREQSEL_HW;
144
145 writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL);
146}
147
Ben Dooks34348012006-09-18 23:52:03 +0100148static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
149 struct s3c24xx_dma_map *map)
150{
Ben Dooksc6709e82008-01-28 13:01:20 +0100151 s3c2412_dma_direction(chan, map, chan->source);
Ben Dooks34348012006-09-18 23:52:03 +0100152}
153
154static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
155 .select = s3c2412_dma_select,
Ben Dooksc6709e82008-01-28 13:01:20 +0100156 .direction = s3c2412_dma_direction,
Ben Dooks34348012006-09-18 23:52:03 +0100157 .dcon_mask = 0,
158 .map = s3c2412_dma_mappings,
159 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
160};
161
Heiko Stuebner04511a62012-01-27 15:35:25 +0900162static int __init s3c2412_dma_add(struct device *dev,
163 struct subsys_interface *sif)
Ben Dooks34348012006-09-18 23:52:03 +0100164{
Ben Dooks48adbcf2007-02-17 15:37:14 +0100165 s3c2410_dma_init();
Ben Dooks34348012006-09-18 23:52:03 +0100166 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
167}
168
Kay Sievers4a858cf2011-12-21 16:01:38 -0800169static struct subsys_interface s3c2412_dma_interface = {
170 .name = "s3c2412_dma",
171 .subsys = &s3c2412_subsys,
172 .add_dev = s3c2412_dma_add,
Ben Dooks34348012006-09-18 23:52:03 +0100173};
174
175static int __init s3c2412_dma_init(void)
176{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800177 return subsys_interface_register(&s3c2412_dma_interface);
Ben Dooks34348012006-09-18 23:52:03 +0100178}
179
180arch_initcall(s3c2412_dma_init);