public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Takahiro Kuwano <tkuw584924@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 04/10] mtd: spi-nor-core: Add support for volatile QE bit
Date: Mon, 8 Mar 2021 18:10:55 +0900	[thread overview]
Message-ID: <0bb89d5a-c3c6-dc1d-ec92-1ee4edb3a2c5@gmail.com> (raw)
In-Reply-To: <CAMty3ZCpw-nH0D_c0aJ_fGh05zytBR9DYtUjbgoydi2W8b=4vg@mail.gmail.com>

Hi Jagan,

On 2/26/2021 7:42 PM, Jagan Teki wrote:
> On Fri, Feb 19, 2021 at 7:26 AM <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.
>>
>> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>> ---
>> Changes in v5:
>>   - Fix register address calculation, 'base | offset' -> 'base + offset'
>>
>>  drivers/mtd/spi/spi-nor-core.c | 53 ++++++++++++++++++++++++++++++++++
>>  include/linux/mtd/spi-nor.h    |  1 +
>>  2 files changed, 54 insertions(+)
>>
>> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
>> index 2803536ed5..87c9fce408 100644
>> --- a/drivers/mtd/spi/spi-nor-core.c
>> +++ b/drivers/mtd/spi/spi-nor-core.c
>> @@ -1576,6 +1576,59 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor)
>>         return 0;
>>  }
>>
>> +/**
>> + * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register.
>> + * @nor:       pointer to a 'struct spi_nor'
>> + * @addr_base: base address of register (can be >0 in multi-die 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 addr_base,
>> +                                        u8 dummy)
>> +{
>> +       u32 addr = addr_base + SPINOR_REG_ADDR_CFR1V;
>> +
>> +       u8 cr;
>> +       int ret;
>> +
>> +       /* Check current Quad Enable bit value. */
>> +       ret = spansion_read_any_reg(nor, addr, dummy, &cr);
> 
> What if we can use the exiting quad_enable hook by identifying
> volatile QE at the function beginning instead of having a separate
> call?
> 
Do you mean something like this?

static int spansion_read_cr_quad_enable(struct spi_nor *nor)
{
	u8 sr_cr[2];
	int ret;

	if (JEDEC_MFR(nor->info) == SNOR_MFR_CYPRESS) {
		u32 base;

		for (base = 0; base < nor->mtd.size; base += SZ_128M) {
			u32 addr = base + SPINOR_REG_ADDR_CFR1V;

			/* Check current Quad Enable bit value. */
			ret = spansion_read_any_reg(nor, addr, 0, &sr_cr[1]);

			[...]

			ret = spansion_write_any_reg(nor, addr, sr_cr[1]);

			[...]

			/* Read back and check it. */
			ret = spansion_read_any_reg(nor, addr, 0, &sr_cr[1]);

			[...]
		}

		return 0;
	}

	/* Check current Quad Enable bit value. */
	ret = read_cr(nor);
	if (ret < 0) {
		dev_dbg(nor->dev,
			"error while reading configuration register\n");
		return -EINVAL;
	}

	[...]
}	

Or defining a new flag like 'SNOR_F_HAS_VOLATILE_QE'?

> Jagan.
> 

Best Regards,
Takahiro

  reply	other threads:[~2021-03-08  9:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-19  1:55 [PATCH v5 00/10] mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-02-19  1:55 ` [PATCH v5 01/10] mtd: spi-nor: Add Cypress manufacturer ID tkuw584924 at gmail.com
2021-02-19  1:55 ` [PATCH v5 02/10] mtd: spi-nor-ids: Add Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-02-19  9:51   ` Pratyush Yadav
2021-02-26 10:35   ` Jagan Teki
2021-03-08  8:49     ` Takahiro Kuwano
2021-02-19  1:55 ` [PATCH v5 03/10] mtd: spi-nor-core: Add support for Read/Write Any Register tkuw584924 at gmail.com
2021-02-19  1:55 ` [PATCH v5 04/10] mtd: spi-nor-core: Add support for volatile QE bit tkuw584924 at gmail.com
2021-02-26 10:42   ` Jagan Teki
2021-03-08  9:10     ` Takahiro Kuwano [this message]
2021-03-08  9:20       ` Pratyush Yadav
2021-02-19  1:55 ` [PATCH v5 05/10] mtd: spi-nor-core: Add the ->ready() hook tkuw584924 at gmail.com
2021-02-19  9:57   ` Pratyush Yadav
2021-03-08  6:53     ` Takahiro Kuwano
2021-02-19  1:56 ` [PATCH v5 06/10] mtd: spi-nor-core: Read status by Read Any Register tkuw584924 at gmail.com
2021-02-19 10:09   ` Pratyush Yadav
2021-02-19  1:56 ` [PATCH v5 07/10] mtd: spi-nor-core: Add non-uniform erase for Spansion/Cypress tkuw584924 at gmail.com
2021-02-24 12:05   ` Pratyush Yadav
2021-03-08  7:15     ` Takahiro Kuwano
2021-02-19  1:56 ` [PATCH v5 08/10] mtd: spi-nor-core: Add Cypress manufacturer ID in set_4byte tkuw584924 at gmail.com
2021-02-24 12:11   ` Pratyush Yadav
2021-03-08  7:26     ` Takahiro Kuwano
2021-02-19  1:56 ` [PATCH v5 09/10] mtd: spi-nor-core: Add fixups for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-02-24 12:40   ` Pratyush Yadav
2021-03-08  8:47     ` Takahiro Kuwano
2021-03-08  8:54       ` Pratyush Yadav
2021-03-08  8:59         ` Takahiro Kuwano
2021-02-19  1:56 ` [PATCH v5 10/10] mtd: spi-nor-tiny: " tkuw584924 at gmail.com
2021-02-24 12:43   ` Pratyush Yadav
2021-04-06  3:00     ` Takahiro Kuwano
2021-02-24 12:45 ` [PATCH v5 00/10] mtd: spi-nor: Add support " Pratyush Yadav

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=0bb89d5a-c3c6-dc1d-ec92-1ee4edb3a2c5@gmail.com \
    --to=tkuw584924@gmail.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