[PATCH 2/4] spi: zynq_qspi: Read only one byte at a time from txbuf
Ashok Reddy Soma
ashok.reddy.soma at xilinx.com
Mon Jan 31 06:22:38 CET 2022
From: Siva Durga Prasad Paladugu <siva.durga.paladugu at xilinx.com>
Read only one byte at a time from txbuf as txbuf may not be
aligned and accessing more than a byte at a time may cause
alignment issues. This fixes the issue of data abort exception
while writing to flash device.
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>
---
drivers/spi/zynq_qspi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c
index 34d39d66fb..aa060d7940 100644
--- a/drivers/spi/zynq_qspi.c
+++ b/drivers/spi/zynq_qspi.c
@@ -276,13 +276,17 @@ static void zynq_qspi_write_data(struct zynq_qspi_priv *priv,
*data |= 0xFFFFFF00;
break;
case 2:
- *data = *((u16 *)priv->tx_buf);
- priv->tx_buf += 2;
+ *data = *((u8 *)priv->tx_buf);
+ priv->tx_buf += 1;
+ *data |= (*((u8 *)priv->tx_buf) << 8);
+ priv->tx_buf += 1;
*data |= 0xFFFF0000;
break;
case 3:
- *data = *((u16 *)priv->tx_buf);
- priv->tx_buf += 2;
+ *data = *((u8 *)priv->tx_buf);
+ priv->tx_buf += 1;
+ *data |= (*((u8 *)priv->tx_buf) << 8);
+ priv->tx_buf += 1;
*data |= (*((u8 *)priv->tx_buf) << 16);
priv->tx_buf += 1;
*data |= 0xFF000000;
--
2.17.1
More information about the U-Boot
mailing list