Re: [PATCH] mtd: spinand: winbond: Add support for W25N08LW

From: Miquel Raynal

Date: Thu Sep 03 2026 - 06:33:48 EST


On 31/08/2026 at 16:38:10 +01, Nuno Sá <nuno.sa@xxxxxxxxxx> wrote:

> Add support for the W25N08LW, a 1.8V 8Gbit SPI-NAND made of two
> 4Gbit LUNs, with 4096-byte pages and 256 bytes of spare area.
>
> The chip reuses the KV ECC status helper, but needs its own OOB
> layout because the geometry of its spare area differs from the
> existing Winbond parts. Only half of it is visible while the
> internal ECC is enabled, so the ECC region is reported as
> inaccessible and just the free bytes are exposed.
>
> Assisted-by: Claude:Opus-5
> Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
> ---
> drivers/mtd/nand/spi/winbond.c | 45 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 9b78c1e6cbc9..c2c4cc306f05 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -345,6 +345,41 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
> .free = w25n02kv_ooblayout_free,
> };
>
> +static int w25n08lw_ooblayout_ecc(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region)
> +{
> + /*
> + * With ecc enabled the parity bits are not accessible. So we can
> + * only see page + 128. Without ecc the full page + 256 is accessible.
> + * To make it simple just return the area as not accessible.
> + */
> + return -ERANGE;
> +}
> +
> +static int w25n08lw_ooblayout_free(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region)
> +{
> + if (section > 7)
> + return -ERANGE;
> +
> + region->offset = (16 * section);
> + /* Note that we include User Data 2 which is not protected by ECC */

The more I think about these free bytes, the more I get convinced that
we should only expose ECC protected bytes. I honestly do not remember
any guarantee regarding these officially stated, the common case
(eg. UBI) there is no impact, but maybe it is best to only expose the
bytes that are actually protected, since the thresholds are getting
lower and lower (and chances to get bitflips there increase with the
optimizations of the technology).

Do you mind only exposing User Data 1?

Thanks,
Miquèl