Skip to contentSkip to conversation

mtd: spinand: Resolve GigaDevice/ESMT ID clash

PATCH Applied Ezra Buehler 4 participants 9 messages Jan 25, 2024 – Feb 5, 2024

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

cover mtd: spinand: Resolve GigaDevice/ESMT ID clash

From: Ezra Buehler <[email protected]>

Since commit aa08bf187f32 ("mtd: spinand: esmt: add support for F50D2G41KA") the MT7688-based GARDENA smart Gateway no longer boots. This is due to an ID clash resulting in the ESMT driver being used together with our GigaDevice GD5F1GQ5UEYIG.

The following patches resolve the issue for our board. However, I do not have any ESMT NAND flash chips to further test my changes with.

Ezra Buehler (2):
mtd: spinand: Add support for 5-byte IDs
mtd: spinand: esmt: Extend IDs to 5 bytes

 drivers/mtd/nand/spi/esmt.c | 9 ++++++---
 include/linux/mtd/spinand.h | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 mtd: spinand: Add support for 5-byte IDs

From: Ezra Buehler <[email protected]>

E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).

---
 include/linux/mtd/spinand.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
index badb4c1ac079..5c19ead60499 100644
@@ -169,7 +169,7 @@
 struct spinand_op;
 struct spinand_device;
 
