Skip to contentSkip to conversation

mtd: nand: spi: fmsh: add FM25S01 support

PATCH In review Florian Fainelli 2 participants 3 messages Nov 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: spi: fmsh: add FM25S01 support

From: David Regan <[email protected]>

FM25S01 is an earlier, lower-density sibling of the already supported FM25S01A (same manufacturer ID, same read/write/update cache variants and memory geometry, 1 bit/512 bytes ECC requirement), identified by device ID 0xa1. Unlike FM25S01A it exposes a real ECC OOB region (64/64 split) rather than none.

[florian: commit message]
---
 drivers/mtd/nand/spi/fmsh.c | 39 +++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
drivers/mtd/nand/spi/fmsh.c +39 -0
index 6352e9c9e502..2bf73e6dfb7a 100644
@@ -112,6 +112,31 @@ static int fm25g01b_ecc_get_status(struct spinand_device *spinand,
 	return -EINVAL;
 }
 
+static int fm25s01_ooblayout_ecc(struct mtd_info *mtd, int section,
+				 struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	region->offset = 64;
+	region->length = 64;
+
+	return 0;
+}
+
+static int fm25s01_ooblayout_free(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	/* reserve 2 bytes for the BBM */
+	region->offset = 2;
+	region->length = 62;
+
+	return 0;
+}
+
 static int fm25s01a_ooblayout_ecc(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *region)
 {
@@ -185,6 +210,11 @@ static const struct mtd_ooblayout_ops fm25g01b_ooblayout = {
 	.free = fm25g01b_ooblayout_free,
 };
 
+static const struct mtd_ooblayout_ops fm25s01_ooblayout = {
+	.ecc = fm25s01_ooblayout_ecc,
+	.free = fm25s01_ooblayout_free,
+};
+
 static const struct mtd_ooblayout_ops fm25s01a_ooblayout = {
 	.ecc = fm25s01a_ooblayout_ecc,
 	.free = fm25s01a_ooblayout_free,
@@ -216,6 +246,15 @@ static const struct spinand_info fmsh_spinand_table[] = {
 		     SPINAND_HAS_QE_BIT,
 		     SPINAND_ECCINFO(&fm25g01b_ooblayout,
 				     fm25g01b_ecc_get_status)),
+	SPINAND_INFO("FM25S01",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa1),
+		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+		     NAND_ECCREQ(1, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&fm25s01_ooblayout, NULL)),
 	SPINAND_INFO("FM25S01A",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mtd: spinand: fmsh: fm25s01_ooblayout duplicates fm25g01b_ooblayout --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mtd: spinand: fmsh: fm25s01_ooblayout duplicates fm25g01b_ooblayout
--

commit 01eac4352ba75888872f9ede79d4df0245a7723e
Author: David Regan <[email protected]>

mtd: nand: spi: fmsh: add FM25S01 support

This commit adds SPI NAND support for the FudanMicro FM25S01 flash chip, including its OOB layout callbacks and device table entry.

Quoted 54 lines
drivers/mtd/nand/spi/fmsh.c +32 -0
index 6352e9c9e502f..2bf73e6dfb7a6 100644
@@ -112,6 +112,31 @@ static int fm25g01b_ecc_get_status(struct spinand_device *spinand,
 	return -EINVAL;
 }
 
+static int fm25s01_ooblayout_ecc(struct mtd_info *mtd, int section,
+				 struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	region->offset = 64;
+	region->length = 64;
+
+	return 0;
+}
+
+static int fm25s01_ooblayout_free(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	/* reserve 2 bytes for the BBM */
+	region->offset = 2;
+	region->length = 62;
+
+	return 0;
+}
+
 static int fm25s01a_ooblayout_ecc(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *region)
 {
@@ -185,6 +210,11 @@ static const struct mtd_ooblayout_ops fm25g01b_ooblayout = {
 	.free = fm25g01b_ooblayout_free,
 };
 
+static const struct mtd_ooblayout_ops fm25s01_ooblayout = {
+	.ecc = fm25s01_ooblayout_ecc,
+	.free = fm25s01_ooblayout_free,
+};
+
 static const struct mtd_ooblayout_ops fm25s01a_ooblayout = {
 	.ecc = fm25s01a_ooblayout_ecc,
 	.free = fm25s01a_ooblayout_free,
@@ -216,6 +246,15 @@ static const struct spinand_info fmsh_spinand_table[] = {
 		     SPINAND_HAS_QE_BIT,
 		     SPINAND_ECCINFO(&fm25g01b_ooblayout,
 				     fm25g01b_ecc_get_status)),
+	SPINAND_INFO("FM25S01",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa1),

drivers/mtd/nand/spi/fmsh.c static const struct spinand_info fmsh_spinand_table[] = { · line 260

Quoted 10 lines
drivers/mtd/nand/spi/fmsh.c +7 -0
+		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+		     NAND_ECCREQ(1, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&fm25s01_ooblayout, NULL)),
 	SPINAND_INFO("FM25S01A",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),

[Severity: Low]
Can FM25S01 reuse fm25g01b_ooblayout instead of defining fm25s01_ooblayout_ecc(), fm25s01_ooblayout_free(), and fm25s01_ooblayout? fm25g01b_ooblayout_ecc() and fm25g01b_ooblayout_free() in this file already implement the same 64/64 OOB split with 2 bytes reserved for the BBM, and FM25G02B already shares fm25g01b_ooblayout.

Also, the commit message describes FM25S01 as a lower-density sibling of FM25S01A with the same memory geometry, whereas both parts have the same 1 Gbit (128 MiB) main array capacity and FM25S01 has a larger 128-byte OOB size per page in NAND_MEMORG than FM25S01A's 64 bytes.

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/
#2 lore raw
Quoted 86 lines · On 11/30/26 14:56, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mtd: spinand: fmsh: fm25s01_ooblayout duplicates fm25g01b_ooblayout
--

commit 01eac4352ba75888872f9ede79d4df0245a7723e
Author: David Regan <[email protected]>

mtd: nand: spi: fmsh: add FM25S01 support

This commit adds SPI NAND support for the FudanMicro FM25S01 flash chip, including its OOB layout callbacks and device table entry.

Quoted 54 lines
drivers/mtd/nand/spi/fmsh.c +32 -0
index 6352e9c9e502f..2bf73e6dfb7a6 100644
@@ -112,6 +112,31 @@ static int fm25g01b_ecc_get_status(struct spinand_device *spinand,
  	return -EINVAL;
  }
 
+static int fm25s01_ooblayout_ecc(struct mtd_info *mtd, int section,
+				 struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	region->offset = 64;
+	region->length = 64;
+
+	return 0;
+}
+
+static int fm25s01_ooblayout_free(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *region)
+{
+	if (section)
+		return -ERANGE;
+
+	/* reserve 2 bytes for the BBM */
+	region->offset = 2;
+	region->length = 62;
+
+	return 0;
+}
+
  static int fm25s01a_ooblayout_ecc(struct mtd_info *mtd, int section,
  				  struct mtd_oob_region *region)
  {
@@ -185,6 +210,11 @@ static const struct mtd_ooblayout_ops fm25g01b_ooblayout = {
  	.free = fm25g01b_ooblayout_free,
  };
 
+static const struct mtd_ooblayout_ops fm25s01_ooblayout = {
+	.ecc = fm25s01_ooblayout_ecc,
+	.free = fm25s01_ooblayout_free,
+};
+
  static const struct mtd_ooblayout_ops fm25s01a_ooblayout = {
  	.ecc = fm25s01a_ooblayout_ecc,
  	.free = fm25s01a_ooblayout_free,
@@ -216,6 +246,15 @@ static const struct spinand_info fmsh_spinand_table[] = {
  		     SPINAND_HAS_QE_BIT,
  		     SPINAND_ECCINFO(&fm25g01b_ooblayout,
  				     fm25g01b_ecc_get_status)),
+	SPINAND_INFO("FM25S01",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa1),

drivers/mtd/nand/spi/fmsh.c static const struct spinand_info fmsh_spinand_table[] = { · line 260

Quoted 10 lines
drivers/mtd/nand/spi/fmsh.c +7 -0
+		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+		     NAND_ECCREQ(1, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&fm25s01_ooblayout, NULL)),
  	SPINAND_INFO("FM25S01A",
  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4),
  		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),

[Severity: Low]
Can FM25S01 reuse fm25g01b_ooblayout instead of defining fm25s01_ooblayout_ecc(), fm25s01_ooblayout_free(), and fm25s01_ooblayout? fm25g01b_ooblayout_ecc() and fm25g01b_ooblayout_free() in this file already implement the same 64/64 OOB split with 2 bytes reserved for the BBM, and FM25G02B already shares fm25g01b_ooblayout.

Quoted 5 lines

Also, the commit message describes FM25S01 as a lower-density sibling of FM25S01A with the same memory geometry, whereas both parts have the same 1 Gbit (128 MiB) main array capacity and FM25S01 has a larger 128-byte OOB size per page in NAND_MEMORG than FM25S01A's 64 bytes.

Both points are valid and will be addressed in the next revision:

- FM25S01 now uses fm25g01b_ooblayout directly. The 64/64 OOB split with 2 bytes reserved for the BBM is identical, so the new fm25s01_ooblayout_ecc(), fm25s01_ooblayout_free() and fm25s01_ooblayout definitions are dropped.

- The commit message no longer describes FM25S01 as a "lower-density" sibling with the "same memory geometry". It now says the array organization (1 Gbit), cache variants and ECC requirement match FM25S01A, that the OOB is 128 bytes per page instead of 64, and that the ECC layout is the same as FM25G01B.

Signature · 1 line
Florian