* [RFC PATCH] mtd: spinand: support FS35ND01G-S1Y2 with external ECC
@ 2026-12-01 2:30 Pengji Li
2026-12-01 2:44 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Pengji Li @ 2026-12-01 2:30 UTC (permalink / raw)
To: Miquel Raynal, linux-mtd
Cc: Richard Weinberger, Vignesh Raghavendra, Daniel Palmer,
linux-kernel
Add support for the FORESEE FS35ND01G-S1Y2 (CD EA 11). Use the ID,
geometry, ECC requirement and read-cache variants from Daniel Palmer's v3.
Hardware testing on the TCL T20 Pro with Realtek BCH6/512 verified all
five single-, dual- and quad-SPI cache-read variants. Each read the same
8 MiB with no reported bitflips. Single-SPI random program load (0x84),
quad program load (0x32) and quad random program load (0x34) each passed
raw and ECC readback of eight programmed pages. Quad tests ran with the
QE bit set in feature register 0xb0.
Testing on the TCL T20 Pro reproduced the on-die ECC symptom Daniel
Palmer reported with nandbiterrs in his 2021 v3 submission: a read
reported as corrected still returned incorrect data. After a raw
partial program, the chip returned status 0x10, which the driver
interpreted as four corrected bitflips, but the readback still differed
from the original data. This suggests a silicon bug, but the test does
not establish the root cause or the ECC correction limit. Leave on-die
ECC disabled and require a verified external ECC engine.
Link: https://lore.kernel.org/linux-mtd/20210811084924.52293-1-daniel@0x0f.com/
Signed-off-by: Pengji Li <wjjsn@qq.com>
---
OpenCode assisted with driver and test code, hardware debugging,
and analysis of raw versus corrected readback.
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 4241ea19d..a238522b2 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -375,6 +375,12 @@ static int spinand_ondie_ecc_init_ctx(struct nand_device *nand)
struct mtd_info *mtd = nanddev_to_mtd(nand);
struct spinand_ondie_ecc_conf *engine_conf;
+ if (spinand->flags & SPINAND_NO_ON_DIE_ECC) {
+ dev_err(&spinand->spimem->spi->dev,
+ "On-die ECC is unsupported; select an external ECC engine\n");
+ return -EOPNOTSUPP;
+ }
+
nand->ecc.ctx.conf.engine_type = NAND_ECC_ENGINE_TYPE_ON_DIE;
nand->ecc.ctx.conf.step_size = nand->ecc.requirements.step_size;
nand->ecc.ctx.conf.strength = nand->ecc.requirements.strength;
diff --git a/drivers/mtd/nand/spi/foresee.c b/drivers/mtd/nand/spi/foresee.c
index 5ff183160..90eddade6 100644
--- a/drivers/mtd/nand/spi/foresee.c
+++ b/drivers/mtd/nand/spi/foresee.c
@@ -94,6 +94,21 @@ static int f35sqb002g_ecc_get_status(struct spinand_device *spinand, u8 status)
return -EINVAL;
}
+static SPINAND_OP_VARIANTS(fs35nd01g_read_cache_variants,
+ SPINAND_PAGE_READ_FROM_CACHE_1S_4S_4S_OP(0, 2, NULL, 0, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_1S_2S_2S_OP(0, 1, NULL, 0, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0));
+
+static SPINAND_OP_VARIANTS(fs35nd01g_write_cache_variants,
+ SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0),
+ SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(fs35nd01g_update_cache_variants,
+ SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
+ SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
+
static const struct spinand_info foresee_spinand_table[] = {
SPINAND_INFO("F35SQA002G",
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x72, 0x72),
@@ -125,6 +140,14 @@ static const struct spinand_info foresee_spinand_table[] = {
SPINAND_HAS_QE_BIT,
SPINAND_ECCINFO(&f35sqa002g_ooblayout,
f35sqb002g_ecc_get_status)),
+ SPINAND_INFO("FS35ND01G-S1Y2",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xea, 0x11),
+ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
+ NAND_ECCREQ(4, 512),
+ SPINAND_INFO_OP_VARIANTS(&fs35nd01g_read_cache_variants,
+ &fs35nd01g_write_cache_variants,
+ &fs35nd01g_update_cache_variants),
+ SPINAND_NO_ON_DIE_ECC | SPINAND_HAS_QE_BIT),
};
static const struct spinand_manufacturer_ops foresee_spinand_manuf_ops = {
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index d7c99fcfb..b4d78e79b 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -492,6 +492,7 @@ struct spinand_ecc_info {
#define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3)
#define SPINAND_NO_RAW_ACCESS BIT(4)
#define SPINAND_ODTR_PACKED_PAGE_READ BIT(5)
+#define SPINAND_NO_ON_DIE_ECC BIT(6)
/**
* struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [RFC PATCH] mtd: spinand: support FS35ND01G-S1Y2 with external ECC
2026-12-01 2:30 [RFC PATCH] mtd: spinand: support FS35ND01G-S1Y2 with external ECC Pengji Li
@ 2026-12-01 2:44 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01 2:44 UTC (permalink / raw)
To: Pengji Li, Miquel Raynal, linux-mtd
Cc: Richard Weinberger, Vignesh Raghavendra, Daniel Palmer
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: spinand: foresee: duplicate write/update cache variants for
FS35ND01G
--
commit e64d1c9825a2af5d412fa5cb7462af483e0672e1
Author: Pengji Li <wjjsn@qq.com>
mtd: spinand: support FS35ND01G-S1Y2 with external ECC
This commit adds a SPINAND_NO_ON_DIE_ECC flag to reject on-die ECC
initialization when unsupported and adds support for the FORESEE
FS35ND01G-S1Y2 SPI NAND flash using external ECC.
Link: https://lore.kernel.org/linux-mtd/20210811084924.52293-1-daniel@0x0f.com/
> diff --git a/drivers/mtd/nand/spi/foresee.c b/drivers/mtd/nand/spi/foresee.c
> index 5ff18316092cd..90eddade6b47a 100644
> --- a/drivers/mtd/nand/spi/foresee.c
> +++ b/drivers/mtd/nand/spi/foresee.c
> @@ -94,6 +94,21 @@ static int f35sqb002g_ecc_get_status(struct spinand_device *spinand, u8 status)
> return -EINVAL;
> }
>
> +static SPINAND_OP_VARIANTS(fs35nd01g_read_cache_variants,
> + SPINAND_PAGE_READ_FROM_CACHE_1S_4S_4S_OP(0, 2, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_2S_2S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0));
> +
> +static SPINAND_OP_VARIANTS(fs35nd01g_write_cache_variants,
> + SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0),
> + SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(fs35nd01g_update_cache_variants,
> + SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
> + SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
[Severity: Low]
This isn't a bug, but fs35nd01g_write_cache_variants and
fs35nd01g_update_cache_variants are identical to write_cache_variants and
update_cache_variants already defined at the top of this file. Could the
FS35ND01G-S1Y2 entry reuse write_cache_variants and update_cache_variants
directly?
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_3C5C30A7964DFBBF3EA5CD0136AB5ECDB20A@qq.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 2:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 2:30 [RFC PATCH] mtd: spinand: support FS35ND01G-S1Y2 with external ECC Pengji Li
2026-12-01 2:44 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox