Skip to contentSkip to conversation

mtd: spi-nor: macronix: enable 4-bit BP support for MX25L6405D

PATCH Superseded Sieng Piaw Liew 3 participants 6 messages Dec 7, 2020 – Jan 23, 2021

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

PATCH 1/1 mtd: spi-nor: macronix: enable 4-bit BP support for MX25L6405D

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.
https://github.com/openwrt/openwrt/pull/3501

---
 drivers/mtd/spi-nor/macronix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +2 -1
index 9203abaac229..7aa8b1ee9daa 100644
@@ -42,7 +42,8 @@ static const struct flash_info macronix_parts[] = {
 	{ "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
 	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
 	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+			      SECT_4K | SPI_NOR_4BIT_BP) },
 	{ "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
 	{ "mx25u3235f",	 INFO(0xc22536, 0, 64 * 1024,  64,
 			      SECT_4K | SPI_NOR_DUAL_READ |
Signature · 6 lines
2.17.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw

Hi, Sieng,

Quoted 6 lines · Sieng Piaw Liew

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.

:) What kind of tests did you exactly make?

Quoted 12 lines

https://github.com/openwrt/openwrt/pull/3501

---
 drivers/mtd/spi-nor/macronix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +0 -0
index 9203abaac229..7aa8b1ee9daa 100644

drivers/mtd/spi-nor/macronix.c static const struct flash_info macronix_parts[] = { · line 46

Quoted 6 lines
drivers/mtd/spi-nor/macronix.c +2 -1
@@ -42,7 +42,8 @@ static const struct flash_info macronix_parts[] = {
        { "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
        { "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
        { "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+                             SECT_4K | SPI_NOR_4BIT_BP) },

I assume this won't work because it misses the SPI_NOR_HAS_LOCK flag.

Cheers,
ta

Quoted 6 lines
drivers/mtd/spi-nor/macronix.c +0 -1
        { "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
        { "mx25u3235f",  INFO(0xc22536, 0, 64 * 1024,  64,
                              SECT_4K | SPI_NOR_DUAL_READ |
--

2.17.1

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
Quoted 11 lines · On Mon, Dec 07, 2020 at 05:53:20PM +0000, [email protected] wrote:

Hi, Sieng,

Quoted 6 lines · Sieng Piaw Liew

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.

:) What kind of tests did you exactly make?

OpenWrt cannot write into spi-nor after first boot.
After hacking 4-bit BP support into OpenWrt's kernel v5.4, writing works.

Quoted 22 lines
Quoted 13 lines

https://github.com/openwrt/openwrt/pull/3501

---
 drivers/mtd/spi-nor/macronix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +0 -0
index 9203abaac229..7aa8b1ee9daa 100644

drivers/mtd/spi-nor/macronix.c static const struct flash_info macronix_parts[] = { · line 46

Quoted 6 lines
drivers/mtd/spi-nor/macronix.c +2 -1
@@ -42,7 +42,8 @@ static const struct flash_info macronix_parts[] = {
        { "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
        { "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
        { "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+                             SECT_4K | SPI_NOR_4BIT_BP) },

I assume this won't work because it misses the SPI_NOR_HAS_LOCK flag.

Quoted 2 lines

Cheers,
ta

Yes, I'll have v2 patch sent shortly.

Quoted 8 lines
Quoted 7 lines
drivers/mtd/spi-nor/macronix.c +0 -1
        { "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
        { "mx25u3235f",  INFO(0xc22536, 0, 64 * 1024,  64,
                              SECT_4K | SPI_NOR_DUAL_READ |
--

2.17.1

#3 lore raw

PATCH v2 1/1 mtd: spi-nor: macronix: enable 4-bit BP support for MX25L6405D

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.
https://github.com/openwrt/openwrt/pull/3501

---
Changes in v2:
- Add SPI_NOR_HAS_LOCK which SPI_NOR_4BIT_BP required.

 drivers/mtd/spi-nor/macronix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +3 -1
index 9203abaac229..033ede381673 100644
@@ -42,7 +42,9 @@ static const struct flash_info macronix_parts[] = {
 	{ "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
 	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
 	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+			      SECT_4K | SPI_NOR_HAS_LOCK |
+			      SPI_NOR_4BIT_BP) },
 	{ "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
 	{ "mx25u3235f",	 INFO(0xc22536, 0, 64 * 1024,  64,
 			      SECT_4K | SPI_NOR_DUAL_READ |
Signature · 6 lines
2.17.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#4 lore raw

Hi, Sieng,

Quoted 21 lines · Sieng Piaw Liew

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.
https://github.com/openwrt/openwrt/pull/3501

---
Changes in v2:
- Add SPI_NOR_HAS_LOCK which SPI_NOR_4BIT_BP required.

 drivers/mtd/spi-nor/macronix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +0 -0
index 9203abaac229..033ede381673 100644

drivers/mtd/spi-nor/macronix.c static const struct flash_info macronix_parts[] = { · line 47

Quoted 7 lines
drivers/mtd/spi-nor/macronix.c +3 -1
@@ -42,7 +42,9 @@ static const struct flash_info macronix_parts[] = {
        { "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
        { "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
        { "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+                             SECT_4K | SPI_NOR_HAS_LOCK |
+                             SPI_NOR_4BIT_BP) },

I've read again the datasheet[1], and to me it looks like we don't support the locking scheme for this flash.
What mx25l6405d calls BP3, we refer to as Top/Bottom support (TB bit). The problem that I see is that mx25l6405d uses some kind of twisted TB bit.

For example, for BP3=1, BP2=0, BP1=0, BP0=1, the flash's datasheet states that the lower half blocks are protected (0th-63th), while in our code we would expect that just the lower first two blocks to be protected (0th and 1st). We need new support for this flash.

Cheers,
ta

[1] https://www.macronix.com/Lists/Datasheet/Attachments/7309/MX25L6405D,%203V,%2064Mb,%20v1.5.pdf

Quoted 6 lines
drivers/mtd/spi-nor/macronix.c +0 -1
        { "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
        { "mx25u3235f",  INFO(0xc22536, 0, 64 * 1024,  64,
                              SECT_4K | SPI_NOR_DUAL_READ |
--

2.17.1

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#5 lore raw

Am 2021-01-23 13:18, schrieb [email protected]:

Quoted 9 lines

Hi, Sieng,

Quoted 6 lines · Sieng Piaw Liew

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Enable 4-bit Block Protect support for MX256405D and its variants using the same ID.

Tested on Innacom W3400V6 router with MX25L6406E chip.

MX25L6406E?

Quoted 29 lines
Quoted 15 lines

https://github.com/openwrt/openwrt/pull/3501

---
Changes in v2:
- Add SPI_NOR_HAS_LOCK which SPI_NOR_4BIT_BP required.

 drivers/mtd/spi-nor/macronix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +0 -0
index 9203abaac229..033ede381673 100644

drivers/mtd/spi-nor/macronix.c static const struct flash_info macronix_parts[] = { · line 47

Quoted 7 lines
drivers/mtd/spi-nor/macronix.c +3 -1
@@ -42,7 +42,9 @@ static const struct flash_info macronix_parts[] = {
        { "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
        { "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, SECT_4K) },
        { "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
+       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128,
+                             SECT_4K | SPI_NOR_HAS_LOCK |
+                             SPI_NOR_4BIT_BP) },

I've read again the datasheet[1], and to me it looks like we don't support the locking scheme for this flash.
What mx25l6405d calls BP3, we refer to as Top/Bottom support (TB bit). The problem that I see is that mx25l6405d uses some kind of twisted TB bit.

Quoted 4 lines

For example, for BP3=1, BP2=0, BP1=0, BP0=1, the flash's datasheet states that the lower half blocks are protected (0th-63th), while in our code we would expect that just the lower first two blocks to be protected (0th and 1st). We need new support for this flash.

I double checked that and we don't support this. BP3 is indeed some kind of TB bit. But not the TB bit which is currently supported. I guess with the current code, protection scheme can be supported iff BP3 == 0.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/