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> |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 17 | #include <linux/device.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 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 21 | #include <mach/dma.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 22 | |
Ben Dooks | 992426b | 2010-02-20 23:01:33 +0000 | [diff] [blame] | 23 | #include <plat/dma-s3c24xx.h> |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 24 | #include <plat/cpu.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 25 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 26 | #include <plat/regs-serial.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/regs-gpio.h> |
Ben Dooks | 44dc940 | 2009-03-19 15:02:35 +0000 | [diff] [blame] | 28 | #include <plat/regs-dma.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/regs-lcd.h> |
Ben Dooks | 1362270 | 2008-10-30 10:14:38 +0000 | [diff] [blame] | 30 | #include <plat/regs-spi.h> |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 31 | |
| 32 | #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID } |
| 33 | |
| 34 | static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = { |
| 35 | [DMACH_XD0] = { |
| 36 | .name = "xdreq0", |
| 37 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 38 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 39 | }, |
| 40 | [DMACH_XD1] = { |
| 41 | .name = "xdreq1", |
| 42 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 43 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 44 | }, |
| 45 | [DMACH_SDI] = { |
| 46 | .name = "sdi", |
| 47 | .channels = MAP(S3C2412_DMAREQSEL_SDI), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 48 | .channels_rx = MAP(S3C2412_DMAREQSEL_SDI), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 49 | }, |
| 50 | [DMACH_SPI0] = { |
| 51 | .name = "spi0", |
| 52 | .channels = MAP(S3C2412_DMAREQSEL_SPI0TX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 53 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 54 | }, |
| 55 | [DMACH_SPI1] = { |
| 56 | .name = "spi1", |
| 57 | .channels = MAP(S3C2412_DMAREQSEL_SPI1TX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 58 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 59 | }, |
| 60 | [DMACH_UART0] = { |
| 61 | .name = "uart0", |
| 62 | .channels = MAP(S3C2412_DMAREQSEL_UART0_0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 63 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 64 | }, |
| 65 | [DMACH_UART1] = { |
| 66 | .name = "uart1", |
| 67 | .channels = MAP(S3C2412_DMAREQSEL_UART1_0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 68 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 69 | }, |
| 70 | [DMACH_UART2] = { |
| 71 | .name = "uart2", |
| 72 | .channels = MAP(S3C2412_DMAREQSEL_UART2_0), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 73 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 74 | }, |
| 75 | [DMACH_UART0_SRC2] = { |
| 76 | .name = "uart0", |
| 77 | .channels = MAP(S3C2412_DMAREQSEL_UART0_1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 78 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 79 | }, |
| 80 | [DMACH_UART1_SRC2] = { |
| 81 | .name = "uart1", |
| 82 | .channels = MAP(S3C2412_DMAREQSEL_UART1_1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 83 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 84 | }, |
| 85 | [DMACH_UART2_SRC2] = { |
| 86 | .name = "uart2", |
| 87 | .channels = MAP(S3C2412_DMAREQSEL_UART2_1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 88 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 89 | }, |
| 90 | [DMACH_TIMER] = { |
| 91 | .name = "timer", |
| 92 | .channels = MAP(S3C2412_DMAREQSEL_TIMER), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 93 | .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 94 | }, |
| 95 | [DMACH_I2S_IN] = { |
| 96 | .name = "i2s-sdi", |
| 97 | .channels = MAP(S3C2412_DMAREQSEL_I2SRX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 98 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 99 | }, |
| 100 | [DMACH_I2S_OUT] = { |
| 101 | .name = "i2s-sdo", |
| 102 | .channels = MAP(S3C2412_DMAREQSEL_I2STX), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 103 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 104 | }, |
| 105 | [DMACH_USB_EP1] = { |
| 106 | .name = "usb-ep1", |
| 107 | .channels = MAP(S3C2412_DMAREQSEL_USBEP1), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 108 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 109 | }, |
| 110 | [DMACH_USB_EP2] = { |
| 111 | .name = "usb-ep2", |
| 112 | .channels = MAP(S3C2412_DMAREQSEL_USBEP2), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 113 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 114 | }, |
| 115 | [DMACH_USB_EP3] = { |
| 116 | .name = "usb-ep3", |
| 117 | .channels = MAP(S3C2412_DMAREQSEL_USBEP3), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 118 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 119 | }, |
| 120 | [DMACH_USB_EP4] = { |
| 121 | .name = "usb-ep4", |
| 122 | .channels = MAP(S3C2412_DMAREQSEL_USBEP4), |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 123 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4), |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 124 | }, |
| 125 | }; |
| 126 | |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 127 | static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan, |
| 128 | struct s3c24xx_dma_map *map, |
Boojin Kim | 51ddf31 | 2011-09-02 09:44:44 +0900 | [diff] [blame] | 129 | enum dma_data_direction dir) |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 130 | { |
| 131 | unsigned long chsel; |
| 132 | |
Boojin Kim | 51ddf31 | 2011-09-02 09:44:44 +0900 | [diff] [blame] | 133 | if (dir == DMA_FROM_DEVICE) |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 134 | 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 Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 144 | static void s3c2412_dma_select(struct s3c2410_dma_chan *chan, |
| 145 | struct s3c24xx_dma_map *map) |
| 146 | { |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 147 | s3c2412_dma_direction(chan, map, chan->source); |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = { |
| 151 | .select = s3c2412_dma_select, |
Ben Dooks | c6709e8 | 2008-01-28 13:01:20 +0100 | [diff] [blame] | 152 | .direction = s3c2412_dma_direction, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 153 | .dcon_mask = 0, |
| 154 | .map = s3c2412_dma_mappings, |
| 155 | .map_size = ARRAY_SIZE(s3c2412_dma_mappings), |
| 156 | }; |
| 157 | |
Heiko Stuebner | 04511a6 | 2012-01-27 15:35:25 +0900 | [diff] [blame] | 158 | static int __init s3c2412_dma_add(struct device *dev, |
| 159 | struct subsys_interface *sif) |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 160 | { |
Ben Dooks | 48adbcf | 2007-02-17 15:37:14 +0100 | [diff] [blame] | 161 | s3c2410_dma_init(); |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 162 | return s3c24xx_dma_init_map(&s3c2412_dma_sel); |
| 163 | } |
| 164 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 165 | static struct subsys_interface s3c2412_dma_interface = { |
| 166 | .name = "s3c2412_dma", |
| 167 | .subsys = &s3c2412_subsys, |
| 168 | .add_dev = s3c2412_dma_add, |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | static int __init s3c2412_dma_init(void) |
| 172 | { |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 173 | return subsys_interface_register(&s3c2412_dma_interface); |
Ben Dooks | 3434801 | 2006-09-18 23:52:03 +0100 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | arch_initcall(s3c2412_dma_init); |