aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2008-07-03 05:24:36 -0400
committerTony Lindgren <tony@atomide.com>2008-07-03 05:24:36 -0400
commit0499bdeb1dec30325aa282a83f9374fa849aa01c (patch)
tree30f16c5516460e8b205d6be967017c9b8c90d4a4 /arch
parent4d96372e6daae89166fed7883ee092dc8db80b21 (diff)
ARM: OMAP: DMA: Remove __REG access
Remove __REG access in DMA code, use dma_read/write instead: - dynamically set the omap_dma_base based on the omap type - omap_read/write becomes dma_read/write - dma channel registers are read with dma_ch_read/write Cc: David Brownell <david-b@pacbell.net> Cc: linux-usb@vger.kernel.org Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/plat-omap/dma.c503
1 files changed, 324 insertions, 179 deletions
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 02f00a98783f..18e757a9ec6b 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -126,6 +126,7 @@ static int dma_chan_count;
126 126
127static spinlock_t dma_chan_lock; 127static spinlock_t dma_chan_lock;
128static struct omap_dma_lch *dma_chan; 128static struct omap_dma_lch *dma_chan;
129static void __iomem *omap_dma_base;
129 130
130static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = { 131static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = {
131 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3, 132 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3,
@@ -142,6 +143,24 @@ static inline void omap_enable_channel_irq(int lch);
142#define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \ 143#define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \
143 __func__); 144 __func__);
144 145
146#define dma_read(reg) \
147({ \
148 u32 __val; \
149 if (cpu_class_is_omap1()) \
150 __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \
151 else \
152 __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \
153 __val; \
154})
155
156#define dma_write(val, reg) \
157({ \
158 if (cpu_class_is_omap1()) \
159 __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \
160 else \
161 __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \
162})
163
145#ifdef CONFIG_ARCH_OMAP15XX 164#ifdef CONFIG_ARCH_OMAP15XX
146/* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ 165/* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */
147int omap_dma_in_1510_mode(void) 166int omap_dma_in_1510_mode(void)
@@ -176,13 +195,14 @@ static inline void set_gdma_dev(int req, int dev)
176#define set_gdma_dev(req, dev) do {} while (0) 195#define set_gdma_dev(req, dev) do {} while (0)
177#endif 196#endif
178 197
198/* Omap1 only */
179static void clear_lch_regs(int lch) 199static void clear_lch_regs(int lch)
180{ 200{
181 int i; 201 int i;
182 u32 lch_base = OMAP_DMA_BASE + lch * 0x40; 202 void __iomem *lch_base = omap_dma_base + OMAP1_DMA_CH_BASE(lch);
183 203
184 for (i = 0; i < 0x2c; i += 2) 204 for (i = 0; i < 0x2c; i += 2)
185 omap_writew(0, lch_base + i); 205 __raw_writew(0, lch_base + i);
186} 206}
187 207
188void omap_set_dma_priority(int lch, int dst_port, int priority) 208void omap_set_dma_priority(int lch, int dst_port, int priority)
@@ -215,10 +235,14 @@ void omap_set_dma_priority(int lch, int dst_port, int priority)
215 } 235 }
216 236
217 if (cpu_class_is_omap2()) { 237 if (cpu_class_is_omap2()) {
238 u32 ccr;
239
240 ccr = dma_read(CCR(lch));
218 if (priority) 241 if (priority)
219 OMAP_DMA_CCR_REG(lch) |= (1 << 6); 242 ccr |= (1 << 6);
220 else 243 else
221 OMAP_DMA_CCR_REG(lch) &= ~(1 << 6); 244 ccr &= ~(1 << 6);
245 dma_write(ccr, CCR(lch));
222 } 246 }
223} 247}
224 248
@@ -226,22 +250,33 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
226 int frame_count, int sync_mode, 250 int frame_count, int sync_mode,
227 int dma_trigger, int src_or_dst_synch) 251 int dma_trigger, int src_or_dst_synch)
228{ 252{
229 OMAP_DMA_CSDP_REG(lch) &= ~0x03; 253 u32 l;
230 OMAP_DMA_CSDP_REG(lch) |= data_type; 254
255 l = dma_read(CSDP(lch));
256 l &= ~0x03;
257 l |= data_type;
258 dma_write(l, CSDP(lch));
231 259
232 if (cpu_class_is_omap1()) { 260 if (cpu_class_is_omap1()) {
233 OMAP_DMA_CCR_REG(lch) &= ~(1 << 5); 261 u16 ccr;
262
263 ccr = dma_read(CCR(lch));
264 ccr &= ~(1 << 5);
234 if (sync_mode == OMAP_DMA_SYNC_FRAME) 265 if (sync_mode == OMAP_DMA_SYNC_FRAME)
235 OMAP_DMA_CCR_REG(lch) |= 1 << 5; 266 ccr |= 1 << 5;
267 dma_write(ccr, CCR(lch));
236 268
237 OMAP1_DMA_CCR2_REG(lch) &= ~(1 << 2); 269 ccr = dma_read(CCR2(lch));
270 ccr &= ~(1 << 2);
238 if (sync_mode == OMAP_DMA_SYNC_BLOCK) 271 if (sync_mode == OMAP_DMA_SYNC_BLOCK)
239 OMAP1_DMA_CCR2_REG(lch) |= 1 << 2; 272 ccr |= 1 << 2;
273 dma_write(ccr, CCR2(lch));
240 } 274 }
241 275
242 if (cpu_class_is_omap2() && dma_trigger) { 276 if (cpu_class_is_omap2() && dma_trigger) {
243 u32 val = OMAP_DMA_CCR_REG(lch); 277 u32 val;
244 278
279 val = dma_read(CCR(lch));
245 val &= ~(3 << 19); 280 val &= ~(3 << 19);
246 if (dma_trigger > 63) 281 if (dma_trigger > 63)
247 val |= 1 << 20; 282 val |= 1 << 20;
@@ -266,11 +301,11 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
266 else 301 else
267 val &= ~(1 << 24); /* dest synch */ 302 val &= ~(1 << 24); /* dest synch */
268 303
269 OMAP_DMA_CCR_REG(lch) = val; 304 dma_write(val, CCR(lch));
270 } 305 }
271 306
272 OMAP_DMA_CEN_REG(lch) = elem_count; 307 dma_write(elem_count, CEN(lch));
273 OMAP_DMA_CFN_REG(lch) = frame_count; 308 dma_write(frame_count, CFN(lch));
274} 309}
275 310
276void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color) 311void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
@@ -284,7 +319,9 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
284 return; 319 return;
285 } 320 }
286 321
287 w = OMAP1_DMA_CCR2_REG(lch) & ~0x03; 322 w = dma_read(CCR2(lch));
323 w &= ~0x03;
324
288 switch (mode) { 325 switch (mode) {
289 case OMAP_DMA_CONSTANT_FILL: 326 case OMAP_DMA_CONSTANT_FILL:
290 w |= 0x01; 327 w |= 0x01;
@@ -297,49 +334,81 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
297 default: 334 default:
298 BUG(); 335 BUG();
299 } 336 }
300 OMAP1_DMA_CCR2_REG(lch) = w; 337 dma_write(w, CCR2(lch));
301 338
302 w = OMAP1_DMA_LCH_CTRL_REG(lch) & ~0x0f; 339 w = dma_read(LCH_CTRL(lch));
340 w &= ~0x0f;
303 /* Default is channel type 2D */ 341 /* Default is channel type 2D */
304 if (mode) { 342 if (mode) {
305 OMAP1_DMA_COLOR_L_REG(lch) = (u16)color; 343 dma_write((u16)color, COLOR_L(lch));
306 OMAP1_DMA_COLOR_U_REG(lch) = (u16)(color >> 16); 344 dma_write((u16)(color >> 16), COLOR_U(lch));
307 w |= 1; /* Channel type G */ 345 w |= 1; /* Channel type G */
308 } 346 }
309 OMAP1_DMA_LCH_CTRL_REG(lch) = w; 347 dma_write(w, LCH_CTRL(lch));
310} 348}
311 349
312void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode) 350void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)
313{ 351{
314 if (cpu_class_is_omap2()) { 352 if (cpu_class_is_omap2()) {
315 OMAP_DMA_CSDP_REG(lch) &= ~(0x3 << 16); 353 u32 csdp;
316 OMAP_DMA_CSDP_REG(lch) |= (mode << 16); 354
355 csdp = dma_read(CSDP(lch));
356 csdp &= ~(0x3 << 16);
357 csdp |= (mode << 16);
358 dma_write(csdp, CSDP(lch));
317 } 359 }
318} 360}
319 361
362void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode)
363{
364 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) {
365 u32 l;
366
367 l = dma_read(LCH_CTRL(lch));
368 l &= ~0x7;
369 l |= mode;
370 dma_write(l, LCH_CTRL(lch));
371 }
372}
373EXPORT_SYMBOL(omap_set_dma_channel_mode);
374
320/* Note that src_port is only for omap1 */ 375/* Note that src_port is only for omap1 */
321void omap_set_dma_src_params(int lch, int src_port, int src_amode, 376void omap_set_dma_src_params(int lch, int src_port, int src_amode,
322 unsigned long src_start, 377 unsigned long src_start,
323 int src_ei, int src_fi) 378 int src_ei, int src_fi)
324{ 379{
325 if (cpu_class_is_omap1()) { 380 if (cpu_class_is_omap1()) {
326 OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 2); 381 u16 w;
327 OMAP_DMA_CSDP_REG(lch) |= src_port << 2;
328 }
329 382
330 OMAP_DMA_CCR_REG(lch) &= ~(0x03 << 12); 383 w = dma_read(CSDP(lch));
331 OMAP_DMA_CCR_REG(lch) |= src_amode << 12; 384 w &= ~(0x1f << 2);
385 w |= src_port << 2;
386 dma_write(w, CSDP(lch));
332 387
333 if (cpu_class_is_omap1()) { 388 w = dma_read(CCR(lch));
334 OMAP1_DMA_CSSA_U_REG(lch) = src_start >> 16; 389 w &= ~(0x03 << 12);
335 OMAP1_DMA_CSSA_L_REG(lch) = src_start; 390 w |= src_amode << 12;
391 dma_write(w, CCR(lch));
392
393 dma_write(src_start >> 16, CSSA_U(lch));
394 dma_write((u16)src_start, CSSA_L(lch));
395
396 dma_write(src_ei, CSEI(lch));
397 dma_write(src_fi, CSFI(lch));
336 } 398 }
337 399
338 if (cpu_class_is_omap2()) 400 if (cpu_class_is_omap2()) {
339 OMAP2_DMA_CSSA_REG(lch) = src_start; 401 u32 l;
402
403 l = dma_read(CCR(lch));
404 l &= ~(0x03 << 12);
405 l |= src_amode << 12;
406 dma_write(l, CCR(lch));
340 407
341 OMAP_DMA_CSEI_REG(lch) = src_ei; 408 dma_write(src_start, CSSA(lch));
342 OMAP_DMA_CSFI_REG(lch) = src_fi; 409 dma_write(src_ei, CSEI(lch));
410 dma_write(src_fi, CSFI(lch));
411 }
343} 412}
344 413
345void omap_set_dma_params(int lch, struct omap_dma_channel_params * params) 414void omap_set_dma_params(int lch, struct omap_dma_channel_params * params)
@@ -366,21 +435,28 @@ void omap_set_dma_src_index(int lch, int eidx, int fidx)
366 REVISIT_24XX(); 435 REVISIT_24XX();
367 return; 436 return;
368 } 437 }
369 OMAP_DMA_CSEI_REG(lch) = eidx; 438 dma_write(eidx, CSEI(lch));
370 OMAP_DMA_CSFI_REG(lch) = fidx; 439 dma_write(fidx, CSFI(lch));
371} 440}
372 441
373void omap_set_dma_src_data_pack(int lch, int enable) 442void omap_set_dma_src_data_pack(int lch, int enable)
374{ 443{
375 OMAP_DMA_CSDP_REG(lch) &= ~(1 << 6); 444 u32 l;
445
446 l = dma_read(CSDP(lch));
447 l &= ~(1 << 6);
376 if (enable) 448 if (enable)
377 OMAP_DMA_CSDP_REG(lch) |= (1 << 6); 449 l |= (1 << 6);
450 dma_write(l, CSDP(lch));
378} 451}
379 452
380void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) 453void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
381{ 454{
382 unsigned int burst = 0; 455 unsigned int burst = 0;
383 OMAP_DMA_CSDP_REG(lch) &= ~(0x03 << 7); 456 u32 l;
457
458 l = dma_read(CSDP(lch));
459 l &= ~(0x03 << 7);
384 460
385 switch (burst_mode) { 461 switch (burst_mode) {
386 case OMAP_DMA_DATA_BURST_DIS: 462 case OMAP_DMA_DATA_BURST_DIS:
@@ -411,7 +487,9 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
411 default: 487 default:
412 BUG(); 488 BUG();
413 } 489 }
414 OMAP_DMA_CSDP_REG(lch) |= (burst << 7); 490
491 l |= (burst << 7);
492 dma_write(l, CSDP(lch));
415} 493}
416 494
417/* Note that dest_port is only for OMAP1 */ 495/* Note that dest_port is only for OMAP1 */
@@ -419,24 +497,30 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
419 unsigned long dest_start, 497 unsigned long dest_start,
420 int dst_ei, int dst_fi) 498 int dst_ei, int dst_fi)
421{ 499{
500 u32 l;
501
422 if (cpu_class_is_omap1()) { 502 if (cpu_class_is_omap1()) {
423 OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 9); 503 l = dma_read(CSDP(lch));
424 OMAP_DMA_CSDP_REG(lch) |= dest_port << 9; 504 l &= ~(0x1f << 9);
505 l |= dest_port << 9;
506 dma_write(l, CSDP(lch));
425 } 507 }
426 508
427 OMAP_DMA_CCR_REG(lch) &= ~(0x03 << 14); 509 l = dma_read(CCR(lch));
428 OMAP_DMA_CCR_REG(lch) |= dest_amode << 14; 510 l &= ~(0x03 << 14);
511 l |= dest_amode << 14;
512 dma_write(l, CCR(lch));
429 513
430 if (cpu_class_is_omap1()) { 514 if (cpu_class_is_omap1()) {
431 OMAP1_DMA_CDSA_U_REG(lch) = dest_start >> 16; 515 dma_write(dest_start >> 16, CDSA_U(lch));
432 OMAP1_DMA_CDSA_L_REG(lch) = dest_start; 516 dma_write(dest_start, CDSA_L(lch));
433 } 517 }
434 518
435 if (cpu_class_is_omap2()) 519 if (cpu_class_is_omap2())
436 OMAP2_DMA_CDSA_REG(lch) = dest_start; 520 dma_write(dest_start, CDSA(lch));
437 521
438 OMAP_DMA_CDEI_REG(lch) = dst_ei; 522 dma_write(dst_ei, CDEI(lch));
439 OMAP_DMA_CDFI_REG(lch) = dst_fi; 523 dma_write(dst_fi, CDFI(lch));
440} 524}
441 525
442void omap_set_dma_dest_index(int lch, int eidx, int fidx) 526void omap_set_dma_dest_index(int lch, int eidx, int fidx)
@@ -445,21 +529,28 @@ void omap_set_dma_dest_index(int lch, int eidx, int fidx)
445 REVISIT_24XX(); 529 REVISIT_24XX();
446 return; 530 return;
447 } 531 }
448 OMAP_DMA_CDEI_REG(lch) = eidx; 532 dma_write(eidx, CDEI(lch));
449 OMAP_DMA_CDFI_REG(lch) = fidx; 533 dma_write(fidx, CDFI(lch));
450} 534}
451 535
452void omap_set_dma_dest_data_pack(int lch, int enable) 536void omap_set_dma_dest_data_pack(int lch, int enable)
453{ 537{
454 OMAP_DMA_CSDP_REG(lch) &= ~(1 << 13); 538 u32 l;
539
540 l = dma_read(CSDP(lch));
541 l &= ~(1 << 13);
455 if (enable) 542 if (enable)
456 OMAP_DMA_CSDP_REG(lch) |= 1 << 13; 543 l |= 1 << 13;
544 dma_write(l, CSDP(lch));
457} 545}
458 546
459void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) 547void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
460{ 548{
461 unsigned int burst = 0; 549 unsigned int burst = 0;
462 OMAP_DMA_CSDP_REG(lch) &= ~(0x03 << 14); 550 u32 l;
551
552 l = dma_read(CSDP(lch));
553 l &= ~(0x03 << 14);
463 554
464 switch (burst_mode) { 555 switch (burst_mode) {
465 case OMAP_DMA_DATA_BURST_DIS: 556 case OMAP_DMA_DATA_BURST_DIS:
@@ -489,7 +580,8 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
489 BUG(); 580 BUG();
490 return; 581 return;
491 } 582 }
492 OMAP_DMA_CSDP_REG(lch) |= (burst << 14); 583 l |= (burst << 14);
584 dma_write(l, CSDP(lch));
493} 585}
494 586
495static inline void omap_enable_channel_irq(int lch) 587static inline void omap_enable_channel_irq(int lch)
@@ -498,18 +590,18 @@ static inline void omap_enable_channel_irq(int lch)
498 590
499 /* Clear CSR */ 591 /* Clear CSR */
500 if (cpu_class_is_omap1()) 592 if (cpu_class_is_omap1())
501 status = OMAP_DMA_CSR_REG(lch); 593 status = dma_read(CSR(lch));
502 else if (cpu_class_is_omap2()) 594 else if (cpu_class_is_omap2())
503 OMAP_DMA_CSR_REG(lch) = OMAP2_DMA_CSR_CLEAR_MASK; 595 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch));
504 596
505 /* Enable some nice interrupts. */ 597 /* Enable some nice interrupts. */
506 OMAP_DMA_CICR_REG(lch) = dma_chan[lch].enabled_irqs; 598 dma_write(dma_chan[lch].enabled_irqs, CICR(lch));
507} 599}
508 600
509static void omap_disable_channel_irq(int lch) 601static void omap_disable_channel_irq(int lch)
510{ 602{
511 if (cpu_class_is_omap2()) 603 if (cpu_class_is_omap2())
512 OMAP_DMA_CICR_REG(lch) = 0; 604 dma_write(0, CICR(lch));
513} 605}
514 606
515void omap_enable_dma_irq(int lch, u16 bits) 607void omap_enable_dma_irq(int lch, u16 bits)
@@ -524,36 +616,45 @@ void omap_disable_dma_irq(int lch, u16 bits)
524 616
525static inline void enable_lnk(int lch) 617static inline void enable_lnk(int lch)
526{ 618{
619 u32 l;
620
621 l = dma_read(CLNK_CTRL(lch));
622
527 if (cpu_class_is_omap1()) 623 if (cpu_class_is_omap1())
528 OMAP_DMA_CLNK_CTRL_REG(lch) &= ~(1 << 14); 624 l &= ~(1 << 14);
529 625
530 /* Set the ENABLE_LNK bits */ 626 /* Set the ENABLE_LNK bits */
531 if (dma_chan[lch].next_lch != -1) 627 if (dma_chan[lch].next_lch != -1)
532 OMAP_DMA_CLNK_CTRL_REG(lch) = 628 l = dma_chan[lch].next_lch | (1 << 15);
533 dma_chan[lch].next_lch | (1 << 15);
534 629
535#ifndef CONFIG_ARCH_OMAP1 630#ifndef CONFIG_ARCH_OMAP1
536 if (dma_chan[lch].next_linked_ch != -1) 631 if (dma_chan[lch].next_linked_ch != -1)
537 OMAP_DMA_CLNK_CTRL_REG(lch) = 632 l = dma_chan[lch].next_linked_ch | (1 << 15);
538 dma_chan[lch].next_linked_ch | (1 << 15);
539#endif 633#endif
634
635 dma_write(l, CLNK_CTRL(lch));
540} 636}
541 637
542static inline void disable_lnk(int lch) 638static inline void disable_lnk(int lch)
543{ 639{
640 u32 l;
641
642 l = dma_read(CLNK_CTRL(lch));
643
544 /* Disable interrupts */ 644 /* Disable interrupts */
545 if (cpu_class_is_omap1()) { 645 if (cpu_class_is_omap1()) {
546 OMAP_DMA_CICR_REG(lch) = 0; 646 dma_write(0, CICR(lch));
547 /* Set the STOP_LNK bit */ 647 /* Set the STOP_LNK bit */
548 OMAP_DMA_CLNK_CTRL_REG(lch) |= 1 << 14; 648 l |= 1 << 14;
549 } 649 }
550 650
551 if (cpu_class_is_omap2()) { 651 if (cpu_class_is_omap2()) {
552 omap_disable_channel_irq(lch); 652 omap_disable_channel_irq(lch);
553 /* Clear the ENABLE_LNK bit */ 653 /* Clear the ENABLE_LNK bit */
554 OMAP_DMA_CLNK_CTRL_REG(lch) &= ~(1 << 15); 654 l &= ~(1 << 15);
555 } 655 }
556 656
657 dma_write(l, CLNK_CTRL(lch));
557 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 658 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE;
558} 659}
559 660
@@ -564,9 +665,9 @@ static inline void omap2_enable_irq_lch(int lch)
564 if (!cpu_class_is_omap2()) 665 if (!cpu_class_is_omap2())
565 return; 666 return;
566 667
567 val = omap_readl(OMAP_DMA4_IRQENABLE_L0); 668 val = dma_read(IRQENABLE_L0);
568 val |= 1 << lch; 669 val |= 1 << lch;
569 omap_writel(val, OMAP_DMA4_IRQENABLE_L0); 670 dma_write(val, IRQENABLE_L0);
570} 671}
571 672
572int omap_request_dma(int dev_id, const char *dev_name, 673int omap_request_dma(int dev_id, const char *dev_name,
@@ -623,9 +724,9 @@ int omap_request_dma(int dev_id, const char *dev_name,
623 } 724 }
624 /* Disable the 1510 compatibility mode and set the sync device 725 /* Disable the 1510 compatibility mode and set the sync device
625 * id. */ 726 * id. */
626 OMAP_DMA_CCR_REG(free_ch) = dev_id | (1 << 10); 727 dma_write(dev_id | (1 << 10), CCR(free_ch));
627 } else if (cpu_is_omap730() || cpu_is_omap15xx()) { 728 } else if (cpu_is_omap730() || cpu_is_omap15xx()) {
628 OMAP_DMA_CCR_REG(free_ch) = dev_id; 729 dma_write(dev_id, CCR(free_ch));
629 } 730 }
630 731
631 if (cpu_class_is_omap2()) { 732 if (cpu_class_is_omap2()) {
@@ -633,8 +734,8 @@ int omap_request_dma(int dev_id, const char *dev_name,
633 734
634 omap_enable_channel_irq(free_ch); 735 omap_enable_channel_irq(free_ch);
635 /* Clear the CSR register and IRQ status register */ 736 /* Clear the CSR register and IRQ status register */
636 OMAP_DMA_CSR_REG(free_ch) = OMAP2_DMA_CSR_CLEAR_MASK; 737 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(free_ch));
637 omap_writel(1 << free_ch, OMAP_DMA4_IRQSTATUS_L0); 738 dma_write(1 << free_ch, IRQSTATUS_L0);
638 } 739 }
639 740
640 *dma_ch_out = free_ch; 741 *dma_ch_out = free_ch;
@@ -660,27 +761,27 @@ void omap_free_dma(int lch)
660 761
661 if (cpu_class_is_omap1()) { 762 if (cpu_class_is_omap1()) {
662 /* Disable all DMA interrupts for the channel. */ 763 /* Disable all DMA interrupts for the channel. */
663 OMAP_DMA_CICR_REG(lch) = 0; 764 dma_write(0, CICR(lch));
664 /* Make sure the DMA transfer is stopped. */ 765 /* Make sure the DMA transfer is stopped. */
665 OMAP_DMA_CCR_REG(lch) = 0; 766 dma_write(0, CCR(lch));
666 } 767 }
667 768
668 if (cpu_class_is_omap2()) { 769 if (cpu_class_is_omap2()) {
669 u32 val; 770 u32 val;
670 /* Disable interrupts */ 771 /* Disable interrupts */
671 val = omap_readl(OMAP_DMA4_IRQENABLE_L0); 772 val = dma_read(IRQENABLE_L0);
672 val &= ~(1 << lch); 773 val &= ~(1 << lch);
673 omap_writel(val, OMAP_DMA4_IRQENABLE_L0); 774 dma_write(val, IRQENABLE_L0);
674 775
675 /* Clear the CSR register and IRQ status register */ 776 /* Clear the CSR register and IRQ status register */
676 OMAP_DMA_CSR_REG(lch) = OMAP2_DMA_CSR_CLEAR_MASK; 777 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch));
677 omap_writel(1 << lch, OMAP_DMA4_IRQSTATUS_L0); 778 dma_write(1 << lch, IRQSTATUS_L0);
678 779
679 /* Disable all DMA interrupts for the channel. */ 780 /* Disable all DMA interrupts for the channel. */
680 OMAP_DMA_CICR_REG(lch) = 0; 781 dma_write(0, CICR(lch));
681 782
682 /* Make sure the DMA transfer is stopped. */ 783 /* Make sure the DMA transfer is stopped. */
683 OMAP_DMA_CCR_REG(lch) = 0; 784 dma_write(0, CCR(lch));
684 omap_clear_dma(lch); 785 omap_clear_dma(lch);
685 } 786 }
686} 787}
@@ -711,7 +812,7 @@ omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams)
711 reg = (arb_rate & 0xff) << 16; 812 reg = (arb_rate & 0xff) << 16;
712 reg |= (0xff & max_fifo_depth); 813 reg |= (0xff & max_fifo_depth);
713 814
714 omap_writel(reg, OMAP_DMA4_GCR_REG); 815 dma_write(reg, GCR);
715} 816}
716EXPORT_SYMBOL(omap_dma_set_global_params); 817EXPORT_SYMBOL(omap_dma_set_global_params);
717 818
@@ -728,20 +829,21 @@ int
728omap_dma_set_prio_lch(int lch, unsigned char read_prio, 829omap_dma_set_prio_lch(int lch, unsigned char read_prio,
729 unsigned char write_prio) 830 unsigned char write_prio)
730{ 831{
731 u32 w; 832 u32 l;
732 833
733 if (unlikely((lch < 0 || lch >= dma_lch_count))) { 834 if (unlikely((lch < 0 || lch >= dma_lch_count))) {
734 printk(KERN_ERR "Invalid channel id\n"); 835 printk(KERN_ERR "Invalid channel id\n");
735 return -EINVAL; 836 return -EINVAL;
736 } 837 }
737 w = OMAP_DMA_CCR_REG(lch); 838 l = dma_read(CCR(lch));
738 w &= ~((1 << 6) | (1 << 26)); 839 l &= ~((1 << 6) | (1 << 26));
739 if (cpu_is_omap2430() || cpu_is_omap34xx()) 840 if (cpu_is_omap2430() || cpu_is_omap34xx())
740 w |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); 841 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26);
741 else 842 else
742 w |= ((read_prio & 0x1) << 6); 843 l |= ((read_prio & 0x1) << 6);
844
845 dma_write(l, CCR(lch));
743 846
744 OMAP_DMA_CCR_REG(lch) = w;
745 return 0; 847 return 0;
746} 848}
747EXPORT_SYMBOL(omap_dma_set_prio_lch); 849EXPORT_SYMBOL(omap_dma_set_prio_lch);
@@ -757,18 +859,21 @@ void omap_clear_dma(int lch)
757 local_irq_save(flags); 859 local_irq_save(flags);
758 860
759 if (cpu_class_is_omap1()) { 861 if (cpu_class_is_omap1()) {
760 int status; 862 u32 l;
761 OMAP_DMA_CCR_REG(lch) &= ~OMAP_DMA_CCR_EN; 863
864 l = dma_read(CCR(lch));
865 l &= ~OMAP_DMA_CCR_EN;
866 dma_write(l, CCR(lch));
762 867
763 /* Clear pending interrupts */ 868 /* Clear pending interrupts */
764 status = OMAP_DMA_CSR_REG(lch); 869 l = dma_read(CSR(lch));
765 } 870 }
766 871
767 if (cpu_class_is_omap2()) { 872 if (cpu_class_is_omap2()) {
768 int i; 873 int i;
769 u32 lch_base = OMAP_DMA4_BASE + lch * 0x60 + 0x80; 874 void __iomem *lch_base = omap_dma_base + OMAP_DMA4_CH_BASE(lch);
770 for (i = 0; i < 0x44; i += 4) 875 for (i = 0; i < 0x44; i += 4)
771 omap_writel(0, lch_base + i); 876 __raw_writel(0, lch_base + i);
772 } 877 }
773 878
774 local_irq_restore(flags); 879 local_irq_restore(flags);
@@ -776,6 +881,8 @@ void omap_clear_dma(int lch)
776 881
777void omap_start_dma(int lch) 882void omap_start_dma(int lch)
778{ 883{
884 u32 l;
885
779 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 886 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
780 int next_lch, cur_lch; 887 int next_lch, cur_lch;
781 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 888 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT];
@@ -802,24 +909,28 @@ void omap_start_dma(int lch)
802 } while (next_lch != -1); 909 } while (next_lch != -1);
803 } else if (cpu_class_is_omap2()) { 910 } else if (cpu_class_is_omap2()) {
804 /* Errata: Need to write lch even if not using chaining */ 911 /* Errata: Need to write lch even if not using chaining */
805 OMAP_DMA_CLNK_CTRL_REG(lch) = lch; 912 dma_write(lch, CLNK_CTRL(lch));
806 } 913 }
807 914
808 omap_enable_channel_irq(lch); 915 omap_enable_channel_irq(lch);
809 916
917 l = dma_read(CCR(lch));
918
810 /* Errata: On ES2.0 BUFFERING disable must be set. 919 /* Errata: On ES2.0 BUFFERING disable must be set.
811 * This will always fail on ES1.0 */ 920 * This will always fail on ES1.0 */
812 if (cpu_is_omap24xx()) { 921 if (cpu_is_omap24xx())
813 OMAP_DMA_CCR_REG(lch) |= OMAP_DMA_CCR_EN; 922 l |= OMAP_DMA_CCR_EN;
814 }
815 923
816 OMAP_DMA_CCR_REG(lch) |= OMAP_DMA_CCR_EN; 924 l |= OMAP_DMA_CCR_EN;
925 dma_write(l, CCR(lch));
817 926
818 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 927 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
819} 928}
820 929
821void omap_stop_dma(int lch) 930void omap_stop_dma(int lch)
822{ 931{
932 u32 l;
933
823 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 934 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
824 int next_lch, cur_lch = lch; 935 int next_lch, cur_lch = lch;
825 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 936 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT];
@@ -843,9 +954,12 @@ void omap_stop_dma(int lch)
843 954
844 /* Disable all interrupts on the channel */ 955 /* Disable all interrupts on the channel */
845 if (cpu_class_is_omap1()) 956 if (cpu_class_is_omap1())
846 OMAP_DMA_CICR_REG(lch) = 0; 957 dma_write(0, CICR(lch));
958
959 l = dma_read(CCR(lch));
960 l &= ~OMAP_DMA_CCR_EN;
961 dma_write(l, CCR(lch));
847 962
848 OMAP_DMA_CCR_REG(lch) &= ~OMAP_DMA_CCR_EN;
849 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 963 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE;
850} 964}
851 965
@@ -887,12 +1001,20 @@ dma_addr_t omap_get_dma_src_pos(int lch)
887{ 1001{
888 dma_addr_t offset = 0; 1002 dma_addr_t offset = 0;
889 1003
890 if (cpu_class_is_omap1()) 1004 if (cpu_is_omap15xx())
891 offset = (dma_addr_t) (OMAP1_DMA_CSSA_L_REG(lch) | 1005 offset = dma_read(CPC(lch));
892 (OMAP1_DMA_CSSA_U_REG(lch) << 16)); 1006 else
1007 offset = dma_read(CSAC(lch));
893 1008
894 if (cpu_class_is_omap2()) 1009 /*
895 offset = OMAP_DMA_CSAC_REG(lch); 1010 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is
1011 * read before the DMA controller finished disabling the channel.
1012 */
1013 if (!cpu_is_omap15xx() && offset == 0)
1014 offset = dma_read(CSAC(lch));
1015
1016 if (cpu_class_is_omap1())
1017 offset |= (dma_read(CSSA_U(lch)) << 16);
896 1018
897 return offset; 1019 return offset;
898} 1020}
@@ -909,12 +1031,20 @@ dma_addr_t omap_get_dma_dst_pos(int lch)
909{ 1031{
910 dma_addr_t offset = 0; 1032 dma_addr_t offset = 0;
911 1033
912 if (cpu_class_is_omap1()) 1034 if (cpu_is_omap15xx())
913 offset = (dma_addr_t) (OMAP1_DMA_CDSA_L_REG(lch) | 1035 offset = dma_read(CPC(lch));
914 (OMAP1_DMA_CDSA_U_REG(lch) << 16)); 1036 else
1037 offset = dma_read(CDAC(lch));
915 1038
916 if (cpu_class_is_omap2()) 1039 /*
917 offset = OMAP_DMA_CDAC_REG(lch); 1040 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is
1041 * read before the DMA controller finished disabling the channel.
1042 */
1043 if (!cpu_is_omap15xx() && offset == 0)
1044 offset = dma_read(CDAC(lch));
1045
1046 if (cpu_class_is_omap1())
1047 offset |= (dma_read(CDSA_U(lch)) << 16);
918 1048
919 return offset; 1049 return offset;
920} 1050}
@@ -926,8 +1056,14 @@ dma_addr_t omap_get_dma_dst_pos(int lch)
926 */ 1056 */
927int omap_get_dma_src_addr_counter(int lch) 1057int omap_get_dma_src_addr_counter(int lch)
928{ 1058{
929 return (dma_addr_t) OMAP_DMA_CSAC_REG(lch); 1059 return (dma_addr_t)dma_read(CSAC(lch));
1060}
1061
1062int omap_get_dma_active_status(int lch)
1063{
1064 return (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) != 0;
930} 1065}
1066EXPORT_SYMBOL(omap_get_dma_active_status);
931 1067
932int omap_dma_running(void) 1068int omap_dma_running(void)
933{ 1069{
@@ -939,7 +1075,7 @@ int omap_dma_running(void)
939 return 1; 1075 return 1;
940 1076
941 for (lch = 0; lch < dma_chan_count; lch++) 1077 for (lch = 0; lch < dma_chan_count; lch++)
942 if (OMAP_DMA_CCR_REG(lch) & OMAP_DMA_CCR_EN) 1078 if (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN)
943 return 1; 1079 return 1;
944 1080
945 return 0; 1081 return 0;
@@ -1001,7 +1137,7 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue)
1001/* Create chain of DMA channesls */ 1137/* Create chain of DMA channesls */
1002static void create_dma_lch_chain(int lch_head, int lch_queue) 1138static void create_dma_lch_chain(int lch_head, int lch_queue)
1003{ 1139{
1004 u32 w; 1140 u32 l;
1005 1141
1006 /* Check if this is the first link in chain */ 1142 /* Check if this is the first link in chain */
1007 if (dma_chan[lch_head].next_linked_ch == -1) { 1143 if (dma_chan[lch_head].next_linked_ch == -1) {
@@ -1021,15 +1157,15 @@ static void create_dma_lch_chain(int lch_head, int lch_queue)
1021 lch_queue; 1157 lch_queue;
1022 } 1158 }
1023 1159
1024 w = OMAP_DMA_CLNK_CTRL_REG(lch_head); 1160 l = dma_read(CLNK_CTRL(lch_head));
1025 w &= ~(0x1f); 1161 l &= ~(0x1f);
1026 w |= lch_queue; 1162 l |= lch_queue;
1027 OMAP_DMA_CLNK_CTRL_REG(lch_head) = w; 1163 dma_write(l, CLNK_CTRL(lch_head));
1028 1164
1029 w = OMAP_DMA_CLNK_CTRL_REG(lch_queue); 1165 l = dma_read(CLNK_CTRL(lch_queue));
1030 w &= ~(0x1f); 1166 l &= ~(0x1f);
1031 w |= (dma_chan[lch_queue].next_linked_ch); 1167 l |= (dma_chan[lch_queue].next_linked_ch);
1032 OMAP_DMA_CLNK_CTRL_REG(lch_queue) = w; 1168 dma_write(l, CLNK_CTRL(lch_queue));
1033} 1169}
1034 1170
1035/** 1171/**
@@ -1256,7 +1392,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1256 int elem_count, int frame_count, void *callbk_data) 1392 int elem_count, int frame_count, void *callbk_data)
1257{ 1393{
1258 int *channels; 1394 int *channels;
1259 u32 w, lch; 1395 u32 l, lch;
1260 int start_dma = 0; 1396 int start_dma = 0;
1261 1397
1262 /* if buffer size is less than 1 then there is 1398 /* if buffer size is less than 1 then there is
@@ -1297,13 +1433,13 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1297 1433
1298 /* Set the params to the free channel */ 1434 /* Set the params to the free channel */
1299 if (src_start != 0) 1435 if (src_start != 0)
1300 OMAP2_DMA_CSSA_REG(lch) = src_start; 1436 dma_write(src_start, CSSA(lch));
1301 if (dest_start != 0) 1437 if (dest_start != 0)
1302 OMAP2_DMA_CDSA_REG(lch) = dest_start; 1438 dma_write(dest_start, CDSA(lch));
1303 1439
1304 /* Write the buffer size */ 1440 /* Write the buffer size */
1305 OMAP_DMA_CEN_REG(lch) = elem_count; 1441 dma_write(elem_count, CEN(lch));
1306 OMAP_DMA_CFN_REG(lch) = frame_count; 1442 dma_write(frame_count, CFN(lch));
1307 1443
1308 /* If the chain is dynamically linked, 1444 /* If the chain is dynamically linked,
1309 * then we may have to start the chain if its not active */ 1445 * then we may have to start the chain if its not active */
@@ -1330,8 +1466,8 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1330 enable_lnk(dma_chan[lch].prev_linked_ch); 1466 enable_lnk(dma_chan[lch].prev_linked_ch);
1331 dma_chan[lch].state = DMA_CH_QUEUED; 1467 dma_chan[lch].state = DMA_CH_QUEUED;
1332 start_dma = 0; 1468 start_dma = 0;
1333 if (0 == ((1 << 7) & (OMAP_DMA_CCR_REG 1469 if (0 == ((1 << 7) & dma_read(
1334 (dma_chan[lch].prev_linked_ch)))) { 1470 CCR(dma_chan[lch].prev_linked_ch)))) {
1335 disable_lnk(dma_chan[lch]. 1471 disable_lnk(dma_chan[lch].
1336 prev_linked_ch); 1472 prev_linked_ch);
1337 pr_debug("\n prev ch is stopped\n"); 1473 pr_debug("\n prev ch is stopped\n");
@@ -1347,23 +1483,23 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1347 } 1483 }
1348 omap_enable_channel_irq(lch); 1484 omap_enable_channel_irq(lch);
1349 1485
1350 w = OMAP_DMA_CCR_REG(lch); 1486 l = dma_read(CCR(lch));
1351 1487
1352 if ((0 == (w & (1 << 24)))) 1488 if ((0 == (l & (1 << 24))))
1353 w &= ~(1 << 25); 1489 l &= ~(1 << 25);
1354 else 1490 else
1355 w |= (1 << 25); 1491 l |= (1 << 25);
1356 if (start_dma == 1) { 1492 if (start_dma == 1) {
1357 if (0 == (w & (1 << 7))) { 1493 if (0 == (l & (1 << 7))) {
1358 w |= (1 << 7); 1494 l |= (1 << 7);
1359 dma_chan[lch].state = DMA_CH_STARTED; 1495 dma_chan[lch].state = DMA_CH_STARTED;
1360 pr_debug("starting %d\n", lch); 1496 pr_debug("starting %d\n", lch);
1361 OMAP_DMA_CCR_REG(lch) = w; 1497 dma_write(l, CCR(lch));
1362 } else 1498 } else
1363 start_dma = 0; 1499 start_dma = 0;
1364 } else { 1500 } else {
1365 if (0 == (w & (1 << 7))) 1501 if (0 == (l & (1 << 7)))
1366 OMAP_DMA_CCR_REG(lch) = w; 1502 dma_write(l, CCR(lch));
1367 } 1503 }
1368 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 1504 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
1369 } 1505 }
@@ -1383,7 +1519,7 @@ EXPORT_SYMBOL(omap_dma_chain_a_transfer);
1383int omap_start_dma_chain_transfers(int chain_id) 1519int omap_start_dma_chain_transfers(int chain_id)
1384{ 1520{
1385 int *channels; 1521 int *channels;
1386 u32 w, i; 1522 u32 l, i;
1387 1523
1388 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) { 1524 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) {
1389 printk(KERN_ERR "Invalid chain id\n"); 1525 printk(KERN_ERR "Invalid chain id\n");
@@ -1407,16 +1543,16 @@ int omap_start_dma_chain_transfers(int chain_id)
1407 omap_enable_channel_irq(channels[0]); 1543 omap_enable_channel_irq(channels[0]);
1408 } 1544 }
1409 1545
1410 w = OMAP_DMA_CCR_REG(channels[0]); 1546 l = dma_read(CCR(channels[0]));
1411 w |= (1 << 7); 1547 l |= (1 << 7);
1412 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED; 1548 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED;
1413 dma_chan[channels[0]].state = DMA_CH_STARTED; 1549 dma_chan[channels[0]].state = DMA_CH_STARTED;
1414 1550
1415 if ((0 == (w & (1 << 24)))) 1551 if ((0 == (l & (1 << 24))))
1416 w &= ~(1 << 25); 1552 l &= ~(1 << 25);
1417 else 1553 else
1418 w |= (1 << 25); 1554 l |= (1 << 25);
1419 OMAP_DMA_CCR_REG(channels[0]) = w; 1555 dma_write(l, CCR(channels[0]));
1420 1556
1421 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE; 1557 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE;
1422 return 0; 1558 return 0;
@@ -1434,7 +1570,7 @@ EXPORT_SYMBOL(omap_start_dma_chain_transfers);
1434int omap_stop_dma_chain_transfers(int chain_id) 1570int omap_stop_dma_chain_transfers(int chain_id)
1435{ 1571{
1436 int *channels; 1572 int *channels;
1437 u32 w, i; 1573 u32 l, i;
1438 u32 sys_cf; 1574 u32 sys_cf;
1439 1575
1440 /* Check for input params */ 1576 /* Check for input params */
@@ -1453,18 +1589,18 @@ int omap_stop_dma_chain_transfers(int chain_id)
1453 /* DMA Errata: 1589 /* DMA Errata:
1454 * Special programming model needed to disable DMA before end of block 1590 * Special programming model needed to disable DMA before end of block
1455 */ 1591 */
1456 sys_cf = omap_readl(OMAP_DMA4_OCP_SYSCONFIG); 1592 sys_cf = dma_read(OCP_SYSCONFIG);
1457 w = sys_cf; 1593 l = sys_cf;
1458 /* Middle mode reg set no Standby */ 1594 /* Middle mode reg set no Standby */
1459 w &= ~((1 << 12)|(1 << 13)); 1595 l &= ~((1 << 12)|(1 << 13));
1460 omap_writel(w, OMAP_DMA4_OCP_SYSCONFIG); 1596 dma_write(l, OCP_SYSCONFIG);
1461 1597
1462 for (i = 0; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) { 1598 for (i = 0; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) {
1463 1599
1464 /* Stop the Channel transmission */ 1600 /* Stop the Channel transmission */
1465 w = OMAP_DMA_CCR_REG(channels[i]); 1601 l = dma_read(CCR(channels[i]));
1466 w &= ~(1 << 7); 1602 l &= ~(1 << 7);
1467 OMAP_DMA_CCR_REG(channels[i]) = w; 1603 dma_write(l, CCR(channels[i]));
1468 1604
1469 /* Disable the link in all the channels */ 1605 /* Disable the link in all the channels */
1470 disable_lnk(channels[i]); 1606 disable_lnk(channels[i]);
@@ -1477,7 +1613,7 @@ int omap_stop_dma_chain_transfers(int chain_id)
1477 OMAP_DMA_CHAIN_QINIT(chain_id); 1613 OMAP_DMA_CHAIN_QINIT(chain_id);
1478 1614
1479 /* Errata - put in the old value */ 1615 /* Errata - put in the old value */
1480 omap_writel(sys_cf, OMAP_DMA4_OCP_SYSCONFIG); 1616 dma_write(sys_cf, OCP_SYSCONFIG);
1481 return 0; 1617 return 0;
1482} 1618}
1483EXPORT_SYMBOL(omap_stop_dma_chain_transfers); 1619EXPORT_SYMBOL(omap_stop_dma_chain_transfers);
@@ -1518,8 +1654,8 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)
1518 /* Get the current channel */ 1654 /* Get the current channel */
1519 lch = channels[dma_linked_lch[chain_id].q_head]; 1655 lch = channels[dma_linked_lch[chain_id].q_head];
1520 1656
1521 *ei = OMAP2_DMA_CCEN_REG(lch); 1657 *ei = dma_read(CCEN(lch));
1522 *fi = OMAP2_DMA_CCFN_REG(lch); 1658 *fi = dma_read(CCFN(lch));
1523 1659
1524 return 0; 1660 return 0;
1525} 1661}
@@ -1556,7 +1692,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)
1556 /* Get the current channel */ 1692 /* Get the current channel */
1557 lch = channels[dma_linked_lch[chain_id].q_head]; 1693 lch = channels[dma_linked_lch[chain_id].q_head];
1558 1694
1559 return (OMAP_DMA_CDAC_REG(lch)); 1695 return dma_read(CDAC(lch));
1560} 1696}
1561EXPORT_SYMBOL(omap_get_dma_chain_dst_pos); 1697EXPORT_SYMBOL(omap_get_dma_chain_dst_pos);
1562 1698
@@ -1590,7 +1726,7 @@ int omap_get_dma_chain_src_pos(int chain_id)
1590 /* Get the current channel */ 1726 /* Get the current channel */
1591 lch = channels[dma_linked_lch[chain_id].q_head]; 1727 lch = channels[dma_linked_lch[chain_id].q_head];
1592 1728
1593 return (OMAP_DMA_CSAC_REG(lch)); 1729 return dma_read(CSAC(lch));
1594} 1730}
1595EXPORT_SYMBOL(omap_get_dma_chain_src_pos); 1731EXPORT_SYMBOL(omap_get_dma_chain_src_pos);
1596#endif 1732#endif
@@ -1601,13 +1737,13 @@ EXPORT_SYMBOL(omap_get_dma_chain_src_pos);
1601 1737
1602static int omap1_dma_handle_ch(int ch) 1738static int omap1_dma_handle_ch(int ch)
1603{ 1739{
1604 u16 csr; 1740 u32 csr;
1605 1741
1606 if (enable_1510_mode && ch >= 6) { 1742 if (enable_1510_mode && ch >= 6) {
1607 csr = dma_chan[ch].saved_csr; 1743 csr = dma_chan[ch].saved_csr;
1608 dma_chan[ch].saved_csr = 0; 1744 dma_chan[ch].saved_csr = 0;
1609 } else 1745 } else
1610 csr = OMAP_DMA_CSR_REG(ch); 1746 csr = dma_read(CSR(ch));
1611 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) { 1747 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) {
1612 dma_chan[ch + 6].saved_csr = csr >> 7; 1748 dma_chan[ch + 6].saved_csr = csr >> 7;
1613 csr &= 0x7f; 1749 csr &= 0x7f;
@@ -1659,12 +1795,12 @@ static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id)
1659 1795
1660static int omap2_dma_handle_ch(int ch) 1796static int omap2_dma_handle_ch(int ch)
1661{ 1797{
1662 u32 status = OMAP_DMA_CSR_REG(ch); 1798 u32 status = dma_read(CSR(ch));
1663 1799
1664 if (!status) { 1800 if (!status) {
1665 if (printk_ratelimit()) 1801 if (printk_ratelimit())
1666 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n", ch); 1802 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n", ch);
1667 omap_writel(1 << ch, OMAP_DMA4_IRQSTATUS_L0); 1803 dma_write(1 << ch, IRQSTATUS_L0);
1668 return 0; 1804 return 0;
1669 } 1805 }
1670 if (unlikely(dma_chan[ch].dev_id == -1)) { 1806 if (unlikely(dma_chan[ch].dev_id == -1)) {
@@ -1687,14 +1823,14 @@ static int omap2_dma_handle_ch(int ch)
1687 printk(KERN_INFO "DMA misaligned error with device %d\n", 1823 printk(KERN_INFO "DMA misaligned error with device %d\n",
1688 dma_chan[ch].dev_id); 1824 dma_chan[ch].dev_id);
1689 1825
1690 OMAP_DMA_CSR_REG(ch) = OMAP2_DMA_CSR_CLEAR_MASK; 1826 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch));
1691 omap_writel(1 << ch, OMAP_DMA4_IRQSTATUS_L0); 1827 dma_write(1 << ch, IRQSTATUS_L0);
1692 1828
1693 /* If the ch is not chained then chain_id will be -1 */ 1829 /* If the ch is not chained then chain_id will be -1 */
1694 if (dma_chan[ch].chain_id != -1) { 1830 if (dma_chan[ch].chain_id != -1) {
1695 int chain_id = dma_chan[ch].chain_id; 1831 int chain_id = dma_chan[ch].chain_id;
1696 dma_chan[ch].state = DMA_CH_NOTSTARTED; 1832 dma_chan[ch].state = DMA_CH_NOTSTARTED;
1697 if (OMAP_DMA_CLNK_CTRL_REG(ch) & (1 << 15)) 1833 if (dma_read(CLNK_CTRL(ch)) & (1 << 15))
1698 dma_chan[dma_chan[ch].next_linked_ch].state = 1834 dma_chan[dma_chan[ch].next_linked_ch].state =
1699 DMA_CH_STARTED; 1835 DMA_CH_STARTED;
1700 if (dma_linked_lch[chain_id].chain_mode == 1836 if (dma_linked_lch[chain_id].chain_mode ==
@@ -1704,13 +1840,13 @@ static int omap2_dma_handle_ch(int ch)
1704 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id)) 1840 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id))
1705 OMAP_DMA_CHAIN_INCQHEAD(chain_id); 1841 OMAP_DMA_CHAIN_INCQHEAD(chain_id);
1706 1842
1707 status = OMAP_DMA_CSR_REG(ch); 1843 status = dma_read(CSR(ch));
1708 } 1844 }
1709 1845
1710 if (likely(dma_chan[ch].callback != NULL)) 1846 if (likely(dma_chan[ch].callback != NULL))
1711 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1847 dma_chan[ch].callback(ch, status, dma_chan[ch].data);
1712 1848
1713 OMAP_DMA_CSR_REG(ch) = status; 1849 dma_write(status, CSR(ch));
1714 1850
1715 return 0; 1851 return 0;
1716} 1852}
@@ -1721,7 +1857,7 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)
1721 u32 val; 1857 u32 val;
1722 int i; 1858 int i;
1723 1859
1724 val = omap_readl(OMAP_DMA4_IRQSTATUS_L0); 1860 val = dma_read(IRQSTATUS_L0);
1725 if (val == 0) { 1861 if (val == 0) {
1726 if (printk_ratelimit()) 1862 if (printk_ratelimit())
1727 printk(KERN_WARNING "Spurious DMA IRQ\n"); 1863 printk(KERN_WARNING "Spurious DMA IRQ\n");
@@ -2109,10 +2245,19 @@ static int __init omap_init_dma(void)
2109{ 2245{
2110 int ch, r; 2246 int ch, r;
2111 2247
2112 if (cpu_class_is_omap1()) 2248 if (cpu_class_is_omap1()) {
2249 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP1_DMA_BASE);
2113 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 2250 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT;
2114 else 2251 } else if (cpu_is_omap24xx()) {
2252 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP24XX_DMA4_BASE);
2115 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2253 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2254 } else if (cpu_is_omap34xx()) {
2255 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP34XX_DMA4_BASE);
2256 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2257 } else {
2258 pr_err("DMA init failed for unsupported omap\n");
2259 return -ENODEV;
2260 }
2116 2261
2117 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count, 2262 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count,
2118 GFP_KERNEL); 2263 GFP_KERNEL);
@@ -2134,21 +2279,21 @@ static int __init omap_init_dma(void)
2134 enable_1510_mode = 1; 2279 enable_1510_mode = 1;
2135 } else if (cpu_is_omap16xx() || cpu_is_omap730()) { 2280 } else if (cpu_is_omap16xx() || cpu_is_omap730()) {
2136 printk(KERN_INFO "OMAP DMA hardware version %d\n", 2281 printk(KERN_INFO "OMAP DMA hardware version %d\n",
2137 omap_readw(OMAP_DMA_HW_ID)); 2282 dma_read(HW_ID));
2138 printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n", 2283 printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
2139 (omap_readw(OMAP_DMA_CAPS_0_U) << 16) | 2284 (dma_read(CAPS_0_U) << 16) |
2140 omap_readw(OMAP_DMA_CAPS_0_L), 2285 dma_read(CAPS_0_L),
2141 (omap_readw(OMAP_DMA_CAPS_1_U) << 16) | 2286 (dma_read(CAPS_1_U) << 16) |
2142 omap_readw(OMAP_DMA_CAPS_1_L), 2287 dma_read(CAPS_1_L),
2143 omap_readw(OMAP_DMA_CAPS_2), omap_readw(OMAP_DMA_CAPS_3), 2288 dma_read(CAPS_2), dma_read(CAPS_3),
2144 omap_readw(OMAP_DMA_CAPS_4)); 2289 dma_read(CAPS_4));
2145 if (!enable_1510_mode) { 2290 if (!enable_1510_mode) {
2146 u16 w; 2291 u16 w;
2147 2292
2148 /* Disable OMAP 3.0/3.1 compatibility mode. */ 2293 /* Disable OMAP 3.0/3.1 compatibility mode. */
2149 w = omap_readw(OMAP_DMA_GSCR); 2294 w = dma_read(GSCR);
2150 w |= 1 << 3; 2295 w |= 1 << 3;
2151 omap_writew(w, OMAP_DMA_GSCR); 2296 dma_write(w, GSCR);
2152 dma_chan_count = 16; 2297 dma_chan_count = 16;
2153 } else 2298 } else
2154 dma_chan_count = 9; 2299 dma_chan_count = 9;
@@ -2161,7 +2306,7 @@ static int __init omap_init_dma(void)
2161 omap_writew(w, OMAP1610_DMA_LCD_CTRL); 2306 omap_writew(w, OMAP1610_DMA_LCD_CTRL);
2162 } 2307 }
2163 } else if (cpu_class_is_omap2()) { 2308 } else if (cpu_class_is_omap2()) {
2164 u8 revision = omap_readb(OMAP_DMA4_REVISION); 2309 u8 revision = dma_read(REVISION) & 0xff;
2165 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n", 2310 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n",
2166 revision >> 4, revision & 0xf); 2311 revision >> 4, revision & 0xf);
2167 dma_chan_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2312 dma_chan_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;