blob: ab1700ec8e64f9cf3870179b4d2d2afc733e5d60 [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 Dooks44dc9402009-03-19 15:02:35 +000028#include <plat/regs-dma.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/regs-lcd.h>
Ben Dooks13622702008-10-30 10:14:38 +000030#include <plat/regs-spi.h>
Ben Dooks34348012006-09-18 23:52:03 +010031
32#define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
33
34static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = {
35 [DMACH_XD0] = {
36 .name = "xdreq0",
37 .channels = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooksc6709e82008-01-28 13:01:20 +010038 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0),
Ben Dooks34348012006-09-18 23:52:03 +010039 },
40 [DMACH_XD1] = {
41 .name = "xdreq1",
42 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooksc6709e82008-01-28 13:01:20 +010043 .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1),
Ben Dooks34348012006-09-18 23:52:03 +010044 },
45 [DMACH_SDI] = {
46 .name = "sdi",
47 .channels = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooksc6709e82008-01-28 13:01:20 +010048 .channels_rx = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooks34348012006-09-18 23:52:03 +010049 },
50 [DMACH_SPI0] = {
51 .name = "spi0",
52 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010053 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX),
Ben Dooks34348012006-09-18 23:52:03 +010054 },
55 [DMACH_SPI1] = {
56 .name = "spi1",
57 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
Ben Dooksc6709e82008-01-28 13:01:20 +010058 .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX),
Ben Dooks34348012006-09-18 23:52:03 +010059 },
60 [DMACH_UART0] = {
61 .name = "uart0",
62 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010063 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooks34348012006-09-18 23:52:03 +010064 },
65 [DMACH_UART1] = {
66 .name = "uart1",
67 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010068 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooks34348012006-09-18 23:52:03 +010069 },
70 [DMACH_UART2] = {
71 .name = "uart2",
72 .channels = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooksc6709e82008-01-28 13:01:20 +010073 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0),
Ben Dooks34348012006-09-18 23:52:03 +010074 },
75 [DMACH_UART0_SRC2] = {
76 .name = "uart0",
77 .channels = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010078 .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1),
Ben Dooks34348012006-09-18 23:52:03 +010079 },
80 [DMACH_UART1_SRC2] = {
81 .name = "uart1",
82 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010083 .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooks34348012006-09-18 23:52:03 +010084 },
85 [DMACH_UART2_SRC2] = {
86 .name = "uart2",
87 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooksc6709e82008-01-28 13:01:20 +010088 .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooks34348012006-09-18 23:52:03 +010089 },
90 [DMACH_TIMER] = {
91 .name = "timer",
92 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooksc6709e82008-01-28 13:01:20 +010093 .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER),
Ben Dooks34348012006-09-18 23:52:03 +010094 },
95 [DMACH_I2S_IN] = {
96 .name = "i2s-sdi",
97 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooksc6709e82008-01-28 13:01:20 +010098 .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooks34348012006-09-18 23:52:03 +010099 },
100 [DMACH_I2S_OUT] = {
101 .name = "i2s-sdo",
102 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooksc6709e82008-01-28 13:01:20 +0100103 .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooks34348012006-09-18 23:52:03 +0100104 },
105 [DMACH_USB_EP1] = {
106 .name = "usb-ep1",
107 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooksc6709e82008-01-28 13:01:20 +0100108 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1),
Ben Dooks34348012006-09-18 23:52:03 +0100109 },
110 [DMACH_USB_EP2] = {
111 .name = "usb-ep2",
112 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooksc6709e82008-01-28 13:01:20 +0100113 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2),
Ben Dooks34348012006-09-18 23:52:03 +0100114 },
115 [DMACH_USB_EP3] = {
116 .name = "usb-ep3",
117 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooksc6709e82008-01-28 13:01:20 +0100118 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3),
Ben Dooks34348012006-09-18 23:52:03 +0100119 },
120 [DMACH_USB_EP4] = {
121 .name = "usb-ep4",
122 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooksc6709e82008-01-28 13:01:20 +0100123 .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4),
Ben Dooks34348012006-09-18 23:52:03 +0100124 },
125};
126
Ben Dooksc6709e82008-01-28 13:01:20 +0100127static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan,
128 struct s3c24xx_dma_map *map,
Boojin Kim51ddf312011-09-02 09:44:44 +0900129 enum dma_data_direction dir)
Ben Dooksc6709e82008-01-28 13:01:20 +0100130{
131 unsigned long chsel;
132
Boojin Kim51ddf312011-09-02 09:44:44 +0900133 if (dir == DMA_FROM_DEVICE)
Ben Dooksc6709e82008-01-28 13:01:20 +0100134 chsel = map->channels_rx[0];
135 else
136 chsel = map->channels[0];
137
138 chsel &= ~DMA_CH_VALID;
139 chsel |= S3C2412_DMAREQSEL_HW;
140
141 writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL);
142}
143
Ben Dooks34348012006-09-18 23:52:03 +0100144static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
145 struct s3c24xx_dma_map *map)
146{
Ben Dooksc6709e82008-01-28 13:01:20 +0100147 s3c2412_dma_direction(chan, map, chan->source);
Ben Dooks34348012006-09-18 23:52:03 +0100148}
149
150static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
151 .select = s3c2412_dma_select,
Ben Dooksc6709e82008-01-28 13:01:20 +0100152 .direction = s3c2412_dma_direction,
Ben Dooks34348012006-09-18 23:52:03 +0100153 .dcon_mask = 0,
154 .map = s3c2412_dma_mappings,
155 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
156};
157
Heiko Stuebner04511a62012-01-27 15:35:25 +0900158static int __init s3c2412_dma_add(struct device *dev,
159 struct subsys_interface *sif)
Ben Dooks34348012006-09-18 23:52:03 +0100160{
Ben Dooks48adbcf2007-02-17 15:37:14 +0100161 s3c2410_dma_init();
Ben Dooks34348012006-09-18 23:52:03 +0100162 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
163}
164
Kay Sievers4a858cf2011-12-21 16:01:38 -0800165static struct subsys_interface s3c2412_dma_interface = {
166 .name = "s3c2412_dma",
167 .subsys = &s3c2412_subsys,
168 .add_dev = s3c2412_dma_add,
Ben Dooks34348012006-09-18 23:52:03 +0100169};
170
171static int __init s3c2412_dma_init(void)
172{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800173 return subsys_interface_register(&s3c2412_dma_interface);
Ben Dooks34348012006-09-18 23:52:03 +0100174}
175
176arch_initcall(s3c2412_dma_init);