| .. | .. |
|---|
| 13 | 13 | #include "reg.h" |
|---|
| 14 | 14 | #include <linux/stddef.h> |
|---|
| 15 | 15 | #include <linux/kernel.h> |
|---|
| 16 | +#include <linux/io.h> |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | /* |
|---|
| 18 | 19 | * Size factor for isochronous DBR buffer. |
|---|
| .. | .. |
|---|
| 143 | 144 | |
|---|
| 144 | 145 | static void dim2_transfer_madr(u32 val) |
|---|
| 145 | 146 | { |
|---|
| 146 | | - dimcb_io_write(&g.dim2->MADR, val); |
|---|
| 147 | + writel(val, &g.dim2->MADR); |
|---|
| 147 | 148 | |
|---|
| 148 | 149 | /* wait for transfer completion */ |
|---|
| 149 | | - while ((dimcb_io_read(&g.dim2->MCTL) & 1) != 1) |
|---|
| 150 | + while ((readl(&g.dim2->MCTL) & 1) != 1) |
|---|
| 150 | 151 | continue; |
|---|
| 151 | 152 | |
|---|
| 152 | | - dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */ |
|---|
| 153 | + writel(0, &g.dim2->MCTL); /* clear transfer complete */ |
|---|
| 153 | 154 | } |
|---|
| 154 | 155 | |
|---|
| 155 | 156 | static void dim2_clear_dbr(u16 addr, u16 size) |
|---|
| .. | .. |
|---|
| 159 | 160 | u16 const end_addr = addr + size; |
|---|
| 160 | 161 | u32 const cmd = bit_mask(MADR_WNR_BIT) | bit_mask(MADR_TB_BIT); |
|---|
| 161 | 162 | |
|---|
| 162 | | - dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */ |
|---|
| 163 | | - dimcb_io_write(&g.dim2->MDAT0, 0); |
|---|
| 163 | + writel(0, &g.dim2->MCTL); /* clear transfer complete */ |
|---|
| 164 | + writel(0, &g.dim2->MDAT0); |
|---|
| 164 | 165 | |
|---|
| 165 | 166 | for (; addr < end_addr; addr++) |
|---|
| 166 | 167 | dim2_transfer_madr(cmd | addr); |
|---|
| .. | .. |
|---|
| 170 | 171 | { |
|---|
| 171 | 172 | dim2_transfer_madr(ctr_addr); |
|---|
| 172 | 173 | |
|---|
| 173 | | - return dimcb_io_read((&g.dim2->MDAT0) + mdat_idx); |
|---|
| 174 | + return readl((&g.dim2->MDAT0) + mdat_idx); |
|---|
| 174 | 175 | } |
|---|
| 175 | 176 | |
|---|
| 176 | 177 | static void dim2_write_ctr_mask(u32 ctr_addr, const u32 *mask, const u32 *value) |
|---|
| 177 | 178 | { |
|---|
| 178 | 179 | enum { MADR_WNR_BIT = 31 }; |
|---|
| 179 | 180 | |
|---|
| 180 | | - dimcb_io_write(&g.dim2->MCTL, 0); /* clear transfer complete */ |
|---|
| 181 | + writel(0, &g.dim2->MCTL); /* clear transfer complete */ |
|---|
| 181 | 182 | |
|---|
| 182 | 183 | if (mask[0] != 0) |
|---|
| 183 | | - dimcb_io_write(&g.dim2->MDAT0, value[0]); |
|---|
| 184 | + writel(value[0], &g.dim2->MDAT0); |
|---|
| 184 | 185 | if (mask[1] != 0) |
|---|
| 185 | | - dimcb_io_write(&g.dim2->MDAT1, value[1]); |
|---|
| 186 | + writel(value[1], &g.dim2->MDAT1); |
|---|
| 186 | 187 | if (mask[2] != 0) |
|---|
| 187 | | - dimcb_io_write(&g.dim2->MDAT2, value[2]); |
|---|
| 188 | + writel(value[2], &g.dim2->MDAT2); |
|---|
| 188 | 189 | if (mask[3] != 0) |
|---|
| 189 | | - dimcb_io_write(&g.dim2->MDAT3, value[3]); |
|---|
| 190 | + writel(value[3], &g.dim2->MDAT3); |
|---|
| 190 | 191 | |
|---|
| 191 | | - dimcb_io_write(&g.dim2->MDWE0, mask[0]); |
|---|
| 192 | | - dimcb_io_write(&g.dim2->MDWE1, mask[1]); |
|---|
| 193 | | - dimcb_io_write(&g.dim2->MDWE2, mask[2]); |
|---|
| 194 | | - dimcb_io_write(&g.dim2->MDWE3, mask[3]); |
|---|
| 192 | + writel(mask[0], &g.dim2->MDWE0); |
|---|
| 193 | + writel(mask[1], &g.dim2->MDWE1); |
|---|
| 194 | + writel(mask[2], &g.dim2->MDWE2); |
|---|
| 195 | + writel(mask[3], &g.dim2->MDWE3); |
|---|
| 195 | 196 | |
|---|
| 196 | 197 | dim2_transfer_madr(bit_mask(MADR_WNR_BIT) | ctr_addr); |
|---|
| 197 | 198 | } |
|---|
| .. | .. |
|---|
| 356 | 357 | dim2_configure_cat(AHB_CAT, ch_addr, type, is_tx ? 0 : 1); |
|---|
| 357 | 358 | |
|---|
| 358 | 359 | /* unmask interrupt for used channel, enable mlb_sys_int[0] interrupt */ |
|---|
| 359 | | - dimcb_io_write(&g.dim2->ACMR0, |
|---|
| 360 | | - dimcb_io_read(&g.dim2->ACMR0) | bit_mask(ch_addr)); |
|---|
| 360 | + writel(readl(&g.dim2->ACMR0) | bit_mask(ch_addr), &g.dim2->ACMR0); |
|---|
| 361 | 361 | } |
|---|
| 362 | 362 | |
|---|
| 363 | 363 | static void dim2_clear_channel(u8 ch_addr) |
|---|
| 364 | 364 | { |
|---|
| 365 | 365 | /* mask interrupt for used channel, disable mlb_sys_int[0] interrupt */ |
|---|
| 366 | | - dimcb_io_write(&g.dim2->ACMR0, |
|---|
| 367 | | - dimcb_io_read(&g.dim2->ACMR0) & ~bit_mask(ch_addr)); |
|---|
| 366 | + writel(readl(&g.dim2->ACMR0) & ~bit_mask(ch_addr), &g.dim2->ACMR0); |
|---|
| 368 | 367 | |
|---|
| 369 | 368 | dim2_clear_cat(AHB_CAT, ch_addr); |
|---|
| 370 | 369 | dim2_clear_adt(ch_addr); |
|---|
| .. | .. |
|---|
| 373 | 372 | dim2_clear_cdt(ch_addr); |
|---|
| 374 | 373 | |
|---|
| 375 | 374 | /* clear channel status bit */ |
|---|
| 376 | | - dimcb_io_write(&g.dim2->ACSR0, bit_mask(ch_addr)); |
|---|
| 375 | + writel(bit_mask(ch_addr), &g.dim2->ACSR0); |
|---|
| 377 | 376 | } |
|---|
| 378 | 377 | |
|---|
| 379 | 378 | /* -------------------------------------------------------------------------- */ |
|---|
| .. | .. |
|---|
| 471 | 470 | return true; |
|---|
| 472 | 471 | } |
|---|
| 473 | 472 | |
|---|
| 474 | | -static inline u16 norm_ctrl_async_buffer_size(u16 buf_size) |
|---|
| 473 | +u16 dim_norm_ctrl_async_buffer_size(u16 buf_size) |
|---|
| 475 | 474 | { |
|---|
| 476 | 475 | u16 const max_size = (u16)ADT1_CTRL_ASYNC_BD_MASK + 1u; |
|---|
| 477 | 476 | |
|---|
| .. | .. |
|---|
| 517 | 516 | static void dim2_cleanup(void) |
|---|
| 518 | 517 | { |
|---|
| 519 | 518 | /* disable MediaLB */ |
|---|
| 520 | | - dimcb_io_write(&g.dim2->MLBC0, false << MLBC0_MLBEN_BIT); |
|---|
| 519 | + writel(false << MLBC0_MLBEN_BIT, &g.dim2->MLBC0); |
|---|
| 521 | 520 | |
|---|
| 522 | 521 | dim2_clear_ctram(); |
|---|
| 523 | 522 | |
|---|
| 524 | 523 | /* disable mlb_int interrupt */ |
|---|
| 525 | | - dimcb_io_write(&g.dim2->MIEN, 0); |
|---|
| 524 | + writel(0, &g.dim2->MIEN); |
|---|
| 526 | 525 | |
|---|
| 527 | 526 | /* clear status for all dma channels */ |
|---|
| 528 | | - dimcb_io_write(&g.dim2->ACSR0, 0xFFFFFFFF); |
|---|
| 529 | | - dimcb_io_write(&g.dim2->ACSR1, 0xFFFFFFFF); |
|---|
| 527 | + writel(0xFFFFFFFF, &g.dim2->ACSR0); |
|---|
| 528 | + writel(0xFFFFFFFF, &g.dim2->ACSR1); |
|---|
| 530 | 529 | |
|---|
| 531 | 530 | /* mask interrupts for all channels */ |
|---|
| 532 | | - dimcb_io_write(&g.dim2->ACMR0, 0); |
|---|
| 533 | | - dimcb_io_write(&g.dim2->ACMR1, 0); |
|---|
| 531 | + writel(0, &g.dim2->ACMR0); |
|---|
| 532 | + writel(0, &g.dim2->ACMR1); |
|---|
| 534 | 533 | } |
|---|
| 535 | 534 | |
|---|
| 536 | 535 | static void dim2_initialize(bool enable_6pin, u8 mlb_clock) |
|---|
| .. | .. |
|---|
| 538 | 537 | dim2_cleanup(); |
|---|
| 539 | 538 | |
|---|
| 540 | 539 | /* configure and enable MediaLB */ |
|---|
| 541 | | - dimcb_io_write(&g.dim2->MLBC0, |
|---|
| 542 | | - enable_6pin << MLBC0_MLBPEN_BIT | |
|---|
| 543 | | - mlb_clock << MLBC0_MLBCLK_SHIFT | |
|---|
| 544 | | - g.fcnt << MLBC0_FCNT_SHIFT | |
|---|
| 545 | | - true << MLBC0_MLBEN_BIT); |
|---|
| 540 | + writel(enable_6pin << MLBC0_MLBPEN_BIT | |
|---|
| 541 | + mlb_clock << MLBC0_MLBCLK_SHIFT | |
|---|
| 542 | + g.fcnt << MLBC0_FCNT_SHIFT | |
|---|
| 543 | + true << MLBC0_MLBEN_BIT, |
|---|
| 544 | + &g.dim2->MLBC0); |
|---|
| 546 | 545 | |
|---|
| 547 | 546 | /* activate all HBI channels */ |
|---|
| 548 | | - dimcb_io_write(&g.dim2->HCMR0, 0xFFFFFFFF); |
|---|
| 549 | | - dimcb_io_write(&g.dim2->HCMR1, 0xFFFFFFFF); |
|---|
| 547 | + writel(0xFFFFFFFF, &g.dim2->HCMR0); |
|---|
| 548 | + writel(0xFFFFFFFF, &g.dim2->HCMR1); |
|---|
| 550 | 549 | |
|---|
| 551 | 550 | /* enable HBI */ |
|---|
| 552 | | - dimcb_io_write(&g.dim2->HCTL, bit_mask(HCTL_EN_BIT)); |
|---|
| 551 | + writel(bit_mask(HCTL_EN_BIT), &g.dim2->HCTL); |
|---|
| 553 | 552 | |
|---|
| 554 | 553 | /* configure DMA */ |
|---|
| 555 | | - dimcb_io_write(&g.dim2->ACTL, |
|---|
| 556 | | - ACTL_DMA_MODE_VAL_DMA_MODE_1 << ACTL_DMA_MODE_BIT | |
|---|
| 557 | | - true << ACTL_SCE_BIT); |
|---|
| 554 | + writel(ACTL_DMA_MODE_VAL_DMA_MODE_1 << ACTL_DMA_MODE_BIT | |
|---|
| 555 | + true << ACTL_SCE_BIT, &g.dim2->ACTL); |
|---|
| 558 | 556 | } |
|---|
| 559 | 557 | |
|---|
| 560 | 558 | static bool dim2_is_mlb_locked(void) |
|---|
| .. | .. |
|---|
| 562 | 560 | u32 const mask0 = bit_mask(MLBC0_MLBLK_BIT); |
|---|
| 563 | 561 | u32 const mask1 = bit_mask(MLBC1_CLKMERR_BIT) | |
|---|
| 564 | 562 | bit_mask(MLBC1_LOCKERR_BIT); |
|---|
| 565 | | - u32 const c1 = dimcb_io_read(&g.dim2->MLBC1); |
|---|
| 563 | + u32 const c1 = readl(&g.dim2->MLBC1); |
|---|
| 566 | 564 | u32 const nda_mask = (u32)MLBC1_NDA_MASK << MLBC1_NDA_SHIFT; |
|---|
| 567 | 565 | |
|---|
| 568 | | - dimcb_io_write(&g.dim2->MLBC1, c1 & nda_mask); |
|---|
| 569 | | - return (dimcb_io_read(&g.dim2->MLBC1) & mask1) == 0 && |
|---|
| 570 | | - (dimcb_io_read(&g.dim2->MLBC0) & mask0) != 0; |
|---|
| 566 | + writel(c1 & nda_mask, &g.dim2->MLBC1); |
|---|
| 567 | + return (readl(&g.dim2->MLBC1) & mask1) == 0 && |
|---|
| 568 | + (readl(&g.dim2->MLBC0) & mask0) != 0; |
|---|
| 571 | 569 | } |
|---|
| 572 | 570 | |
|---|
| 573 | 571 | /* -------------------------------------------------------------------------- */ |
|---|
| .. | .. |
|---|
| 590 | 588 | dim2_write_ctr_mask(ADT + ch_addr, mask, adt_w); |
|---|
| 591 | 589 | |
|---|
| 592 | 590 | /* clear channel status bit */ |
|---|
| 593 | | - dimcb_io_write(&g.dim2->ACSR0, bit_mask(ch_addr)); |
|---|
| 591 | + writel(bit_mask(ch_addr), &g.dim2->ACSR0); |
|---|
| 594 | 592 | |
|---|
| 595 | 593 | return true; |
|---|
| 596 | 594 | } |
|---|
| .. | .. |
|---|
| 652 | 650 | return dim_on_error(DIM_ERR_BAD_BUFFER_SIZE, "Bad buffer size"); |
|---|
| 653 | 651 | |
|---|
| 654 | 652 | if (ch->packet_length == 0 && ch->bytes_per_frame == 0 && |
|---|
| 655 | | - buf_size != norm_ctrl_async_buffer_size(buf_size)) |
|---|
| 653 | + buf_size != dim_norm_ctrl_async_buffer_size(buf_size)) |
|---|
| 656 | 654 | return dim_on_error(DIM_ERR_BAD_BUFFER_SIZE, |
|---|
| 657 | 655 | "Bad control/async buffer size"); |
|---|
| 658 | 656 | |
|---|
| .. | .. |
|---|
| 776 | 774 | |
|---|
| 777 | 775 | void dim_service_mlb_int_irq(void) |
|---|
| 778 | 776 | { |
|---|
| 779 | | - dimcb_io_write(&g.dim2->MS0, 0); |
|---|
| 780 | | - dimcb_io_write(&g.dim2->MS1, 0); |
|---|
| 781 | | -} |
|---|
| 782 | | - |
|---|
| 783 | | -u16 dim_norm_ctrl_async_buffer_size(u16 buf_size) |
|---|
| 784 | | -{ |
|---|
| 785 | | - return norm_ctrl_async_buffer_size(buf_size); |
|---|
| 777 | + writel(0, &g.dim2->MS0); |
|---|
| 778 | + writel(0, &g.dim2->MS1); |
|---|
| 786 | 779 | } |
|---|
| 787 | 780 | |
|---|
| 788 | 781 | /** |
|---|
| .. | .. |
|---|
| 829 | 822 | if (is_tx && !g.atx_dbr.ch_addr) { |
|---|
| 830 | 823 | g.atx_dbr.ch_addr = ch->addr; |
|---|
| 831 | 824 | dbrcnt_init(ch->addr, ch->dbr_size); |
|---|
| 832 | | - dimcb_io_write(&g.dim2->MIEN, bit_mask(20)); |
|---|
| 825 | + writel(bit_mask(20), &g.dim2->MIEN); |
|---|
| 833 | 826 | } |
|---|
| 834 | 827 | |
|---|
| 835 | 828 | return ret; |
|---|
| .. | .. |
|---|
| 896 | 889 | return DIM_ERR_DRIVER_NOT_INITIALIZED; |
|---|
| 897 | 890 | |
|---|
| 898 | 891 | if (ch->addr == g.atx_dbr.ch_addr) { |
|---|
| 899 | | - dimcb_io_write(&g.dim2->MIEN, 0); |
|---|
| 892 | + writel(0, &g.dim2->MIEN); |
|---|
| 900 | 893 | g.atx_dbr.ch_addr = 0; |
|---|
| 901 | 894 | } |
|---|
| 902 | 895 | |
|---|