Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Walle" <mwalle@kernel.org>
To: "Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Pratyush Yadav" <pratyush@kernel.org>,
	"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Steam Lin" <STLin2@winbond.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 04/30] mtd: spi-nor: winbond: Make the RDCR fixup Winbond wide
Date: Mon, 06 Jul 2026 16:11:31 +0200	[thread overview]
Message-ID: <DJRJS82LPRIZ.2NG59E6DSDTHM@kernel.org> (raw)
In-Reply-To: <20260529-winbond-v7-1-spi-nor-jv-cleanup-v1-4-87e5d3122244@bootlin.com>


[-- Attachment #1.1: Type: text/plain, Size: 4498 bytes --]

On Fri May 29, 2026 at 5:22 PM CEST, Miquel Raynal wrote:
> The top level paragraph of the QER field in the JESD216B mentions:
>
> "In this standard, [...]  Status register 2 refers to the byte read
> using instruction 35h. Status register 2 is the second byte transferred
> in a Write Status (01h) command. [...]"
>
> Value 100b, named in Linux BFPT_DWORD15_QER_SR2_BIT1_NO_RD, does not
> mention anything about reads and only brings details about writes.
>
> This has been interpreted in the spi-nor core by the absence of read
> capability, but there is no explicit reason for that, except that there
> were probably some very old chips which didn't support command 35h.

I agree. But making it a vendor default we always have to have an
entry. So if this is really for all winbond chips, we shall do a
catch all entry (like in macronix.c).

> All quad capable Winbond chips carry a CMP SWP bit in SR2. SR2 is
> readable with command 35h. In practice, all Winbond families but the
> W25X family have support for this feature, so re-enable it Winbond-wide
> in a late vendor fixup, except for the {EF, 30, xx} family.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

> ---
>  drivers/mtd/spi-nor/winbond.c | 37 ++++++++++++++-----------------------
>  1 file changed, 14 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c
> index b4088fc5fde9..4300f0419f13 100644
> --- a/drivers/mtd/spi-nor/winbond.c
> +++ b/drivers/mtd/spi-nor/winbond.c
> @@ -73,26 +73,6 @@ static const struct spi_nor_fixups w25q256_fixups = {
>  	.post_bfpt = w25q256_post_bfpt_fixups,
>  };
>  
> -static int
> -winbond_rdcr_post_bfpt_fixup(struct spi_nor *nor,
> -			     const struct sfdp_parameter_header *bfpt_header,
> -			     const struct sfdp_bfpt *bfpt)
> -{
> -	/*
> -	 * W25H02NW, unlike its W25H512NW nor W25H01NW cousins, improperly sets
> -	 * the QE BFPT configuration bits, indicating a non readable CR. This is
> -	 * both incorrect and impractical, as the chip features a CMP bit for its
> -	 * locking scheme that lays in the Control Register, and needs to be read.
> -	 */
> -	nor->flags &= ~SNOR_F_NO_READ_CR;
> -
> -	return 0;
> -}
> -
> -static const struct spi_nor_fixups winbond_rdcr_fixup = {
> -	.post_bfpt = winbond_rdcr_post_bfpt_fixup,
> -};
> -
>  /**
>   * winbond_nor_select_die() - Set active die.
>   * @nor:	pointer to 'struct spi_nor'.
> @@ -305,7 +285,6 @@ static const struct flash_info winbond_nor_parts[] = {
>  		.id = SNOR_ID(0xef, 0x60, 0x21),
>  		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
>  			 SPI_NOR_4BIT_BP | SPI_NOR_HAS_CMP,
> -		.fixups = &winbond_rdcr_fixup,
>  	}, {
>  		/* W25Q16JV-M */
>  		.id = SNOR_ID(0xef, 0x70, 0x15),
> @@ -381,7 +360,6 @@ static const struct flash_info winbond_nor_parts[] = {
>  		.id = SNOR_ID(0xef, 0x80, 0x22),
>  		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
>  			 SPI_NOR_4BIT_BP | SPI_NOR_HAS_CMP,
> -		.fixups = &winbond_rdcr_fixup,
>  	}, {
>  		/* W25H512NW-M */
>  		.id = SNOR_ID(0xef, 0xa0, 0x20),
> @@ -397,7 +375,6 @@ static const struct flash_info winbond_nor_parts[] = {
>  		.id = SNOR_ID(0xef, 0xa0, 0x22),
>  		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
>  			 SPI_NOR_4BIT_BP | SPI_NOR_HAS_CMP,
> -		.fixups = &winbond_rdcr_fixup,
>  	},
>  };
>  
> @@ -490,6 +467,20 @@ static int winbond_nor_late_init(struct spi_nor *nor)
>  	 */
>  	params->set_4byte_addr_mode = winbond_nor_set_4byte_addr_mode;
>  
> +	/*
> +	 * All W25Q/W25H chips do set the BFPT_DWORD15_QER_SR2_BIT1_NO_RD bit in
> +	 * their SFDP tables. The historical spi-nor assumption in this case has
> +	 * been to declare CR reads as unsupported, whereas the Jedec
> +	 * specification doesn't clearly state that. In practice, all these
> +	 * chips do support reading back the CR, which is needed for SWP support,
> +	 * so make sure that capability remains enabled (needed for SWP).
> +	 * In practice, only exclude the old W25X family (JEDEC ID: EF 30 xx)
> +	 * which actually does not support this feature.
> +	 */
> +	if (nor->info->id->bytes[0] == 0xef &&
> +	    nor->info->id->bytes[1] > 0x30)
> +		nor->flags &= ~SNOR_F_NO_READ_CR;

This is somewhat hard to read and the byte[0] is redundant here.
Maybe you can come up with some macro magic sugar :)

