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

Greg Malysa greg.malysa at timesys.com
Fri Mar 29 01:44:37 CET 2024


Hi Tejas,

+ Ian Roberts, my coworker has the following comments:

I do not think it is appropriate to put what appears to be use-case
specific logic into the core functionality.

Your problem statement sounds like the chip is stuck in a stateful
mode after a reset. As alternatives, I would suggest:
1) Toggle the hardware reset line for the chip.
2) If one does not exist, use SPI_FLASH_SOFT_RESET_ON_BOOT
3) Alter your recovery application set the chip back to 3B mode on exit.

As is, I also think this would cause problems for chips with existing
support. set_4byte() sends commands to the chip, which may be
unrecognized or overlap with a manufacturer's custom command and cause
unintended side effects.

On Thu, Mar 28, 2024 at 11:37 AM Tejas Bhumkar
<tejas.arvind.bhumkar at amd.com> wrote:
>
> 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;

Can you elaborate on the purpose of this wait_till_ready?

>
>                 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
>

Thanks,
Greg

-- 
Greg Malysa
Timesys Corporation


More information about the U-Boot mailing list