mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hendrik Donner <hd@os-cillation.de>
To: Sanjaikumar V S <sanjaikumarvs@gmail.com>, mwalle@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	miquel.raynal@bootlin.com, pratyush@kernel.org, richard@nod.at,
	sanjaikumar.vs@dicortech.com, stable@vger.kernel.org,
	tudor.ambarus@linaro.org, vigneshr@ti.com
Subject: Re: [PATCH v4 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence
Date: Mon, 16 Mar 2026 14:44:37 +0100	[thread overview]
Message-ID: <229484e3-d1b1-4cac-ae80-e483b7b90597@os-cillation.de> (raw)
In-Reply-To: <20260311103057.29-2-sanjaikumarvs@gmail.com>

Hello,

On 3/11/26 11:30, Sanjaikumar V S wrote:
> From: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
> 
> When writing to SST flash starting at an odd address, a single byte is
> first programmed using the byte program (BP) command. After this
> operation completes, the flash hardware automatically clears the Write
> Enable Latch (WEL) bit.
> 
> If an AAI (Auto Address Increment) word program sequence follows, it
> requires WEL to be set. Without re-enabling writes, the AAI sequence
> fails.
> 
> Add spi_nor_write_enable() after the odd-address byte program when more
> data needs to be written. Use a local boolean for clarity.
> 
> Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
> ---
>   drivers/mtd/spi-nor/sst.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
> index 175211fe6a5e..db02c14ba16f 100644
> --- a/drivers/mtd/spi-nor/sst.c
> +++ b/drivers/mtd/spi-nor/sst.c
> @@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>   
>   	/* Start write from odd address. */
>   	if (to % 2) {
> +		bool needs_write_enable = (len > 1);
> +
>   		/* write one byte. */
>   		ret = sst_nor_write_data(nor, to, 1, buf);
>   		if (ret < 0)
> @@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>   
>   		to++;
>   		actual++;
> +
> +		/*
> +		 * Byte program clears the write enable latch. If more
> +		 * data needs to be written using the AAI sequence,
> +		 * re-enable writes.
> +		 */
> +		if (needs_write_enable) {
> +			ret = spi_nor_write_enable(nor);
> +			if (ret)
> +				goto out;
> +		}
>   	}
>   
>   	/* Write out most of the data here. */

found a board with

   spi-nor spi0.0: sst25vf032b (4096 Kbytes)

for testing. Tests are on top of

   94645aa41bf9e (mtd/spi-nor/next)

This should be done according to the datasheet and fixes that only 1
byte is written on writes to a an odd address and following AAI writes
fail, resulting in something looking like this:

ffa9 ffff ffff ffff ffff ffff ffff ffff

when

24a9 91b3 7cb6 f01c 2994 c368 fdad d3a2

was supposed to be written.

Tested-by: Hendrik Donner <hd@os-cillation.de>
Reviewed-by: Hendrik Donner <hd@os-cillation.de>

Regards,
Hendrik

  reply	other threads:[~2026-03-16 13:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 10:30 [PATCH v4 0/2] mtd: spi-nor: Fix SST AAI write mode Sanjaikumar V S
2026-03-11 10:30 ` [PATCH v4 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Sanjaikumar V S
2026-03-16 13:44   ` Hendrik Donner [this message]
2026-03-30 14:21   ` Pratyush Yadav
2026-03-11 10:30 ` [PATCH v4 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available Sanjaikumar V S
2026-03-16 13:44   ` Hendrik Donner
2026-03-30 14:23   ` Pratyush Yadav
2026-03-31  6:24     ` Sanjaikumar V S
2026-03-30  7:31 ` [PATCH v4 0/2] mtd: spi-nor: Fix SST AAI write mode Sanjaikumar V S
2026-03-30 14:25   ` 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=229484e3-d1b1-4cac-ae80-e483b7b90597@os-cillation.de \
    --to=hd@os-cillation.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sanjaikumar.vs@dicortech.com \
    --cc=sanjaikumarvs@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --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

all inboxes | Powered by JetHome®