From: Takahiro Kuwano <tkuw584924@gmail.com>
To: Pratyush Yadav <p.yadav@ti.com>
Cc: linux-mtd@lists.infradead.org, tudor.ambarus@microchip.com,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
Bacem.Daassi@infineon.com,
Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Subject: Re: [PATCH v3 4/6] mtd: spi-nor: spansion: Add support for volatile QE bit
Date: Thu, 18 Mar 2021 17:24:42 +0900 [thread overview]
Message-ID: <a49e55df-f268-ce8f-b042-1b7e6ea32593@gmail.com> (raw)
In-Reply-To: <20210318081918.vmex64kcnhc6udla@ti.com>
On 3/18/2021 5:19 PM, Pratyush Yadav wrote:
> On 18/03/21 05:00PM, Takahiro Kuwano wrote:
>> On 3/15/2021 8:47 PM, Pratyush Yadav wrote:
>>> On 12/03/21 06:44PM, tkuw584924@gmail.com wrote:
>>>> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>>>>
>>>> Some of Spansion/Cypress chips support volatile version of configuration
>>>> registers and 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 patch adds a function to set Quad Enable bit in CFR1
>>>> volatile. The function supports multi-die package parts that require to
>>>> set the Quad Enable bit in each die.
>>>>
>>>> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>>>> ---
>>>> Changes in v3:
>>>> - Add multi-die package parts support
>>>>
>>>> drivers/mtd/spi-nor/spansion.c | 58 ++++++++++++++++++++++++++++++++++
>>>> 1 file changed, 58 insertions(+)
>>>>
>>>> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
>>>> index 1bce95cb7896..b5b5df4836c6 100644
>>>> --- a/drivers/mtd/spi-nor/spansion.c
>>>> +++ b/drivers/mtd/spi-nor/spansion.c
>>>> @@ -10,6 +10,8 @@
>>>>
>>>> #define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */
>>>> #define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */
>>>> +#define SPINOR_REG_CYPRESS_CFR1V 0x00800002
>>>> +#define SPINOR_REG_CYPRESS_CFR1V_QUAD_EN BIT(1) /* Quad Enable */
>>>> #define SPINOR_REG_CYPRESS_CFR2V 0x00800003
>>>> #define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24 0xb
>>>> #define SPINOR_REG_CYPRESS_CFR3V 0x00800004
>>>> @@ -121,6 +123,62 @@ static int spansion_write_any_reg(struct spi_nor *nor, u32 reg_addr, u8 reg_val)
>>>> return ret;
>>>> }
>>>>
>>>> +/**
>>>> + * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register.
>>>> + * @nor: pointer to a 'struct spi_nor'
>>>> + * @reg_dummy: number of dummy cycles for register read
>>>> + * @die_size: size of each die to determine the number of dies
>>>> + *
>>>> + * 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. If users set the Quad Enable
>>>> + * bit in the CFR1 non-volatile in advance (typically by a Flash programmer
>>>> + * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is
>>>> + * also set during Flash power-up. This function supports multi-die package
>>>> + * parts that require to set the Quad Enable bit in each die.
>>>> + *
>>>> + * Return: 0 on success, -errno otherwise.
>>>> + */
>>>> +static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy,
>>>> + u32 die_size)
>>>> +{
>>>> + int ret;
>>>> + u32 base, reg_addr;
>>>> + u8 cfr1v, cfr1v_written;
>>>> +
>>>> + for (base = 0; base < nor->params->size; base += die_size) {
>>>> + reg_addr = base + SPINOR_REG_CYPRESS_CFR1V;
>>>> +
>>>> + ret = spansion_read_any_reg(nor, reg_addr, reg_dummy, &cfr1v);
>>>
>>> I didn't notice it when reviewing the U-Boot series. How does register
>>> read work here? This will be issued in 1-1-4 mode since the
>>> nor->read_proto should be set to that protocol. But the flash is still
>>> in 1-1-1 mode. So the flash will output data on 1 line and the
>>> controller will read it on 4 lines, giving us a bogus register value. In
>>> fact I see this with pretty much every quad_enable() hook. What am I
>>> missing?
>>>
>> The nor->reg_proto is used for register access and it is 1-1-1 at this
>> point.
>
> Ah, right. Also...
>
>>
>>>> + if (ret)
>>>> + return ret;
>>>> +
>>>> + if (cfr1v & SPINOR_REG_CYPRESS_CFR1V_QUAD_EN)
>>>> + continue;
>>>> +
>>>> + /* Update the Quad Enable bit. */
>>>> + cfr1v |= SPINOR_REG_CYPRESS_CFR1V_QUAD_EN;
>>>> +
>>>> + ret = spansion_write_any_reg(nor, reg_addr, cfr1v);
>>>> + if (ret)
>>>> + return ret;
>>>> +
>>>> + cfr1v_written = cfr1v;
>>>> +
>>>> + /* Read back and check it. */
>>>> + ret = spansion_read_any_reg(nor, reg_addr, reg_dummy, &cfr1v);
>>>> + if (ret)
>>>> + return ret;
>
> ... this would still send data in 1-1-1 even after quad mode being
> enabled, right? If so,
>
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
>
Yes, the Flash works in 1-1-1 for register access even if quad mode
is enabled.
Best Regards,
Takahiro
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-03-18 8:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 9:40 [PATCH v3 0/6] mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t tkuw584924
2021-03-12 9:41 ` [PATCH v3 1/6] mtd: spi-nor: core: Add the ->ready() hook tkuw584924
2021-03-15 10:47 ` Pratyush Yadav
2021-03-12 9:42 ` [PATCH v3 2/6] mtd: spi-nor: core: Expose spi_nor_clear_sr() to manufacturer drivers tkuw584924
2021-03-15 10:54 ` Pratyush Yadav
2021-03-12 9:44 ` [PATCH v3 3/6] mtd: spi-nor: spansion: Add support for Read/Write Any Register tkuw584924
2021-03-15 11:27 ` Pratyush Yadav
2021-03-18 6:31 ` Takahiro Kuwano
2021-03-12 9:44 ` [PATCH v3 4/6] mtd: spi-nor: spansion: Add support for volatile QE bit tkuw584924
2021-03-15 11:47 ` Pratyush Yadav
2021-03-18 8:00 ` Takahiro Kuwano
2021-03-18 8:19 ` Pratyush Yadav
2021-03-18 8:24 ` Takahiro Kuwano [this message]
2021-03-12 9:44 ` [PATCH v3 5/6] mtd: spi-nor: spansion: Add status check for multi-die parts tkuw584924
2021-03-15 11:57 ` Pratyush Yadav
2021-03-12 9:45 ` [PATCH v3 6/6] mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups tkuw584924
2021-03-15 12:15 ` Pratyush Yadav
2021-03-18 6:50 ` Takahiro Kuwano
2021-03-19 2:51 ` 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=a49e55df-f268-ce8f-b042-1b7e6ea32593@gmail.com \
--to=tkuw584924@gmail.com \
--cc=Bacem.Daassi@infineon.com \
--cc=Takahiro.Kuwano@infineon.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=p.yadav@ti.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).