Skip to contentSkip to conversation

mtd: spi-nor: fix reading/writing of MX25L6405D

PATCH In review [email protected] 2 participants 2 messages Dec 27, 2021

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

PATCH 1/1 mtd: spi-nor: fix reading/writing of MX25L6405D

From: Nick Hainke <[email protected]>

Macronix MX25L6405D supports locking with four block protection bits in its status register. Furthermore, the chip will not work with the "16-bit Write Status (01h) Command". Add flash-specific fixup that disables the SNOR_F_HAS_16BIT_SR flag.

Tested on Nanostation M2 XM.

Fixes 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit on

lock()/unlock()")

---
 drivers/mtd/spi-nor/macronix.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +12 -1
index 27498ed0cc0d..6dd148e9f660 100644
@@ -8,6 +8,15 @@
 
 #include "core.h"
 
+static void mx25l6405d_default_init_fixups(struct spi_nor *nor)
+{
+	nor->flags &= ~SNOR_F_HAS_16BIT_SR;
+}
+
+static struct spi_nor_fixups mx25l6405d_fixups = {
+	.default_init = mx25l6405d_default_init_fixups,
+};
+
 static int
 mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
 			    const struct sfdp_parameter_header *bfpt_header,
@@ -41,7 +50,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)
+		.fixups = &mx25l6405d_fixups },
 	{ "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.34.1


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

Hi Nick,

Quoted 6 lines · On 12/27/21 02:35, [email protected] wrote:

From: Nick Hainke <[email protected]>

Macronix MX25L6405D supports locking with four block protection bits in its status register. Furthermore, the chip will not work with the "16-bit Write Status (01h) Command". Add flash-specific fixup that disables the SNOR_F_HAS_16BIT_SR flag.

As briefly noted on IRC - all Macronix flash chips do seem to only have one status register. So removing the SNOR_F_HAS_16BIT_SR flag in macronix_default_init is probably the better fix.

Best
David

Quoted 33 lines

Tested on Nanostation M2 XM.

Fixes 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit on

lock()/unlock()")

---
  drivers/mtd/spi-nor/macronix.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +9 -0
index 27498ed0cc0d..6dd148e9f660 100644
@@ -8,6 +8,15 @@
 
  #include "core.h"
 
+static void mx25l6405d_default_init_fixups(struct spi_nor *nor)
+{
+	nor->flags &= ~SNOR_F_HAS_16BIT_SR;
+}
+
+static struct spi_nor_fixups mx25l6405d_fixups = {
+	.default_init = mx25l6405d_default_init_fixups,
+};
+
  static int
  mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
  			    const struct sfdp_parameter_header *bfpt_header,

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

Quoted 10 lines
drivers/mtd/spi-nor/macronix.c +3 -1
@@ -41,7 +50,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)
+		.fixups = &mx25l6405d_fixups },
  	{ "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
  	{ "mx25u3235f",	 INFO(0xc22536, 0, 64 * 1024,  64,
  			      SECT_4K | SPI_NOR_DUAL_READ |

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