Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/plat-omap/dma.c |
| 4 | * |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 5 | * Copyright (C) 2003 - 2008 Nokia Corporation |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 6 | * Author: Juha Yrjölä <juha.yrjola@nokia.com> |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 7 | * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com> |
| 8 | * Graphics DMA and LCD DMA graphics tranformations |
| 9 | * by Imre Deak <imre.deak@nokia.com> |
Anand Gadiyar | f8151e5 | 2007-12-01 12:14:11 -0800 | [diff] [blame] | 10 | * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc. |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 11 | * Merged to support both OMAP1 and OMAP2 by Tony Lindgren <tony@atomide.com> |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 12 | * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc. |
| 13 | * |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 14 | * Copyright (C) 2009 Texas Instruments |
| 15 | * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 16 | * |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 17 | * Support functions for the OMAP internal DMA channels. |
| 18 | * |
Alexander A. Klimov | e9dbeba | 2020-07-13 08:48:50 +0200 | [diff] [blame] | 19 | * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 20 | * Converted DMA library into DMA platform driver. |
| 21 | * - G, Manjunath Kondaiah <manjugk@ti.com> |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/sched.h> |
| 27 | #include <linux/spinlock.h> |
| 28 | #include <linux/errno.h> |
| 29 | #include <linux/interrupt.h> |
Thomas Gleixner | 418ca1f0 | 2006-07-01 22:32:41 +0100 | [diff] [blame] | 30 | #include <linux/irq.h> |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 31 | #include <linux/io.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 32 | #include <linux/slab.h> |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 33 | #include <linux/delay.h> |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 34 | |
Tony Lindgren | 45c3eb7 | 2012-11-30 08:41:50 -0800 | [diff] [blame] | 35 | #include <linux/omap-dma.h> |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 36 | |
Tony Lindgren | 685e2d0 | 2015-05-20 09:01:21 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_ARCH_OMAP1 |
| 38 | #include <mach/soc.h> |
| 39 | #endif |
| 40 | |
Paul Walmsley | bc4d8b5 | 2012-04-13 06:34:30 -0600 | [diff] [blame] | 41 | /* |
| 42 | * MAX_LOGICAL_DMA_CH_COUNT: the maximum number of logical DMA |
| 43 | * channels that an instance of the SDMA IP block can support. Used |
| 44 | * to size arrays. (The actual maximum on a particular SoC may be less |
| 45 | * than this -- for example, OMAP1 SDMA instances only support 17 logical |
| 46 | * DMA channels.) |
| 47 | */ |
| 48 | #define MAX_LOGICAL_DMA_CH_COUNT 32 |
| 49 | |
Anand Gadiyar | f8151e5 | 2007-12-01 12:14:11 -0800 | [diff] [blame] | 50 | #undef DEBUG |
| 51 | |
| 52 | #ifndef CONFIG_ARCH_OMAP1 |
| 53 | enum { DMA_CH_ALLOC_DONE, DMA_CH_PARAMS_SET_DONE, DMA_CH_STARTED, |
| 54 | DMA_CH_QUEUED, DMA_CH_NOTSTARTED, DMA_CH_PAUSED, DMA_CH_LINK_ENABLED |
| 55 | }; |
| 56 | |
| 57 | enum { DMA_CHAIN_STARTED, DMA_CHAIN_NOTSTARTED }; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 58 | #endif |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 59 | |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 60 | #define OMAP_DMA_ACTIVE 0x01 |
Adrian Hunter | 4fb699b | 2010-11-24 13:23:21 +0200 | [diff] [blame] | 61 | #define OMAP2_DMA_CSR_CLEAR_MASK 0xffffffff |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 62 | |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 63 | #define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 64 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 65 | static struct omap_system_dma_plat_info *p; |
| 66 | static struct omap_dma_dev_attr *d; |
Tony Lindgren | 175655b | 2014-09-16 17:36:28 -0700 | [diff] [blame] | 67 | static void omap_clear_dma(int lch); |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 68 | static int enable_1510_mode; |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 69 | static u32 errata; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 70 | |
Anand Gadiyar | f8151e5 | 2007-12-01 12:14:11 -0800 | [diff] [blame] | 71 | struct dma_link_info { |
| 72 | int *linked_dmach_q; |
| 73 | int no_of_lchs_linked; |
| 74 | |
| 75 | int q_count; |
| 76 | int q_tail; |
| 77 | int q_head; |
| 78 | |
| 79 | int chain_state; |
| 80 | int chain_mode; |
| 81 | |
| 82 | }; |
| 83 | |
Tony Lindgren | 4d96372 | 2008-07-03 12:24:31 +0300 | [diff] [blame] | 84 | static int dma_lch_count; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 85 | static int dma_chan_count; |
Santosh Shilimkar | 2263f02 | 2009-03-23 18:07:48 -0700 | [diff] [blame] | 86 | static int omap_dma_reserve_channels; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 87 | |
| 88 | static spinlock_t dma_chan_lock; |
Tony Lindgren | 4d96372 | 2008-07-03 12:24:31 +0300 | [diff] [blame] | 89 | static struct omap_dma_lch *dma_chan; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 90 | |
Anand Gadiyar | f8151e5 | 2007-12-01 12:14:11 -0800 | [diff] [blame] | 91 | static inline void disable_lnk(int lch); |
| 92 | static void omap_disable_channel_irq(int lch); |
| 93 | static inline void omap_enable_channel_irq(int lch); |
| 94 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 95 | #ifdef CONFIG_ARCH_OMAP15XX |
| 96 | /* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ |
Aaro Koskinen | c776758 | 2011-01-27 16:39:43 -0800 | [diff] [blame] | 97 | static int omap_dma_in_1510_mode(void) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 98 | { |
| 99 | return enable_1510_mode; |
| 100 | } |
| 101 | #else |
| 102 | #define omap_dma_in_1510_mode() 0 |
| 103 | #endif |
| 104 | |
| 105 | #ifdef CONFIG_ARCH_OMAP1 |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 106 | static inline void set_gdma_dev(int req, int dev) |
| 107 | { |
| 108 | u32 reg = OMAP_FUNC_MUX_ARM_BASE + ((req - 1) / 5) * 4; |
| 109 | int shift = ((req - 1) % 5) * 6; |
| 110 | u32 l; |
| 111 | |
| 112 | l = omap_readl(reg); |
| 113 | l &= ~(0x3f << shift); |
| 114 | l |= (dev - 1) << shift; |
| 115 | omap_writel(l, reg); |
| 116 | } |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 117 | #else |
| 118 | #define set_gdma_dev(req, dev) do {} while (0) |
Tony Lindgren | 2c799ce | 2012-02-24 10:34:35 -0800 | [diff] [blame] | 119 | #define omap_readl(reg) 0 |
| 120 | #define omap_writel(val, reg) do {} while (0) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 121 | #endif |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 122 | |
Tony Lindgren | 54b693d | 2012-10-02 13:39:28 -0700 | [diff] [blame] | 123 | #ifdef CONFIG_ARCH_OMAP1 |
Tony Lindgren | 709eb3e5 | 2006-09-25 12:45:45 +0300 | [diff] [blame] | 124 | void omap_set_dma_priority(int lch, int dst_port, int priority) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 125 | { |
| 126 | unsigned long reg; |
| 127 | u32 l; |
| 128 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 129 | if (dma_omap1()) { |
Tony Lindgren | 709eb3e5 | 2006-09-25 12:45:45 +0300 | [diff] [blame] | 130 | switch (dst_port) { |
| 131 | case OMAP_DMA_PORT_OCP_T1: /* FFFECC00 */ |
| 132 | reg = OMAP_TC_OCPT1_PRIOR; |
| 133 | break; |
| 134 | case OMAP_DMA_PORT_OCP_T2: /* FFFECCD0 */ |
| 135 | reg = OMAP_TC_OCPT2_PRIOR; |
| 136 | break; |
| 137 | case OMAP_DMA_PORT_EMIFF: /* FFFECC08 */ |
| 138 | reg = OMAP_TC_EMIFF_PRIOR; |
| 139 | break; |
| 140 | case OMAP_DMA_PORT_EMIFS: /* FFFECC04 */ |
| 141 | reg = OMAP_TC_EMIFS_PRIOR; |
| 142 | break; |
| 143 | default: |
| 144 | BUG(); |
| 145 | return; |
| 146 | } |
| 147 | l = omap_readl(reg); |
| 148 | l &= ~(0xf << 8); |
| 149 | l |= (priority & 0xf) << 8; |
| 150 | omap_writel(l, reg); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 151 | } |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 152 | } |
Tony Lindgren | 54b693d | 2012-10-02 13:39:28 -0700 | [diff] [blame] | 153 | #endif |
| 154 | |
| 155 | #ifdef CONFIG_ARCH_OMAP2PLUS |
| 156 | void omap_set_dma_priority(int lch, int dst_port, int priority) |
| 157 | { |
| 158 | u32 ccr; |
| 159 | |
| 160 | ccr = p->dma_read(CCR, lch); |
| 161 | if (priority) |
| 162 | ccr |= (1 << 6); |
| 163 | else |
| 164 | ccr &= ~(1 << 6); |
| 165 | p->dma_write(ccr, CCR, lch); |
| 166 | } |
| 167 | #endif |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 168 | EXPORT_SYMBOL(omap_set_dma_priority); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 169 | |
| 170 | void omap_set_dma_transfer_params(int lch, int data_type, int elem_count, |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 171 | int frame_count, int sync_mode, |
| 172 | int dma_trigger, int src_or_dst_synch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 173 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 174 | u32 l; |
| 175 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 176 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 177 | l &= ~0x03; |
| 178 | l |= data_type; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 179 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 180 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 181 | if (dma_omap1()) { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 182 | u16 ccr; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 183 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 184 | ccr = p->dma_read(CCR, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 185 | ccr &= ~(1 << 5); |
| 186 | if (sync_mode == OMAP_DMA_SYNC_FRAME) |
| 187 | ccr |= 1 << 5; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 188 | p->dma_write(ccr, CCR, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 189 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 190 | ccr = p->dma_read(CCR2, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 191 | ccr &= ~(1 << 2); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 192 | if (sync_mode == OMAP_DMA_SYNC_BLOCK) |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 193 | ccr |= 1 << 2; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 194 | p->dma_write(ccr, CCR2, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 195 | } |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 196 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 197 | if (dma_omap2plus() && dma_trigger) { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 198 | u32 val; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 199 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 200 | val = p->dma_read(CCR, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 201 | |
Anand Gadiyar | 4b3cf44 | 2009-01-15 13:09:53 +0200 | [diff] [blame] | 202 | /* DMA_SYNCHRO_CONTROL_UPPER depends on the channel number */ |
Samu Onkalo | 72a1179 | 2010-08-02 14:21:40 +0300 | [diff] [blame] | 203 | val &= ~((1 << 23) | (3 << 19) | 0x1f); |
Anand Gadiyar | 4b3cf44 | 2009-01-15 13:09:53 +0200 | [diff] [blame] | 204 | val |= (dma_trigger & ~0x1f) << 14; |
| 205 | val |= dma_trigger & 0x1f; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 206 | |
| 207 | if (sync_mode & OMAP_DMA_SYNC_FRAME) |
| 208 | val |= 1 << 5; |
Peter Ujfalusi | eca9e56 | 2006-06-26 16:16:06 -0700 | [diff] [blame] | 209 | else |
| 210 | val &= ~(1 << 5); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 211 | |
| 212 | if (sync_mode & OMAP_DMA_SYNC_BLOCK) |
| 213 | val |= 1 << 18; |
Peter Ujfalusi | eca9e56 | 2006-06-26 16:16:06 -0700 | [diff] [blame] | 214 | else |
| 215 | val &= ~(1 << 18); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 216 | |
Samu Onkalo | 72a1179 | 2010-08-02 14:21:40 +0300 | [diff] [blame] | 217 | if (src_or_dst_synch == OMAP_DMA_DST_SYNC_PREFETCH) { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 218 | val &= ~(1 << 24); /* dest synch */ |
Samu Onkalo | 72a1179 | 2010-08-02 14:21:40 +0300 | [diff] [blame] | 219 | val |= (1 << 23); /* Prefetch */ |
| 220 | } else if (src_or_dst_synch) { |
| 221 | val |= 1 << 24; /* source synch */ |
| 222 | } else { |
| 223 | val &= ~(1 << 24); /* dest synch */ |
| 224 | } |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 225 | p->dma_write(val, CCR, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 226 | } |
| 227 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 228 | p->dma_write(elem_count, CEN, lch); |
| 229 | p->dma_write(frame_count, CFN, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 230 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 231 | EXPORT_SYMBOL(omap_set_dma_transfer_params); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 232 | |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 233 | void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode) |
| 234 | { |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 235 | if (dma_omap1() && !dma_omap15xx()) { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 236 | u32 l; |
| 237 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 238 | l = p->dma_read(LCH_CTRL, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 239 | l &= ~0x7; |
| 240 | l |= mode; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 241 | p->dma_write(l, LCH_CTRL, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 242 | } |
| 243 | } |
| 244 | EXPORT_SYMBOL(omap_set_dma_channel_mode); |
| 245 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 246 | /* Note that src_port is only for omap1 */ |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 247 | void omap_set_dma_src_params(int lch, int src_port, int src_amode, |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 248 | unsigned long src_start, |
| 249 | int src_ei, int src_fi) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 250 | { |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 251 | u32 l; |
| 252 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 253 | if (dma_omap1()) { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 254 | u16 w; |
| 255 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 256 | w = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 257 | w &= ~(0x1f << 2); |
| 258 | w |= src_port << 2; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 259 | p->dma_write(w, CSDP, lch); |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 260 | } |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 261 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 262 | l = p->dma_read(CCR, lch); |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 263 | l &= ~(0x03 << 12); |
| 264 | l |= src_amode << 12; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 265 | p->dma_write(l, CCR, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 266 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 267 | p->dma_write(src_start, CSSA, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 268 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 269 | p->dma_write(src_ei, CSEI, lch); |
| 270 | p->dma_write(src_fi, CSFI, lch); |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 271 | } |
| 272 | EXPORT_SYMBOL(omap_set_dma_src_params); |
| 273 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 274 | void omap_set_dma_src_data_pack(int lch, int enable) |
| 275 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 276 | u32 l; |
| 277 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 278 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 279 | l &= ~(1 << 6); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 280 | if (enable) |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 281 | l |= (1 << 6); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 282 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 283 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 284 | EXPORT_SYMBOL(omap_set_dma_src_data_pack); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 285 | |
| 286 | void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) |
| 287 | { |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 288 | unsigned int burst = 0; |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 289 | u32 l; |
| 290 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 291 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 292 | l &= ~(0x03 << 7); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 293 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 294 | switch (burst_mode) { |
| 295 | case OMAP_DMA_DATA_BURST_DIS: |
| 296 | break; |
| 297 | case OMAP_DMA_DATA_BURST_4: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 298 | if (dma_omap2plus()) |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 299 | burst = 0x1; |
| 300 | else |
| 301 | burst = 0x2; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 302 | break; |
| 303 | case OMAP_DMA_DATA_BURST_8: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 304 | if (dma_omap2plus()) { |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 305 | burst = 0x2; |
| 306 | break; |
| 307 | } |
manjugk manjugk | ea221a6 | 2010-05-14 12:05:25 -0700 | [diff] [blame] | 308 | /* |
| 309 | * not supported by current hardware on OMAP1 |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 310 | * w |= (0x03 << 7); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 311 | */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 312 | fallthrough; |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 313 | case OMAP_DMA_DATA_BURST_16: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 314 | if (dma_omap2plus()) { |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 315 | burst = 0x3; |
| 316 | break; |
| 317 | } |
Gustavo A. R. Silva | 3da6bd9 | 2019-07-28 18:19:41 -0500 | [diff] [blame] | 318 | /* OMAP1 don't support burst 16 */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 319 | fallthrough; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 320 | default: |
| 321 | BUG(); |
| 322 | } |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 323 | |
| 324 | l |= (burst << 7); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 325 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 326 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 327 | EXPORT_SYMBOL(omap_set_dma_src_burst_mode); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 328 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 329 | /* Note that dest_port is only for OMAP1 */ |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 330 | void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode, |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 331 | unsigned long dest_start, |
| 332 | int dst_ei, int dst_fi) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 333 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 334 | u32 l; |
| 335 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 336 | if (dma_omap1()) { |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 337 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 338 | l &= ~(0x1f << 9); |
| 339 | l |= dest_port << 9; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 340 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 341 | } |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 342 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 343 | l = p->dma_read(CCR, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 344 | l &= ~(0x03 << 14); |
| 345 | l |= dest_amode << 14; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 346 | p->dma_write(l, CCR, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 347 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 348 | p->dma_write(dest_start, CDSA, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 349 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 350 | p->dma_write(dst_ei, CDEI, lch); |
| 351 | p->dma_write(dst_fi, CDFI, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 352 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 353 | EXPORT_SYMBOL(omap_set_dma_dest_params); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 354 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 355 | void omap_set_dma_dest_data_pack(int lch, int enable) |
| 356 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 357 | u32 l; |
| 358 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 359 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 360 | l &= ~(1 << 13); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 361 | if (enable) |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 362 | l |= 1 << 13; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 363 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 364 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 365 | EXPORT_SYMBOL(omap_set_dma_dest_data_pack); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 366 | |
| 367 | void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) |
| 368 | { |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 369 | unsigned int burst = 0; |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 370 | u32 l; |
| 371 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 372 | l = p->dma_read(CSDP, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 373 | l &= ~(0x03 << 14); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 374 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 375 | switch (burst_mode) { |
| 376 | case OMAP_DMA_DATA_BURST_DIS: |
| 377 | break; |
| 378 | case OMAP_DMA_DATA_BURST_4: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 379 | if (dma_omap2plus()) |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 380 | burst = 0x1; |
| 381 | else |
| 382 | burst = 0x2; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 383 | break; |
| 384 | case OMAP_DMA_DATA_BURST_8: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 385 | if (dma_omap2plus()) |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 386 | burst = 0x2; |
| 387 | else |
| 388 | burst = 0x3; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 389 | break; |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 390 | case OMAP_DMA_DATA_BURST_16: |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 391 | if (dma_omap2plus()) { |
Kyungmin Park | 6dc3c8f | 2006-06-26 16:16:14 -0700 | [diff] [blame] | 392 | burst = 0x3; |
| 393 | break; |
| 394 | } |
Gustavo A. R. Silva | 3da6bd9 | 2019-07-28 18:19:41 -0500 | [diff] [blame] | 395 | /* OMAP1 don't support burst 16 */ |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 396 | fallthrough; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 397 | default: |
| 398 | printk(KERN_ERR "Invalid DMA burst mode\n"); |
| 399 | BUG(); |
| 400 | return; |
| 401 | } |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 402 | l |= (burst << 14); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 403 | p->dma_write(l, CSDP, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 404 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 405 | EXPORT_SYMBOL(omap_set_dma_dest_burst_mode); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 406 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 407 | static inline void omap_enable_channel_irq(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 408 | { |
Tony Lindgren | 7ff879d | 2006-06-26 16:16:15 -0700 | [diff] [blame] | 409 | /* Clear CSR */ |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 410 | if (dma_omap1()) |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 411 | p->dma_read(CSR, lch); |
| 412 | else |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 413 | p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 414 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 415 | /* Enable some nice interrupts. */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 416 | p->dma_write(dma_chan[lch].enabled_irqs, CICR, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 417 | } |
| 418 | |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 419 | static inline void omap_disable_channel_irq(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 420 | { |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 421 | /* disable channel interrupts */ |
| 422 | p->dma_write(0, CICR, lch); |
| 423 | /* Clear CSR */ |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 424 | if (dma_omap1()) |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 425 | p->dma_read(CSR, lch); |
| 426 | else |
| 427 | p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 428 | } |
| 429 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 430 | void omap_disable_dma_irq(int lch, u16 bits) |
| 431 | { |
| 432 | dma_chan[lch].enabled_irqs &= ~bits; |
| 433 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 434 | EXPORT_SYMBOL(omap_disable_dma_irq); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 435 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 436 | static inline void enable_lnk(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 437 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 438 | u32 l; |
| 439 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 440 | l = p->dma_read(CLNK_CTRL, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 441 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 442 | if (dma_omap1()) |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 443 | l &= ~(1 << 14); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 444 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 445 | /* Set the ENABLE_LNK bits */ |
| 446 | if (dma_chan[lch].next_lch != -1) |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 447 | l = dma_chan[lch].next_lch | (1 << 15); |
Anand Gadiyar | f8151e5 | 2007-12-01 12:14:11 -0800 | [diff] [blame] | 448 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 449 | p->dma_write(l, CLNK_CTRL, lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 450 | } |
| 451 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 452 | static inline void disable_lnk(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 453 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 454 | u32 l; |
| 455 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 456 | l = p->dma_read(CLNK_CTRL, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 457 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 458 | /* Disable interrupts */ |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 459 | omap_disable_channel_irq(lch); |
| 460 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 461 | if (dma_omap1()) { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 462 | /* Set the STOP_LNK bit */ |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 463 | l |= 1 << 14; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 464 | } |
| 465 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 466 | if (dma_omap2plus()) { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 467 | /* Clear the ENABLE_LNK bit */ |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 468 | l &= ~(1 << 15); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 469 | } |
| 470 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 471 | p->dma_write(l, CLNK_CTRL, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 472 | dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; |
| 473 | } |
| 474 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 475 | int omap_request_dma(int dev_id, const char *dev_name, |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 476 | void (*callback)(int lch, u16 ch_status, void *data), |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 477 | void *data, int *dma_ch_out) |
| 478 | { |
| 479 | int ch, free_ch = -1; |
| 480 | unsigned long flags; |
| 481 | struct omap_dma_lch *chan; |
| 482 | |
Russell King | 5c65c36 | 2014-06-07 10:47:36 +0100 | [diff] [blame] | 483 | WARN(strcmp(dev_name, "DMA engine"), "Using deprecated platform DMA API - please update to DMA engine"); |
| 484 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 485 | spin_lock_irqsave(&dma_chan_lock, flags); |
| 486 | for (ch = 0; ch < dma_chan_count; ch++) { |
| 487 | if (free_ch == -1 && dma_chan[ch].dev_id == -1) { |
| 488 | free_ch = ch; |
R Sricharan | 03a6d4a | 2013-06-13 19:47:09 +0530 | [diff] [blame] | 489 | /* Exit after first free channel found */ |
| 490 | break; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | if (free_ch == -1) { |
| 494 | spin_unlock_irqrestore(&dma_chan_lock, flags); |
| 495 | return -EBUSY; |
| 496 | } |
| 497 | chan = dma_chan + free_ch; |
| 498 | chan->dev_id = dev_id; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 499 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 500 | if (p->clear_lch_regs) |
| 501 | p->clear_lch_regs(free_ch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 502 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 503 | spin_unlock_irqrestore(&dma_chan_lock, flags); |
| 504 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 505 | chan->dev_name = dev_name; |
| 506 | chan->callback = callback; |
| 507 | chan->data = data; |
Jarkko Nikula | a92fda1 | 2009-01-29 08:57:12 -0800 | [diff] [blame] | 508 | chan->flags = 0; |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 509 | |
Tony Lindgren | 7ff879d | 2006-06-26 16:16:15 -0700 | [diff] [blame] | 510 | chan->enabled_irqs = OMAP_DMA_DROP_IRQ | OMAP_DMA_BLOCK_IRQ; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 511 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 512 | if (dma_omap1()) |
Tony Lindgren | 7ff879d | 2006-06-26 16:16:15 -0700 | [diff] [blame] | 513 | chan->enabled_irqs |= OMAP1_DMA_TOUT_IRQ; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 514 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 515 | if (dma_omap16xx()) { |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 516 | /* If the sync device is set, configure it dynamically. */ |
| 517 | if (dev_id != 0) { |
| 518 | set_gdma_dev(free_ch + 1, dev_id); |
| 519 | dev_id = free_ch + 1; |
| 520 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 521 | /* |
| 522 | * Disable the 1510 compatibility mode and set the sync device |
| 523 | * id. |
| 524 | */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 525 | p->dma_write(dev_id | (1 << 10), CCR, free_ch); |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 526 | } else if (dma_omap1()) { |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 527 | p->dma_write(dev_id, CCR, free_ch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 528 | } |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 529 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 530 | *dma_ch_out = free_ch; |
| 531 | |
| 532 | return 0; |
| 533 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 534 | EXPORT_SYMBOL(omap_request_dma); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 535 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 536 | void omap_free_dma(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 537 | { |
| 538 | unsigned long flags; |
| 539 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 540 | if (dma_chan[lch].dev_id == -1) { |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 541 | pr_err("omap_dma: trying to free unallocated DMA channel %d\n", |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 542 | lch); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 543 | return; |
| 544 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 545 | |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 546 | /* Disable all DMA interrupts for the channel. */ |
| 547 | omap_disable_channel_irq(lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 548 | |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 549 | /* Make sure the DMA transfer is stopped. */ |
| 550 | p->dma_write(0, CCR, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 551 | |
Santosh Shilimkar | da1b94e | 2009-04-23 11:10:40 -0700 | [diff] [blame] | 552 | spin_lock_irqsave(&dma_chan_lock, flags); |
| 553 | dma_chan[lch].dev_id = -1; |
| 554 | dma_chan[lch].next_lch = -1; |
| 555 | dma_chan[lch].callback = NULL; |
| 556 | spin_unlock_irqrestore(&dma_chan_lock, flags); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 557 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 558 | EXPORT_SYMBOL(omap_free_dma); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 559 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 560 | /* |
| 561 | * Clears any DMA state so the DMA engine is ready to restart with new buffers |
| 562 | * through omap_start_dma(). Any buffers in flight are discarded. |
| 563 | */ |
Tony Lindgren | 175655b | 2014-09-16 17:36:28 -0700 | [diff] [blame] | 564 | static void omap_clear_dma(int lch) |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 565 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 566 | unsigned long flags; |
| 567 | |
| 568 | local_irq_save(flags); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 569 | p->clear_dma(lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 570 | local_irq_restore(flags); |
| 571 | } |
| 572 | |
| 573 | void omap_start_dma(int lch) |
| 574 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 575 | u32 l; |
| 576 | |
manjugk manjugk | 519e616 | 2010-03-04 07:11:56 +0000 | [diff] [blame] | 577 | /* |
| 578 | * The CPC/CDAC register needs to be initialized to zero |
| 579 | * before starting dma transfer. |
| 580 | */ |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 581 | if (dma_omap15xx()) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 582 | p->dma_write(0, CPC, lch); |
manjugk manjugk | 519e616 | 2010-03-04 07:11:56 +0000 | [diff] [blame] | 583 | else |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 584 | p->dma_write(0, CDAC, lch); |
manjugk manjugk | 519e616 | 2010-03-04 07:11:56 +0000 | [diff] [blame] | 585 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 586 | if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { |
| 587 | int next_lch, cur_lch; |
Paul Walmsley | bc4d8b5 | 2012-04-13 06:34:30 -0600 | [diff] [blame] | 588 | char dma_chan_link_map[MAX_LOGICAL_DMA_CH_COUNT]; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 589 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 590 | /* Set the link register of the first channel */ |
| 591 | enable_lnk(lch); |
| 592 | |
| 593 | memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map)); |
R Sricharan | f0a3ff2 | 2013-06-13 19:47:10 +0530 | [diff] [blame] | 594 | dma_chan_link_map[lch] = 1; |
| 595 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 596 | cur_lch = dma_chan[lch].next_lch; |
| 597 | do { |
| 598 | next_lch = dma_chan[cur_lch].next_lch; |
| 599 | |
| 600 | /* The loop case: we've been here already */ |
| 601 | if (dma_chan_link_map[cur_lch]) |
| 602 | break; |
| 603 | /* Mark the current channel */ |
| 604 | dma_chan_link_map[cur_lch] = 1; |
| 605 | |
| 606 | enable_lnk(cur_lch); |
| 607 | omap_enable_channel_irq(cur_lch); |
| 608 | |
| 609 | cur_lch = next_lch; |
| 610 | } while (next_lch != -1); |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 611 | } else if (IS_DMA_ERRATA(DMA_ERRATA_PARALLEL_CHANNELS)) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 612 | p->dma_write(lch, CLNK_CTRL, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 613 | |
| 614 | omap_enable_channel_irq(lch); |
| 615 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 616 | l = p->dma_read(CCR, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 617 | |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 618 | if (IS_DMA_ERRATA(DMA_ERRATA_IFRAME_BUFFERING)) |
| 619 | l |= OMAP_DMA_CCR_BUFFERING_DISABLE; |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 620 | l |= OMAP_DMA_CCR_EN; |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 621 | |
Russell King | 3545358 | 2012-04-14 18:57:10 +0100 | [diff] [blame] | 622 | /* |
| 623 | * As dma_write() uses IO accessors which are weakly ordered, there |
| 624 | * is no guarantee that data in coherent DMA memory will be visible |
| 625 | * to the DMA device. Add a memory barrier here to ensure that any |
| 626 | * such data is visible prior to enabling DMA. |
| 627 | */ |
| 628 | mb(); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 629 | p->dma_write(l, CCR, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 630 | |
| 631 | dma_chan[lch].flags |= OMAP_DMA_ACTIVE; |
| 632 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 633 | EXPORT_SYMBOL(omap_start_dma); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 634 | |
| 635 | void omap_stop_dma(int lch) |
| 636 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 637 | u32 l; |
| 638 | |
Santosh Shilimkar | 9da65a9 | 2009-10-22 14:46:31 -0700 | [diff] [blame] | 639 | /* Disable all interrupts on the channel */ |
Oleg Matcovschi | bedfb7a | 2012-05-15 14:35:08 -0700 | [diff] [blame] | 640 | omap_disable_channel_irq(lch); |
Santosh Shilimkar | 9da65a9 | 2009-10-22 14:46:31 -0700 | [diff] [blame] | 641 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 642 | l = p->dma_read(CCR, lch); |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 643 | if (IS_DMA_ERRATA(DMA_ERRATA_i541) && |
| 644 | (l & OMAP_DMA_CCR_SEL_SRC_DST_SYNC)) { |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 645 | int i = 0; |
| 646 | u32 sys_cf; |
| 647 | |
| 648 | /* Configure No-Standby */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 649 | l = p->dma_read(OCP_SYSCONFIG, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 650 | sys_cf = l; |
| 651 | l &= ~DMA_SYSCONFIG_MIDLEMODE_MASK; |
| 652 | l |= DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_NO_IDLE); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 653 | p->dma_write(l , OCP_SYSCONFIG, 0); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 654 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 655 | l = p->dma_read(CCR, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 656 | l &= ~OMAP_DMA_CCR_EN; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 657 | p->dma_write(l, CCR, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 658 | |
| 659 | /* Wait for sDMA FIFO drain */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 660 | l = p->dma_read(CCR, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 661 | while (i < 100 && (l & (OMAP_DMA_CCR_RD_ACTIVE | |
| 662 | OMAP_DMA_CCR_WR_ACTIVE))) { |
| 663 | udelay(5); |
| 664 | i++; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 665 | l = p->dma_read(CCR, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 666 | } |
| 667 | if (i >= 100) |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 668 | pr_err("DMA drain did not complete on lch %d\n", lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 669 | /* Restore OCP_SYSCONFIG */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 670 | p->dma_write(sys_cf, OCP_SYSCONFIG, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 671 | } else { |
| 672 | l &= ~OMAP_DMA_CCR_EN; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 673 | p->dma_write(l, CCR, lch); |
Peter Ujfalusi | 0e4905c | 2010-10-11 14:18:56 -0700 | [diff] [blame] | 674 | } |
Santosh Shilimkar | 9da65a9 | 2009-10-22 14:46:31 -0700 | [diff] [blame] | 675 | |
Russell King | 3545358 | 2012-04-14 18:57:10 +0100 | [diff] [blame] | 676 | /* |
| 677 | * Ensure that data transferred by DMA is visible to any access |
| 678 | * after DMA has been disabled. This is important for coherent |
| 679 | * DMA regions. |
| 680 | */ |
| 681 | mb(); |
| 682 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 683 | if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { |
| 684 | int next_lch, cur_lch = lch; |
Paul Walmsley | bc4d8b5 | 2012-04-13 06:34:30 -0600 | [diff] [blame] | 685 | char dma_chan_link_map[MAX_LOGICAL_DMA_CH_COUNT]; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 686 | |
| 687 | memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map)); |
| 688 | do { |
| 689 | /* The loop case: we've been here already */ |
| 690 | if (dma_chan_link_map[cur_lch]) |
| 691 | break; |
| 692 | /* Mark the current channel */ |
| 693 | dma_chan_link_map[cur_lch] = 1; |
| 694 | |
| 695 | disable_lnk(cur_lch); |
| 696 | |
| 697 | next_lch = dma_chan[cur_lch].next_lch; |
| 698 | cur_lch = next_lch; |
| 699 | } while (next_lch != -1); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 700 | } |
| 701 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 702 | dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; |
| 703 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 704 | EXPORT_SYMBOL(omap_stop_dma); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 705 | |
| 706 | /* |
Tony Lindgren | 709eb3e5 | 2006-09-25 12:45:45 +0300 | [diff] [blame] | 707 | * Allows changing the DMA callback function or data. This may be needed if |
| 708 | * the driver shares a single DMA channel for multiple dma triggers. |
| 709 | */ |
Tony Lindgren | 709eb3e5 | 2006-09-25 12:45:45 +0300 | [diff] [blame] | 710 | /* |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 711 | * Returns current physical source address for the given DMA channel. |
| 712 | * If the channel is running the caller must disable interrupts prior calling |
| 713 | * this function and process the returned value before re-enabling interrupt to |
| 714 | * prevent races with the interrupt handler. Note that in continuous mode there |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 715 | * is a chance for CSSA_L register overflow between the two reads resulting |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 716 | * in incorrect return value. |
| 717 | */ |
| 718 | dma_addr_t omap_get_dma_src_pos(int lch) |
| 719 | { |
Tony Lindgren | 0695de3 | 2007-05-07 18:24:14 -0700 | [diff] [blame] | 720 | dma_addr_t offset = 0; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 721 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 722 | if (dma_omap15xx()) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 723 | offset = p->dma_read(CPC, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 724 | else |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 725 | offset = p->dma_read(CSAC, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 726 | |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 727 | if (IS_DMA_ERRATA(DMA_ERRATA_3_3) && offset == 0) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 728 | offset = p->dma_read(CSAC, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 729 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 730 | if (!dma_omap15xx()) { |
Peter Ujfalusi | 7ba9668 | 2011-12-09 13:38:00 -0800 | [diff] [blame] | 731 | /* |
| 732 | * CDAC == 0 indicates that the DMA transfer on the channel has |
| 733 | * not been started (no data has been transferred so far). |
| 734 | * Return the programmed source start address in this case. |
| 735 | */ |
| 736 | if (likely(p->dma_read(CDAC, lch))) |
| 737 | offset = p->dma_read(CSAC, lch); |
| 738 | else |
| 739 | offset = p->dma_read(CSSA, lch); |
| 740 | } |
| 741 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 742 | if (dma_omap1()) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 743 | offset |= (p->dma_read(CSSA, lch) & 0xFFFF0000); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 744 | |
| 745 | return offset; |
| 746 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 747 | EXPORT_SYMBOL(omap_get_dma_src_pos); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 748 | |
| 749 | /* |
| 750 | * Returns current physical destination address for the given DMA channel. |
| 751 | * If the channel is running the caller must disable interrupts prior calling |
| 752 | * this function and process the returned value before re-enabling interrupt to |
| 753 | * prevent races with the interrupt handler. Note that in continuous mode there |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 754 | * is a chance for CDSA_L register overflow between the two reads resulting |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 755 | * in incorrect return value. |
| 756 | */ |
| 757 | dma_addr_t omap_get_dma_dst_pos(int lch) |
| 758 | { |
Tony Lindgren | 0695de3 | 2007-05-07 18:24:14 -0700 | [diff] [blame] | 759 | dma_addr_t offset = 0; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 760 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 761 | if (dma_omap15xx()) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 762 | offset = p->dma_read(CPC, lch); |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 763 | else |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 764 | offset = p->dma_read(CDAC, lch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 765 | |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 766 | /* |
| 767 | * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is |
| 768 | * read before the DMA controller finished disabling the channel. |
| 769 | */ |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 770 | if (!dma_omap15xx() && offset == 0) { |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 771 | offset = p->dma_read(CDAC, lch); |
Peter Ujfalusi | 06e8077 | 2011-12-09 13:38:00 -0800 | [diff] [blame] | 772 | /* |
| 773 | * CDAC == 0 indicates that the DMA transfer on the channel has |
| 774 | * not been started (no data has been transferred so far). |
| 775 | * Return the programmed destination start address in this case. |
| 776 | */ |
| 777 | if (unlikely(!offset)) |
| 778 | offset = p->dma_read(CDSA, lch); |
| 779 | } |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 780 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 781 | if (dma_omap1()) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 782 | offset |= (p->dma_read(CDSA, lch) & 0xFFFF0000); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 783 | |
| 784 | return offset; |
| 785 | } |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 786 | EXPORT_SYMBOL(omap_get_dma_dst_pos); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 787 | |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 788 | int omap_get_dma_active_status(int lch) |
| 789 | { |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 790 | return (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN) != 0; |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 791 | } |
| 792 | EXPORT_SYMBOL(omap_get_dma_active_status); |
| 793 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 794 | int omap_dma_running(void) |
| 795 | { |
| 796 | int lch; |
| 797 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 798 | if (dma_omap1()) |
Janusz Krzysztofik | f8e9e98 | 2009-12-11 16:16:33 -0800 | [diff] [blame] | 799 | if (omap_lcd_dma_running()) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 800 | return 1; |
| 801 | |
| 802 | for (lch = 0; lch < dma_chan_count; lch++) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 803 | if (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 804 | return 1; |
| 805 | |
| 806 | return 0; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 807 | } |
| 808 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 809 | /*----------------------------------------------------------------------------*/ |
| 810 | |
| 811 | #ifdef CONFIG_ARCH_OMAP1 |
| 812 | |
| 813 | static int omap1_dma_handle_ch(int ch) |
| 814 | { |
Tony Lindgren | 0499bde | 2008-07-03 12:24:36 +0300 | [diff] [blame] | 815 | u32 csr; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 816 | |
| 817 | if (enable_1510_mode && ch >= 6) { |
| 818 | csr = dma_chan[ch].saved_csr; |
| 819 | dma_chan[ch].saved_csr = 0; |
| 820 | } else |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 821 | csr = p->dma_read(CSR, ch); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 822 | if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) { |
| 823 | dma_chan[ch + 6].saved_csr = csr >> 7; |
| 824 | csr &= 0x7f; |
| 825 | } |
| 826 | if ((csr & 0x3f) == 0) |
| 827 | return 0; |
| 828 | if (unlikely(dma_chan[ch].dev_id == -1)) { |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 829 | pr_warn("Spurious interrupt from DMA channel %d (CSR %04x)\n", |
| 830 | ch, csr); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 831 | return 0; |
| 832 | } |
Tony Lindgren | 7ff879d | 2006-06-26 16:16:15 -0700 | [diff] [blame] | 833 | if (unlikely(csr & OMAP1_DMA_TOUT_IRQ)) |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 834 | pr_warn("DMA timeout with device %d\n", dma_chan[ch].dev_id); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 835 | if (unlikely(csr & OMAP_DMA_DROP_IRQ)) |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 836 | pr_warn("DMA synchronization event drop occurred with device %d\n", |
| 837 | dma_chan[ch].dev_id); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 838 | if (likely(csr & OMAP_DMA_BLOCK_IRQ)) |
| 839 | dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE; |
| 840 | if (likely(dma_chan[ch].callback != NULL)) |
| 841 | dma_chan[ch].callback(ch, csr, dma_chan[ch].data); |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 842 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 843 | return 1; |
| 844 | } |
| 845 | |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 846 | static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 847 | { |
| 848 | int ch = ((int) dev_id) - 1; |
| 849 | int handled = 0; |
| 850 | |
| 851 | for (;;) { |
| 852 | int handled_now = 0; |
| 853 | |
| 854 | handled_now += omap1_dma_handle_ch(ch); |
| 855 | if (enable_1510_mode && dma_chan[ch + 6].saved_csr) |
| 856 | handled_now += omap1_dma_handle_ch(ch + 6); |
| 857 | if (!handled_now) |
| 858 | break; |
| 859 | handled += handled_now; |
| 860 | } |
| 861 | |
| 862 | return handled ? IRQ_HANDLED : IRQ_NONE; |
| 863 | } |
| 864 | |
| 865 | #else |
| 866 | #define omap1_dma_irq_handler NULL |
| 867 | #endif |
| 868 | |
Russell King | 1b416c4 | 2013-11-02 13:00:03 +0000 | [diff] [blame] | 869 | struct omap_system_dma_plat_info *omap_get_plat_info(void) |
| 870 | { |
| 871 | return p; |
| 872 | } |
| 873 | EXPORT_SYMBOL_GPL(omap_get_plat_info); |
| 874 | |
Greg Kroah-Hartman | 351a102 | 2012-12-21 14:02:24 -0800 | [diff] [blame] | 875 | static int omap_system_dma_probe(struct platform_device *pdev) |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 876 | { |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 877 | int ch, ret = 0; |
| 878 | int dma_irq; |
| 879 | char irq_name[4]; |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 880 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 881 | p = pdev->dev.platform_data; |
| 882 | if (!p) { |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 883 | dev_err(&pdev->dev, |
| 884 | "%s: System DMA initialized without platform data\n", |
| 885 | __func__); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 886 | return -EINVAL; |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 887 | } |
| 888 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 889 | d = p->dma_attr; |
| 890 | errata = p->errata; |
G, Manjunath Kondaiah | d3c9be2 | 2010-12-20 18:27:18 -0800 | [diff] [blame] | 891 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 892 | if ((d->dev_caps & RESERVE_CHANNEL) && omap_dma_reserve_channels |
Chen Gang | e78f9606 | 2013-01-11 13:39:18 +0800 | [diff] [blame] | 893 | && (omap_dma_reserve_channels < d->lch_count)) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 894 | d->lch_count = omap_dma_reserve_channels; |
Santosh Shilimkar | 2263f02 | 2009-03-23 18:07:48 -0700 | [diff] [blame] | 895 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 896 | dma_lch_count = d->lch_count; |
| 897 | dma_chan_count = dma_lch_count; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 898 | enable_1510_mode = d->dev_caps & ENABLE_1510_MODE; |
Tony Lindgren | 4d96372 | 2008-07-03 12:24:31 +0300 | [diff] [blame] | 899 | |
Russell King | 9834f81 | 2013-11-08 18:10:42 +0000 | [diff] [blame] | 900 | dma_chan = devm_kcalloc(&pdev->dev, dma_lch_count, |
Markus Elfring | 16e7ea5 | 2017-10-03 20:46:48 +0200 | [diff] [blame] | 901 | sizeof(*dma_chan), GFP_KERNEL); |
Markus Elfring | d679950 | 2017-10-03 13:10:26 +0200 | [diff] [blame] | 902 | if (!dma_chan) |
Russell King | 9834f81 | 2013-11-08 18:10:42 +0000 | [diff] [blame] | 903 | return -ENOMEM; |
Russell King | 9834f81 | 2013-11-08 18:10:42 +0000 | [diff] [blame] | 904 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 905 | spin_lock_init(&dma_chan_lock); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 906 | for (ch = 0; ch < dma_chan_count; ch++) { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 907 | omap_clear_dma(ch); |
Mika Westerberg | ada8d4a | 2010-05-14 12:05:25 -0700 | [diff] [blame] | 908 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 909 | dma_chan[ch].dev_id = -1; |
| 910 | dma_chan[ch].next_lch = -1; |
| 911 | |
| 912 | if (ch >= 6 && enable_1510_mode) |
| 913 | continue; |
| 914 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 915 | if (dma_omap1()) { |
Tony Lindgren | 97b7f71 | 2008-07-03 12:24:37 +0300 | [diff] [blame] | 916 | /* |
| 917 | * request_irq() doesn't like dev_id (ie. ch) being |
| 918 | * zero, so we have to kludge around this. |
| 919 | */ |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 920 | sprintf(&irq_name[0], "%d", ch); |
| 921 | dma_irq = platform_get_irq_byname(pdev, irq_name); |
| 922 | |
| 923 | if (dma_irq < 0) { |
| 924 | ret = dma_irq; |
| 925 | goto exit_dma_irq_fail; |
| 926 | } |
| 927 | |
| 928 | /* INT_DMA_LCD is handled in lcd_dma.c */ |
| 929 | if (dma_irq == INT_DMA_LCD) |
| 930 | continue; |
| 931 | |
| 932 | ret = request_irq(dma_irq, |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 933 | omap1_dma_irq_handler, 0, "DMA", |
| 934 | (void *) (ch + 1)); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 935 | if (ret != 0) |
| 936 | goto exit_dma_irq_fail; |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 937 | } |
| 938 | } |
| 939 | |
Tony Lindgren | 8280960 | 2012-10-30 11:03:22 -0700 | [diff] [blame] | 940 | /* reserve dma channels 0 and 1 in high security devices on 34xx */ |
| 941 | if (d->dev_caps & HS_CHANNELS_RESERVED) { |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 942 | pr_info("Reserving DMA channels 0 and 1 for HS ROM code\n"); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 943 | dma_chan[0].dev_id = 0; |
| 944 | dma_chan[1].dev_id = 1; |
| 945 | } |
| 946 | p->show_dma_caps(); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 947 | return 0; |
Tony Lindgren | 7e9bf84 | 2009-10-19 15:25:15 -0700 | [diff] [blame] | 948 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 949 | exit_dma_irq_fail: |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 950 | return ret; |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 951 | } |
| 952 | |
Greg Kroah-Hartman | 351a102 | 2012-12-21 14:02:24 -0800 | [diff] [blame] | 953 | static int omap_system_dma_remove(struct platform_device *pdev) |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 954 | { |
Tony Lindgren | 755cbfd | 2019-12-16 14:41:53 -0800 | [diff] [blame] | 955 | int dma_irq, irq_rel = 0; |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 956 | |
Tony Lindgren | 755cbfd | 2019-12-16 14:41:53 -0800 | [diff] [blame] | 957 | if (dma_omap2plus()) |
| 958 | return 0; |
| 959 | |
| 960 | for ( ; irq_rel < dma_chan_count; irq_rel++) { |
| 961 | dma_irq = platform_get_irq(pdev, irq_rel); |
| 962 | free_irq(dma_irq, (void *)(irq_rel + 1)); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 963 | } |
Tony Lindgren | 755cbfd | 2019-12-16 14:41:53 -0800 | [diff] [blame] | 964 | |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | static struct platform_driver omap_system_dma_driver = { |
| 969 | .probe = omap_system_dma_probe, |
Greg Kroah-Hartman | 351a102 | 2012-12-21 14:02:24 -0800 | [diff] [blame] | 970 | .remove = omap_system_dma_remove, |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 971 | .driver = { |
| 972 | .name = "omap_dma_system" |
| 973 | }, |
| 974 | }; |
| 975 | |
| 976 | static int __init omap_system_dma_init(void) |
| 977 | { |
| 978 | return platform_driver_register(&omap_system_dma_driver); |
| 979 | } |
| 980 | arch_initcall(omap_system_dma_init); |
| 981 | |
| 982 | static void __exit omap_system_dma_exit(void) |
| 983 | { |
| 984 | platform_driver_unregister(&omap_system_dma_driver); |
| 985 | } |
| 986 | |
| 987 | MODULE_DESCRIPTION("OMAP SYSTEM DMA DRIVER"); |
| 988 | MODULE_LICENSE("GPL"); |
G, Manjunath Kondaiah | f31cc96 | 2010-12-20 18:27:19 -0800 | [diff] [blame] | 989 | MODULE_AUTHOR("Texas Instruments Inc"); |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 990 | |
Santosh Shilimkar | 2263f02 | 2009-03-23 18:07:48 -0700 | [diff] [blame] | 991 | /* |
| 992 | * Reserve the omap SDMA channels using cmdline bootarg |
| 993 | * "omap_dma_reserve_ch=". The valid range is 1 to 32 |
| 994 | */ |
| 995 | static int __init omap_dma_cmdline_reserve_ch(char *str) |
| 996 | { |
| 997 | if (get_option(&str, &omap_dma_reserve_channels) != 1) |
| 998 | omap_dma_reserve_channels = 0; |
| 999 | return 1; |
| 1000 | } |
| 1001 | |
| 1002 | __setup("omap_dma_reserve_ch=", omap_dma_cmdline_reserve_ch); |
| 1003 | |
Tony Lindgren | 5e1c5ff | 2005-07-10 19:58:15 +0100 | [diff] [blame] | 1004 | |