From: Pengji Li <wjjsn@qq.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>, linux-mtd@lists.infradead.org
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Daniel Palmer <daniel@0x0f.com>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH] mtd: spinand: support FS35ND01G-S1Y2 with external ECC
Date: Tue, 1 Dec 2026 10:30:06 +0800 [thread overview]
Message-ID: <tencent_3C5C30A7964DFBBF3EA5CD0136AB5ECDB20A@qq.com> (raw)
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
reply other threads:[~2026-12-01 2:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tencent_3C5C30A7964DFBBF3EA5CD0136AB5ECDB20A@qq.com \
--to=wjjsn@qq.com \
--cc=daniel@0x0f.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--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®