Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+450 -305
+326 -181
arch/arm/plat-omap/dma.c
··· 126 126 127 127 static spinlock_t dma_chan_lock; 128 128 static struct omap_dma_lch *dma_chan; 129 + static void __iomem *omap_dma_base; 129 130 130 131 static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = { 131 132 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3, ··· 142 141 143 142 #define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \ 144 143 __func__); 144 + 145 + #define dma_read(reg) \ 146 + ({ \ 147 + u32 __val; \ 148 + if (cpu_class_is_omap1()) \ 149 + __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \ 150 + else \ 151 + __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \ 152 + __val; \ 153 + }) 154 + 155 + #define dma_write(val, reg) \ 156 + ({ \ 157 + if (cpu_class_is_omap1()) \ 158 + __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \ 159 + else \ 160 + __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \ 161 + }) 145 162 146 163 #ifdef CONFIG_ARCH_OMAP15XX 147 164 /* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ ··· 195 176 #define set_gdma_dev(req, dev) do {} while (0) 196 177 #endif 197 178 179 + /* Omap1 only */ 198 180 static void clear_lch_regs(int lch) 199 181 { 200 182 int i; 201 - u32 lch_base = OMAP_DMA_BASE + lch * 0x40; 183 + void __iomem *lch_base = omap_dma_base + OMAP1_DMA_CH_BASE(lch); 202 184 203 185 for (i = 0; i < 0x2c; i += 2) 204 - omap_writew(0, lch_base + i); 186 + __raw_writew(0, lch_base + i); 205 187 } 206 188 207 189 void omap_set_dma_priority(int lch, int dst_port, int priority) ··· 235 215 } 236 216 237 217 if (cpu_class_is_omap2()) { 218 + u32 ccr; 219 + 220 + ccr = dma_read(CCR(lch)); 238 221 if (priority) 239 - OMAP_DMA_CCR_REG(lch) |= (1 << 6); 222 + ccr |= (1 << 6); 240 223 else 241 - OMAP_DMA_CCR_REG(lch) &= ~(1 << 6); 224 + ccr &= ~(1 << 6); 225 + dma_write(ccr, CCR(lch)); 242 226 } 243 227 } 244 228 ··· 250 226 int frame_count, int sync_mode, 251 227 int dma_trigger, int src_or_dst_synch) 252 228 { 253 - OMAP_DMA_CSDP_REG(lch) &= ~0x03; 254 - OMAP_DMA_CSDP_REG(lch) |= data_type; 229 + u32 l; 230 + 231 + l = dma_read(CSDP(lch)); 232 + l &= ~0x03; 233 + l |= data_type; 234 + dma_write(l, CSDP(lch)); 255 235 256 236 if (cpu_class_is_omap1()) { 257 - OMAP_DMA_CCR_REG(lch) &= ~(1 << 5); 258 - if (sync_mode == OMAP_DMA_SYNC_FRAME) 259 - OMAP_DMA_CCR_REG(lch) |= 1 << 5; 237 + u16 ccr; 260 238 261 - OMAP1_DMA_CCR2_REG(lch) &= ~(1 << 2); 239 + ccr = dma_read(CCR(lch)); 240 + ccr &= ~(1 << 5); 241 + if (sync_mode == OMAP_DMA_SYNC_FRAME) 242 + ccr |= 1 << 5; 243 + dma_write(ccr, CCR(lch)); 244 + 245 + ccr = dma_read(CCR2(lch)); 246 + ccr &= ~(1 << 2); 262 247 if (sync_mode == OMAP_DMA_SYNC_BLOCK) 263 - OMAP1_DMA_CCR2_REG(lch) |= 1 << 2; 248 + ccr |= 1 << 2; 249 + dma_write(ccr, CCR2(lch)); 264 250 } 265 251 266 252 if (cpu_class_is_omap2() && dma_trigger) { 267 - u32 val = OMAP_DMA_CCR_REG(lch); 253 + u32 val; 268 254 255 + val = dma_read(CCR(lch)); 269 256 val &= ~(3 << 19); 270 257 if (dma_trigger > 63) 271 258 val |= 1 << 20; ··· 301 266 else 302 267 val &= ~(1 << 24); /* dest synch */ 303 268 304 - OMAP_DMA_CCR_REG(lch) = val; 269 + dma_write(val, CCR(lch)); 305 270 } 306 271 307 - OMAP_DMA_CEN_REG(lch) = elem_count; 308 - OMAP_DMA_CFN_REG(lch) = frame_count; 272 + dma_write(elem_count, CEN(lch)); 273 + dma_write(frame_count, CFN(lch)); 309 274 } 310 275 311 276 void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color) ··· 319 284 return; 320 285 } 321 286 322 - w = OMAP1_DMA_CCR2_REG(lch) & ~0x03; 287 + w = dma_read(CCR2(lch)); 288 + w &= ~0x03; 289 + 323 290 switch (mode) { 324 291 case OMAP_DMA_CONSTANT_FILL: 325 292 w |= 0x01; ··· 334 297 default: 335 298 BUG(); 336 299 } 337 - OMAP1_DMA_CCR2_REG(lch) = w; 300 + dma_write(w, CCR2(lch)); 338 301 339 - w = OMAP1_DMA_LCH_CTRL_REG(lch) & ~0x0f; 302 + w = dma_read(LCH_CTRL(lch)); 303 + w &= ~0x0f; 340 304 /* Default is channel type 2D */ 341 305 if (mode) { 342 - OMAP1_DMA_COLOR_L_REG(lch) = (u16)color; 343 - OMAP1_DMA_COLOR_U_REG(lch) = (u16)(color >> 16); 306 + dma_write((u16)color, COLOR_L(lch)); 307 + dma_write((u16)(color >> 16), COLOR_U(lch)); 344 308 w |= 1; /* Channel type G */ 345 309 } 346 - OMAP1_DMA_LCH_CTRL_REG(lch) = w; 310 + dma_write(w, LCH_CTRL(lch)); 347 311 } 348 312 349 313 void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode) 350 314 { 351 315 if (cpu_class_is_omap2()) { 352 - OMAP_DMA_CSDP_REG(lch) &= ~(0x3 << 16); 353 - OMAP_DMA_CSDP_REG(lch) |= (mode << 16); 316 + u32 csdp; 317 + 318 + csdp = dma_read(CSDP(lch)); 319 + csdp &= ~(0x3 << 16); 320 + csdp |= (mode << 16); 321 + dma_write(csdp, CSDP(lch)); 354 322 } 355 323 } 324 + 325 + void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode) 326 + { 327 + if (cpu_class_is_omap1() && !cpu_is_omap15xx()) { 328 + u32 l; 329 + 330 + l = dma_read(LCH_CTRL(lch)); 331 + l &= ~0x7; 332 + l |= mode; 333 + dma_write(l, LCH_CTRL(lch)); 334 + } 335 + } 336 + EXPORT_SYMBOL(omap_set_dma_channel_mode); 356 337 357 338 /* Note that src_port is only for omap1 */ 358 339 void omap_set_dma_src_params(int lch, int src_port, int src_amode, ··· 378 323 int src_ei, int src_fi) 379 324 { 380 325 if (cpu_class_is_omap1()) { 381 - OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 2); 382 - OMAP_DMA_CSDP_REG(lch) |= src_port << 2; 326 + u16 w; 327 + 328 + w = dma_read(CSDP(lch)); 329 + w &= ~(0x1f << 2); 330 + w |= src_port << 2; 331 + dma_write(w, CSDP(lch)); 332 + 333 + w = dma_read(CCR(lch)); 334 + w &= ~(0x03 << 12); 335 + w |= src_amode << 12; 336 + dma_write(w, CCR(lch)); 337 + 338 + dma_write(src_start >> 16, CSSA_U(lch)); 339 + dma_write((u16)src_start, CSSA_L(lch)); 340 + 341 + dma_write(src_ei, CSEI(lch)); 342 + dma_write(src_fi, CSFI(lch)); 383 343 } 384 344 385 - OMAP_DMA_CCR_REG(lch) &= ~(0x03 << 12); 386 - OMAP_DMA_CCR_REG(lch) |= src_amode << 12; 345 + if (cpu_class_is_omap2()) { 346 + u32 l; 387 347 388 - if (cpu_class_is_omap1()) { 389 - OMAP1_DMA_CSSA_U_REG(lch) = src_start >> 16; 390 - OMAP1_DMA_CSSA_L_REG(lch) = src_start; 348 + l = dma_read(CCR(lch)); 349 + l &= ~(0x03 << 12); 350 + l |= src_amode << 12; 351 + dma_write(l, CCR(lch)); 352 + 353 + dma_write(src_start, CSSA(lch)); 354 + dma_write(src_ei, CSEI(lch)); 355 + dma_write(src_fi, CSFI(lch)); 391 356 } 392 - 393 - if (cpu_class_is_omap2()) 394 - OMAP2_DMA_CSSA_REG(lch) = src_start; 395 - 396 - OMAP_DMA_CSEI_REG(lch) = src_ei; 397 - OMAP_DMA_CSFI_REG(lch) = src_fi; 398 357 } 399 358 400 359 void omap_set_dma_params(int lch, struct omap_dma_channel_params * params) ··· 435 366 REVISIT_24XX(); 436 367 return; 437 368 } 438 - OMAP_DMA_CSEI_REG(lch) = eidx; 439 - OMAP_DMA_CSFI_REG(lch) = fidx; 369 + dma_write(eidx, CSEI(lch)); 370 + dma_write(fidx, CSFI(lch)); 440 371 } 441 372 442 373 void omap_set_dma_src_data_pack(int lch, int enable) 443 374 { 444 - OMAP_DMA_CSDP_REG(lch) &= ~(1 << 6); 375 + u32 l; 376 + 377 + l = dma_read(CSDP(lch)); 378 + l &= ~(1 << 6); 445 379 if (enable) 446 - OMAP_DMA_CSDP_REG(lch) |= (1 << 6); 380 + l |= (1 << 6); 381 + dma_write(l, CSDP(lch)); 447 382 } 448 383 449 384 void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) 450 385 { 451 386 unsigned int burst = 0; 452 - OMAP_DMA_CSDP_REG(lch) &= ~(0x03 << 7); 387 + u32 l; 388 + 389 + l = dma_read(CSDP(lch)); 390 + l &= ~(0x03 << 7); 453 391 454 392 switch (burst_mode) { 455 393 case OMAP_DMA_DATA_BURST_DIS: ··· 487 411 default: 488 412 BUG(); 489 413 } 490 - OMAP_DMA_CSDP_REG(lch) |= (burst << 7); 414 + 415 + l |= (burst << 7); 416 + dma_write(l, CSDP(lch)); 491 417 } 492 418 493 419 /* Note that dest_port is only for OMAP1 */ ··· 497 419 unsigned long dest_start, 498 420 int dst_ei, int dst_fi) 499 421 { 422 + u32 l; 423 + 500 424 if (cpu_class_is_omap1()) { 501 - OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 9); 502 - OMAP_DMA_CSDP_REG(lch) |= dest_port << 9; 425 + l = dma_read(CSDP(lch)); 426 + l &= ~(0x1f << 9); 427 + l |= dest_port << 9; 428 + dma_write(l, CSDP(lch)); 503 429 } 504 430 505 - OMAP_DMA_CCR_REG(lch) &= ~(0x03 << 14); 506 - OMAP_DMA_CCR_REG(lch) |= dest_amode << 14; 431 + l = dma_read(CCR(lch)); 432 + l &= ~(0x03 << 14); 433 + l |= dest_amode << 14; 434 + dma_write(l, CCR(lch)); 507 435 508 436 if (cpu_class_is_omap1()) { 509 - OMAP1_DMA_CDSA_U_REG(lch) = dest_start >> 16; 510 - OMAP1_DMA_CDSA_L_REG(lch) = dest_start; 437 + dma_write(dest_start >> 16, CDSA_U(lch)); 438 + dma_write(dest_start, CDSA_L(lch)); 511 439 } 512 440 513 441 if (cpu_class_is_omap2()) 514 - OMAP2_DMA_CDSA_REG(lch) = dest_start; 442 + dma_write(dest_start, CDSA(lch)); 515 443 516 - OMAP_DMA_CDEI_REG(lch) = dst_ei; 517 - OMAP_DMA_CDFI_REG(lch) = dst_fi; 444 + dma_write(dst_ei, CDEI(lch)); 445 + dma_write(dst_fi, CDFI(lch)); 518 446 } 519 447 520 448 void omap_set_dma_dest_index(int lch, int eidx, int fidx) ··· 529 445 REVISIT_24XX(); 530 446 return; 531 447 } 532 - OMAP_DMA_CDEI_REG(lch) = eidx; 533 - OMAP_DMA_CDFI_REG(lch) = fidx; 448 + dma_write(eidx, CDEI(lch)); 449 + dma_write(fidx, CDFI(lch)); 534 450 } 535 451 536 452 void omap_set_dma_dest_data_pack(int lch, int enable) 537 453 { 538 - OMAP_DMA_CSDP_REG(lch) &= ~(1 << 13); 454 + u32 l; 455 + 456 + l = dma_read(CSDP(lch)); 457 + l &= ~(1 << 13); 539 458 if (enable) 540 - OMAP_DMA_CSDP_REG(lch) |= 1 << 13; 459 + l |= 1 << 13; 460 + dma_write(l, CSDP(lch)); 541 461 } 542 462 543 463 void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) 544 464 { 545 465 unsigned int burst = 0; 546 - OMAP_DMA_CSDP_REG(lch) &= ~(0x03 << 14); 466 + u32 l; 467 + 468 + l = dma_read(CSDP(lch)); 469 + l &= ~(0x03 << 14); 547 470 548 471 switch (burst_mode) { 549 472 case OMAP_DMA_DATA_BURST_DIS: ··· 580 489 BUG(); 581 490 return; 582 491 } 583 - OMAP_DMA_CSDP_REG(lch) |= (burst << 14); 492 + l |= (burst << 14); 493 + dma_write(l, CSDP(lch)); 584 494 } 585 495 586 496 static inline void omap_enable_channel_irq(int lch) ··· 590 498 591 499 /* Clear CSR */ 592 500 if (cpu_class_is_omap1()) 593 - status = OMAP_DMA_CSR_REG(lch); 501 + status = dma_read(CSR(lch)); 594 502 else if (cpu_class_is_omap2()) 595 - OMAP_DMA_CSR_REG(lch) = OMAP2_DMA_CSR_CLEAR_MASK; 503 + dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 596 504 597 505 /* Enable some nice interrupts. */ 598 - OMAP_DMA_CICR_REG(lch) = dma_chan[lch].enabled_irqs; 506 + dma_write(dma_chan[lch].enabled_irqs, CICR(lch)); 599 507 } 600 508 601 509 static void omap_disable_channel_irq(int lch) 602 510 { 603 511 if (cpu_class_is_omap2()) 604 - OMAP_DMA_CICR_REG(lch) = 0; 512 + dma_write(0, CICR(lch)); 605 513 } 606 514 607 515 void omap_enable_dma_irq(int lch, u16 bits) ··· 616 524 617 525 static inline void enable_lnk(int lch) 618 526 { 527 + u32 l; 528 + 529 + l = dma_read(CLNK_CTRL(lch)); 530 + 619 531 if (cpu_class_is_omap1()) 620 - OMAP_DMA_CLNK_CTRL_REG(lch) &= ~(1 << 14); 532 + l &= ~(1 << 14); 621 533 622 534 /* Set the ENABLE_LNK bits */ 623 535 if (dma_chan[lch].next_lch != -1) 624 - OMAP_DMA_CLNK_CTRL_REG(lch) = 625 - dma_chan[lch].next_lch | (1 << 15); 536 + l = dma_chan[lch].next_lch | (1 << 15); 626 537 627 538 #ifndef CONFIG_ARCH_OMAP1 628 539 if (dma_chan[lch].next_linked_ch != -1) 629 - OMAP_DMA_CLNK_CTRL_REG(lch) = 630 - dma_chan[lch].next_linked_ch | (1 << 15); 540 + l = dma_chan[lch].next_linked_ch | (1 << 15); 631 541 #endif 542 + 543 + dma_write(l, CLNK_CTRL(lch)); 632 544 } 633 545 634 546 static inline void disable_lnk(int lch) 635 547 { 548 + u32 l; 549 + 550 + l = dma_read(CLNK_CTRL(lch)); 551 + 636 552 /* Disable interrupts */ 637 553 if (cpu_class_is_omap1()) { 638 - OMAP_DMA_CICR_REG(lch) = 0; 554 + dma_write(0, CICR(lch)); 639 555 /* Set the STOP_LNK bit */ 640 - OMAP_DMA_CLNK_CTRL_REG(lch) |= 1 << 14; 556 + l |= 1 << 14; 641 557 } 642 558 643 559 if (cpu_class_is_omap2()) { 644 560 omap_disable_channel_irq(lch); 645 561 /* Clear the ENABLE_LNK bit */ 646 - OMAP_DMA_CLNK_CTRL_REG(lch) &= ~(1 << 15); 562 + l &= ~(1 << 15); 647 563 } 648 564 565 + dma_write(l, CLNK_CTRL(lch)); 649 566 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 650 567 } 651 568 ··· 665 564 if (!cpu_class_is_omap2()) 666 565 return; 667 566 668 - val = omap_readl(OMAP_DMA4_IRQENABLE_L0); 567 + val = dma_read(IRQENABLE_L0); 669 568 val |= 1 << lch; 670 - omap_writel(val, OMAP_DMA4_IRQENABLE_L0); 569 + dma_write(val, IRQENABLE_L0); 671 570 } 672 571 673 572 int omap_request_dma(int dev_id, const char *dev_name, ··· 724 623 } 725 624 /* Disable the 1510 compatibility mode and set the sync device 726 625 * id. */ 727 - OMAP_DMA_CCR_REG(free_ch) = dev_id | (1 << 10); 626 + dma_write(dev_id | (1 << 10), CCR(free_ch)); 728 627 } else if (cpu_is_omap730() || cpu_is_omap15xx()) { 729 - OMAP_DMA_CCR_REG(free_ch) = dev_id; 628 + dma_write(dev_id, CCR(free_ch)); 730 629 } 731 630 732 631 if (cpu_class_is_omap2()) { ··· 734 633 735 634 omap_enable_channel_irq(free_ch); 736 635 /* Clear the CSR register and IRQ status register */ 737 - OMAP_DMA_CSR_REG(free_ch) = OMAP2_DMA_CSR_CLEAR_MASK; 738 - omap_writel(1 << free_ch, OMAP_DMA4_IRQSTATUS_L0); 636 + dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(free_ch)); 637 + dma_write(1 << free_ch, IRQSTATUS_L0); 739 638 } 740 639 741 640 *dma_ch_out = free_ch; ··· 761 660 762 661 if (cpu_class_is_omap1()) { 763 662 /* Disable all DMA interrupts for the channel. */ 764 - OMAP_DMA_CICR_REG(lch) = 0; 663 + dma_write(0, CICR(lch)); 765 664 /* Make sure the DMA transfer is stopped. */ 766 - OMAP_DMA_CCR_REG(lch) = 0; 665 + dma_write(0, CCR(lch)); 767 666 } 768 667 769 668 if (cpu_class_is_omap2()) { 770 669 u32 val; 771 670 /* Disable interrupts */ 772 - val = omap_readl(OMAP_DMA4_IRQENABLE_L0); 671 + val = dma_read(IRQENABLE_L0); 773 672 val &= ~(1 << lch); 774 - omap_writel(val, OMAP_DMA4_IRQENABLE_L0); 673 + dma_write(val, IRQENABLE_L0); 775 674 776 675 /* Clear the CSR register and IRQ status register */ 777 - OMAP_DMA_CSR_REG(lch) = OMAP2_DMA_CSR_CLEAR_MASK; 778 - omap_writel(1 << lch, OMAP_DMA4_IRQSTATUS_L0); 676 + dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 677 + dma_write(1 << lch, IRQSTATUS_L0); 779 678 780 679 /* Disable all DMA interrupts for the channel. */ 781 - OMAP_DMA_CICR_REG(lch) = 0; 680 + dma_write(0, CICR(lch)); 782 681 783 682 /* Make sure the DMA transfer is stopped. */ 784 - OMAP_DMA_CCR_REG(lch) = 0; 683 + dma_write(0, CCR(lch)); 785 684 omap_clear_dma(lch); 786 685 } 787 686 } ··· 812 711 reg = (arb_rate & 0xff) << 16; 813 712 reg |= (0xff & max_fifo_depth); 814 713 815 - omap_writel(reg, OMAP_DMA4_GCR_REG); 714 + dma_write(reg, GCR); 816 715 } 817 716 EXPORT_SYMBOL(omap_dma_set_global_params); 818 717 ··· 829 728 omap_dma_set_prio_lch(int lch, unsigned char read_prio, 830 729 unsigned char write_prio) 831 730 { 832 - u32 w; 731 + u32 l; 833 732 834 733 if (unlikely((lch < 0 || lch >= dma_lch_count))) { 835 734 printk(KERN_ERR "Invalid channel id\n"); 836 735 return -EINVAL; 837 736 } 838 - w = OMAP_DMA_CCR_REG(lch); 839 - w &= ~((1 << 6) | (1 << 26)); 737 + l = dma_read(CCR(lch)); 738 + l &= ~((1 << 6) | (1 << 26)); 840 739 if (cpu_is_omap2430() || cpu_is_omap34xx()) 841 - w |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); 740 + l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); 842 741 else 843 - w |= ((read_prio & 0x1) << 6); 742 + l |= ((read_prio & 0x1) << 6); 844 743 845 - OMAP_DMA_CCR_REG(lch) = w; 744 + dma_write(l, CCR(lch)); 745 + 846 746 return 0; 847 747 } 848 748 EXPORT_SYMBOL(omap_dma_set_prio_lch); ··· 859 757 local_irq_save(flags); 860 758 861 759 if (cpu_class_is_omap1()) { 862 - int status; 863 - OMAP_DMA_CCR_REG(lch) &= ~OMAP_DMA_CCR_EN; 760 + u32 l; 761 + 762 + l = dma_read(CCR(lch)); 763 + l &= ~OMAP_DMA_CCR_EN; 764 + dma_write(l, CCR(lch)); 864 765 865 766 /* Clear pending interrupts */ 866 - status = OMAP_DMA_CSR_REG(lch); 767 + l = dma_read(CSR(lch)); 867 768 } 868 769 869 770 if (cpu_class_is_omap2()) { 870 771 int i; 871 - u32 lch_base = OMAP_DMA4_BASE + lch * 0x60 + 0x80; 772 + void __iomem *lch_base = omap_dma_base + OMAP_DMA4_CH_BASE(lch); 872 773 for (i = 0; i < 0x44; i += 4) 873 - omap_writel(0, lch_base + i); 774 + __raw_writel(0, lch_base + i); 874 775 } 875 776 876 777 local_irq_restore(flags); ··· 881 776 882 777 void omap_start_dma(int lch) 883 778 { 779 + u32 l; 780 + 884 781 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 885 782 int next_lch, cur_lch; 886 783 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; ··· 909 802 } while (next_lch != -1); 910 803 } else if (cpu_class_is_omap2()) { 911 804 /* Errata: Need to write lch even if not using chaining */ 912 - OMAP_DMA_CLNK_CTRL_REG(lch) = lch; 805 + dma_write(lch, CLNK_CTRL(lch)); 913 806 } 914 807 915 808 omap_enable_channel_irq(lch); 916 809 810 + l = dma_read(CCR(lch)); 811 + 917 812 /* Errata: On ES2.0 BUFFERING disable must be set. 918 813 * This will always fail on ES1.0 */ 919 - if (cpu_is_omap24xx()) { 920 - OMAP_DMA_CCR_REG(lch) |= OMAP_DMA_CCR_EN; 921 - } 814 + if (cpu_is_omap24xx()) 815 + l |= OMAP_DMA_CCR_EN; 922 816 923 - OMAP_DMA_CCR_REG(lch) |= OMAP_DMA_CCR_EN; 817 + l |= OMAP_DMA_CCR_EN; 818 + dma_write(l, CCR(lch)); 924 819 925 820 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 926 821 } 927 822 928 823 void omap_stop_dma(int lch) 929 824 { 825 + u32 l; 826 + 930 827 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 931 828 int next_lch, cur_lch = lch; 932 829 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; ··· 954 843 955 844 /* Disable all interrupts on the channel */ 956 845 if (cpu_class_is_omap1()) 957 - OMAP_DMA_CICR_REG(lch) = 0; 846 + dma_write(0, CICR(lch)); 958 847 959 - OMAP_DMA_CCR_REG(lch) &= ~OMAP_DMA_CCR_EN; 848 + l = dma_read(CCR(lch)); 849 + l &= ~OMAP_DMA_CCR_EN; 850 + dma_write(l, CCR(lch)); 851 + 960 852 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 961 853 } 962 854 ··· 1001 887 { 1002 888 dma_addr_t offset = 0; 1003 889 1004 - if (cpu_class_is_omap1()) 1005 - offset = (dma_addr_t) (OMAP1_DMA_CSSA_L_REG(lch) | 1006 - (OMAP1_DMA_CSSA_U_REG(lch) << 16)); 890 + if (cpu_is_omap15xx()) 891 + offset = dma_read(CPC(lch)); 892 + else 893 + offset = dma_read(CSAC(lch)); 1007 894 1008 - if (cpu_class_is_omap2()) 1009 - offset = OMAP_DMA_CSAC_REG(lch); 895 + /* 896 + * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 897 + * read before the DMA controller finished disabling the channel. 898 + */ 899 + if (!cpu_is_omap15xx() && offset == 0) 900 + offset = dma_read(CSAC(lch)); 901 + 902 + if (cpu_class_is_omap1()) 903 + offset |= (dma_read(CSSA_U(lch)) << 16); 1010 904 1011 905 return offset; 1012 906 } ··· 1031 909 { 1032 910 dma_addr_t offset = 0; 1033 911 1034 - if (cpu_class_is_omap1()) 1035 - offset = (dma_addr_t) (OMAP1_DMA_CDSA_L_REG(lch) | 1036 - (OMAP1_DMA_CDSA_U_REG(lch) << 16)); 912 + if (cpu_is_omap15xx()) 913 + offset = dma_read(CPC(lch)); 914 + else 915 + offset = dma_read(CDAC(lch)); 1037 916 1038 - if (cpu_class_is_omap2()) 1039 - offset = OMAP_DMA_CDAC_REG(lch); 917 + /* 918 + * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 919 + * read before the DMA controller finished disabling the channel. 920 + */ 921 + if (!cpu_is_omap15xx() && offset == 0) 922 + offset = dma_read(CDAC(lch)); 923 + 924 + if (cpu_class_is_omap1()) 925 + offset |= (dma_read(CDSA_U(lch)) << 16); 1040 926 1041 927 return offset; 1042 928 } ··· 1056 926 */ 1057 927 int omap_get_dma_src_addr_counter(int lch) 1058 928 { 1059 - return (dma_addr_t) OMAP_DMA_CSAC_REG(lch); 929 + return (dma_addr_t)dma_read(CSAC(lch)); 1060 930 } 931 + 932 + int omap_get_dma_active_status(int lch) 933 + { 934 + return (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) != 0; 935 + } 936 + EXPORT_SYMBOL(omap_get_dma_active_status); 1061 937 1062 938 int omap_dma_running(void) 1063 939 { ··· 1075 939 return 1; 1076 940 1077 941 for (lch = 0; lch < dma_chan_count; lch++) 1078 - if (OMAP_DMA_CCR_REG(lch) & OMAP_DMA_CCR_EN) 942 + if (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) 1079 943 return 1; 1080 944 1081 945 return 0; ··· 1137 1001 /* Create chain of DMA channesls */ 1138 1002 static void create_dma_lch_chain(int lch_head, int lch_queue) 1139 1003 { 1140 - u32 w; 1004 + u32 l; 1141 1005 1142 1006 /* Check if this is the first link in chain */ 1143 1007 if (dma_chan[lch_head].next_linked_ch == -1) { ··· 1157 1021 lch_queue; 1158 1022 } 1159 1023 1160 - w = OMAP_DMA_CLNK_CTRL_REG(lch_head); 1161 - w &= ~(0x1f); 1162 - w |= lch_queue; 1163 - OMAP_DMA_CLNK_CTRL_REG(lch_head) = w; 1024 + l = dma_read(CLNK_CTRL(lch_head)); 1025 + l &= ~(0x1f); 1026 + l |= lch_queue; 1027 + dma_write(l, CLNK_CTRL(lch_head)); 1164 1028 1165 - w = OMAP_DMA_CLNK_CTRL_REG(lch_queue); 1166 - w &= ~(0x1f); 1167 - w |= (dma_chan[lch_queue].next_linked_ch); 1168 - OMAP_DMA_CLNK_CTRL_REG(lch_queue) = w; 1029 + l = dma_read(CLNK_CTRL(lch_queue)); 1030 + l &= ~(0x1f); 1031 + l |= (dma_chan[lch_queue].next_linked_ch); 1032 + dma_write(l, CLNK_CTRL(lch_queue)); 1169 1033 } 1170 1034 1171 1035 /** ··· 1392 1256 int elem_count, int frame_count, void *callbk_data) 1393 1257 { 1394 1258 int *channels; 1395 - u32 w, lch; 1259 + u32 l, lch; 1396 1260 int start_dma = 0; 1397 1261 1398 1262 /* if buffer size is less than 1 then there is ··· 1433 1297 1434 1298 /* Set the params to the free channel */ 1435 1299 if (src_start != 0) 1436 - OMAP2_DMA_CSSA_REG(lch) = src_start; 1300 + dma_write(src_start, CSSA(lch)); 1437 1301 if (dest_start != 0) 1438 - OMAP2_DMA_CDSA_REG(lch) = dest_start; 1302 + dma_write(dest_start, CDSA(lch)); 1439 1303 1440 1304 /* Write the buffer size */ 1441 - OMAP_DMA_CEN_REG(lch) = elem_count; 1442 - OMAP_DMA_CFN_REG(lch) = frame_count; 1305 + dma_write(elem_count, CEN(lch)); 1306 + dma_write(frame_count, CFN(lch)); 1443 1307 1444 1308 /* If the chain is dynamically linked, 1445 1309 * then we may have to start the chain if its not active */ ··· 1466 1330 enable_lnk(dma_chan[lch].prev_linked_ch); 1467 1331 dma_chan[lch].state = DMA_CH_QUEUED; 1468 1332 start_dma = 0; 1469 - if (0 == ((1 << 7) & (OMAP_DMA_CCR_REG 1470 - (dma_chan[lch].prev_linked_ch)))) { 1333 + if (0 == ((1 << 7) & dma_read( 1334 + CCR(dma_chan[lch].prev_linked_ch)))) { 1471 1335 disable_lnk(dma_chan[lch]. 1472 1336 prev_linked_ch); 1473 1337 pr_debug("\n prev ch is stopped\n"); ··· 1483 1347 } 1484 1348 omap_enable_channel_irq(lch); 1485 1349 1486 - w = OMAP_DMA_CCR_REG(lch); 1350 + l = dma_read(CCR(lch)); 1487 1351 1488 - if ((0 == (w & (1 << 24)))) 1489 - w &= ~(1 << 25); 1352 + if ((0 == (l & (1 << 24)))) 1353 + l &= ~(1 << 25); 1490 1354 else 1491 - w |= (1 << 25); 1355 + l |= (1 << 25); 1492 1356 if (start_dma == 1) { 1493 - if (0 == (w & (1 << 7))) { 1494 - w |= (1 << 7); 1357 + if (0 == (l & (1 << 7))) { 1358 + l |= (1 << 7); 1495 1359 dma_chan[lch].state = DMA_CH_STARTED; 1496 1360 pr_debug("starting %d\n", lch); 1497 - OMAP_DMA_CCR_REG(lch) = w; 1361 + dma_write(l, CCR(lch)); 1498 1362 } else 1499 1363 start_dma = 0; 1500 1364 } else { 1501 - if (0 == (w & (1 << 7))) 1502 - OMAP_DMA_CCR_REG(lch) = w; 1365 + if (0 == (l & (1 << 7))) 1366 + dma_write(l, CCR(lch)); 1503 1367 } 1504 1368 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 1505 1369 } ··· 1519 1383 int omap_start_dma_chain_transfers(int chain_id) 1520 1384 { 1521 1385 int *channels; 1522 - u32 w, i; 1386 + u32 l, i; 1523 1387 1524 1388 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) { 1525 1389 printk(KERN_ERR "Invalid chain id\n"); ··· 1543 1407 omap_enable_channel_irq(channels[0]); 1544 1408 } 1545 1409 1546 - w = OMAP_DMA_CCR_REG(channels[0]); 1547 - w |= (1 << 7); 1410 + l = dma_read(CCR(channels[0])); 1411 + l |= (1 << 7); 1548 1412 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED; 1549 1413 dma_chan[channels[0]].state = DMA_CH_STARTED; 1550 1414 1551 - if ((0 == (w & (1 << 24)))) 1552 - w &= ~(1 << 25); 1415 + if ((0 == (l & (1 << 24)))) 1416 + l &= ~(1 << 25); 1553 1417 else 1554 - w |= (1 << 25); 1555 - OMAP_DMA_CCR_REG(channels[0]) = w; 1418 + l |= (1 << 25); 1419 + dma_write(l, CCR(channels[0])); 1556 1420 1557 1421 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE; 1558 1422 return 0; ··· 1570 1434 int omap_stop_dma_chain_transfers(int chain_id) 1571 1435 { 1572 1436 int *channels; 1573 - u32 w, i; 1437 + u32 l, i; 1574 1438 u32 sys_cf; 1575 1439 1576 1440 /* Check for input params */ ··· 1589 1453 /* DMA Errata: 1590 1454 * Special programming model needed to disable DMA before end of block 1591 1455 */ 1592 - sys_cf = omap_readl(OMAP_DMA4_OCP_SYSCONFIG); 1593 - w = sys_cf; 1456 + sys_cf = dma_read(OCP_SYSCONFIG); 1457 + l = sys_cf; 1594 1458 /* Middle mode reg set no Standby */ 1595 - w &= ~((1 << 12)|(1 << 13)); 1596 - omap_writel(w, OMAP_DMA4_OCP_SYSCONFIG); 1459 + l &= ~((1 << 12)|(1 << 13)); 1460 + dma_write(l, OCP_SYSCONFIG); 1597 1461 1598 1462 for (i = 0; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) { 1599 1463 1600 1464 /* Stop the Channel transmission */ 1601 - w = OMAP_DMA_CCR_REG(channels[i]); 1602 - w &= ~(1 << 7); 1603 - OMAP_DMA_CCR_REG(channels[i]) = w; 1465 + l = dma_read(CCR(channels[i])); 1466 + l &= ~(1 << 7); 1467 + dma_write(l, CCR(channels[i])); 1604 1468 1605 1469 /* Disable the link in all the channels */ 1606 1470 disable_lnk(channels[i]); ··· 1613 1477 OMAP_DMA_CHAIN_QINIT(chain_id); 1614 1478 1615 1479 /* Errata - put in the old value */ 1616 - omap_writel(sys_cf, OMAP_DMA4_OCP_SYSCONFIG); 1480 + dma_write(sys_cf, OCP_SYSCONFIG); 1617 1481 return 0; 1618 1482 } 1619 1483 EXPORT_SYMBOL(omap_stop_dma_chain_transfers); ··· 1654 1518 /* Get the current channel */ 1655 1519 lch = channels[dma_linked_lch[chain_id].q_head]; 1656 1520 1657 - *ei = OMAP2_DMA_CCEN_REG(lch); 1658 - *fi = OMAP2_DMA_CCFN_REG(lch); 1521 + *ei = dma_read(CCEN(lch)); 1522 + *fi = dma_read(CCFN(lch)); 1659 1523 1660 1524 return 0; 1661 1525 } ··· 1692 1556 /* Get the current channel */ 1693 1557 lch = channels[dma_linked_lch[chain_id].q_head]; 1694 1558 1695 - return (OMAP_DMA_CDAC_REG(lch)); 1559 + return dma_read(CDAC(lch)); 1696 1560 } 1697 1561 EXPORT_SYMBOL(omap_get_dma_chain_dst_pos); 1698 1562 ··· 1726 1590 /* Get the current channel */ 1727 1591 lch = channels[dma_linked_lch[chain_id].q_head]; 1728 1592 1729 - return (OMAP_DMA_CSAC_REG(lch)); 1593 + return dma_read(CSAC(lch)); 1730 1594 } 1731 1595 EXPORT_SYMBOL(omap_get_dma_chain_src_pos); 1732 1596 #endif ··· 1737 1601 1738 1602 static int omap1_dma_handle_ch(int ch) 1739 1603 { 1740 - u16 csr; 1604 + u32 csr; 1741 1605 1742 1606 if (enable_1510_mode && ch >= 6) { 1743 1607 csr = dma_chan[ch].saved_csr; 1744 1608 dma_chan[ch].saved_csr = 0; 1745 1609 } else 1746 - csr = OMAP_DMA_CSR_REG(ch); 1610 + csr = dma_read(CSR(ch)); 1747 1611 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) { 1748 1612 dma_chan[ch + 6].saved_csr = csr >> 7; 1749 1613 csr &= 0x7f; ··· 1795 1659 1796 1660 static int omap2_dma_handle_ch(int ch) 1797 1661 { 1798 - u32 status = OMAP_DMA_CSR_REG(ch); 1662 + u32 status = dma_read(CSR(ch)); 1799 1663 1800 1664 if (!status) { 1801 1665 if (printk_ratelimit()) 1802 1666 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n", ch); 1803 - omap_writel(1 << ch, OMAP_DMA4_IRQSTATUS_L0); 1667 + dma_write(1 << ch, IRQSTATUS_L0); 1804 1668 return 0; 1805 1669 } 1806 1670 if (unlikely(dma_chan[ch].dev_id == -1)) { ··· 1823 1687 printk(KERN_INFO "DMA misaligned error with device %d\n", 1824 1688 dma_chan[ch].dev_id); 1825 1689 1826 - OMAP_DMA_CSR_REG(ch) = OMAP2_DMA_CSR_CLEAR_MASK; 1827 - omap_writel(1 << ch, OMAP_DMA4_IRQSTATUS_L0); 1690 + dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch)); 1691 + dma_write(1 << ch, IRQSTATUS_L0); 1828 1692 1829 1693 /* If the ch is not chained then chain_id will be -1 */ 1830 1694 if (dma_chan[ch].chain_id != -1) { 1831 1695 int chain_id = dma_chan[ch].chain_id; 1832 1696 dma_chan[ch].state = DMA_CH_NOTSTARTED; 1833 - if (OMAP_DMA_CLNK_CTRL_REG(ch) & (1 << 15)) 1697 + if (dma_read(CLNK_CTRL(ch)) & (1 << 15)) 1834 1698 dma_chan[dma_chan[ch].next_linked_ch].state = 1835 1699 DMA_CH_STARTED; 1836 1700 if (dma_linked_lch[chain_id].chain_mode == ··· 1840 1704 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id)) 1841 1705 OMAP_DMA_CHAIN_INCQHEAD(chain_id); 1842 1706 1843 - status = OMAP_DMA_CSR_REG(ch); 1707 + status = dma_read(CSR(ch)); 1844 1708 } 1845 1709 1846 1710 if (likely(dma_chan[ch].callback != NULL)) 1847 1711 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1848 1712 1849 - OMAP_DMA_CSR_REG(ch) = status; 1713 + dma_write(status, CSR(ch)); 1850 1714 1851 1715 return 0; 1852 1716 } ··· 1857 1721 u32 val; 1858 1722 int i; 1859 1723 1860 - val = omap_readl(OMAP_DMA4_IRQSTATUS_L0); 1724 + val = dma_read(IRQSTATUS_L0); 1861 1725 if (val == 0) { 1862 1726 if (printk_ratelimit()) 1863 1727 printk(KERN_WARNING "Spurious DMA IRQ\n"); ··· 2245 2109 { 2246 2110 int ch, r; 2247 2111 2248 - if (cpu_class_is_omap1()) 2112 + if (cpu_class_is_omap1()) { 2113 + omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP1_DMA_BASE); 2249 2114 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 2250 - else 2115 + } else if (cpu_is_omap24xx()) { 2116 + omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP24XX_DMA4_BASE); 2251 2117 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2118 + } else if (cpu_is_omap34xx()) { 2119 + omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP34XX_DMA4_BASE); 2120 + dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2121 + } else { 2122 + pr_err("DMA init failed for unsupported omap\n"); 2123 + return -ENODEV; 2124 + } 2252 2125 2253 2126 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count, 2254 2127 GFP_KERNEL); ··· 2279 2134 enable_1510_mode = 1; 2280 2135 } else if (cpu_is_omap16xx() || cpu_is_omap730()) { 2281 2136 printk(KERN_INFO "OMAP DMA hardware version %d\n", 2282 - omap_readw(OMAP_DMA_HW_ID)); 2137 + dma_read(HW_ID)); 2283 2138 printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n", 2284 - (omap_readw(OMAP_DMA_CAPS_0_U) << 16) | 2285 - omap_readw(OMAP_DMA_CAPS_0_L), 2286 - (omap_readw(OMAP_DMA_CAPS_1_U) << 16) | 2287 - omap_readw(OMAP_DMA_CAPS_1_L), 2288 - omap_readw(OMAP_DMA_CAPS_2), omap_readw(OMAP_DMA_CAPS_3), 2289 - omap_readw(OMAP_DMA_CAPS_4)); 2139 + (dma_read(CAPS_0_U) << 16) | 2140 + dma_read(CAPS_0_L), 2141 + (dma_read(CAPS_1_U) << 16) | 2142 + dma_read(CAPS_1_L), 2143 + dma_read(CAPS_2), dma_read(CAPS_3), 2144 + dma_read(CAPS_4)); 2290 2145 if (!enable_1510_mode) { 2291 2146 u16 w; 2292 2147 2293 2148 /* Disable OMAP 3.0/3.1 compatibility mode. */ 2294 - w = omap_readw(OMAP_DMA_GSCR); 2149 + w = dma_read(GSCR); 2295 2150 w |= 1 << 3; 2296 - omap_writew(w, OMAP_DMA_GSCR); 2151 + dma_write(w, GSCR); 2297 2152 dma_chan_count = 16; 2298 2153 } else 2299 2154 dma_chan_count = 9; ··· 2306 2161 omap_writew(w, OMAP1610_DMA_LCD_CTRL); 2307 2162 } 2308 2163 } else if (cpu_class_is_omap2()) { 2309 - u8 revision = omap_readb(OMAP_DMA4_REVISION); 2164 + u8 revision = dma_read(REVISION) & 0xff; 2310 2165 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n", 2311 2166 revision >> 4, revision & 0xf); 2312 2167 dma_chan_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
+6 -36
drivers/usb/gadget/omap_udc.c
··· 491 491 492 492 /*-------------------------------------------------------------------------*/ 493 493 494 - static inline dma_addr_t dma_csac(unsigned lch) 495 - { 496 - dma_addr_t csac; 497 - 498 - /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 499 - * read before the DMA controller finished disabling the channel. 500 - */ 501 - csac = OMAP_DMA_CSAC_REG(lch); 502 - if (csac == 0) 503 - csac = OMAP_DMA_CSAC_REG(lch); 504 - return csac; 505 - } 506 - 507 - static inline dma_addr_t dma_cdac(unsigned lch) 508 - { 509 - dma_addr_t cdac; 510 - 511 - /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 512 - * read before the DMA controller finished disabling the channel. 513 - */ 514 - cdac = OMAP_DMA_CDAC_REG(lch); 515 - if (cdac == 0) 516 - cdac = OMAP_DMA_CDAC_REG(lch); 517 - return cdac; 518 - } 519 - 520 494 static u16 dma_src_len(struct omap_ep *ep, dma_addr_t start) 521 495 { 522 496 dma_addr_t end; ··· 501 527 if (cpu_is_omap15xx()) 502 528 return 0; 503 529 504 - end = dma_csac(ep->lch); 530 + end = omap_get_dma_src_pos(ep->lch); 505 531 if (end == ep->dma_counter) 506 532 return 0; 507 533 ··· 511 537 return end - start; 512 538 } 513 539 514 - #define DMA_DEST_LAST(x) (cpu_is_omap15xx() \ 515 - ? OMAP_DMA_CSAC_REG(x) /* really: CPC */ \ 516 - : dma_cdac(x)) 517 - 518 540 static u16 dma_dest_len(struct omap_ep *ep, dma_addr_t start) 519 541 { 520 542 dma_addr_t end; 521 543 522 - end = DMA_DEST_LAST(ep->lch); 544 + end = omap_get_dma_dst_pos(ep->lch); 523 545 if (end == ep->dma_counter) 524 546 return 0; 525 547 ··· 566 596 0, 0); 567 597 568 598 omap_start_dma(ep->lch); 569 - ep->dma_counter = dma_csac(ep->lch); 599 + ep->dma_counter = omap_get_dma_src_pos(ep->lch); 570 600 UDC_DMA_IRQ_EN_REG |= UDC_TX_DONE_IE(ep->dma_channel); 571 601 UDC_TXDMA_REG(ep->dma_channel) = UDC_TXN_START | txdma_ctrl; 572 602 req->dma_bytes = length; ··· 624 654 omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, 625 655 OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, 626 656 0, 0); 627 - ep->dma_counter = DMA_DEST_LAST(ep->lch); 657 + ep->dma_counter = omap_get_dma_dst_pos(ep->lch); 628 658 629 659 UDC_RXDMA_REG(ep->dma_channel) = UDC_RXN_STOP | (packets - 1); 630 660 UDC_DMA_IRQ_EN_REG |= UDC_RX_EOT_IE(ep->dma_channel); ··· 804 834 805 835 /* channel type P: hw synch (fifo) */ 806 836 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) 807 - OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2; 837 + omap_set_dma_channel_mode(ep->lch, OMAP_DMA_LCH_P); 808 838 } 809 839 810 840 just_restart: ··· 851 881 else 852 882 req = NULL; 853 883 854 - active = ((1 << 7) & OMAP_DMA_CCR_REG(ep->lch)) != 0; 884 + active = omap_get_dma_active_status(ep->lch); 855 885 856 886 DBG("%s release %s %cxdma%d %p\n", ep->ep.name, 857 887 active ? "active" : "idle",
+118 -88
include/asm-arm/arch-omap/dma.h
··· 22 22 #define __ASM_ARCH_DMA_H 23 23 24 24 /* Hardware registers for omap1 */ 25 - #define OMAP_DMA_BASE (0xfffed800) 26 - #define OMAP_DMA_GCR (OMAP_DMA_BASE + 0x400) 27 - #define OMAP_DMA_GSCR (OMAP_DMA_BASE + 0x404) 28 - #define OMAP_DMA_GRST (OMAP_DMA_BASE + 0x408) 29 - #define OMAP_DMA_HW_ID (OMAP_DMA_BASE + 0x442) 30 - #define OMAP_DMA_PCH2_ID (OMAP_DMA_BASE + 0x444) 31 - #define OMAP_DMA_PCH0_ID (OMAP_DMA_BASE + 0x446) 32 - #define OMAP_DMA_PCH1_ID (OMAP_DMA_BASE + 0x448) 33 - #define OMAP_DMA_PCHG_ID (OMAP_DMA_BASE + 0x44a) 34 - #define OMAP_DMA_PCHD_ID (OMAP_DMA_BASE + 0x44c) 35 - #define OMAP_DMA_CAPS_0_U (OMAP_DMA_BASE + 0x44e) 36 - #define OMAP_DMA_CAPS_0_L (OMAP_DMA_BASE + 0x450) 37 - #define OMAP_DMA_CAPS_1_U (OMAP_DMA_BASE + 0x452) 38 - #define OMAP_DMA_CAPS_1_L (OMAP_DMA_BASE + 0x454) 39 - #define OMAP_DMA_CAPS_2 (OMAP_DMA_BASE + 0x456) 40 - #define OMAP_DMA_CAPS_3 (OMAP_DMA_BASE + 0x458) 41 - #define OMAP_DMA_CAPS_4 (OMAP_DMA_BASE + 0x45a) 42 - #define OMAP_DMA_PCH2_SR (OMAP_DMA_BASE + 0x460) 43 - #define OMAP_DMA_PCH0_SR (OMAP_DMA_BASE + 0x480) 44 - #define OMAP_DMA_PCH1_SR (OMAP_DMA_BASE + 0x482) 45 - #define OMAP_DMA_PCHD_SR (OMAP_DMA_BASE + 0x4c0) 25 + #define OMAP1_DMA_BASE (0xfffed800) 46 26 47 - /* Hardware registers for omap2 */ 48 - #if defined(CONFIG_ARCH_OMAP3) 49 - #define OMAP_DMA4_BASE (L4_34XX_BASE + 0x56000) 50 - #else /* CONFIG_ARCH_OMAP2 */ 51 - #define OMAP_DMA4_BASE (L4_24XX_BASE + 0x56000) 52 - #endif 27 + #define OMAP1_DMA_GCR 0x400 28 + #define OMAP1_DMA_GSCR 0x404 29 + #define OMAP1_DMA_GRST 0x408 30 + #define OMAP1_DMA_HW_ID 0x442 31 + #define OMAP1_DMA_PCH2_ID 0x444 32 + #define OMAP1_DMA_PCH0_ID 0x446 33 + #define OMAP1_DMA_PCH1_ID 0x448 34 + #define OMAP1_DMA_PCHG_ID 0x44a 35 + #define OMAP1_DMA_PCHD_ID 0x44c 36 + #define OMAP1_DMA_CAPS_0_U 0x44e 37 + #define OMAP1_DMA_CAPS_0_L 0x450 38 + #define OMAP1_DMA_CAPS_1_U 0x452 39 + #define OMAP1_DMA_CAPS_1_L 0x454 40 + #define OMAP1_DMA_CAPS_2 0x456 41 + #define OMAP1_DMA_CAPS_3 0x458 42 + #define OMAP1_DMA_CAPS_4 0x45a 43 + #define OMAP1_DMA_PCH2_SR 0x460 44 + #define OMAP1_DMA_PCH0_SR 0x480 45 + #define OMAP1_DMA_PCH1_SR 0x482 46 + #define OMAP1_DMA_PCHD_SR 0x4c0 53 47 54 - #define OMAP_DMA4_REVISION (OMAP_DMA4_BASE + 0x00) 55 - #define OMAP_DMA4_GCR_REG (OMAP_DMA4_BASE + 0x78) 56 - #define OMAP_DMA4_IRQSTATUS_L0 (OMAP_DMA4_BASE + 0x08) 57 - #define OMAP_DMA4_IRQSTATUS_L1 (OMAP_DMA4_BASE + 0x0c) 58 - #define OMAP_DMA4_IRQSTATUS_L2 (OMAP_DMA4_BASE + 0x10) 59 - #define OMAP_DMA4_IRQSTATUS_L3 (OMAP_DMA4_BASE + 0x14) 60 - #define OMAP_DMA4_IRQENABLE_L0 (OMAP_DMA4_BASE + 0x18) 61 - #define OMAP_DMA4_IRQENABLE_L1 (OMAP_DMA4_BASE + 0x1c) 62 - #define OMAP_DMA4_IRQENABLE_L2 (OMAP_DMA4_BASE + 0x20) 63 - #define OMAP_DMA4_IRQENABLE_L3 (OMAP_DMA4_BASE + 0x24) 64 - #define OMAP_DMA4_SYSSTATUS (OMAP_DMA4_BASE + 0x28) 65 - #define OMAP_DMA4_OCP_SYSCONFIG (OMAP_DMA4_BASE + 0x2c) 66 - #define OMAP_DMA4_CAPS_0 (OMAP_DMA4_BASE + 0x64) 67 - #define OMAP_DMA4_CAPS_2 (OMAP_DMA4_BASE + 0x6c) 68 - #define OMAP_DMA4_CAPS_3 (OMAP_DMA4_BASE + 0x70) 69 - #define OMAP_DMA4_CAPS_4 (OMAP_DMA4_BASE + 0x74) 48 + /* Hardware registers for omap2 and omap3 */ 49 + #define OMAP24XX_DMA4_BASE (L4_24XX_BASE + 0x56000) 50 + #define OMAP34XX_DMA4_BASE (L4_34XX_BASE + 0x56000) 51 + 52 + #define OMAP_DMA4_REVISION 0x00 53 + #define OMAP_DMA4_GCR 0x78 54 + #define OMAP_DMA4_IRQSTATUS_L0 0x08 55 + #define OMAP_DMA4_IRQSTATUS_L1 0x0c 56 + #define OMAP_DMA4_IRQSTATUS_L2 0x10 57 + #define OMAP_DMA4_IRQSTATUS_L3 0x14 58 + #define OMAP_DMA4_IRQENABLE_L0 0x18 59 + #define OMAP_DMA4_IRQENABLE_L1 0x1c 60 + #define OMAP_DMA4_IRQENABLE_L2 0x20 61 + #define OMAP_DMA4_IRQENABLE_L3 0x24 62 + #define OMAP_DMA4_SYSSTATUS 0x28 63 + #define OMAP_DMA4_OCP_SYSCONFIG 0x2c 64 + #define OMAP_DMA4_CAPS_0 0x64 65 + #define OMAP_DMA4_CAPS_2 0x6c 66 + #define OMAP_DMA4_CAPS_3 0x70 67 + #define OMAP_DMA4_CAPS_4 0x74 70 68 71 69 #define OMAP1_LOGICAL_DMA_CH_COUNT 17 72 70 #define OMAP_DMA4_LOGICAL_DMA_CH_COUNT 32 /* REVISIT: Is this 32 + 2? */ 73 71 74 - #ifdef CONFIG_ARCH_OMAP1 75 - 76 72 /* Common channel specific registers for omap1 */ 77 - #define OMAP_DMA_CSDP_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x00) 78 - #define OMAP_DMA_CCR_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x02) 79 - #define OMAP_DMA_CICR_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x04) 80 - #define OMAP_DMA_CSR_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x06) 81 - #define OMAP_DMA_CEN_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x10) 82 - #define OMAP_DMA_CFN_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x12) 83 - #define OMAP_DMA_CSFI_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x14) 84 - #define OMAP_DMA_CSEI_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x16) 85 - #define OMAP_DMA_CSAC_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x18) 86 - #define OMAP_DMA_CDAC_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x1a) 87 - #define OMAP_DMA_CDEI_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x1c) 88 - #define OMAP_DMA_CDFI_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x1e) 89 - #define OMAP_DMA_CLNK_CTRL_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x28) 90 - 91 - #else 73 + #define OMAP1_DMA_CH_BASE(n) (0x40 * (n) + 0x00) 74 + #define OMAP1_DMA_CSDP(n) (0x40 * (n) + 0x00) 75 + #define OMAP1_DMA_CCR(n) (0x40 * (n) + 0x02) 76 + #define OMAP1_DMA_CICR(n) (0x40 * (n) + 0x04) 77 + #define OMAP1_DMA_CSR(n) (0x40 * (n) + 0x06) 78 + #define OMAP1_DMA_CEN(n) (0x40 * (n) + 0x10) 79 + #define OMAP1_DMA_CFN(n) (0x40 * (n) + 0x12) 80 + #define OMAP1_DMA_CSFI(n) (0x40 * (n) + 0x14) 81 + #define OMAP1_DMA_CSEI(n) (0x40 * (n) + 0x16) 82 + #define OMAP1_DMA_CPC(n) (0x40 * (n) + 0x18) /* 15xx only */ 83 + #define OMAP1_DMA_CSAC(n) (0x40 * (n) + 0x18) 84 + #define OMAP1_DMA_CDAC(n) (0x40 * (n) + 0x1a) 85 + #define OMAP1_DMA_CDEI(n) (0x40 * (n) + 0x1c) 86 + #define OMAP1_DMA_CDFI(n) (0x40 * (n) + 0x1e) 87 + #define OMAP1_DMA_CLNK_CTRL(n) (0x40 * (n) + 0x28) 92 88 93 89 /* Common channel specific registers for omap2 */ 94 - #define OMAP_DMA_CCR_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x80) 95 - #define OMAP_DMA_CLNK_CTRL_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x84) 96 - #define OMAP_DMA_CICR_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x88) 97 - #define OMAP_DMA_CSR_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x8c) 98 - #define OMAP_DMA_CSDP_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x90) 99 - #define OMAP_DMA_CEN_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x94) 100 - #define OMAP_DMA_CFN_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x98) 101 - #define OMAP_DMA_CSEI_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xa4) 102 - #define OMAP_DMA_CSFI_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xa8) 103 - #define OMAP_DMA_CDEI_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xac) 104 - #define OMAP_DMA_CDFI_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xb0) 105 - #define OMAP_DMA_CSAC_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xb4) 106 - #define OMAP_DMA_CDAC_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xb8) 107 - 108 - #endif 90 + #define OMAP_DMA4_CH_BASE(n) (0x60 * (n) + 0x80) 91 + #define OMAP_DMA4_CCR(n) (0x60 * (n) + 0x80) 92 + #define OMAP_DMA4_CLNK_CTRL(n) (0x60 * (n) + 0x84) 93 + #define OMAP_DMA4_CICR(n) (0x60 * (n) + 0x88) 94 + #define OMAP_DMA4_CSR(n) (0x60 * (n) + 0x8c) 95 + #define OMAP_DMA4_CSDP(n) (0x60 * (n) + 0x90) 96 + #define OMAP_DMA4_CEN(n) (0x60 * (n) + 0x94) 97 + #define OMAP_DMA4_CFN(n) (0x60 * (n) + 0x98) 98 + #define OMAP_DMA4_CSEI(n) (0x60 * (n) + 0xa4) 99 + #define OMAP_DMA4_CSFI(n) (0x60 * (n) + 0xa8) 100 + #define OMAP_DMA4_CDEI(n) (0x60 * (n) + 0xac) 101 + #define OMAP_DMA4_CDFI(n) (0x60 * (n) + 0xb0) 102 + #define OMAP_DMA4_CSAC(n) (0x60 * (n) + 0xb4) 103 + #define OMAP_DMA4_CDAC(n) (0x60 * (n) + 0xb8) 109 104 110 105 /* Channel specific registers only on omap1 */ 111 - #define OMAP1_DMA_CSSA_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x08) 112 - #define OMAP1_DMA_CSSA_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0a) 113 - #define OMAP1_DMA_CDSA_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0c) 114 - #define OMAP1_DMA_CDSA_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x0e) 115 - #define OMAP1_DMA_COLOR_L_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x20) 116 - #define OMAP1_DMA_CCR2_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x24) 117 - #define OMAP1_DMA_COLOR_U_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x22) 118 - #define OMAP1_DMA_LCH_CTRL_REG(n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x2a) 106 + #define OMAP1_DMA_CSSA_L(n) (0x40 * (n) + 0x08) 107 + #define OMAP1_DMA_CSSA_U(n) (0x40 * (n) + 0x0a) 108 + #define OMAP1_DMA_CDSA_L(n) (0x40 * (n) + 0x0c) 109 + #define OMAP1_DMA_CDSA_U(n) (0x40 * (n) + 0x0e) 110 + #define OMAP1_DMA_COLOR_L(n) (0x40 * (n) + 0x20) 111 + #define OMAP1_DMA_COLOR_U(n) (0x40 * (n) + 0x22) 112 + #define OMAP1_DMA_CCR2(n) (0x40 * (n) + 0x24) 113 + #define OMAP1_DMA_LCH_CTRL(n) (0x40 * (n) + 0x2a) /* not on 15xx */ 114 + #define OMAP1_DMA_CCEN(n) 0 115 + #define OMAP1_DMA_CCFN(n) 0 119 116 120 117 /* Channel specific registers only on omap2 */ 121 - #define OMAP2_DMA_CSSA_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x9c) 122 - #define OMAP2_DMA_CDSA_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xa0) 123 - #define OMAP2_DMA_CCEN_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xbc) 124 - #define OMAP2_DMA_CCFN_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xc0) 125 - #define OMAP2_DMA_COLOR_REG(n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0xc4) 118 + #define OMAP_DMA4_CSSA(n) (0x60 * (n) + 0x9c) 119 + #define OMAP_DMA4_CDSA(n) (0x60 * (n) + 0xa0) 120 + #define OMAP_DMA4_CCEN(n) (0x60 * (n) + 0xbc) 121 + #define OMAP_DMA4_CCFN(n) (0x60 * (n) + 0xc0) 122 + #define OMAP_DMA4_COLOR(n) (0x60 * (n) + 0xc4) 123 + 124 + /* Dummy defines to keep multi-omap compiles happy */ 125 + #define OMAP1_DMA_REVISION 0 126 + #define OMAP1_DMA_IRQSTATUS_L0 0 127 + #define OMAP1_DMA_IRQENABLE_L0 0 128 + #define OMAP1_DMA_OCP_SYSCONFIG 0 129 + #define OMAP_DMA4_HW_ID 0 130 + #define OMAP_DMA4_CAPS_0_L 0 131 + #define OMAP_DMA4_CAPS_0_U 0 132 + #define OMAP_DMA4_CAPS_1_L 0 133 + #define OMAP_DMA4_CAPS_1_U 0 134 + #define OMAP_DMA4_GSCR 0 135 + #define OMAP_DMA4_CPC(n) 0 136 + 137 + #define OMAP_DMA4_LCH_CTRL(n) 0 138 + #define OMAP_DMA4_COLOR_L(n) 0 139 + #define OMAP_DMA4_COLOR_U(n) 0 140 + #define OMAP_DMA4_CCR2(n) 0 141 + #define OMAP1_DMA_CSSA(n) 0 142 + #define OMAP1_DMA_CDSA(n) 0 143 + #define OMAP_DMA4_CSSA_L(n) 0 144 + #define OMAP_DMA4_CSSA_U(n) 0 145 + #define OMAP_DMA4_CDSA_L(n) 0 146 + #define OMAP_DMA4_CDSA_U(n) 0 126 147 127 148 /*----------------------------------------------------------------------------*/ 128 149 ··· 390 369 OMAP_DMA_WRITE_LAST_NON_POSTED 391 370 }; 392 371 372 + enum omap_dma_channel_mode { 373 + OMAP_DMA_LCH_2D = 0, 374 + OMAP_DMA_LCH_G, 375 + OMAP_DMA_LCH_P, 376 + OMAP_DMA_LCH_PD 377 + }; 378 + 393 379 struct omap_dma_channel_params { 394 380 int data_type; /* data type 8,16,32 */ 395 381 int elem_count; /* number of elements in a frame */ ··· 445 417 extern void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, 446 418 u32 color); 447 419 extern void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode); 420 + extern void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode); 448 421 449 422 extern void omap_set_dma_src_params(int lch, int src_port, int src_amode, 450 423 unsigned long src_start, ··· 476 447 extern dma_addr_t omap_get_dma_dst_pos(int lch); 477 448 extern int omap_get_dma_src_addr_counter(int lch); 478 449 extern void omap_clear_dma(int lch); 450 + extern int omap_get_dma_active_status(int lch); 479 451 extern int omap_dma_running(void); 480 452 extern void omap_dma_set_global_params(int arb_rate, int max_fifo_depth, 481 453 int tparams);