From: Pratyush Yadav <p.yadav@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 9/9] mtd: spi-nor-tiny: Add fixups for Cypress s25hl-t/s25hs-t
Date: Tue, 2 Feb 2021 01:10:56 +0530 [thread overview]
Message-ID: <20210201194054.wwiljqilafpdrpr7@ti.com> (raw)
In-Reply-To: <a5c3cf1353d9a621379e2fcfefc51fb44c9680c5.1611729896.git.Takahiro.Kuwano@infineon.com>
On 28/01/21 01:37PM, tkuw584924 at gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Fixes mode clocks for SPINOR_OP_READ_FAST_4B and volatile QE bit in tiny.
> The volatile QE bit function, spansion_quad_enable_volatile() supports
> dual/quad die package parts, by taking 'die_size' parameter that is used
> to iterate register update for all dies in the device.
I'm not so sure if this is a good idea. spi-nor-tiny should be the
minimal set of functionality to get the bootloader to the next stage.
1S-1S-1S mode is sufficient for that. Adding quad enable functions of
all the flashes will increase the size quite a bit. I know that some
flashes already have their quad enable hooks, and I don't think they
should be there either.
Of course, the maintainers have the final call, but from my side,
Nacked-by: Pratyush Yadav <p.yadav@ti.com>
Anyway, comments below in case the maintainers do plan on picking this
patch up.
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
> drivers/mtd/spi/spi-nor-tiny.c | 89 ++++++++++++++++++++++++++++++++++
> 1 file changed, 89 insertions(+)
>
> diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
> index 5cc2b7d996..66680df5a9 100644
> --- a/drivers/mtd/spi/spi-nor-tiny.c
> +++ b/drivers/mtd/spi/spi-nor-tiny.c
> @@ -555,6 +555,85 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor)
> }
> #endif /* CONFIG_SPI_FLASH_SPANSION */
>
> +#ifdef CONFIG_SPI_FLASH_SPANSION
> +/**
> + * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register.
> + * @nor: pointer to a 'struct spi_nor'
> + * @die_size: maximum number of bytes per die ('mtd.size' > 'die_size' in
> + * multi die package parts).
> + * @dummy: number of dummy cycles for register read
> + *
> + * It is recommended to update volatile registers in the field application due
> + * to a risk of the non-volatile registers corruption by power interrupt. This
> + * function sets Quad Enable bit in CFR1 volatile.
> + *
> + * Return: 0 on success, -errno otherwise.
> + */
> +static int spansion_quad_enable_volatile(struct spi_nor *nor, u32 die_size,
> + u8 dummy)
> +{
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(0, 1),
> + SPI_MEM_OP_ADDR(4, 0, 1),
> + SPI_MEM_OP_DUMMY(0, 1),
> + SPI_MEM_OP_DATA_IN(1, NULL, 1));
> + u32 addr;
> + u8 cr;
> + int ret;
> +
> + /* Use 4-byte address for RDAR/WRAR */
> + ret = spi_nor_write_reg(nor, SPINOR_OP_EN4B, NULL, 0);
> + if (ret < 0) {
> + dev_dbg(nor->dev,
> + "error while enabling 4-byte address\n");
> + return ret;
> + }
> +
> + for (addr = 0; addr < nor->mtd.size; addr += die_size) {
> + op.addr.val = addr + SPINOR_REG_ADDR_CFR1V;
So here you add the register offset to the base address, instead of
ORing it. Ok.
> +
> + /* Check current Quad Enable bit value. */
> + op.cmd.opcode = SPINOR_OP_RDAR;
> + op.dummy.nbytes = dummy / 8;
> + op.data.dir = SPI_MEM_DATA_IN;
> + ret = spi_nor_read_write_reg(nor, &op, &cr);
> + if (ret < 0) {
> + dev_dbg(nor->dev,
> + "error while reading configuration register\n");
> + return -EINVAL;
> + }
> +
> + if (cr & CR_QUAD_EN_SPAN)
> + return 0;
> +
> + /* Write new value. */
> + cr |= CR_QUAD_EN_SPAN;
> + op.cmd.opcode = SPINOR_OP_WRAR;
> + op.dummy.nbytes = 0;
> + op.data.dir = SPI_MEM_DATA_OUT;
> + write_enable(nor);
> + ret = spi_nor_read_write_reg(nor, &op, &cr);
> + if (ret < 0) {
> + dev_dbg(nor->dev,
> + "error while writing configuration register\n");
> + return -EINVAL;
> + }
> +
> + /* Read back and check it. */
> + op.data.dir = SPI_MEM_DATA_IN;
> + ret = spi_nor_read_write_reg(nor, &op, &cr);
> + if (ret || !(cr & CR_QUAD_EN_SPAN)) {
> + dev_dbg(nor->dev, "Spansion Quad bit not set\n");
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
> +#endif
> +
LGTM.
> static void
> spi_nor_set_read_settings(struct spi_nor_read_command *read,
> u8 num_mode_clocks,
> @@ -583,6 +662,11 @@ static int spi_nor_init_params(struct spi_nor *nor,
> spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST],
> 0, 8, SPINOR_OP_READ_FAST,
> SNOR_PROTO_1_1_1);
> +#ifdef CONFIG_SPI_FLASH_SPANSION
> + if (JEDEC_MFR(info) == SNOR_MFR_CYPRESS &&
> + (info->id[1] == 0x2a || info->id[1] == 0x2b))
Add a comment about which flash models these two are.
> + params->reads[SNOR_CMD_READ_FAST].num_mode_clocks = 8;
> +#endif
> }
>
> if (info->flags & SPI_NOR_QUAD_READ) {
> @@ -659,6 +743,11 @@ static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
> case SNOR_MFR_MACRONIX:
> err = macronix_quad_enable(nor);
> break;
> +#endif
> +#ifdef CONFIG_SPI_FLASH_SPANSION
> + case SNOR_MFR_CYPRESS:
> + err = spansion_quad_enable_volatile(nor, SZ_128M, 0);
> + break;
> #endif
> case SNOR_MFR_ST:
> case SNOR_MFR_MICRON:
> --
> 2.25.1
>
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
next prev parent reply other threads:[~2021-02-01 19:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 4:36 [PATCH v4 0/9] mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-01-28 4:36 ` [PATCH v4 1/9] mtd: spi-nor: Add Cypress manufacturer ID tkuw584924 at gmail.com
2021-01-29 17:52 ` Pratyush Yadav
2021-01-28 4:36 ` [PATCH v4 2/9] mtd: spi-nor-ids: Add Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-01-29 18:08 ` Pratyush Yadav
2021-02-09 5:44 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 3/9] mtd: spi-nor-core: Add support for Read/Write Any Register tkuw584924 at gmail.com
2021-01-29 18:17 ` Pratyush Yadav
2021-02-09 5:51 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 4/9] mtd: spi-nor-core: Add support for volatile QE bit tkuw584924 at gmail.com
2021-01-29 18:40 ` Pratyush Yadav
2021-02-09 5:57 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 5/9] mtd: spi-nor-core: Add the ->ready() hook tkuw584924 at gmail.com
2021-01-29 18:49 ` Pratyush Yadav
2021-02-09 6:10 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 6/9] mtd: spi-nor-core: Add overlaid sector erase feature tkuw584924 at gmail.com
2021-02-01 18:56 ` Pratyush Yadav
2021-02-10 2:37 ` Takahiro Kuwano
2021-01-28 4:37 ` [PATCH v4 7/9] mtd: spi-nor-core: Add Cypress manufacturer ID in set_4byte tkuw584924 at gmail.com
2021-01-28 4:37 ` [PATCH v4 8/9] mtd: spi-nor-core: Add fixups for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-02-01 19:22 ` Pratyush Yadav
2021-02-15 7:45 ` Takahiro Kuwano
2021-01-28 4:37 ` [PATCH v4 9/9] mtd: spi-nor-tiny: " tkuw584924 at gmail.com
2021-02-01 19:40 ` Pratyush Yadav [this message]
2021-02-10 9:20 ` Takahiro Kuwano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210201194054.wwiljqilafpdrpr7@ti.com \
--to=p.yadav@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox