All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: nand: raw: rockchip_nfc: fix ecc setup
@ 2026-07-14  6:39 Johan Jonker
  2026-07-20 18:25 ` Quentin Schulz via U-Boot
  2026-07-22  9:16 ` Johan Jonker via U-Boot
  0 siblings, 2 replies; 10+ messages in thread
From: Johan Jonker @ 2026-07-14  6:39 UTC (permalink / raw)
  To: u-boot; +Cc: kever.yang, sjg, dario.binacchi, michael, trini, u-boot

The Rockchip boot ROM only checks for NAND chip 0 and with
reduced ECC strength. Currently only the read page functions
have this condition check added.

Fix by adding the same condition to all read and write page
functions by dropping the existing 'selected_bank == 0' check
and use the NAND_IS_BOOT_MEDIUM option that was introduced to
U-Boot more recently than this driver to behave
identically to the Linux driver.

It is now the users responsibility to apply the device tree
property "nand-is-boot-medium" to only NAND chip 0.

Fixes: b12dc5d6fa76 ("mtd: nand: NFC drivers for RK3308, RK2928 and others")
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Tested-by: Hüseyin BIYIK <boogiepop@gmx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changed V2:
fix typos
reword
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index ea8e67d1a23e..e788fda22a95 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -440,7 +440,8 @@ static int rk_nfc_write_page_raw(struct mtd_info *mtd,
 	int i, pages_per_blk;
 
 	pages_per_blk = mtd->erasesize / mtd->writesize;
-	if ((page < (pages_per_blk * rknand->boot_blks)) &&
+	if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+	    (page < (pages_per_blk * rknand->boot_blks)) &&
 	    rknand->boot_ecc != ecc->strength) {
 		/*
 		 * There's currently no method to notify the MTD framework that
@@ -560,7 +561,8 @@ static int rk_nfc_write_page_hwecc(struct mtd_info *mtd,
 	 *
 	 * Configure the ECC algorithm supported by the boot ROM.
 	 */
-	if (page < (pages_per_blk * rknand->boot_blks)) {
+	if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+	    (page < (pages_per_blk * rknand->boot_blks))) {
 		boot_rom_mode = 1;
 		if (rknand->boot_ecc != ecc->strength)
 			rk_nfc_hw_ecc_setup(chip, rknand->boot_ecc);
@@ -624,8 +626,8 @@ static int rk_nfc_read_page_raw(struct mtd_info *mtd,
 	int i, pages_per_blk;
 
 	pages_per_blk = mtd->erasesize / mtd->writesize;
-	if ((page < (pages_per_blk * rknand->boot_blks)) &&
-	    nfc->selected_bank == 0 &&
+	if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+	    (page < (pages_per_blk * rknand->boot_blks)) &&
 	    rknand->boot_ecc != ecc->strength) {
 		/*
 		 * There's currently no method to notify the MTD framework that
@@ -700,8 +702,8 @@ static int rk_nfc_read_page_hwecc(struct mtd_info *mtd,
 	 * are used by the boot ROM.
 	 * Configure the ECC algorithm supported by the boot ROM.
 	 */
-	if (page < (pages_per_blk * rknand->boot_blks) &&
-	    nfc->selected_bank == 0) {
+	if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+	    (page < (pages_per_blk * rknand->boot_blks))) {
 		boot_rom_mode = 1;
 		if (rknand->boot_ecc != ecc->strength)
 			rk_nfc_hw_ecc_setup(chip, rknand->boot_ecc);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread
[parent not found: <e108fe69-533a-4734-8728-b17b172c4be9 () cherry ! de>]

end of thread, other threads:[~2026-07-25 15:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14  6:39 [PATCH v2] mtd: nand: raw: rockchip_nfc: fix ecc setup Johan Jonker
2026-07-20 18:25 ` Quentin Schulz via U-Boot
2026-07-22  9:16 ` Johan Jonker via U-Boot
2026-07-22 11:49   ` Boogie via U-Boot
2026-07-24  9:26   ` Miquel Raynal via U-Boot
2026-07-25 15:57     ` Boogie
     [not found] <e108fe69-533a-4734-8728-b17b172c4be9 () cherry ! de>
2026-07-21 22:56 ` Boogie via U-Boot
2026-07-22  9:28   ` Quentin Schulz via U-Boot
2026-07-22 11:39     ` Boogie via U-Boot
2026-07-22 12:33       ` Quentin Schulz via U-Boot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.