Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2412/dma.c |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 2 | * |
Ben Dooks | c16f7bd | 2006-12-17 20:05:21 +0100 | [diff] [blame] | 3 | * Copyright (c) 2006 Simtec Electronics |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 4 | * 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 Dooks | b6d1f54 | 2006-12-17 23:22:26 +0100 | [diff] [blame] | 18 | #include <linux/serial_core.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 19 | #include <linux/io.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 20 | |
| 21 | #include <asm/dma.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 22 | #include <mach/dma.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 23 | |
Ben Dooks | d5120ae | 2008-10-07 23:09:51 +0100 | [diff] [blame] | 24 | #include <plat/dma.h> |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 25 | #include <plat/cpu.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 26 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 27 | #include <plat/regs-serial.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/regs-gpio.h> |
Ben Dooks | 06cfa55 | 2007-07-22 16:23:02 +0100 | [diff] [blame] | 29 | #include <asm/plat-s3c/regs-ac97.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | #include <mach/regs-mem.h> |
| 31 | #include <mach/regs-lcd.h> |
| 32 | #include <mach/regs-sdi.h> |
Ben Dooks | d45c30c | 2007-12-23 03:09:40 +0100 | [diff] [blame] | 33 | #include <asm/plat-s3c24xx/regs-s3c2412-iis.h> |
Ben Dooks | 06cfa55 | 2007-07-22 16:23:02 +0100 | [diff] [blame] | 34 | #include <asm/plat-s3c24xx/regs-iis.h> |
| 35 | #include <asm/plat-s3c24xx/regs-spi.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 36 | |
| 37 | #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID } |
| 38 | |
| 39 | static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = { |
| 40 | [DMACH_XD0] = { |
| 41 | .name = "xdreq0", |
| 42 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 43 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 44 | }, |
| 45 | [DMACH_XD1] = { |
| 46 | .name = "xdreq1", |
| 47 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 48 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 49 | }, |
| 50 | [DMACH_SDI] = { |
| 51 | .name = "sdi", |
| 52 | .channels = MAP(S3C2412_DMAREQSEL_SDI), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 53 | .channels_rx = MAP(S3C2412_DMAREQSEL_SDI), |
Ben Dooks | d45c30c | 2007-12-23 03:09:40 +0100 | [diff] [blame] | 54 | .hw_addr.to = S3C2410_PA_SDI + S3C2410_SDIDATA, |
| 55 | .hw_addr.from = S3C2410_PA_SDI + S3C2410_SDIDATA, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 56 | }, |
| 57 | [DMACH_SPI0] = { |
| 58 | .name = "spi0", |
| 59 | .channels = MAP(S3C2412_DMAREQSEL_SPI0TX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 60 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 61 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 67 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX), |
Sandeep Sanjay Patil | e903382 | 2007-05-16 10:51:45 +0100 | [diff] [blame] | 68 | .hw_addr.to = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPTDAT, |
| 69 | .hw_addr.from = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPRDAT, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 70 | }, |
| 71 | [DMACH_UART0] = { |
| 72 | .name = "uart0", |
| 73 | .channels = MAP(S3C2412_DMAREQSEL_UART0_0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 74 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 75 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 81 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 82 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 88 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 89 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 95 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 96 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 102 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 103 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 109 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 110 | .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 Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 116 | .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 117 | }, |
| 118 | [DMACH_I2S_IN] = { |
| 119 | .name = "i2s-sdi", |
| 120 | .channels = MAP(S3C2412_DMAREQSEL_I2SRX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 121 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX), |
Ben Dooks | d45c30c | 2007-12-23 03:09:40 +0100 | [diff] [blame] | 122 | .hw_addr.from = S3C2410_PA_IIS + S3C2412_IISRXD, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 123 | }, |
| 124 | [DMACH_I2S_OUT] = { |
| 125 | .name = "i2s-sdo", |
| 126 | .channels = MAP(S3C2412_DMAREQSEL_I2STX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 127 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX), |
Ben Dooks | d45c30c | 2007-12-23 03:09:40 +0100 | [diff] [blame] | 128 | .hw_addr.to = S3C2410_PA_IIS + S3C2412_IISTXD, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 129 | }, |
| 130 | [DMACH_USB_EP1] = { |
| 131 | .name = "usb-ep1", |
| 132 | .channels = MAP(S3C2412_DMAREQSEL_USBEP1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 133 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 134 | }, |
| 135 | [DMACH_USB_EP2] = { |
| 136 | .name = "usb-ep2", |
| 137 | .channels = MAP(S3C2412_DMAREQSEL_USBEP2), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 138 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 139 | }, |
| 140 | [DMACH_USB_EP3] = { |
| 141 | .name = "usb-ep3", |
| 142 | .channels = MAP(S3C2412_DMAREQSEL_USBEP3), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 143 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 144 | }, |
| 145 | [DMACH_USB_EP4] = { |
| 146 | .name = "usb-ep4", |
| 147 | .channels = MAP(S3C2412_DMAREQSEL_USBEP4), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 148 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 149 | }, |
| 150 | }; |
| 151 | |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 152 | static 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 Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 169 | static void s3c2412_dma_select(struct s3c2410_dma_chan *chan, |
| 170 | struct s3c24xx_dma_map *map) |
| 171 | { |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 172 | s3c2412_dma_direction(chan, map, chan->source); |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = { |
| 176 | .select = s3c2412_dma_select, |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 177 | .direction = s3c2412_dma_direction, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 178 | .dcon_mask = 0, |
| 179 | .map = s3c2412_dma_mappings, |
| 180 | .map_size = ARRAY_SIZE(s3c2412_dma_mappings), |
| 181 | }; |
| 182 | |
Krzysztof Helt | f2c10d6 | 2007-09-04 17:19:33 +0100 | [diff] [blame] | 183 | static int __init s3c2412_dma_add(struct sys_device *sysdev) |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 184 | { |
Ben Dooks | 48adbcf | 2007-02-17 15:37:14 +0100 | [diff] [blame] | 185 | s3c2410_dma_init(); |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 186 | return s3c24xx_dma_init_map(&s3c2412_dma_sel); |
| 187 | } |
| 188 | |
| 189 | static struct sysdev_driver s3c2412_dma_driver = { |
| 190 | .add = s3c2412_dma_add, |
| 191 | }; |
| 192 | |
| 193 | static int __init s3c2412_dma_init(void) |
| 194 | { |
| 195 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver); |
| 196 | } |
| 197 | |
| 198 | arch_initcall(s3c2412_dma_init); |