Skip to contentSkip to conversation

mtd: spi-nor: macronix: backport Quad Input Page Program fixups

PATCH In review Cheng Ming Lin 2 participants 4 messages Jul 2

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

v2 cover mtd: spi-nor: macronix: backport Quad Input Page Program fixups

From: Cheng Ming Lin <[email protected]>

This is a backport of two upstream commits to 6.6.y:

commit 798aafeffb36 ("mtd: spi-nor: macronix: Add post_sfdp fixups for Quad Input Page Program")
commit 797bbaa7531f ("mtd: spi-nor: macronix: add support for mx66{l2, u1}g45g")

Neither commit was tagged for -stable when merged. 6.6.y also predates commit 09e5a29fa3ad ("mtd: spi-nor: macronix: convert flash_info to new format"), which landed in v6.10, so drivers/mtd/spi-nor/macronix.c is still in the old INFO()/NO_SFDP_FLAGS()/FIXUP_FLAGS() macro-based format. Both patches have been adapted to that format with no other functional change; patch 2 depends on the macronix_qpp4b_fixups hook introduced by patch 1.

Changes in v2:
- Patch 2: added .name for the mx66l2g45g/mx66u1g45g entries. v1 left them anonymous like the upstream (new-format) entries, but on 6.6.y drivers/mtd/spi-nor/core.c:spi_nor_match_name() does strcmp(name, manufacturers[i]->parts[j].name) while walking every manufacturer's part table to resolve a flash by name. A NULL .name makes that strcmp() dereference NULL as soon as the scan reaches either entry, i.e. an oops on any name-based spi-nor probe on the system, not just when probing these two parts.

Cheng Ming Lin (2):
mtd: spi-nor: macronix: Add post_sfdp fixups for Quad Input Page
Program
mtd: spi-nor: macronix: add support for mx66{l2, u1}g45g

 drivers/mtd/spi-nor/macronix.c | 37 +++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 mtd: spi-nor: macronix: Add post_sfdp fixups for Quad Input Page Program

From: Cheng Ming Lin <[email protected]>

commit 798aafeffb369c5eb36e406b18970ef27baa820d upstream.

Although certain Macronix NOR flash support the Quad Input Page Program feature, the corresponding information in the 4-byte Address Instruction Table of these flash is not properly filled. As a result, this feature cannot be enabled as expected.

To address this issue, a post_sfdp fixups implementation is required to correct the missing information.

---
 drivers/mtd/spi-nor/macronix.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
drivers/mtd/spi-nor/macronix.c +28 -5
index eb149e517c1f..b676a71822a3 100644
@@ -28,8 +28,26 @@ mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
 	return 0;
 }
 
+static int
+macronix_qpp4b_post_sfdp_fixups(struct spi_nor *nor)
+{
+	/* PP_1_1_4_4B is supported but missing in 4BAIT. */
+	struct spi_nor_flash_parameter *params = nor->params;
+
+	params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+	spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_1_1_4],
+				SPINOR_OP_PP_1_1_4_4B, SNOR_PROTO_1_1_4);
+
+	return 0;
+}
+
 static const struct spi_nor_fixups mx25l25635_fixups = {
 	.post_bfpt = mx25l25635_post_bfpt_fixups,
+	.post_sfdp = macronix_qpp4b_post_sfdp_fixups,
+};
+
+static const struct spi_nor_fixups macronix_qpp4b_fixups = {
+	.post_sfdp = macronix_qpp4b_post_sfdp_fixups,
 };
 
 static const struct flash_info macronix_nor_parts[] = {
@@ -81,7 +99,8 @@ static const struct flash_info macronix_nor_parts[] = {
 		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
 	{ "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
-		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
 		PARSE_SFDP
 		FLAGS(SPI_NOR_RWW) },
@@ -91,18 +110,22 @@ static const struct flash_info macronix_nor_parts[] = {
 	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512) },
 	{ "mx66l51235f", INFO(0xc2201a, 0, 64 * 1024, 1024)
 		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
-		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
-		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx66l1g45g",  INFO(0xc2201b, 0, 64 * 1024, 2048)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
-			      SPI_NOR_QUAD_READ) },
+			      SPI_NOR_QUAD_READ)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048)
 		NO_SFDP_FLAGS(SPI_NOR_QUAD_READ) },
 	{ "mx66u2g45g",	 INFO(0xc2253c, 0, 64 * 1024, 4096)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
-		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
+		.fixups = &macronix_qpp4b_fixups },
 };
 
 static void macronix_nor_default_init(struct spi_nor *nor)
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/2 mtd: spi-nor: macronix: add support for mx66{l2, u1}g45g

In reply to Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

commit 797bbaa7531f75985b199e484451fa3f954382b3 upstream.

Due to incorrect values in the 4-BAIT table for these two flash IDs, it is necessary to add these two flash IDs with fixups.

---
 drivers/mtd/spi-nor/macronix.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/macronix.c +4 -0
index b676a71822a3..fc43e0ffa3d9 100644
@@ -116,10 +116,14 @@ static const struct flash_info macronix_nor_parts[] = {
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
 		FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
 		.fixups = &macronix_qpp4b_fixups },
+	{ "mx66u1g45g", INFO(0xc2253b, 0, 0, 0)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx66l1g45g",  INFO(0xc2201b, 0, 64 * 1024, 2048)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
 			      SPI_NOR_QUAD_READ)
 		.fixups = &macronix_qpp4b_fixups },
+	{ "mx66l2g45g", INFO(0xc2201c, 0, 0, 0)
+		.fixups = &macronix_qpp4b_fixups },
 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048)
 		NO_SFDP_FLAGS(SPI_NOR_QUAD_READ) },
 	{ "mx66u2g45g",	 INFO(0xc2253c, 0, 64 * 1024, 4096)
Signature · 1 line
2.25.1
maintainer
#3 lore raw
In reply to Cheng Ming Lin
Quoted 9 lines · Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

This is a backport of two upstream commits to 6.6.y:

commit 798aafeffb36 ("mtd: spi-nor: macronix: Add post_sfdp fixups for Quad Input Page Program")
commit 797bbaa7531f ("mtd: spi-nor: macronix: add support for mx66{l2, u1}g45g")

Quoted 7 lines

Neither commit was tagged for -stable when merged. 6.6.y also predates commit 09e5a29fa3ad ("mtd: spi-nor: macronix: convert flash_info to new format"), which landed in v6.10, so drivers/mtd/spi-nor/macronix.c is still in the old INFO()/NO_SFDP_FLAGS()/FIXUP_FLAGS() macro-based format. Both patches have been adapted to that format with no other functional change; patch 2 depends on the macronix_qpp4b_fixups hook introduced by patch 1.

Why not just move to a newer kernel to get support for these newer devices instead? That's much simpler and I'd prefer that over taking much-different patches instead.

thanks,

greg k-h