-michael

> +
>  	return 0;
>  }
>  


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2026-07-06 14:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 15:22 [PATCH 00/30] mtd: spi-nor: Clean Winbond W25QxxJV family Miquel Raynal
2026-05-29 15:22 ` [PATCH 01/30] mtd: spi-nor: winbond: Move W25Q01NW to its right place Miquel Raynal
2026-07-06 13:54   ` Michael Walle
2026-05-29 15:22 ` [PATCH 02/30] mtd: spi-nor: winbond: Normalize names Miquel Raynal
2026-07-06 13:57   ` Michael Walle
2026-05-29 15:22 ` [PATCH 03/30] mtd: spi-nor: winbond: Stop filling the .name entry Miquel Raynal
2026-07-06 13:59   ` Michael Walle
2026-05-29 15:22 ` [PATCH 04/30] mtd: spi-nor: winbond: Make the RDCR fixup Winbond wide Miquel Raynal
2026-07-06 14:11   ` Michael Walle [this message]
2026-05-29 15:22 ` [PATCH 05/30] mtd: spi-nor: winbond: W25Q32JV-Q/N: Drop redundant data Miquel Raynal
2026-07-06 14:13   ` Michael Walle
2026-05-29 15:22 ` [PATCH 06/30] mtd: spi-nor: winbond: W25Q64JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 07/30] mtd: spi-nor: winbond: W25Q512JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 08/30] mtd: spi-nor: winbond: W25Q32JV-Q/N: Add quad page program capability Miquel Raynal
2026-07-06 14:16   ` Michael Walle
2026-05-29 15:22 ` [PATCH 09/30] mtd: spi-nor: winbond: W25Q64JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 10/30] mtd: spi-nor: winbond: W25Q128JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 11/30] mtd: spi-nor: winbond: W25Q32JV-Q/N: Fill locking information Miquel Raynal
2026-07-06 14:21   ` Michael Walle
2026-05-29 15:22 ` [PATCH 12/30] mtd: spi-nor: winbond: W25Q64JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 13/30] mtd: spi-nor: winbond: W25Q128JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 14/30] mtd: spi-nor: winbond: W25Q512JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 15/30] mtd: spi-nor: winbond: W25Q01JV-Q/N: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 16/30] mtd: spi-nor: winbond: W25Q32JV-M: Drop redundant data Miquel Raynal
2026-07-06 14:23   ` Michael Walle
2026-05-29 15:22 ` [PATCH 17/30] mtd: spi-nor: winbond: W25Q64JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 18/30] mtd: spi-nor: winbond: W25Q128JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 19/30] mtd: spi-nor: winbond: W25Q32JV-M: Add quad page program capability Miquel Raynal
2026-05-29 15:22 ` [PATCH 20/30] mtd: spi-nor: winbond: W25Q64JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 21/30] mtd: spi-nor: winbond: W25Q128JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 22/30] mtd: spi-nor: winbond: W25Q32JV-M: Fill locking information Miquel Raynal
2026-05-29 15:22 ` [PATCH 23/30] mtd: spi-nor: winbond: W25Q64JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 24/30] mtd: spi-nor: winbond: W25Q128JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 25/30] mtd: spi-nor: winbond: W25Q02JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 26/30] mtd: spi-nor: winbond: W25Q512JV-M: New chip Miquel Raynal
2026-05-29 15:22 ` [PATCH 27/30] mtd: spi-nor: winbond: W25Q01JV-M: " Miquel Raynal
2026-05-29 15:22 ` [PATCH 28/30] mtd: spi-nor: winbond: W25QxxJV-Q/N/M: Drop redundant data Miquel Raynal
2026-05-29 15:22 ` [PATCH 29/30] mtd: spi-nor: winbond: W25QxxJV-Q/N/M: Add quad page program capability Miquel Raynal
2026-05-29 15:22 ` [PATCH 30/30] mtd: spi-nor: winbond: W25QxxJV-Q/N/M: Fill locking information Miquel Raynal
2026-07-06 14:27 ` [PATCH 00/30] mtd: spi-nor: Clean Winbond W25QxxJV family Michael Walle

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=DJRJS82LPRIZ.2NG59E6DSDTHM@kernel.org \
    --to=mwalle@kernel.org \
    --cc=STLin2@winbond.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=takahiro.kuwano@infineon.com \
    --cc=thomas.petazzoni@bootlin.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