[U-Boot] [PATCH 2/6] spi: fsl_qspi: Fix erase issue to adapt spi-mem

Ye Li ye.li at nxp.com
Wed Aug 14 10:09:01 UTC 2019


After switched to spi-mem, the data format passed by xfer is changed
for erase. The address of erase is moved to data phase in SPI_XFER_END.
Update the driver to fix the erase issue

Signed-off-by: Ye Li <ye.li at nxp.com>
---
 drivers/spi/fsl_qspi.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 8845986..13cf0e9 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -785,6 +785,19 @@ int qspi_xfer(struct fsl_qspi_priv *priv, unsigned int bitlen,
 		}
 
 		if (flags == SPI_XFER_END) {
+			if ((priv->cur_seqid == QSPI_CMD_SE) ||
+				(priv->cur_seqid == QSPI_CMD_BE_4K)) {
+				int i;
+				txbuf = *(u8 *)dout;
+				for (i = 1; i < bytes; i++) {
+					txbuf <<= 8;
+					txbuf |= *(((u8 *)dout) + i);
+				}
+
+				priv->sf_addr = txbuf;
+				qspi_op_erase(priv);
+				return 0;
+			}
 			priv->sf_addr = wr_sfaddr;
 			qspi_op_write(priv, (u8 *)dout, bytes);
 			return 0;
@@ -793,10 +806,6 @@ int qspi_xfer(struct fsl_qspi_priv *priv, unsigned int bitlen,
 		if (priv->cur_seqid == QSPI_CMD_FAST_READ ||
 		    priv->cur_seqid == QSPI_CMD_RDAR) {
 			priv->sf_addr = swab32(txbuf) & OFFSET_BITS_MASK;
-		} else if ((priv->cur_seqid == QSPI_CMD_SE) ||
-			   (priv->cur_seqid == QSPI_CMD_BE_4K)) {
-			priv->sf_addr = swab32(txbuf) & OFFSET_BITS_MASK;
-			qspi_op_erase(priv);
 		} else if (priv->cur_seqid == QSPI_CMD_PP ||
 			   priv->cur_seqid == QSPI_CMD_WRAR) {
 			wr_sfaddr = swab32(txbuf) & OFFSET_BITS_MASK;
-- 
2.7.4



More information about the U-Boot mailing list