[PATCH v12 2/6] mtd: spi-nor: core: Call set_4byte_addr_mode() before spi_nor_quad_enalbe()

Tudor.Ambarus at microchip.com Tudor.Ambarus at microchip.com
Thu Apr 21 00:32:57 PDT 2022


On 4/21/22 09:40, tkuw584924 at gmail.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>

Hi, Takahiro!
> 
> The part specific quad_enable method for s25hl-t and s25hs-t relies on
> address mode. Flash's address mode needs to be set before
> spi_nor_quad_enable() call.

Maybe I haven't understood something, but I thought you were going to use
3-byte addr for enabling quad mode. Can't you enable quad with 3-byte addr?
If not, why?

Cheers,
ta
> 
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
> ---
>  drivers/mtd/spi-nor/core.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 87603a99938f..748b77eb7841 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2665,6 +2665,21 @@ static int spi_nor_init(struct spi_nor *nor)
>                 return err;
>         }
> 
> +       if (nor->addr_width == 4 &&
> +           nor->read_proto != SNOR_PROTO_8_8_8_DTR &&
> +           !(nor->flags & SNOR_F_4B_OPCODES)) {
> +               /*
> +                * If the RESET# pin isn't hooked up properly, or the system
> +                * otherwise doesn't perform a reset command in the boot
> +                * sequence, it's impossible to 100% protect against unexpected
> +                * reboots (e.g., crashes). Warn the user (or hopefully, system
> +                * designer) that this is bad.
> +                */
> +               WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET,
> +                         "enabling reset hack; may not recover from unexpected reboots\n");
> +               nor->params->set_4byte_addr_mode(nor, true);
> +       }
> +
>         err = spi_nor_quad_enable(nor);
>         if (err) {
>                 dev_dbg(nor->dev, "quad mode not supported\n");
> @@ -2686,21 +2701,6 @@ static int spi_nor_init(struct spi_nor *nor)
>              nor->flags & SNOR_F_SWP_IS_VOLATILE))
>                 spi_nor_try_unlock_all(nor);
> 
> -       if (nor->addr_width == 4 &&
> -           nor->read_proto != SNOR_PROTO_8_8_8_DTR &&
> -           !(nor->flags & SNOR_F_4B_OPCODES)) {
> -               /*
> -                * If the RESET# pin isn't hooked up properly, or the system
> -                * otherwise doesn't perform a reset command in the boot
> -                * sequence, it's impossible to 100% protect against unexpected
> -                * reboots (e.g., crashes). Warn the user (or hopefully, system
> -                * designer) that this is bad.
> -                */
> -               WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET,
> -                         "enabling reset hack; may not recover from unexpected reboots\n");
> -               nor->params->set_4byte_addr_mode(nor, true);
> -       }
> -
>         return 0;
>  }
> 
> --
> 2.25.1
> 



More information about the linux-mtd mailing list