Commit 5fd6739e authored by Miquel Raynal's avatar Miquel Raynal
Browse files

spi: mxic: Fix the transmit path



By working with external hardware ECC engines, we figured out that
Under certain circumstances, it is needed for the SPI controller to
check INT_TX_EMPTY and INT_RX_NOT_EMPTY in both receive and transmit
path (not only in the receive path). The delay penalty being
negligible, move this code in the common path.

Fixes: b942d80b ("spi: Add MXIC controller driver")
Cc: stable@vger.kernel.org
Suggested-by: default avatarMason Yang <masonccyang@mxic.com.tw>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarZhengxun Li <zhengxunli@mxic.com.tw>
Reviewed-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-10-miquel.raynal@bootlin.com
parent f9d7c726
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -304,10 +304,8 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf,

		writel(data, mxic->regs + TXD(nbytes % 4));

		if (rxbuf) {
		ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
						 sts & INT_TX_EMPTY, 0,
						 USEC_PER_SEC);
					 sts & INT_TX_EMPTY, 0, USEC_PER_SEC);
		if (ret)
			return ret;

@@ -318,11 +316,9 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf,
			return ret;

		data = readl(mxic->regs + RXD);
		if (rxbuf) {
			data >>= (8 * (4 - nbytes));
			memcpy(rxbuf + pos, &data, nbytes);
			WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
		} else {
			readl(mxic->regs + RXD);
		}
		WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);