Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.205.221.191 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796092247; b=wlqcUyrp/WbwcAUwR/Q7u0PGTJRroOcrG8D+yC3fGCPFLRw5GJSw+vxTZGTqsiu9rYMM Vr1KASt1gerzoOBjPqFRch6TVGGX/MGe6PklokxUdNKh7uBOwrTWu0fgNh+cerFLCRZ26 +9jFGLTB6Ir4WAhFX7GB4LBP96MOktzH2BNr57oWCkxCJcvJsje7c4O/R7df78EuI0sR6 uw7BJp79fY1CsYlVJl/rB2LliM6JAC/836hSZXVzyQMh1QcQw4Ln3j07hqpL9nOefxfUj OXE4KbVeKcbHmYM1H2c2KdZ3Jot02o2h0gvIL8SI+afTpb0M1DEhprMmqb+2f1DO/Nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796092247; h=DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:Message-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:X-OQ-MSGID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=8s8EScuPMPEl0tpqtI9X0cky5OjPA2+tekbetNVbt70=; b=uj8wzwmPC4idy4+1mqakvzrYscI5FcamrgIAapRHBQEodfjDsBQb7O++2wlOXg6bQ/EZ OBCkcjf4/MU9Bp/L3s85nCDm8jZS3wfY9sCNMg71LZzfT1svRBldUZzMuGq8rCgnNRlOX +glRsW0TKUo2Ky+e0u+oHJVFlHjTXap5+6fzqx7ADWXl6gF78xZD/x1/Rf+BbF8kW6fdA LChir1HfFm7P32lRrV0ZZ4SxOcSvxKABewVMAF+Ho38V8mME/OUo3yaf8J7Atq/mwUqjH v+/imI9TFnFLOAmUhH32QvMlFcFR0RnYPVglQkAz0jk2ygEteUNffHxZT8+lkNg9oqg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b="ohgpMmH/"; arc=none smtp.remote-ip=203.205.221.191 Received: from out203-205-221-191.mail.qq.com (out203-205-221-191.mail.qq.com [203.205.221.191]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26E7B606A327 for ; Tue, 1 Dec 2026 02:30:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26E7B606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=ohgpMmH/ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1796092242; bh=8s8EScuPMPEl0tpqtI9X0cky5OjPA2+tekbetNVbt70=; h=From:To:Cc:Subject:Date; b=ohgpMmH/0MbAJqQ6AXSS6UhWHPy/cuELKcG2uqBpUfvLdTLKrMp/mzHCQDWcb4sYM 7Lhqsqff+4hs6RF7LxEpykrY3BLaMEo3aNhxtLp4mAdgQAm51fXh+2RGNJlBcWWAS6 n+rxS5HE85ohpTfSdI+Lt2vTK2un1czMkg8KLh74= Received: from MYJGMC.localdomain ([218.1.141.174]) by newxmesmtplogicsvrszc43-0.qq.com (NewEsmtp) with SMTP id 7A82406C; Tue, 01 Dec 2026 10:30:40 +0800 X-QQ-mid: xmsmtpt1796092240tvw71z0vz Message-ID: X-QQ-XMAILINFO: NUaRPsENHoCK46ljmkBtux4icGwDmYVCCo73XcMHT6lKqbhKQlUvH/TC7P/uj/ rGZ51nWu27zrnqRVxYBZAjwi5brbp6upTHyRErm5yrLFA1t3hEyXpbyZCUnekfJyRb905zPGTsTL en1oDFzabaUbrkNFwJbl/IOoV/2nFQVu7n1NUSSMAXxbMtTu3lXOhBPy8C5wA/2NOBPPhbFzpa07 L50H+bR0qIz4Q3YAaU6HMdyyYKAfT5y56X+i5xAYcfy91UoCrW11gGBjps6ly0fWqrgAfyrlO7eP Nf2j9QR7mYVt5pFtX2RXzVQhSeUUwQ202lSST3WomkpuQ0rln4qJOiwH+I0tqEbhJE0N5YzCOhhR 9QWQb8IQrGJ8ba3sgbMJXxaywfBkAYY7kEC8TFT5ZyqRRDxzuA16rjaWB1FwC3VdJhPaXGVjzsOy s71uWSgOBIop9iV24QL2gxhib4FvVzDB+WW5gCxqT/yR5EQ5ced0QnxYeF/6frMavD96VhTtnkrq yTz687l+7Rt73jl9yY71CmH6hoGy51yYnduUV6wMykC/sd9WNTuvC8hujv2DcWNSrZs1JUGoNJFE +MszQhTE77TbooM6r21zxTkInsLaDwqyIvKHbMSZ/i3uxDEs1gxnoTTvzFMfnVRWOCouwkVtM465 PRmL9jDj8KGglbptJTXGKdHuxGjwBSv6otOXfuKmQfbRPYGNzO8qvYDqlt7OustJxwcC0xx2TTNs EGZH0Q8piw6TGESIJnmBoTDX6DALxYpJfx/X+Xf1yHTICKpDUUEy/6uPT8tbS4u/Z/Wpn9B/oMdL xU60+RpGoM8Ts9cQbTOeo6EvBxfn/0lYY7HeF8wjVM8RIPU12UYDjWj2IM2PFrQpSbqdYGOLuR80 8cO1skn91Is9nq6a1Ryu/dg/VU3+Q3TqgEBt2E91/7iEBnQNQq5jOSJreydvj/pKhssR28I4pxB5 akUANWLjZDrsx1neAXHfGeu518HxryI5QNoUO+NN+rvCVg7SWsvRkh6WaN4NRH1hwrDaAbjOPQp1 DxUUsxksFW/q+mvhns X-QQ-XMRINFO: M/715EihBoGS47X28/vv4NpnfpeBLnr4Qg== From: Pengji Li To: Miquel Raynal , linux-mtd@lists.infradead.org Cc: Richard Weinberger , Vignesh Raghavendra , Daniel Palmer , 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 X-OQ-MSGID: <20261201023006.549172-1-wjjsn@qq.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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