]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-s3c24xx/dma-s3c2410.c
Merge remote-tracking branch 'asoc/topic/ux500' into asoc-next
[karo-tx-linux.git] / arch / arm / mach-s3c24xx / dma-s3c2410.c
1 /* linux/arch/arm/mach-s3c2410/dma.c
2  *
3  * Copyright (c) 2006 Simtec Electronics
4  *      Ben Dooks <ben@simtec.co.uk>
5  *
6  * S3C2410 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/device.h>
18 #include <linux/serial_core.h>
19
20 #include <mach/map.h>
21 #include <mach/dma.h>
22
23 #include <plat/cpu.h>
24 #include <plat/dma-s3c24xx.h>
25
26 #include <plat/regs-serial.h>
27 #include <mach/regs-gpio.h>
28 #include <plat/regs-dma.h>
29 #include <mach/regs-lcd.h>
30 #include <mach/regs-sdi.h>
31 #include <plat/regs-spi.h>
32
33 static struct s3c24xx_dma_map __initdata s3c2410_dma_mappings[] = {
34         [DMACH_XD0] = {
35                 .name           = "xdreq0",
36                 .channels[0]    = S3C2410_DCON_CH0_XDREQ0 | DMA_CH_VALID,
37         },
38         [DMACH_XD1] = {
39                 .name           = "xdreq1",
40                 .channels[1]    = S3C2410_DCON_CH1_XDREQ1 | DMA_CH_VALID,
41         },
42         [DMACH_SDI] = {
43                 .name           = "sdi",
44                 .channels[0]    = S3C2410_DCON_CH0_SDI | DMA_CH_VALID,
45                 .channels[2]    = S3C2410_DCON_CH2_SDI | DMA_CH_VALID,
46                 .channels[3]    = S3C2410_DCON_CH3_SDI | DMA_CH_VALID,
47         },
48         [DMACH_SPI0] = {
49                 .name           = "spi0",
50                 .channels[1]    = S3C2410_DCON_CH1_SPI | DMA_CH_VALID,
51         },
52         [DMACH_SPI1] = {
53                 .name           = "spi1",
54                 .channels[3]    = S3C2410_DCON_CH3_SPI | DMA_CH_VALID,
55         },
56         [DMACH_UART0] = {
57                 .name           = "uart0",
58                 .channels[0]    = S3C2410_DCON_CH0_UART0 | DMA_CH_VALID,
59         },
60         [DMACH_UART1] = {
61                 .name           = "uart1",
62                 .channels[1]    = S3C2410_DCON_CH1_UART1 | DMA_CH_VALID,
63         },
64         [DMACH_UART2] = {
65                 .name           = "uart2",
66                 .channels[3]    = S3C2410_DCON_CH3_UART2 | DMA_CH_VALID,
67         },
68         [DMACH_TIMER] = {
69                 .name           = "timer",
70                 .channels[0]    = S3C2410_DCON_CH0_TIMER | DMA_CH_VALID,
71                 .channels[2]    = S3C2410_DCON_CH2_TIMER | DMA_CH_VALID,
72                 .channels[3]    = S3C2410_DCON_CH3_TIMER | DMA_CH_VALID,
73         },
74         [DMACH_I2S_IN] = {
75                 .name           = "i2s-sdi",
76                 .channels[1]    = S3C2410_DCON_CH1_I2SSDI | DMA_CH_VALID,
77                 .channels[2]    = S3C2410_DCON_CH2_I2SSDI | DMA_CH_VALID,
78         },
79         [DMACH_I2S_OUT] = {
80                 .name           = "i2s-sdo",
81                 .channels[2]    = S3C2410_DCON_CH2_I2SSDO | DMA_CH_VALID,
82         },
83         [DMACH_USB_EP1] = {
84                 .name           = "usb-ep1",
85                 .channels[0]    = S3C2410_DCON_CH0_USBEP1 | DMA_CH_VALID,
86         },
87         [DMACH_USB_EP2] = {
88                 .name           = "usb-ep2",
89                 .channels[1]    = S3C2410_DCON_CH1_USBEP2 | DMA_CH_VALID,
90         },
91         [DMACH_USB_EP3] = {
92                 .name           = "usb-ep3",
93                 .channels[2]    = S3C2410_DCON_CH2_USBEP3 | DMA_CH_VALID,
94         },
95         [DMACH_USB_EP4] = {
96                 .name           = "usb-ep4",
97                 .channels[3]    =S3C2410_DCON_CH3_USBEP4 | DMA_CH_VALID,
98         },
99 };
100
101 static void s3c2410_dma_select(struct s3c2410_dma_chan *chan,
102                                struct s3c24xx_dma_map *map)
103 {
104         chan->dcon = map->channels[chan->number] & ~DMA_CH_VALID;
105 }
106
107 static struct s3c24xx_dma_selection __initdata s3c2410_dma_sel = {
108         .select         = s3c2410_dma_select,
109         .dcon_mask      = 7 << 24,
110         .map            = s3c2410_dma_mappings,
111         .map_size       = ARRAY_SIZE(s3c2410_dma_mappings),
112 };
113
114 static struct s3c24xx_dma_order __initdata s3c2410_dma_order = {
115         .channels       = {
116                 [DMACH_SDI]     = {
117                         .list   = {
118                                 [0]     = 3 | DMA_CH_VALID,
119                                 [1]     = 2 | DMA_CH_VALID,
120                                 [2]     = 0 | DMA_CH_VALID,
121                         },
122                 },
123                 [DMACH_I2S_IN]  = {
124                         .list   = {
125                                 [0]     = 1 | DMA_CH_VALID,
126                                 [1]     = 2 | DMA_CH_VALID,
127                         },
128                 },
129         },
130 };
131
132 static int __init s3c2410_dma_add(struct device *dev,
133                                   struct subsys_interface *sif)
134 {
135         s3c2410_dma_init();
136         s3c24xx_dma_order_set(&s3c2410_dma_order);
137         return s3c24xx_dma_init_map(&s3c2410_dma_sel);
138 }
139
140 #if defined(CONFIG_CPU_S3C2410)
141 static struct subsys_interface s3c2410_dma_interface = {
142         .name           = "s3c2410_dma",
143         .subsys         = &s3c2410_subsys,
144         .add_dev        = s3c2410_dma_add,
145 };
146
147 static int __init s3c2410_dma_drvinit(void)
148 {
149         return subsys_interface_register(&s3c2410_dma_interface);
150 }
151
152 arch_initcall(s3c2410_dma_drvinit);
153
154 static struct subsys_interface s3c2410a_dma_interface = {
155         .name           = "s3c2410a_dma",
156         .subsys         = &s3c2410a_subsys,
157         .add_dev        = s3c2410_dma_add,
158 };
159
160 static int __init s3c2410a_dma_drvinit(void)
161 {
162         return subsys_interface_register(&s3c2410a_dma_interface);
163 }
164
165 arch_initcall(s3c2410a_dma_drvinit);
166 #endif
167
168 #if defined(CONFIG_CPU_S3C2442)
169 /* S3C2442 DMA contains the same selection table as the S3C2410 */
170 static struct subsys_interface s3c2442_dma_interface = {
171         .name           = "s3c2442_dma",
172         .subsys         = &s3c2442_subsys,
173         .add_dev        = s3c2410_dma_add,
174 };
175
176 static int __init s3c2442_dma_drvinit(void)
177 {
178         return subsys_interface_register(&s3c2442_dma_interface);
179 }
180
181 arch_initcall(s3c2442_dma_drvinit);
182 #endif
183