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

spi: omap2-mcspi: raw read and write endian fix

All OMAP IP blocks expect LE data, but CPU may operate in BE mode.
Need to use endian neutral functions to read/write h/w registers.
I.e instead of __raw_read[lw] and __raw_write[lw] functions code
need to use read[lw]_relaxed and write[lw]_relaxed functions.
If the first simply reads/writes register, the second will byteswap
it if host operates in BE mode.

Changes are trivial sed like replacement of __raw_xxx functions
with xxx_relaxed variant.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Victor Kamensky and committed by
Mark Brown
21b2ce5e 6ce4eac1

+19 -19
+19 -19
drivers/spi/spi-omap2-mcspi.c
··· 157 157 { 158 158 struct omap2_mcspi *mcspi = spi_master_get_devdata(master); 159 159 160 - __raw_writel(val, mcspi->base + idx); 160 + writel_relaxed(val, mcspi->base + idx); 161 161 } 162 162 163 163 static inline u32 mcspi_read_reg(struct spi_master *master, int idx) 164 164 { 165 165 struct omap2_mcspi *mcspi = spi_master_get_devdata(master); 166 166 167 - return __raw_readl(mcspi->base + idx); 167 + return readl_relaxed(mcspi->base + idx); 168 168 } 169 169 170 170 static inline void mcspi_write_cs_reg(const struct spi_device *spi, ··· 172 172 { 173 173 struct omap2_mcspi_cs *cs = spi->controller_state; 174 174 175 - __raw_writel(val, cs->base + idx); 175 + writel_relaxed(val, cs->base + idx); 176 176 } 177 177 178 178 static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx) 179 179 { 180 180 struct omap2_mcspi_cs *cs = spi->controller_state; 181 181 182 - return __raw_readl(cs->base + idx); 182 + return readl_relaxed(cs->base + idx); 183 183 } 184 184 185 185 static inline u32 mcspi_cached_chconf0(const struct spi_device *spi) ··· 338 338 mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); 339 339 340 340 list_for_each_entry(cs, &ctx->cs, node) 341 - __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 341 + writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 342 342 } 343 343 344 344 static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) ··· 346 346 unsigned long timeout; 347 347 348 348 timeout = jiffies + msecs_to_jiffies(1000); 349 - while (!(__raw_readl(reg) & bit)) { 349 + while (!(readl_relaxed(reg) & bit)) { 350 350 if (time_after(jiffies, timeout)) { 351 - if (!(__raw_readl(reg) & bit)) 351 + if (!(readl_relaxed(reg) & bit)) 352 352 return -ETIMEDOUT; 353 353 else 354 354 return 0; ··· 675 675 } 676 676 dev_vdbg(&spi->dev, "write-%d %02x\n", 677 677 word_len, *tx); 678 - __raw_writel(*tx++, tx_reg); 678 + writel_relaxed(*tx++, tx_reg); 679 679 } 680 680 if (rx != NULL) { 681 681 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 687 687 if (c == 1 && tx == NULL && 688 688 (l & OMAP2_MCSPI_CHCONF_TURBO)) { 689 689 omap2_mcspi_set_enable(spi, 0); 690 - *rx++ = __raw_readl(rx_reg); 690 + *rx++ = readl_relaxed(rx_reg); 691 691 dev_vdbg(&spi->dev, "read-%d %02x\n", 692 692 word_len, *(rx - 1)); 693 693 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 701 701 omap2_mcspi_set_enable(spi, 0); 702 702 } 703 703 704 - *rx++ = __raw_readl(rx_reg); 704 + *rx++ = readl_relaxed(rx_reg); 705 705 dev_vdbg(&spi->dev, "read-%d %02x\n", 706 706 word_len, *(rx - 1)); 707 707 } ··· 722 722 } 723 723 dev_vdbg(&spi->dev, "write-%d %04x\n", 724 724 word_len, *tx); 725 - __raw_writel(*tx++, tx_reg); 725 + writel_relaxed(*tx++, tx_reg); 726 726 } 727 727 if (rx != NULL) { 728 728 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 734 734 if (c == 2 && tx == NULL && 735 735 (l & OMAP2_MCSPI_CHCONF_TURBO)) { 736 736 omap2_mcspi_set_enable(spi, 0); 737 - *rx++ = __raw_readl(rx_reg); 737 + *rx++ = readl_relaxed(rx_reg); 738 738 dev_vdbg(&spi->dev, "read-%d %04x\n", 739 739 word_len, *(rx - 1)); 740 740 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 748 748 omap2_mcspi_set_enable(spi, 0); 749 749 } 750 750 751 - *rx++ = __raw_readl(rx_reg); 751 + *rx++ = readl_relaxed(rx_reg); 752 752 dev_vdbg(&spi->dev, "read-%d %04x\n", 753 753 word_len, *(rx - 1)); 754 754 } ··· 769 769 } 770 770 dev_vdbg(&spi->dev, "write-%d %08x\n", 771 771 word_len, *tx); 772 - __raw_writel(*tx++, tx_reg); 772 + writel_relaxed(*tx++, tx_reg); 773 773 } 774 774 if (rx != NULL) { 775 775 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 781 781 if (c == 4 && tx == NULL && 782 782 (l & OMAP2_MCSPI_CHCONF_TURBO)) { 783 783 omap2_mcspi_set_enable(spi, 0); 784 - *rx++ = __raw_readl(rx_reg); 784 + *rx++ = readl_relaxed(rx_reg); 785 785 dev_vdbg(&spi->dev, "read-%d %08x\n", 786 786 word_len, *(rx - 1)); 787 787 if (mcspi_wait_for_reg_bit(chstat_reg, ··· 795 795 omap2_mcspi_set_enable(spi, 0); 796 796 } 797 797 798 - *rx++ = __raw_readl(rx_reg); 798 + *rx++ = readl_relaxed(rx_reg); 799 799 dev_vdbg(&spi->dev, "read-%d %08x\n", 800 800 word_len, *(rx - 1)); 801 801 } ··· 1107 1107 1108 1108 /* RX_ONLY mode needs dummy data in TX reg */ 1109 1109 if (t->tx_buf == NULL) 1110 - __raw_writel(0, cs->base 1110 + writel_relaxed(0, cs->base 1111 1111 + OMAP2_MCSPI_TX0); 1112 1112 1113 1113 if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && ··· 1470 1470 * change in account. 1471 1471 */ 1472 1472 cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE; 1473 - __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1473 + writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1474 1474 cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE; 1475 - __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1475 + writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1476 1476 } 1477 1477 } 1478 1478 pm_runtime_mark_last_busy(mcspi->dev);