blob: b7e094671522d33d9b197fc28272d83473031310 [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),
38 },
39 [DMACH_XD1] = {
40 .name = "xdreq1",
41 .channels = MAP(S3C2412_DMAREQSEL_XDREQ1),
42 },
43 [DMACH_SDI] = {
44 .name = "sdi",
45 .channels = MAP(S3C2412_DMAREQSEL_SDI),
Ben Dooks34348012006-09-18 23:52:03 +010046 },
Heiko Stuebner4c4e9752013-05-21 01:01:33 +090047 [DMACH_SPI0_RX] = {
48 .name = "spi0-rx",
49 .channels = MAP(S3C2412_DMAREQSEL_SPI0RX),
Ben Dooks34348012006-09-18 23:52:03 +010050 },
Heiko Stuebner4c4e9752013-05-21 01:01:33 +090051 [DMACH_SPI0_TX] = {
52 .name = "spi0-tx",
53 .channels = MAP(S3C2412_DMAREQSEL_SPI0TX),
Heiko Stuebner4c4e9752013-05-21 01:01:33 +090054 },
55 [DMACH_SPI1_RX] = {
56 .name = "spi1-rx",
57 .channels = MAP(S3C2412_DMAREQSEL_SPI1RX),
Ben Dooks34348012006-09-18 23:52:03 +010058 },
Heiko Stuebner4c4e9752013-05-21 01:01:33 +090059 [DMACH_SPI1_TX] = {
60 .name = "spi1-tx",
61 .channels = MAP(S3C2412_DMAREQSEL_SPI1TX),
Heiko Stuebner4c4e9752013-05-21 01:01:33 +090062 },
Ben Dooks34348012006-09-18 23:52:03 +010063 [DMACH_UART0] = {
64 .name = "uart0",
65 .channels = MAP(S3C2412_DMAREQSEL_UART0_0),
Ben Dooks34348012006-09-18 23:52:03 +010066 },
67 [DMACH_UART1] = {
68 .name = "uart1",
69 .channels = MAP(S3C2412_DMAREQSEL_UART1_0),
Ben Dooks34348012006-09-18 23:52:03 +010070 },
71 [DMACH_UART2] = {
72 .name = "uart2",
73 .channels = 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 Dooks34348012006-09-18 23:52:03 +010078 },
79 [DMACH_UART1_SRC2] = {
80 .name = "uart1",
81 .channels = MAP(S3C2412_DMAREQSEL_UART1_1),
Ben Dooks34348012006-09-18 23:52:03 +010082 },
83 [DMACH_UART2_SRC2] = {
84 .name = "uart2",
85 .channels = MAP(S3C2412_DMAREQSEL_UART2_1),
Ben Dooks34348012006-09-18 23:52:03 +010086 },
87 [DMACH_TIMER] = {
88 .name = "timer",
89 .channels = MAP(S3C2412_DMAREQSEL_TIMER),
90 },
91 [DMACH_I2S_IN] = {
92 .name = "i2s-sdi",
93 .channels = MAP(S3C2412_DMAREQSEL_I2SRX),
Ben Dooks34348012006-09-18 23:52:03 +010094 },
95 [DMACH_I2S_OUT] = {
96 .name = "i2s-sdo",
97 .channels = MAP(S3C2412_DMAREQSEL_I2STX),
Ben Dooks34348012006-09-18 23:52:03 +010098 },
99 [DMACH_USB_EP1] = {
100 .name = "usb-ep1",
101 .channels = MAP(S3C2412_DMAREQSEL_USBEP1),
102 },
103 [DMACH_USB_EP2] = {
104 .name = "usb-ep2",
105 .channels = MAP(S3C2412_DMAREQSEL_USBEP2),
106 },
107 [DMACH_USB_EP3] = {
108 .name = "usb-ep3",
109 .channels = MAP(S3C2412_DMAREQSEL_USBEP3),
110 },
111 [DMACH_USB_EP4] = {
112 .name = "usb-ep4",
113 .channels = MAP(S3C2412_DMAREQSEL_USBEP4),
114 },
115};
116
117static void s3c2412_dma_select(struct s3c2410_dma_chan *chan,
118 struct s3c24xx_dma_map *map)
119{
Heiko Stuebnera496bda2013-05-21 01:01:41 +0900120 unsigned long chsel = map->channels[0] & (~DMA_CH_VALID);
121 writel(chsel | S3C2412_DMAREQSEL_HW,
122 chan->regs + S3C2412_DMA_DMAREQSEL);
Ben Dooks34348012006-09-18 23:52:03 +0100123}
124
125static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = {
126 .select = s3c2412_dma_select,
127 .dcon_mask = 0,
128 .map = s3c2412_dma_mappings,
129 .map_size = ARRAY_SIZE(s3c2412_dma_mappings),
130};
131
Heiko Stuebner04511a62012-01-27 15:35:25 +0900132static int __init s3c2412_dma_add(struct device *dev,
133 struct subsys_interface *sif)
Ben Dooks34348012006-09-18 23:52:03 +0100134{
Ben Dooks48adbcf2007-02-17 15:37:14 +0100135 s3c2410_dma_init();
Ben Dooks34348012006-09-18 23:52:03 +0100136 return s3c24xx_dma_init_map(&s3c2412_dma_sel);
137}
138
Kay Sievers4a858cf2011-12-21 16:01:38 -0800139static struct subsys_interface s3c2412_dma_interface = {
140 .name = "s3c2412_dma",
141 .subsys = &s3c2412_subsys,
142 .add_dev = s3c2412_dma_add,
Ben Dooks34348012006-09-18 23:52:03 +0100143};
144
145static int __init s3c2412_dma_init(void)
146{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800147 return subsys_interface_register(&s3c2412_dma_interface);
Ben Dooks34348012006-09-18 23:52:03 +0100148}
149
150arch_initcall(s3c2412_dma_init);