diff mbox series

[v3,3/4] mtd: spi-nor-core: set 4byte opcode when possible

Message ID 20210913054223.25209-4-jaimeliao.tw@gmail.com
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Add octal DTR support for Macronix flash | expand

Commit Message

liao jaime Sept. 13, 2021, 5:42 a.m. UTC
Following linux kernel to check address width and 4byte flag to enable
4byte opcode setting.

Signed-off-by: JaimeLiao <jaimeliao.tw@gmail.com>
---
 drivers/mtd/spi/spi-nor-core.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Pratyush Yadav Sept. 24, 2021, 6:29 p.m. UTC | #1
On 13/09/21 01:42PM, JaimeLiao wrote:
> Following linux kernel to check address width and 4byte flag to enable
> 4byte opcode setting.
> 
> Signed-off-by: JaimeLiao <jaimeliao.tw@gmail.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 4bcd58d839..81c61d87bc 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -3902,6 +3902,10 @@ int spi_nor_scan(struct spi_nor *nor)
>  		return -EINVAL;
>  	}
>  
> +	/* Set 4byte opcodes when possible. */
> +	if (nor->addr_width == 4 && info->flags & SPI_NOR_4B_OPCODES)
> +		spi_nor_set_4byte_opcodes(nor, info);

This is already done a few lines above. Why do you need to do it again?

> +
>  	/* Send all the required SPI flash commands to initialize device */
>  	ret = spi_nor_init(nor);
>  	if (ret)
> -- 
> 2.17.1
>
liao jaime Sept. 27, 2021, 2:52 a.m. UTC | #2
>if (spi_nor_protocol_is_dtr(nor->read_proto)) {
>                 /* Always use 4-byte addresses in DTR mode. */
>                nor->addr_width = 4;
because of nor->addr_width have been set to 4 when protocol is dtr
>        } else if (nor->addr_width) {
>                /* already configured from SFDP */
>        } else if (info->addr_width) {
>                nor->addr_width = info->addr_width;
>        } else {
>                nor->addr_width = 3;
>        }
>
>        if (nor->addr_width == 3 && mtd->size > SZ_16M) {
>#ifndef CONFIG_SPI_FLASH_BAR
>                /* enable 4-byte addressing if the device exceeds 16MiB */
>                nor->addr_width = 4;
>                if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
>                    info->flags & SPI_NOR_4B_OPCODES)
>                        spi_nor_set_4byte_opcodes(nor, info);
nor->addr_width is equal 4 when protocol is dtr
so we need a judgement to do spi_nor_set_4byte_opcodes(nor, info)
>#else
>        /* Configure the BAR - discover bank cmds and read current bank */
>        nor->addr_width = 3;
>        ret = read_bar(nor, info);
>        if (ret < 0)
>                return ret;
>#endif
>        }

Pratyush Yadav <p.yadav@ti.com> 於 2021年9月25日 週六 上午2:29寫道:

> On 13/09/21 01:42PM, JaimeLiao wrote:
> > Following linux kernel to check address width and 4byte flag to enable
> > 4byte opcode setting.
> >
> > Signed-off-by: JaimeLiao <jaimeliao.tw@gmail.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 4bcd58d839..81c61d87bc 100644
> > --- a/drivers/mtd/spi/spi-nor-core.c
> > +++ b/drivers/mtd/spi/spi-nor-core.c
> > @@ -3902,6 +3902,10 @@ int spi_nor_scan(struct spi_nor *nor)
> >               return -EINVAL;
> >       }
> >
> > +     /* Set 4byte opcodes when possible. */
> > +     if (nor->addr_width == 4 && info->flags & SPI_NOR_4B_OPCODES)
> > +             spi_nor_set_4byte_opcodes(nor, info);
>
> This is already done a few lines above. Why do you need to do it again?
>
> > +
> >       /* Send all the required SPI flash commands to initialize device */
> >       ret = spi_nor_init(nor);
> >       if (ret)
> > --
> > 2.17.1
> >
>
> --
> Regards,
> Pratyush Yadav
> Texas Instruments Inc.
>
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 4bcd58d839..81c61d87bc 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3902,6 +3902,10 @@  int spi_nor_scan(struct spi_nor *nor)
 		return -EINVAL;
 	}
 
+	/* Set 4byte opcodes when possible. */
+	if (nor->addr_width == 4 && info->flags & SPI_NOR_4B_OPCODES)
+		spi_nor_set_4byte_opcodes(nor, info);
+
 	/* Send all the required SPI flash commands to initialize device */
 	ret = spi_nor_init(nor);
 	if (ret)