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

spi: pxa2xx: Cleanup register access macros

Currently SSP registers are accessed by having an own read and write macros
for each register. For instance read_SSSR(iobase) and write_SSSR(iobase).

In my opinion this hurts readability and requires new macros to be defined
for each new added register. Let's define and use instead common
pxa2xx_spi_read() and pxa2xx_spi_write() accessors.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jarkko Nikula and committed by
Mark Brown
c039dd27 8e8dd9fb

+116 -141
+10 -7
drivers/spi/spi-pxa2xx-dma.c
··· 111 111 * by using ->dma_running. 112 112 */ 113 113 if (atomic_dec_and_test(&drv_data->dma_running)) { 114 - void __iomem *reg = drv_data->ioaddr; 115 - 116 114 /* 117 115 * If the other CPU is still handling the ROR interrupt we 118 116 * might not know about the error yet. So we re-check the 119 117 * ROR bit here before we clear the status register. 120 118 */ 121 119 if (!error) { 122 - u32 status = read_SSSR(reg) & drv_data->mask_sr; 120 + u32 status = pxa2xx_spi_read(drv_data, SSSR) 121 + & drv_data->mask_sr; 123 122 error = status & SSSR_ROR; 124 123 } 125 124 126 125 /* Clear status & disable interrupts */ 127 - write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 126 + pxa2xx_spi_write(drv_data, SSCR1, 127 + pxa2xx_spi_read(drv_data, SSCR1) 128 + & ~drv_data->dma_cr1); 128 129 write_SSSR_CS(drv_data, drv_data->clear_sr); 129 130 if (!pxa25x_ssp_comp(drv_data)) 130 - write_SSTO(0, reg); 131 + pxa2xx_spi_write(drv_data, SSTO, 0); 131 132 132 133 if (!error) { 133 134 pxa2xx_spi_unmap_dma_buffers(drv_data); ··· 140 139 msg->state = pxa2xx_spi_next_transfer(drv_data); 141 140 } else { 142 141 /* In case we got an error we disable the SSP now */ 143 - write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 142 + pxa2xx_spi_write(drv_data, SSCR0, 143 + pxa2xx_spi_read(drv_data, SSCR0) 144 + & ~SSCR0_SSE); 144 145 145 146 msg->state = ERROR_STATE; 146 147 } ··· 250 247 { 251 248 u32 status; 252 249 253 - status = read_SSSR(drv_data->ioaddr) & drv_data->mask_sr; 250 + status = pxa2xx_spi_read(drv_data, SSSR) & drv_data->mask_sr; 254 251 if (status & SSSR_ROR) { 255 252 dev_err(&drv_data->pdev->dev, "FIFO overrun\n"); 256 253
+13 -12
drivers/spi/spi-pxa2xx-pxadma.c
··· 122 122 { 123 123 unsigned long limit = loops_per_jiffy << 1; 124 124 125 - while ((read_SSSR(drv_data->ioaddr) & SSSR_BSY) && --limit) 125 + while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY) && --limit) 126 126 cpu_relax(); 127 127 128 128 return limit; ··· 141 141 static void pxa2xx_spi_dma_error_stop(struct driver_data *drv_data, 142 142 const char *msg) 143 143 { 144 - void __iomem *reg = drv_data->ioaddr; 145 - 146 144 /* Stop and reset */ 147 145 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 148 146 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 149 147 write_SSSR_CS(drv_data, drv_data->clear_sr); 150 - write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 148 + pxa2xx_spi_write(drv_data, SSCR1, 149 + pxa2xx_spi_read(drv_data, SSCR1) 150 + & ~drv_data->dma_cr1); 151 151 if (!pxa25x_ssp_comp(drv_data)) 152 - write_SSTO(0, reg); 152 + pxa2xx_spi_write(drv_data, SSTO, 0); 153 153 pxa2xx_spi_flush(drv_data); 154 - write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 154 + pxa2xx_spi_write(drv_data, SSCR0, 155 + pxa2xx_spi_read(drv_data, SSCR0) & ~SSCR0_SSE); 155 156 156 157 pxa2xx_spi_unmap_dma_buffers(drv_data); 157 158 ··· 164 163 165 164 static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data) 166 165 { 167 - void __iomem *reg = drv_data->ioaddr; 168 166 struct spi_message *msg = drv_data->cur_msg; 169 167 170 168 /* Clear and disable interrupts on SSP and DMA channels*/ 171 - write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 169 + pxa2xx_spi_write(drv_data, SSCR1, 170 + pxa2xx_spi_read(drv_data, SSCR1) 171 + & ~drv_data->dma_cr1); 172 172 write_SSSR_CS(drv_data, drv_data->clear_sr); 173 173 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 174 174 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; ··· 242 240 irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data) 243 241 { 244 242 u32 irq_status; 245 - void __iomem *reg = drv_data->ioaddr; 246 243 247 - irq_status = read_SSSR(reg) & drv_data->mask_sr; 244 + irq_status = pxa2xx_spi_read(drv_data, SSSR) & drv_data->mask_sr; 248 245 if (irq_status & SSSR_ROR) { 249 246 pxa2xx_spi_dma_error_stop(drv_data, 250 247 "dma_transfer: fifo overrun"); ··· 253 252 /* Check for false positive timeout */ 254 253 if ((irq_status & SSSR_TINT) 255 254 && (DCSR(drv_data->tx_channel) & DCSR_RUN)) { 256 - write_SSSR(SSSR_TINT, reg); 255 + pxa2xx_spi_write(drv_data, SSSR, SSSR_TINT); 257 256 return IRQ_HANDLED; 258 257 } 259 258 ··· 262 261 /* Clear and disable timeout interrupt, do the rest in 263 262 * dma_transfer_complete */ 264 263 if (!pxa25x_ssp_comp(drv_data)) 265 - write_SSTO(0, reg); 264 + pxa2xx_spi_write(drv_data, SSTO, 0); 266 265 267 266 /* finish this transfer, start the next */ 268 267 pxa2xx_spi_dma_transfer_complete(drv_data);
+81 -102
drivers/spi/spi-pxa2xx.c
··· 160 160 161 161 static bool pxa2xx_spi_txfifo_full(const struct driver_data *drv_data) 162 162 { 163 - void __iomem *reg = drv_data->ioaddr; 164 163 u32 mask; 165 164 166 165 switch (drv_data->ssp_type) { ··· 171 172 break; 172 173 } 173 174 174 - return (read_SSSR(reg) & mask) == mask; 175 + return (pxa2xx_spi_read(drv_data, SSSR) & mask) == mask; 175 176 } 176 177 177 178 static void pxa2xx_spi_clear_rx_thre(const struct driver_data *drv_data, ··· 311 312 struct chip_data *chip = drv_data->cur_chip; 312 313 313 314 if (drv_data->ssp_type == CE4100_SSP) { 314 - write_SSSR(drv_data->cur_chip->frm, drv_data->ioaddr); 315 + pxa2xx_spi_write(drv_data, SSSR, drv_data->cur_chip->frm); 315 316 return; 316 317 } 317 318 ··· 354 355 { 355 356 unsigned long limit = loops_per_jiffy << 1; 356 357 357 - void __iomem *reg = drv_data->ioaddr; 358 - 359 358 do { 360 - while (read_SSSR(reg) & SSSR_RNE) { 361 - read_SSDR(reg); 362 - } 363 - } while ((read_SSSR(reg) & SSSR_BSY) && --limit); 359 + while (pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE) 360 + pxa2xx_spi_read(drv_data, SSDR); 361 + } while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY) && --limit); 364 362 write_SSSR_CS(drv_data, SSSR_ROR); 365 363 366 364 return limit; ··· 365 369 366 370 static int null_writer(struct driver_data *drv_data) 367 371 { 368 - void __iomem *reg = drv_data->ioaddr; 369 372 u8 n_bytes = drv_data->n_bytes; 370 373 371 374 if (pxa2xx_spi_txfifo_full(drv_data) 372 375 || (drv_data->tx == drv_data->tx_end)) 373 376 return 0; 374 377 375 - write_SSDR(0, reg); 378 + pxa2xx_spi_write(drv_data, SSDR, 0); 376 379 drv_data->tx += n_bytes; 377 380 378 381 return 1; ··· 379 384 380 385 static int null_reader(struct driver_data *drv_data) 381 386 { 382 - void __iomem *reg = drv_data->ioaddr; 383 387 u8 n_bytes = drv_data->n_bytes; 384 388 385 - while ((read_SSSR(reg) & SSSR_RNE) 386 - && (drv_data->rx < drv_data->rx_end)) { 387 - read_SSDR(reg); 389 + while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE) 390 + && (drv_data->rx < drv_data->rx_end)) { 391 + pxa2xx_spi_read(drv_data, SSDR); 388 392 drv_data->rx += n_bytes; 389 393 } 390 394 ··· 392 398 393 399 static int u8_writer(struct driver_data *drv_data) 394 400 { 395 - void __iomem *reg = drv_data->ioaddr; 396 - 397 401 if (pxa2xx_spi_txfifo_full(drv_data) 398 402 || (drv_data->tx == drv_data->tx_end)) 399 403 return 0; 400 404 401 - write_SSDR(*(u8 *)(drv_data->tx), reg); 405 + pxa2xx_spi_write(drv_data, SSDR, *(u8 *)(drv_data->tx)); 402 406 ++drv_data->tx; 403 407 404 408 return 1; ··· 404 412 405 413 static int u8_reader(struct driver_data *drv_data) 406 414 { 407 - void __iomem *reg = drv_data->ioaddr; 408 - 409 - while ((read_SSSR(reg) & SSSR_RNE) 410 - && (drv_data->rx < drv_data->rx_end)) { 411 - *(u8 *)(drv_data->rx) = read_SSDR(reg); 415 + while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE) 416 + && (drv_data->rx < drv_data->rx_end)) { 417 + *(u8 *)(drv_data->rx) = pxa2xx_spi_read(drv_data, SSDR); 412 418 ++drv_data->rx; 413 419 } 414 420 ··· 415 425 416 426 static int u16_writer(struct driver_data *drv_data) 417 427 { 418 - void __iomem *reg = drv_data->ioaddr; 419 - 420 428 if (pxa2xx_spi_txfifo_full(drv_data) 421 429 || (drv_data->tx == drv_data->tx_end)) 422 430 return 0; 423 431 424 - write_SSDR(*(u16 *)(drv_data->tx), reg); 432 + pxa2xx_spi_write(drv_data, SSDR, *(u16 *)(drv_data->tx)); 425 433 drv_data->tx += 2; 426 434 427 435 return 1; ··· 427 439 428 440 static int u16_reader(struct driver_data *drv_data) 429 441 { 430 - void __iomem *reg = drv_data->ioaddr; 431 - 432 - while ((read_SSSR(reg) & SSSR_RNE) 433 - && (drv_data->rx < drv_data->rx_end)) { 434 - *(u16 *)(drv_data->rx) = read_SSDR(reg); 442 + while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE) 443 + && (drv_data->rx < drv_data->rx_end)) { 444 + *(u16 *)(drv_data->rx) = pxa2xx_spi_read(drv_data, SSDR); 435 445 drv_data->rx += 2; 436 446 } 437 447 ··· 438 452 439 453 static int u32_writer(struct driver_data *drv_data) 440 454 { 441 - void __iomem *reg = drv_data->ioaddr; 442 - 443 455 if (pxa2xx_spi_txfifo_full(drv_data) 444 456 || (drv_data->tx == drv_data->tx_end)) 445 457 return 0; 446 458 447 - write_SSDR(*(u32 *)(drv_data->tx), reg); 459 + pxa2xx_spi_write(drv_data, SSDR, *(u32 *)(drv_data->tx)); 448 460 drv_data->tx += 4; 449 461 450 462 return 1; ··· 450 466 451 467 static int u32_reader(struct driver_data *drv_data) 452 468 { 453 - void __iomem *reg = drv_data->ioaddr; 454 - 455 - while ((read_SSSR(reg) & SSSR_RNE) 456 - && (drv_data->rx < drv_data->rx_end)) { 457 - *(u32 *)(drv_data->rx) = read_SSDR(reg); 469 + while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE) 470 + && (drv_data->rx < drv_data->rx_end)) { 471 + *(u32 *)(drv_data->rx) = pxa2xx_spi_read(drv_data, SSDR); 458 472 drv_data->rx += 4; 459 473 } 460 474 ··· 528 546 529 547 static void reset_sccr1(struct driver_data *drv_data) 530 548 { 531 - void __iomem *reg = drv_data->ioaddr; 532 549 struct chip_data *chip = drv_data->cur_chip; 533 550 u32 sccr1_reg; 534 551 535 - sccr1_reg = read_SSCR1(reg) & ~drv_data->int_cr1; 552 + sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1) & ~drv_data->int_cr1; 536 553 sccr1_reg &= ~SSCR1_RFT; 537 554 sccr1_reg |= chip->threshold; 538 - write_SSCR1(sccr1_reg, reg); 555 + pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg); 539 556 } 540 557 541 558 static void int_error_stop(struct driver_data *drv_data, const char* msg) 542 559 { 543 - void __iomem *reg = drv_data->ioaddr; 544 - 545 560 /* Stop and reset SSP */ 546 561 write_SSSR_CS(drv_data, drv_data->clear_sr); 547 562 reset_sccr1(drv_data); 548 563 if (!pxa25x_ssp_comp(drv_data)) 549 - write_SSTO(0, reg); 564 + pxa2xx_spi_write(drv_data, SSTO, 0); 550 565 pxa2xx_spi_flush(drv_data); 551 - write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 566 + pxa2xx_spi_write(drv_data, SSCR0, 567 + pxa2xx_spi_read(drv_data, SSCR0) & ~SSCR0_SSE); 552 568 553 569 dev_err(&drv_data->pdev->dev, "%s\n", msg); 554 570 ··· 556 576 557 577 static void int_transfer_complete(struct driver_data *drv_data) 558 578 { 559 - void __iomem *reg = drv_data->ioaddr; 560 - 561 579 /* Stop SSP */ 562 580 write_SSSR_CS(drv_data, drv_data->clear_sr); 563 581 reset_sccr1(drv_data); 564 582 if (!pxa25x_ssp_comp(drv_data)) 565 - write_SSTO(0, reg); 583 + pxa2xx_spi_write(drv_data, SSTO, 0); 566 584 567 585 /* Update total byte transferred return count actual bytes read */ 568 586 drv_data->cur_msg->actual_length += drv_data->len - ··· 579 601 580 602 static irqreturn_t interrupt_transfer(struct driver_data *drv_data) 581 603 { 582 - void __iomem *reg = drv_data->ioaddr; 604 + u32 irq_mask = (pxa2xx_spi_read(drv_data, SSCR1) & SSCR1_TIE) ? 605 + drv_data->mask_sr : drv_data->mask_sr & ~SSSR_TFS; 583 606 584 - u32 irq_mask = (read_SSCR1(reg) & SSCR1_TIE) ? 585 - drv_data->mask_sr : drv_data->mask_sr & ~SSSR_TFS; 586 - 587 - u32 irq_status = read_SSSR(reg) & irq_mask; 607 + u32 irq_status = pxa2xx_spi_read(drv_data, SSSR) & irq_mask; 588 608 589 609 if (irq_status & SSSR_ROR) { 590 610 int_error_stop(drv_data, "interrupt_transfer: fifo overrun"); ··· 590 614 } 591 615 592 616 if (irq_status & SSSR_TINT) { 593 - write_SSSR(SSSR_TINT, reg); 617 + pxa2xx_spi_write(drv_data, SSSR, SSSR_TINT); 594 618 if (drv_data->read(drv_data)) { 595 619 int_transfer_complete(drv_data); 596 620 return IRQ_HANDLED; ··· 614 638 u32 bytes_left; 615 639 u32 sccr1_reg; 616 640 617 - sccr1_reg = read_SSCR1(reg); 641 + sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1); 618 642 sccr1_reg &= ~SSCR1_TIE; 619 643 620 644 /* ··· 640 664 641 665 pxa2xx_spi_set_rx_thre(drv_data, &sccr1_reg, rx_thre); 642 666 } 643 - write_SSCR1(sccr1_reg, reg); 667 + pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg); 644 668 } 645 669 646 670 /* We did something */ ··· 650 674 static irqreturn_t ssp_int(int irq, void *dev_id) 651 675 { 652 676 struct driver_data *drv_data = dev_id; 653 - void __iomem *reg = drv_data->ioaddr; 654 677 u32 sccr1_reg; 655 678 u32 mask = drv_data->mask_sr; 656 679 u32 status; ··· 669 694 * are all set to one. That means that the device is already 670 695 * powered off. 671 696 */ 672 - status = read_SSSR(reg); 697 + status = pxa2xx_spi_read(drv_data, SSSR); 673 698 if (status == ~0) 674 699 return IRQ_NONE; 675 700 676 - sccr1_reg = read_SSCR1(reg); 701 + sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1); 677 702 678 703 /* Ignore possible writes if we don't need to write */ 679 704 if (!(sccr1_reg & SSCR1_TIE)) ··· 684 709 685 710 if (!drv_data->cur_msg) { 686 711 687 - write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 688 - write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg); 712 + pxa2xx_spi_write(drv_data, SSCR0, 713 + pxa2xx_spi_read(drv_data, SSCR0) 714 + & ~SSCR0_SSE); 715 + pxa2xx_spi_write(drv_data, SSCR1, 716 + pxa2xx_spi_read(drv_data, SSCR1) 717 + & ~drv_data->int_cr1); 689 718 if (!pxa25x_ssp_comp(drv_data)) 690 - write_SSTO(0, reg); 719 + pxa2xx_spi_write(drv_data, SSTO, 0); 691 720 write_SSSR_CS(drv_data, drv_data->clear_sr); 692 721 693 722 dev_err(&drv_data->pdev->dev, ··· 760 781 struct spi_transfer *transfer = NULL; 761 782 struct spi_transfer *previous = NULL; 762 783 struct chip_data *chip = NULL; 763 - void __iomem *reg = drv_data->ioaddr; 764 784 u32 clk_div = 0; 765 785 u8 bits = 0; 766 786 u32 speed = 0; ··· 903 925 904 926 /* Clear status and start DMA engine */ 905 927 cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1; 906 - write_SSSR(drv_data->clear_sr, reg); 928 + pxa2xx_spi_write(drv_data, SSSR, drv_data->clear_sr); 907 929 908 930 pxa2xx_spi_dma_start(drv_data); 909 931 } else { ··· 916 938 } 917 939 918 940 if (is_lpss_ssp(drv_data)) { 919 - if ((read_SSIRF(reg) & 0xff) != chip->lpss_rx_threshold) 920 - write_SSIRF(chip->lpss_rx_threshold, reg); 921 - if ((read_SSITF(reg) & 0xffff) != chip->lpss_tx_threshold) 922 - write_SSITF(chip->lpss_tx_threshold, reg); 941 + if ((pxa2xx_spi_read(drv_data, SSIRF) & 0xff) 942 + != chip->lpss_rx_threshold) 943 + pxa2xx_spi_write(drv_data, SSIRF, 944 + chip->lpss_rx_threshold); 945 + if ((pxa2xx_spi_read(drv_data, SSITF) & 0xffff) 946 + != chip->lpss_tx_threshold) 947 + pxa2xx_spi_write(drv_data, SSITF, 948 + chip->lpss_tx_threshold); 923 949 } 924 950 925 951 if (is_quark_x1000_ssp(drv_data) && 926 - (read_DDS_RATE(reg) != chip->dds_rate)) 927 - write_DDS_RATE(chip->dds_rate, reg); 952 + (pxa2xx_spi_read(drv_data, DDS_RATE) != chip->dds_rate)) 953 + pxa2xx_spi_write(drv_data, DDS_RATE, chip->dds_rate); 928 954 929 955 /* see if we need to reload the config registers */ 930 - if ((read_SSCR0(reg) != cr0) || 931 - (read_SSCR1(reg) & change_mask) != (cr1 & change_mask)) { 932 - 956 + if ((pxa2xx_spi_read(drv_data, SSCR0) != cr0) 957 + || (pxa2xx_spi_read(drv_data, SSCR1) & change_mask) 958 + != (cr1 & change_mask)) { 933 959 /* stop the SSP, and update the other bits */ 934 - write_SSCR0(cr0 & ~SSCR0_SSE, reg); 960 + pxa2xx_spi_write(drv_data, SSCR0, cr0 & ~SSCR0_SSE); 935 961 if (!pxa25x_ssp_comp(drv_data)) 936 - write_SSTO(chip->timeout, reg); 962 + pxa2xx_spi_write(drv_data, SSTO, chip->timeout); 937 963 /* first set CR1 without interrupt and service enables */ 938 - write_SSCR1(cr1 & change_mask, reg); 964 + pxa2xx_spi_write(drv_data, SSCR1, cr1 & change_mask); 939 965 /* restart the SSP */ 940 - write_SSCR0(cr0, reg); 966 + pxa2xx_spi_write(drv_data, SSCR0, cr0); 941 967 942 968 } else { 943 969 if (!pxa25x_ssp_comp(drv_data)) 944 - write_SSTO(chip->timeout, reg); 970 + pxa2xx_spi_write(drv_data, SSTO, chip->timeout); 945 971 } 946 972 947 973 cs_assert(drv_data); 948 974 949 975 /* after chip select, release the data by enabling service 950 976 * requests and interrupts, without changing any mode bits */ 951 - write_SSCR1(cr1, reg); 977 + pxa2xx_spi_write(drv_data, SSCR1, cr1); 952 978 } 953 979 954 980 static int pxa2xx_spi_transfer_one_message(struct spi_master *master, ··· 981 999 struct driver_data *drv_data = spi_master_get_devdata(master); 982 1000 983 1001 /* Disable the SSP now */ 984 - write_SSCR0(read_SSCR0(drv_data->ioaddr) & ~SSCR0_SSE, 985 - drv_data->ioaddr); 1002 + pxa2xx_spi_write(drv_data, SSCR0, 1003 + pxa2xx_spi_read(drv_data, SSCR0) & ~SSCR0_SSE); 986 1004 987 1005 return 0; 988 1006 } ··· 1265 1283 struct driver_data *drv_data; 1266 1284 struct ssp_device *ssp; 1267 1285 int status; 1286 + u32 tmp; 1268 1287 1269 1288 platform_info = dev_get_platdata(dev); 1270 1289 if (!platform_info) { ··· 1363 1380 drv_data->max_clk_rate = clk_get_rate(ssp->clk); 1364 1381 1365 1382 /* Load default SSP configuration */ 1366 - write_SSCR0(0, drv_data->ioaddr); 1383 + pxa2xx_spi_write(drv_data, SSCR0, 0); 1367 1384 switch (drv_data->ssp_type) { 1368 1385 case QUARK_X1000_SSP: 1369 - write_SSCR1(QUARK_X1000_SSCR1_RxTresh( 1370 - RX_THRESH_QUARK_X1000_DFLT) | 1371 - QUARK_X1000_SSCR1_TxTresh( 1372 - TX_THRESH_QUARK_X1000_DFLT), 1373 - drv_data->ioaddr); 1386 + tmp = QUARK_X1000_SSCR1_RxTresh(RX_THRESH_QUARK_X1000_DFLT) 1387 + | QUARK_X1000_SSCR1_TxTresh(TX_THRESH_QUARK_X1000_DFLT); 1388 + pxa2xx_spi_write(drv_data, SSCR1, tmp); 1374 1389 1375 1390 /* using the Motorola SPI protocol and use 8 bit frame */ 1376 - write_SSCR0(QUARK_X1000_SSCR0_Motorola 1377 - | QUARK_X1000_SSCR0_DataSize(8), 1378 - drv_data->ioaddr); 1391 + pxa2xx_spi_write(drv_data, SSCR0, 1392 + QUARK_X1000_SSCR0_Motorola 1393 + | QUARK_X1000_SSCR0_DataSize(8)); 1379 1394 break; 1380 1395 default: 1381 - write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) | 1382 - SSCR1_TxTresh(TX_THRESH_DFLT), 1383 - drv_data->ioaddr); 1384 - write_SSCR0(SSCR0_SCR(2) 1385 - | SSCR0_Motorola 1386 - | SSCR0_DataSize(8), 1387 - drv_data->ioaddr); 1396 + tmp = SSCR1_RxTresh(RX_THRESH_DFLT) | 1397 + SSCR1_TxTresh(TX_THRESH_DFLT); 1398 + pxa2xx_spi_write(drv_data, SSCR1, tmp); 1399 + tmp = SSCR0_SCR(2) | SSCR0_Motorola | SSCR0_DataSize(8); 1400 + pxa2xx_spi_write(drv_data, SSCR0, tmp); 1388 1401 break; 1389 1402 } 1390 1403 1391 1404 if (!pxa25x_ssp_comp(drv_data)) 1392 - write_SSTO(0, drv_data->ioaddr); 1405 + pxa2xx_spi_write(drv_data, SSTO, 0); 1393 1406 1394 1407 if (!is_quark_x1000_ssp(drv_data)) 1395 - write_SSPSP(0, drv_data->ioaddr); 1408 + pxa2xx_spi_write(drv_data, SSPSP, 0); 1396 1409 1397 1410 if (is_lpss_ssp(drv_data)) 1398 1411 lpss_ssp_setup(drv_data); ··· 1434 1455 pm_runtime_get_sync(&pdev->dev); 1435 1456 1436 1457 /* Disable the SSP at the peripheral and SOC level */ 1437 - write_SSCR0(0, drv_data->ioaddr); 1458 + pxa2xx_spi_write(drv_data, SSCR0, 0); 1438 1459 clk_disable_unprepare(ssp->clk); 1439 1460 1440 1461 /* Release DMA */ ··· 1471 1492 status = spi_master_suspend(drv_data->master); 1472 1493 if (status != 0) 1473 1494 return status; 1474 - write_SSCR0(0, drv_data->ioaddr); 1495 + pxa2xx_spi_write(drv_data, SSCR0, 0); 1475 1496 1476 1497 if (!pm_runtime_suspended(dev)) 1477 1498 clk_disable_unprepare(ssp->clk);
+12 -20
drivers/spi/spi-pxa2xx.h
··· 115 115 void (*cs_control)(u32 command); 116 116 }; 117 117 118 - #define DEFINE_SSP_REG(reg, off) \ 119 - static inline u32 read_##reg(void const __iomem *p) \ 120 - { return __raw_readl(p + (off)); } \ 121 - \ 122 - static inline void write_##reg(u32 v, void __iomem *p) \ 123 - { __raw_writel(v, p + (off)); } 118 + static inline u32 pxa2xx_spi_read(const struct driver_data *drv_data, 119 + unsigned reg) 120 + { 121 + return __raw_readl(drv_data->ioaddr + reg); 122 + } 124 123 125 - DEFINE_SSP_REG(SSCR0, 0x00) 126 - DEFINE_SSP_REG(SSCR1, 0x04) 127 - DEFINE_SSP_REG(SSSR, 0x08) 128 - DEFINE_SSP_REG(SSITR, 0x0c) 129 - DEFINE_SSP_REG(SSDR, 0x10) 130 - DEFINE_SSP_REG(DDS_RATE, 0x28) /* DDS Clock Rate */ 131 - DEFINE_SSP_REG(SSTO, 0x28) 132 - DEFINE_SSP_REG(SSPSP, 0x2c) 133 - DEFINE_SSP_REG(SSITF, SSITF) 134 - DEFINE_SSP_REG(SSIRF, SSIRF) 124 + static inline void pxa2xx_spi_write(const struct driver_data *drv_data, 125 + unsigned reg, u32 val) 126 + { 127 + __raw_writel(val, drv_data->ioaddr + reg); 128 + } 135 129 136 130 #define START_STATE ((void *)0) 137 131 #define RUNNING_STATE ((void *)1) ··· 149 155 150 156 static inline void write_SSSR_CS(struct driver_data *drv_data, u32 val) 151 157 { 152 - void __iomem *reg = drv_data->ioaddr; 153 - 154 158 if (drv_data->ssp_type == CE4100_SSP || 155 159 drv_data->ssp_type == QUARK_X1000_SSP) 156 - val |= read_SSSR(reg) & SSSR_ALT_FRM_MASK; 160 + val |= pxa2xx_spi_read(drv_data, SSSR) & SSSR_ALT_FRM_MASK; 157 161 158 - write_SSSR(val, reg); 162 + pxa2xx_spi_write(drv_data, SSSR, val); 159 163 } 160 164 161 165 extern int pxa2xx_spi_flush(struct driver_data *drv_data);