* [PATCH] mtd: spinand: winbond: Add support for W25N08LW
@ 2026-08-31 15:38 Nuno Sá
2026-09-03 10:12 ` Miquel Raynal
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2026-08-31 15:38 UTC (permalink / raw)
To: linux-mtd, linux-kernel
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
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@analog.com>
---
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 */
+ region->length = 16;
+
+ /* Extract BBM */
+ if (!section) {
+ region->offset += 2;
+ region->length -= 2;
+ }
+
+ return 0;
+}
+
+static const struct mtd_ooblayout_ops w25n08lw_ooblayout = {
+ .ecc = w25n08lw_ooblayout_ecc,
+ .free = w25n08lw_ooblayout_free,
+};
+
static int w25n01jw_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *region)
{
@@ -781,6 +816,16 @@ static const struct spinand_info winbond_spinand_table[] = {
SPINAND_ECCINFO(&w35n01jw_ooblayout, w25w35nxxjw_ecc_get_status),
SPINAND_CONFIGURE_CHIP(w35n0xjw_vcr_cfg),
SPINAND_CONT_READ(w35n0xjw_set_cont_read)),
+ /* 8G-bit densities */
+ SPINAND_INFO("W25N08LW", /* 2x4G-bit 1.8V */
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb3, 0x24),
+ NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 2, 1),
+ NAND_ECCREQ(8, 512),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ 0,
+ SPINAND_ECCINFO(&w25n08lw_ooblayout, w25n02kv_ecc_get_status)),
};
static int winbond_spinand_init(struct spinand_device *spinand)
---
base-commit: 15a3cbce32994141252bb4ecfe3ff3a5d22d0b4f
change-id: 20260831-mtd-nand-new-chip-support-44b10657243f
--
Thanks!
- Nuno Sá
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: spinand: winbond: Add support for W25N08LW
2026-08-31 15:38 [PATCH] mtd: spinand: winbond: Add support for W25N08LW Nuno Sá
@ 2026-09-03 10:12 ` Miquel Raynal
2026-09-03 12:40 ` Nuno Sá
0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2026-09-03 10:12 UTC (permalink / raw)
To: Nuno Sá
Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra
On 31/08/2026 at 16:38:10 +01, Nuno Sá <nuno.sa@analog.com> 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@analog.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: spinand: winbond: Add support for W25N08LW
2026-09-03 10:12 ` Miquel Raynal
@ 2026-09-03 12:40 ` Nuno Sá
0 siblings, 0 replies; 3+ messages in thread
From: Nuno Sá @ 2026-09-03 12:40 UTC (permalink / raw)
To: Miquel Raynal
Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra
On Thu, Sep 03, 2026 at 12:12:15PM +0200, Miquel Raynal wrote:
> On 31/08/2026 at 16:38:10 +01, Nuno Sá <nuno.sa@analog.com> 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@analog.com>
> > ---
> > 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?
Not at all! Will re-spin with that in mind!
Thx!
- Nuno Sá
>
> Thanks,
> Miquèl
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-03 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 15:38 [PATCH] mtd: spinand: winbond: Add support for W25N08LW Nuno Sá
2026-09-03 10:12 ` Miquel Raynal
2026-09-03 12:40 ` Nuno Sá
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®