From 711e6fc4c71355c20a21ea347358d36880187431 Mon Sep 17 00:00:00 2001 From: Andrei Nistor Date: Sat, 28 Nov 2026 16:26:29 +0200 Subject: [PATCH] mtd: spinand: add FORESEE F35SQA512M 512Mbit SPI NAND The Reolink E340 (NT98566) carries a FORESEE F35SQA512M, JEDEC ID cd 70. The driver only accepts chips listed in its own table, so the flash is not usable without an entry. The chip's on-die ECC corrects one bit per segment of 512 bytes of data plus 16 bytes of spare (datasheet rev 1.1, section 11.4). Set strength and bitflip threshold to 1, as is done for the Fudan chip, so that a corrected read makes UBI move the data. With the generic values (4 and 3) a degrading block would never be scrubbed. Tested on a Reolink E340: the chip is detected as 64 MiB with 128 KiB blocks and 2 KiB pages, ecc_strength and bitflip_threshold read 1, and UBI attach, UBIFS mount, erase and write work. Co-Authored-By: Claude Fable 5.2 --- drivers/mtd/nvt_flash_spi/nvt_flash_spi_int.h | 1 + drivers/mtd/spiflash/spinand.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/nvt_flash_spi/nvt_flash_spi_int.h b/drivers/mtd/nvt_flash_spi/nvt_flash_spi_int.h index 8d38966b48..a56a9a7538 100644 --- a/drivers/mtd/nvt_flash_spi/nvt_flash_spi_int.h +++ b/drivers/mtd/nvt_flash_spi/nvt_flash_spi_int.h @@ -283,6 +283,7 @@ struct drv_nand_dev_info { #define MFG_ID_DOSILICON 0xE5 #define MFG_ID_XTX 0x0B #define MFG_ID_FUDAN 0xA1 +#define MFG_ID_FORESEE 0xCD #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ diff --git a/drivers/mtd/spiflash/spinand.c b/drivers/mtd/spiflash/spinand.c index 798630760c..01e1a8f73c 100644 --- a/drivers/mtd/spiflash/spinand.c +++ b/drivers/mtd/spiflash/spinand.c @@ -431,6 +431,10 @@ static struct nand_flash_dev spinand_flash_ids[] = { {"FM25S01A 1Gbit 3.3V", { .id = {MFG_ID_FUDAN, 0xE4} }, SZ_2K, SZ_128, SZ_128K, 0, 2, 64 }, + // FORESEE + {"F35SQA512M 512Mbit 3.3V", + { .id = {MFG_ID_FORESEE, 0x70} }, + SZ_2K, SZ_64, SZ_128K, 0, 2, 64 }, }; #ifdef CONFIG_MTD_SPINAND_HWECC @@ -1397,6 +1401,9 @@ static int spinand_probe(struct platform_device *pdev) } else if (chip_id == MFG_ID_FUDAN) { info->nand_chip.ecc.strength = 1; mtd->bitflip_threshold = 1; + } else if (chip_id == MFG_ID_FORESEE) { + info->nand_chip.ecc.strength = 1; + mtd->bitflip_threshold = 1; } else { mtd->bitflip_threshold = DIV_ROUND_UP(info->nand_chip.ecc.strength * 3, 4); }