[PATCH] mtd: spi-nor: Add support to exit 4-byte mode

Tejas Bhumkar tejas.arvind.bhumkar at amd.com
Thu Mar 28 16:37:27 CET 2024


The Kria board features a recovery application that activates
when the FW_EN button is pressed.
Upon power-up flash operates in 3B mode, However, the recovery
application changes it back to 4B mode.
Following a reset, u-boot activates the CONFIG_SPI_FLASH_BAR
and expects the flash to be in 3B mode. However, there's no
code to handle this configuration. to address this issue, changes
were made to disable the 4B mode when the CONFIG_SPI_FLASH_BAR
is enabled.

Additionally, spi_nor_wait_till_ready() was included because there is
operation that places the device in a busy state before performing
a nor read.

Signed-off-by: Tejas Bhumkar <tejas.arvind.bhumkar at amd.com>
---
 drivers/mtd/spi/spi-nor-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index f86003ca8c..47f65a4f5e 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -1464,6 +1464,9 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
 		else
 			read_len = remain_len;
 #endif
+		ret = spi_nor_wait_till_ready(nor);
+		if (ret)
+			goto read_err;
 
 		ret = nor->read(nor, addr, read_len, buf);
 		if (ret == 0) {
@@ -4161,6 +4164,7 @@ int spi_nor_scan(struct spi_nor *nor)
 #else
 	/* Configure the BAR - discover bank cmds and read current bank */
 	nor->addr_width = 3;
+	set_4byte(nor, info, 0);
 	ret = read_bar(nor, info);
 	if (ret < 0)
 		return ret;
-- 
2.37.6



More information about the U-Boot mailing list