-#define SPINAND_MAX_ID_LEN	4
+#define SPINAND_MAX_ID_LEN	5
 /*
  * For erase, write and read operation, we got the following timings :
  * tBERS (erase) 1ms to 4ms
Signature · 1 line
2.43.0
Reviewed-by Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mtd: spinand: Add support for 5-byte IDs

Quoted 11 lines · Ezra Buehler

From: Ezra Buehler <[email protected]>

E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).

Quoted 1 line

Tested for F50L1G41LB

Quoted 17 lines
---
 include/linux/mtd/spinand.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
index badb4c1ac079..5c19ead60499 100644
@@ -169,7 +169,7 @@
 struct spinand_op;
 struct spinand_device;
 
-#define SPINAND_MAX_ID_LEN	4
+#define SPINAND_MAX_ID_LEN	5
 /*
  * For erase, write and read operation, we got the following timings :
  * tBERS (erase) 1ms to 4ms
Signature · 2 lines
Best Regards,
Martin Kurbanov
maintainer Applied
#3 lore raw

Re: [PATCH 1/2] mtd: spinand: Add support for 5-byte IDs

In reply to Ezra Buehler
Quoted 11 lines · Ezra Buehler

From: Ezra Buehler <[email protected]>

E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).

Quoted 3 lines

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

#4 lore raw

PATCH 2/2 mtd: spinand: esmt: Extend IDs to 5 bytes

In reply to Ezra Buehler

From: Ezra Buehler <[email protected]>

According to the datasheets, the ESMT chips in question will return a 5 byte long identification code where the last 3 bytes are the JEDEC continuation codes (7Fh). Although, I would have expected 4 continuation codes as Powerchip Semiconductor (C8h, corresponding to the parameter page data) is located in bank 5 of the JEDEC database.

By matching the full 5 bytes we can avoid clashes with GigaDevice NAND flashes.

This fix allows the MT7688-based GARDENA smart Gateway to boot again.

Fixes aa08bf187f32 ("mtd: spinand: esmt: add support for F50D2G41KA")
---
 drivers/mtd/nand/spi/esmt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mtd/nand/spi/esmt.c +6 -3
index 31c439a557b1..4597a82de23a 100644
@@ -104,7 +104,8 @@ static const struct mtd_ooblayout_ops f50l1g41lb_ooblayout = {
 
 static const struct spinand_info esmt_c8_spinand_table[] = {
 	SPINAND_INFO("F50L1G41LB",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
 		     NAND_ECCREQ(1, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
@@ -113,7 +114,8 @@ static const struct spinand_info esmt_c8_spinand_table[] = {
 		     0,
 		     SPINAND_ECCINFO(&f50l1g41lb_ooblayout, NULL)),
 	SPINAND_INFO("F50D1G41LB",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x11),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x11, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
 		     NAND_ECCREQ(1, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
@@ -122,7 +124,8 @@ static const struct spinand_info esmt_c8_spinand_table[] = {
 		     0,
 		     SPINAND_ECCINFO(&f50l1g41lb_ooblayout, NULL)),
 	SPINAND_INFO("F50D2G41KA",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x51),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x51, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
 		     NAND_ECCREQ(8, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
Signature · 1 line
2.43.0
Reviewed-by Tested-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] mtd: spinand: esmt: Extend IDs to 5 bytes

Quoted 8 lines · Ezra Buehler

From: Ezra Buehler <[email protected]>

According to the datasheets, the ESMT chips in question will return a 5 byte long identification code where the last 3 bytes are the JEDEC continuation codes (7Fh). Although, I would have expected 4 continuation codes as Powerchip Semiconductor (C8h, corresponding to the parameter page data) is located in bank 5 of the JEDEC database.

Quoted 7 lines

By matching the full 5 bytes we can avoid clashes with GigaDevice NAND flashes.

This fix allows the MT7688-based GARDENA smart Gateway to boot again.

Fixes aa08bf187f32 ("mtd: spinand: esmt: add support for F50D2G41KA")

Tested for F50L1G41LB

Quoted 38 lines
---
 drivers/mtd/nand/spi/esmt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mtd/nand/spi/esmt.c +6 -3
index 31c439a557b1..4597a82de23a 100644
@@ -104,7 +104,8 @@ static const struct mtd_ooblayout_ops f50l1g41lb_ooblayout = {
 
 static const struct spinand_info esmt_c8_spinand_table[] = {
 	SPINAND_INFO("F50L1G41LB",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
 		     NAND_ECCREQ(1, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
@@ -113,7 +114,8 @@ static const struct spinand_info esmt_c8_spinand_table[] = {
 		     0,
 		     SPINAND_ECCINFO(&f50l1g41lb_ooblayout, NULL)),
 	SPINAND_INFO("F50D1G41LB",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x11),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x11, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
 		     NAND_ECCREQ(1, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
@@ -122,7 +124,8 @@ static const struct spinand_info esmt_c8_spinand_table[] = {
 		     0,
 		     SPINAND_ECCINFO(&f50l1g41lb_ooblayout, NULL)),
 	SPINAND_INFO("F50D2G41KA",
-		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x51),
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x51, 0x7f,
+				0x7f, 0x7f),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
 		     NAND_ECCREQ(8, 512),
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
Signature · 2 lines
Best Regards,
Martin Kurbanov
maintainer Applied
#7 lore raw

Re: [PATCH 2/2] mtd: spinand: esmt: Extend IDs to 5 bytes

In reply to Ezra Buehler
Quoted 11 lines · Ezra Buehler

From: Ezra Buehler <[email protected]>

According to the datasheets, the ESMT chips in question will return a 5 byte long identification code where the last 3 bytes are the JEDEC continuation codes (7Fh). Although, I would have expected 4 continuation codes as Powerchip Semiconductor (C8h, corresponding to the parameter page data) is located in bank 5 of the JEDEC database.

By matching the full 5 bytes we can avoid clashes with GigaDevice NAND flashes.

Quoted 6 lines

This fix allows the MT7688-based GARDENA smart Gateway to boot again.

Fixes aa08bf187f32 ("mtd: spinand: esmt: add support for F50D2G41KA")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

#8 lore raw
In reply to Ezra Buehler

Hello Ezra!

Thank you for the patch series!

We will test it on the our side with ESMT flash and back to you soon.

Quoted 18 lines · Ezra Buehler

From: Ezra Buehler <[email protected]>

Since commit aa08bf187f32 ("mtd: spinand: esmt: add support for F50D2G41KA") the MT7688-based GARDENA smart Gateway no longer boots. This is due to an ID clash resulting in the ESMT driver being used together with our GigaDevice GD5F1GQ5UEYIG.

The following patches resolve the issue for our board. However, I do not have any ESMT NAND flash chips to further test my changes with.

Ezra Buehler (2):
mtd: spinand: Add support for 5-byte IDs
mtd: spinand: esmt: Extend IDs to 5 bytes

 drivers/mtd/nand/spi/esmt.c | 9 ++++++---
 include/linux/mtd/spinand.h | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)
Signature · 2 lines
Thank you,
Dmitry