mtd: spinand: support FS35ND01G-S1Y2 with external ECC
Subsystems (2)
RFC PATCH 1/1 mtd: spinand: support FS35ND01G-S1Y2 with external ECC
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.
---
OpenCode assisted with driver and test code, hardware debugging, and analysis of raw versus corrected readback.
drivers/mtd/nand/spi/core.c +6 -0
@@ -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;
drivers/mtd/nand/spi/foresee.c +23 -0
@@ -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 = {
include/linux/mtd/spinand.h +1 -0
@@ -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
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mtd: spinand: foresee: duplicate write/update cache variants for FS35ND01G --
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 <[email protected]>
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.
Quoted 12 lines
drivers/mtd/nand/spi/foresee.c +4
-0@@ -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),
drivers/mtd/nand/spi/foresee.c static int f35sqb002g_ecc_get_status(struct spinand_device *spinand, u8 status) · line 110
Quoted 10 lines
drivers/mtd/nand/spi/foresee.c +10
-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?
Signature · 5 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/