G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * OMAP2+ DMA driver |
| 3 | * |
| 4 | * Copyright (C) 2003 - 2008 Nokia Corporation |
| 5 | * Author: Juha Yrjölä <juha.yrjola@nokia.com> |
| 6 | * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com> |
| 7 | * Graphics DMA and LCD DMA graphics tranformations |
| 8 | * by Imre Deak <imre.deak@nokia.com> |
| 9 | * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc. |
| 10 | * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc. |
| 11 | * |
| 12 | * Copyright (C) 2009 Texas Instruments |
| 13 | * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 14 | * |
| 15 | * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ |
| 16 | * Converted DMA library into platform driver |
| 17 | * - G, Manjunath Kondaiah <manjugk@ti.com> |
| 18 | * |
| 19 | * This program is free software; you can redistribute it and/or modify |
| 20 | * it under the terms of the GNU General Public License version 2 as |
| 21 | * published by the Free Software Foundation. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/err.h> |
| 25 | #include <linux/io.h> |
| 26 | #include <linux/slab.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/device.h> |
Tony Lindgren | be1f948 | 2013-01-11 11:24:19 -0800 | [diff] [blame] | 30 | #include <linux/dma-mapping.h> |
Peter Ujfalusi | 731ec4d | 2016-02-02 16:27:07 +0200 | [diff] [blame] | 31 | #include <linux/dmaengine.h> |
Jon Hunter | 8d30662 | 2013-02-26 12:27:24 -0600 | [diff] [blame] | 32 | #include <linux/of.h> |
Tony Lindgren | 45c3eb7 | 2012-11-30 08:41:50 -0800 | [diff] [blame] | 33 | #include <linux/omap-dma.h> |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 34 | |
Tony Lindgren | e4c060d | 2012-10-05 13:25:59 -0700 | [diff] [blame] | 35 | #include "soc.h" |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 36 | #include "omap_hwmod.h" |
Tony Lindgren | 25c7d49 | 2012-10-02 17:25:48 -0700 | [diff] [blame] | 37 | #include "omap_device.h" |
| 38 | |
Russell King | ad0c381 | 2013-11-08 14:53:35 +0000 | [diff] [blame] | 39 | static enum omap_reg_offsets dma_common_ch_end; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 40 | |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 41 | static const struct omap_dma_reg reg_map[] = { |
| 42 | [REVISION] = { 0x0000, 0x00, OMAP_DMA_REG_32BIT }, |
| 43 | [GCR] = { 0x0078, 0x00, OMAP_DMA_REG_32BIT }, |
| 44 | [IRQSTATUS_L0] = { 0x0008, 0x00, OMAP_DMA_REG_32BIT }, |
| 45 | [IRQSTATUS_L1] = { 0x000c, 0x00, OMAP_DMA_REG_32BIT }, |
| 46 | [IRQSTATUS_L2] = { 0x0010, 0x00, OMAP_DMA_REG_32BIT }, |
| 47 | [IRQSTATUS_L3] = { 0x0014, 0x00, OMAP_DMA_REG_32BIT }, |
| 48 | [IRQENABLE_L0] = { 0x0018, 0x00, OMAP_DMA_REG_32BIT }, |
| 49 | [IRQENABLE_L1] = { 0x001c, 0x00, OMAP_DMA_REG_32BIT }, |
| 50 | [IRQENABLE_L2] = { 0x0020, 0x00, OMAP_DMA_REG_32BIT }, |
| 51 | [IRQENABLE_L3] = { 0x0024, 0x00, OMAP_DMA_REG_32BIT }, |
| 52 | [SYSSTATUS] = { 0x0028, 0x00, OMAP_DMA_REG_32BIT }, |
| 53 | [OCP_SYSCONFIG] = { 0x002c, 0x00, OMAP_DMA_REG_32BIT }, |
| 54 | [CAPS_0] = { 0x0064, 0x00, OMAP_DMA_REG_32BIT }, |
| 55 | [CAPS_2] = { 0x006c, 0x00, OMAP_DMA_REG_32BIT }, |
| 56 | [CAPS_3] = { 0x0070, 0x00, OMAP_DMA_REG_32BIT }, |
| 57 | [CAPS_4] = { 0x0074, 0x00, OMAP_DMA_REG_32BIT }, |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 58 | |
| 59 | /* Common register offsets */ |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 60 | [CCR] = { 0x0080, 0x60, OMAP_DMA_REG_32BIT }, |
| 61 | [CLNK_CTRL] = { 0x0084, 0x60, OMAP_DMA_REG_32BIT }, |
| 62 | [CICR] = { 0x0088, 0x60, OMAP_DMA_REG_32BIT }, |
| 63 | [CSR] = { 0x008c, 0x60, OMAP_DMA_REG_32BIT }, |
| 64 | [CSDP] = { 0x0090, 0x60, OMAP_DMA_REG_32BIT }, |
| 65 | [CEN] = { 0x0094, 0x60, OMAP_DMA_REG_32BIT }, |
| 66 | [CFN] = { 0x0098, 0x60, OMAP_DMA_REG_32BIT }, |
| 67 | [CSEI] = { 0x00a4, 0x60, OMAP_DMA_REG_32BIT }, |
| 68 | [CSFI] = { 0x00a8, 0x60, OMAP_DMA_REG_32BIT }, |
| 69 | [CDEI] = { 0x00ac, 0x60, OMAP_DMA_REG_32BIT }, |
| 70 | [CDFI] = { 0x00b0, 0x60, OMAP_DMA_REG_32BIT }, |
| 71 | [CSAC] = { 0x00b4, 0x60, OMAP_DMA_REG_32BIT }, |
| 72 | [CDAC] = { 0x00b8, 0x60, OMAP_DMA_REG_32BIT }, |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 73 | |
| 74 | /* Channel specific register offsets */ |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 75 | [CSSA] = { 0x009c, 0x60, OMAP_DMA_REG_32BIT }, |
| 76 | [CDSA] = { 0x00a0, 0x60, OMAP_DMA_REG_32BIT }, |
| 77 | [CCEN] = { 0x00bc, 0x60, OMAP_DMA_REG_32BIT }, |
| 78 | [CCFN] = { 0x00c0, 0x60, OMAP_DMA_REG_32BIT }, |
| 79 | [COLOR] = { 0x00c4, 0x60, OMAP_DMA_REG_32BIT }, |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 80 | |
| 81 | /* OMAP4 specific registers */ |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 82 | [CDP] = { 0x00d0, 0x60, OMAP_DMA_REG_32BIT }, |
| 83 | [CNDP] = { 0x00d4, 0x60, OMAP_DMA_REG_32BIT }, |
| 84 | [CCDN] = { 0x00d8, 0x60, OMAP_DMA_REG_32BIT }, |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 85 | }; |
| 86 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 87 | static void __iomem *dma_base; |
| 88 | static inline void dma_write(u32 val, int reg, int lch) |
| 89 | { |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 90 | void __iomem *addr = dma_base; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 91 | |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 92 | addr += reg_map[reg].offset; |
| 93 | addr += reg_map[reg].stride * lch; |
| 94 | |
Victor Kamensky | edfaf05 | 2014-04-15 20:37:46 +0300 | [diff] [blame] | 95 | writel_relaxed(val, addr); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static inline u32 dma_read(int reg, int lch) |
| 99 | { |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 100 | void __iomem *addr = dma_base; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 101 | |
Russell King | 64a2dc3 | 2013-11-08 18:04:06 +0000 | [diff] [blame] | 102 | addr += reg_map[reg].offset; |
| 103 | addr += reg_map[reg].stride * lch; |
| 104 | |
Victor Kamensky | edfaf05 | 2014-04-15 20:37:46 +0300 | [diff] [blame] | 105 | return readl_relaxed(addr); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 106 | } |
| 107 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 108 | static void omap2_clear_dma(int lch) |
| 109 | { |
Russell King | ad0c381 | 2013-11-08 14:53:35 +0000 | [diff] [blame] | 110 | int i; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 111 | |
Russell King | ad0c381 | 2013-11-08 14:53:35 +0000 | [diff] [blame] | 112 | for (i = CSDP; i <= dma_common_ch_end; i += 1) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 113 | dma_write(0, i, lch); |
| 114 | } |
| 115 | |
| 116 | static void omap2_show_dma_caps(void) |
| 117 | { |
| 118 | u8 revision = dma_read(REVISION, 0) & 0xff; |
| 119 | printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n", |
| 120 | revision >> 4, revision & 0xf); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 121 | } |
| 122 | |
Russell King | 0ef6498 | 2013-11-08 18:06:37 +0000 | [diff] [blame] | 123 | static unsigned configure_dma_errata(void) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 124 | { |
Russell King | 0ef6498 | 2013-11-08 18:06:37 +0000 | [diff] [blame] | 125 | unsigned errata = 0; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Errata applicable for OMAP2430ES1.0 and all omap2420 |
| 129 | * |
| 130 | * I. |
| 131 | * Erratum ID: Not Available |
| 132 | * Inter Frame DMA buffering issue DMA will wrongly |
| 133 | * buffer elements if packing and bursting is enabled. This might |
| 134 | * result in data gets stalled in FIFO at the end of the block. |
| 135 | * Workaround: DMA channels must have BUFFERING_DISABLED bit set to |
| 136 | * guarantee no data will stay in the DMA FIFO in case inter frame |
| 137 | * buffering occurs |
| 138 | * |
| 139 | * II. |
| 140 | * Erratum ID: Not Available |
| 141 | * DMA may hang when several channels are used in parallel |
| 142 | * In the following configuration, DMA channel hanging can occur: |
| 143 | * a. Channel i, hardware synchronized, is enabled |
| 144 | * b. Another channel (Channel x), software synchronized, is enabled. |
| 145 | * c. Channel i is disabled before end of transfer |
| 146 | * d. Channel i is reenabled. |
| 147 | * e. Steps 1 to 4 are repeated a certain number of times. |
| 148 | * f. A third channel (Channel y), software synchronized, is enabled. |
| 149 | * Channel x and Channel y may hang immediately after step 'f'. |
| 150 | * Workaround: |
| 151 | * For any channel used - make sure NextLCH_ID is set to the value j. |
| 152 | */ |
| 153 | if (cpu_is_omap2420() || (cpu_is_omap2430() && |
| 154 | (omap_type() == OMAP2430_REV_ES1_0))) { |
| 155 | |
| 156 | SET_DMA_ERRATA(DMA_ERRATA_IFRAME_BUFFERING); |
| 157 | SET_DMA_ERRATA(DMA_ERRATA_PARALLEL_CHANNELS); |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * Erratum ID: i378: OMAP2+: sDMA Channel is not disabled |
| 162 | * after a transaction error. |
| 163 | * Workaround: SW should explicitely disable the channel. |
| 164 | */ |
| 165 | if (cpu_class_is_omap2()) |
| 166 | SET_DMA_ERRATA(DMA_ERRATA_i378); |
| 167 | |
| 168 | /* |
| 169 | * Erratum ID: i541: sDMA FIFO draining does not finish |
| 170 | * If sDMA channel is disabled on the fly, sDMA enters standby even |
| 171 | * through FIFO Drain is still in progress |
| 172 | * Workaround: Put sDMA in NoStandby more before a logical channel is |
| 173 | * disabled, then put it back to SmartStandby right after the channel |
| 174 | * finishes FIFO draining. |
| 175 | */ |
| 176 | if (cpu_is_omap34xx()) |
| 177 | SET_DMA_ERRATA(DMA_ERRATA_i541); |
| 178 | |
| 179 | /* |
| 180 | * Erratum ID: i88 : Special programming model needed to disable DMA |
| 181 | * before end of block. |
| 182 | * Workaround: software must ensure that the DMA is configured in No |
| 183 | * Standby mode(DMAx_OCP_SYSCONFIG.MIDLEMODE = "01") |
| 184 | */ |
| 185 | if (omap_type() == OMAP3430_REV_ES1_0) |
| 186 | SET_DMA_ERRATA(DMA_ERRATA_i88); |
| 187 | |
| 188 | /* |
| 189 | * Erratum 3.2/3.3: sometimes 0 is returned if CSAC/CDAC is |
| 190 | * read before the DMA controller finished disabling the channel. |
| 191 | */ |
| 192 | SET_DMA_ERRATA(DMA_ERRATA_3_3); |
| 193 | |
| 194 | /* |
| 195 | * Erratum ID: Not Available |
| 196 | * A bug in ROM code leaves IRQ status for channels 0 and 1 uncleared |
| 197 | * after secure sram context save and restore. |
| 198 | * Work around: Hence we need to manually clear those IRQs to avoid |
| 199 | * spurious interrupts. This affects only secure devices. |
| 200 | */ |
| 201 | if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP)) |
| 202 | SET_DMA_ERRATA(DMA_ROMCODE_BUG); |
| 203 | |
| 204 | return errata; |
| 205 | } |
| 206 | |
Peter Ujfalusi | 731ec4d | 2016-02-02 16:27:07 +0200 | [diff] [blame] | 207 | static const struct dma_slave_map omap24xx_sdma_map[] = { |
| 208 | { "omap-gpmc", "rxtx", SDMA_FILTER_PARAM(4) }, |
| 209 | { "omap-aes", "tx", SDMA_FILTER_PARAM(9) }, |
| 210 | { "omap-aes", "rx", SDMA_FILTER_PARAM(10) }, |
| 211 | { "omap-sham", "rx", SDMA_FILTER_PARAM(13) }, |
| 212 | { "omap2_mcspi.2", "tx0", SDMA_FILTER_PARAM(15) }, |
| 213 | { "omap2_mcspi.2", "rx0", SDMA_FILTER_PARAM(16) }, |
| 214 | { "omap-mcbsp.3", "tx", SDMA_FILTER_PARAM(17) }, |
| 215 | { "omap-mcbsp.3", "rx", SDMA_FILTER_PARAM(18) }, |
| 216 | { "omap-mcbsp.4", "tx", SDMA_FILTER_PARAM(19) }, |
| 217 | { "omap-mcbsp.4", "rx", SDMA_FILTER_PARAM(20) }, |
| 218 | { "omap-mcbsp.5", "tx", SDMA_FILTER_PARAM(21) }, |
| 219 | { "omap-mcbsp.5", "rx", SDMA_FILTER_PARAM(22) }, |
| 220 | { "omap2_mcspi.2", "tx1", SDMA_FILTER_PARAM(23) }, |
| 221 | { "omap2_mcspi.2", "rx1", SDMA_FILTER_PARAM(24) }, |
| 222 | { "omap_i2c.1", "tx", SDMA_FILTER_PARAM(27) }, |
| 223 | { "omap_i2c.1", "rx", SDMA_FILTER_PARAM(28) }, |
| 224 | { "omap_i2c.2", "tx", SDMA_FILTER_PARAM(29) }, |
| 225 | { "omap_i2c.2", "rx", SDMA_FILTER_PARAM(30) }, |
| 226 | { "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(31) }, |
| 227 | { "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(32) }, |
| 228 | { "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(33) }, |
| 229 | { "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(34) }, |
| 230 | { "omap2_mcspi.0", "tx0", SDMA_FILTER_PARAM(35) }, |
| 231 | { "omap2_mcspi.0", "rx0", SDMA_FILTER_PARAM(36) }, |
| 232 | { "omap2_mcspi.0", "tx1", SDMA_FILTER_PARAM(37) }, |
| 233 | { "omap2_mcspi.0", "rx1", SDMA_FILTER_PARAM(38) }, |
| 234 | { "omap2_mcspi.0", "tx2", SDMA_FILTER_PARAM(39) }, |
| 235 | { "omap2_mcspi.0", "rx2", SDMA_FILTER_PARAM(40) }, |
| 236 | { "omap2_mcspi.0", "tx3", SDMA_FILTER_PARAM(41) }, |
| 237 | { "omap2_mcspi.0", "rx3", SDMA_FILTER_PARAM(42) }, |
| 238 | { "omap2_mcspi.1", "tx0", SDMA_FILTER_PARAM(43) }, |
| 239 | { "omap2_mcspi.1", "rx0", SDMA_FILTER_PARAM(44) }, |
| 240 | { "omap2_mcspi.1", "tx1", SDMA_FILTER_PARAM(45) }, |
| 241 | { "omap2_mcspi.1", "rx1", SDMA_FILTER_PARAM(46) }, |
| 242 | { "omap_hsmmc.1", "tx", SDMA_FILTER_PARAM(47) }, |
| 243 | { "omap_hsmmc.1", "rx", SDMA_FILTER_PARAM(48) }, |
| 244 | { "omap_uart.0", "tx", SDMA_FILTER_PARAM(49) }, |
| 245 | { "omap_uart.0", "rx", SDMA_FILTER_PARAM(50) }, |
| 246 | { "omap_uart.1", "tx", SDMA_FILTER_PARAM(51) }, |
| 247 | { "omap_uart.1", "rx", SDMA_FILTER_PARAM(52) }, |
| 248 | { "omap_uart.2", "tx", SDMA_FILTER_PARAM(53) }, |
| 249 | { "omap_uart.2", "rx", SDMA_FILTER_PARAM(54) }, |
| 250 | { "omap_hsmmc.0", "tx", SDMA_FILTER_PARAM(61) }, |
| 251 | { "omap_hsmmc.0", "rx", SDMA_FILTER_PARAM(62) }, |
| 252 | }; |
| 253 | |
| 254 | static const struct dma_slave_map omap3xxx_sdma_map[] = { |
| 255 | { "omap-gpmc", "rxtx", SDMA_FILTER_PARAM(4) }, |
| 256 | { "omap2_mcspi.2", "tx0", SDMA_FILTER_PARAM(15) }, |
| 257 | { "omap2_mcspi.2", "rx0", SDMA_FILTER_PARAM(16) }, |
| 258 | { "omap-mcbsp.3", "tx", SDMA_FILTER_PARAM(17) }, |
| 259 | { "omap-mcbsp.3", "rx", SDMA_FILTER_PARAM(18) }, |
| 260 | { "omap-mcbsp.4", "tx", SDMA_FILTER_PARAM(19) }, |
| 261 | { "omap-mcbsp.4", "rx", SDMA_FILTER_PARAM(20) }, |
| 262 | { "omap-mcbsp.5", "tx", SDMA_FILTER_PARAM(21) }, |
| 263 | { "omap-mcbsp.5", "rx", SDMA_FILTER_PARAM(22) }, |
| 264 | { "omap2_mcspi.2", "tx1", SDMA_FILTER_PARAM(23) }, |
| 265 | { "omap2_mcspi.2", "rx1", SDMA_FILTER_PARAM(24) }, |
| 266 | { "omap_i2c.3", "tx", SDMA_FILTER_PARAM(25) }, |
| 267 | { "omap_i2c.3", "rx", SDMA_FILTER_PARAM(26) }, |
| 268 | { "omap_i2c.1", "tx", SDMA_FILTER_PARAM(27) }, |
| 269 | { "omap_i2c.1", "rx", SDMA_FILTER_PARAM(28) }, |
| 270 | { "omap_i2c.2", "tx", SDMA_FILTER_PARAM(29) }, |
| 271 | { "omap_i2c.2", "rx", SDMA_FILTER_PARAM(30) }, |
| 272 | { "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(31) }, |
| 273 | { "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(32) }, |
| 274 | { "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(33) }, |
| 275 | { "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(34) }, |
| 276 | { "omap2_mcspi.0", "tx0", SDMA_FILTER_PARAM(35) }, |
| 277 | { "omap2_mcspi.0", "rx0", SDMA_FILTER_PARAM(36) }, |
| 278 | { "omap2_mcspi.0", "tx1", SDMA_FILTER_PARAM(37) }, |
| 279 | { "omap2_mcspi.0", "rx1", SDMA_FILTER_PARAM(38) }, |
| 280 | { "omap2_mcspi.0", "tx2", SDMA_FILTER_PARAM(39) }, |
| 281 | { "omap2_mcspi.0", "rx2", SDMA_FILTER_PARAM(40) }, |
| 282 | { "omap2_mcspi.0", "tx3", SDMA_FILTER_PARAM(41) }, |
| 283 | { "omap2_mcspi.0", "rx3", SDMA_FILTER_PARAM(42) }, |
| 284 | { "omap2_mcspi.1", "tx0", SDMA_FILTER_PARAM(43) }, |
| 285 | { "omap2_mcspi.1", "rx0", SDMA_FILTER_PARAM(44) }, |
| 286 | { "omap2_mcspi.1", "tx1", SDMA_FILTER_PARAM(45) }, |
| 287 | { "omap2_mcspi.1", "rx1", SDMA_FILTER_PARAM(46) }, |
| 288 | { "omap_hsmmc.1", "tx", SDMA_FILTER_PARAM(47) }, |
| 289 | { "omap_hsmmc.1", "rx", SDMA_FILTER_PARAM(48) }, |
| 290 | { "omap_uart.0", "tx", SDMA_FILTER_PARAM(49) }, |
| 291 | { "omap_uart.0", "rx", SDMA_FILTER_PARAM(50) }, |
| 292 | { "omap_uart.1", "tx", SDMA_FILTER_PARAM(51) }, |
| 293 | { "omap_uart.1", "rx", SDMA_FILTER_PARAM(52) }, |
| 294 | { "omap_uart.2", "tx", SDMA_FILTER_PARAM(53) }, |
| 295 | { "omap_uart.2", "rx", SDMA_FILTER_PARAM(54) }, |
| 296 | { "omap_hsmmc.0", "tx", SDMA_FILTER_PARAM(61) }, |
| 297 | { "omap_hsmmc.0", "rx", SDMA_FILTER_PARAM(62) }, |
| 298 | { "omap-aes", "tx", SDMA_FILTER_PARAM(65) }, |
| 299 | { "omap-aes", "rx", SDMA_FILTER_PARAM(66) }, |
| 300 | { "omap-sham", "rx", SDMA_FILTER_PARAM(69) }, |
| 301 | { "omap2_mcspi.3", "tx0", SDMA_FILTER_PARAM(70) }, |
| 302 | { "omap2_mcspi.3", "rx0", SDMA_FILTER_PARAM(71) }, |
| 303 | { "omap_hsmmc.2", "tx", SDMA_FILTER_PARAM(77) }, |
| 304 | { "omap_hsmmc.2", "rx", SDMA_FILTER_PARAM(78) }, |
| 305 | { "omap_uart.3", "tx", SDMA_FILTER_PARAM(81) }, |
| 306 | { "omap_uart.3", "rx", SDMA_FILTER_PARAM(82) }, |
| 307 | }; |
| 308 | |
Russell King | 34a378f | 2013-11-08 18:21:35 +0000 | [diff] [blame] | 309 | static struct omap_system_dma_plat_info dma_plat_info __initdata = { |
Russell King | 596c471 | 2013-12-10 11:08:01 +0000 | [diff] [blame] | 310 | .reg_map = reg_map, |
| 311 | .channel_stride = 0x60, |
Russell King | 34a378f | 2013-11-08 18:21:35 +0000 | [diff] [blame] | 312 | .show_dma_caps = omap2_show_dma_caps, |
| 313 | .clear_dma = omap2_clear_dma, |
| 314 | .dma_write = dma_write, |
| 315 | .dma_read = dma_read, |
| 316 | }; |
| 317 | |
Russell King | 596c471 | 2013-12-10 11:08:01 +0000 | [diff] [blame] | 318 | static struct platform_device_info omap_dma_dev_info = { |
| 319 | .name = "omap-dma-engine", |
| 320 | .id = -1, |
| 321 | .dma_mask = DMA_BIT_MASK(32), |
| 322 | }; |
| 323 | |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 324 | /* One time initializations */ |
| 325 | static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused) |
| 326 | { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 327 | struct platform_device *pdev; |
Russell King | 34a378f | 2013-11-08 18:21:35 +0000 | [diff] [blame] | 328 | struct omap_system_dma_plat_info p; |
| 329 | struct omap_dma_dev_attr *d; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 330 | struct resource *mem; |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 331 | char *name = "omap_dma_system"; |
| 332 | |
Russell King | 34a378f | 2013-11-08 18:21:35 +0000 | [diff] [blame] | 333 | p = dma_plat_info; |
| 334 | p.dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr; |
| 335 | p.errata = configure_dma_errata(); |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 336 | |
Peter Ujfalusi | 731ec4d | 2016-02-02 16:27:07 +0200 | [diff] [blame] | 337 | if (!of_have_populated_dt()) { |
| 338 | if (soc_is_omap24xx()) { |
| 339 | p.slave_map = omap24xx_sdma_map; |
| 340 | p.slavecnt = ARRAY_SIZE(omap24xx_sdma_map); |
| 341 | } else if (soc_is_omap34xx() || soc_is_omap3630()) { |
| 342 | p.slave_map = omap3xxx_sdma_map; |
| 343 | p.slavecnt = ARRAY_SIZE(omap3xxx_sdma_map); |
| 344 | } else { |
| 345 | pr_err("%s: The legacy DMA map is not provided!\n", |
| 346 | __func__); |
| 347 | return -ENODEV; |
| 348 | } |
| 349 | } |
| 350 | |
Russell King | 34a378f | 2013-11-08 18:21:35 +0000 | [diff] [blame] | 351 | pdev = omap_device_build(name, 0, oh, &p, sizeof(p)); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 352 | if (IS_ERR(pdev)) { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 353 | pr_err("%s: Can't build omap_device for %s:%s.\n", |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 354 | __func__, name, oh->name); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 355 | return PTR_ERR(pdev); |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 356 | } |
| 357 | |
Russell King | 596c471 | 2013-12-10 11:08:01 +0000 | [diff] [blame] | 358 | omap_dma_dev_info.res = pdev->resource; |
| 359 | omap_dma_dev_info.num_res = pdev->num_resources; |
| 360 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 361 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 362 | if (!mem) { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 363 | dev_err(&pdev->dev, "%s: no mem resource\n", __func__); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 364 | return -EINVAL; |
| 365 | } |
Russell King | 596c471 | 2013-12-10 11:08:01 +0000 | [diff] [blame] | 366 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 367 | dma_base = ioremap(mem->start, resource_size(mem)); |
| 368 | if (!dma_base) { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 369 | dev_err(&pdev->dev, "%s: ioremap fail\n", __func__); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 370 | return -ENOMEM; |
| 371 | } |
| 372 | |
| 373 | d = oh->dev_attr; |
R Sricharan | f6d5e07 | 2012-05-07 14:02:25 +0530 | [diff] [blame] | 374 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 375 | if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP)) |
| 376 | d->dev_caps |= HS_CHANNELS_RESERVED; |
| 377 | |
Nishanth Menon | 76be4a5 | 2014-06-12 17:15:22 +0530 | [diff] [blame] | 378 | if (platform_get_irq_byname(pdev, "0") < 0) |
| 379 | d->dev_caps |= DMA_ENGINE_HANDLE_IRQ; |
| 380 | |
R Sricharan | f6d5e07 | 2012-05-07 14:02:25 +0530 | [diff] [blame] | 381 | /* Check the capabilities register for descriptor loading feature */ |
| 382 | if (dma_read(CAPS_0, 0) & DMA_HAS_DESCRIPTOR_CAPS) |
| 383 | dma_common_ch_end = CCDN; |
| 384 | else |
| 385 | dma_common_ch_end = CCFN; |
| 386 | |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | static int __init omap2_system_dma_init(void) |
| 391 | { |
Tony Lindgren | be1f948 | 2013-01-11 11:24:19 -0800 | [diff] [blame] | 392 | struct platform_device *pdev; |
| 393 | int res; |
| 394 | |
| 395 | res = omap_hwmod_for_each_by_class("dma", |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 396 | omap2_system_dma_init_dev, NULL); |
Tony Lindgren | be1f948 | 2013-01-11 11:24:19 -0800 | [diff] [blame] | 397 | if (res) |
| 398 | return res; |
| 399 | |
Jon Hunter | 8d30662 | 2013-02-26 12:27:24 -0600 | [diff] [blame] | 400 | if (of_have_populated_dt()) |
| 401 | return res; |
| 402 | |
Tony Lindgren | be1f948 | 2013-01-11 11:24:19 -0800 | [diff] [blame] | 403 | pdev = platform_device_register_full(&omap_dma_dev_info); |
| 404 | if (IS_ERR(pdev)) |
| 405 | return PTR_ERR(pdev); |
| 406 | |
| 407 | return res; |
G, Manjunath Kondaiah | 59de3cf | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 408 | } |
Tony Lindgren | b76c8b19 | 2013-01-11 11:24:18 -0800 | [diff] [blame] | 409 | omap_arch_initcall(omap2_system_dma_init); |