Skip to contentSkip to conversation

mtd: spi-nor: winbond: Fix protection handling and enable dual/quad reads

PATCH Superseded Eliav Farber 3 participants 11 messages Feb 8 – Feb 10

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mtd: spi-nor: winbond: Fix protection handling and enable dual/quad reads

This series fixes block protection handling for the following Winbond SPI-NOR devices:
- w25q256jwm
- w25q256jw
- w25q64jvm

The devices do not correctly describe their Status Register layout and protection capabilities (locking flags, TB bit, BP bit configuration). As a result, the spi-nor core rejects protection requests and locking operations fail with -EINVAL, e.g.:

flash_lock -l /dev/mtd29
flash_lock: error!: could not lock device: /dev/mtd29 error 22 (Invalid argument)

Update the device flags to match the actual hardware behavior so that locking and unlocking regions work correctly.

Additionally, enable Dual and Quad read support for w25q64jvm when SFDP is not used.

All changes were validated using flash_lock on the affected devices.

Eliav Farber (4):
mtd: spi-nor: winbond: Fix locking support for w25q256jwm
mtd: spi-nor: winbond: Fix locking support for w25q256jw
mtd: spi-nor: winbond: Fix locking support for w25q64jvm
mtd: spi-nor: winbond: Enable Dual and Quad support for w25q64jvm

 drivers/mtd/spi-nor/winbond.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/4 mtd: spi-nor: winbond: Fix locking support for w25q256jwm

The Winbond w25q256jwm device supports four Block Protect (BP) bits and uses Status Register bit 6 as the Top/Bottom (TB) protect bit.

Update the flash parameters by enabling SPI_NOR_4BIT_BP and SPI_NOR_TB_SR_BIT6. Without these flags, the locking configuration is incorrect.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q256JW.1

---
 drivers/mtd/spi-nor/winbond.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/winbond.c +1 -1
index fb855fe44733..55f1209936d5 100644
@@ -337,7 +337,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x80, 0x19),
 		.name = "w25q256jwm",
 		.size = SZ_32M,
-		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
 		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x80, 0x20),
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] mtd: spi-nor: winbond: Fix locking support for w25q256jwm

Quoted 20 lines · Eliav Farber

The Winbond w25q256jwm device supports four Block Protect (BP) bits and uses Status Register bit 6 as the Top/Bottom (TB) protect bit.

Update the flash parameters by enabling SPI_NOR_4BIT_BP and SPI_NOR_TB_SR_BIT6. Without these flags, the locking configuration is incorrect.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q256JW.1

---
 drivers/mtd/spi-nor/winbond.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/winbond.c +0 -0
index fb855fe44733..55f1209936d5 100644

drivers/mtd/spi-nor/winbond.c static const struct flash_info winbond_nor_parts[] = { · line 343

Quoted 8 lines
drivers/mtd/spi-nor/winbond.c +1 -1
@@ -337,7 +337,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x80, 0x19),
 		.name = "w25q256jwm",
 		.size = SZ_32M,
-		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
 		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x80, 0x20),

-michael

#3 lore raw

PATCH 2/4 mtd: spi-nor: winbond: Fix locking support for w25q256jw

In reply to Eliav Farber

The Winbond w25q256jw device:
- Supports lock/unlock via SR.
- Has Top/Bottom (TB) protect bit.
- Uses Status Register bit 6 as the Top/Bottom (TB) protect bit.
- Supports four Block Protect (BP) bits.

Update the flash parameters by enabling SPI_NOR_HAS_LOCK, SPI_NOR_HAS_TB, SPI_NOR_TB_SR_BIT6 and SPI_NOR_4BIT_BP. Without these flags, the locking configuration is incorrect.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q256JW.1

---
 drivers/mtd/spi-nor/winbond.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/winbond.c +1 -0
index 55f1209936d5..6d325da121b4 100644
@@ -274,6 +274,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x60, 0x19),
 		.name = "w25q256jw",
 		.size = SZ_32M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
 		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x60, 0x20),
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] mtd: spi-nor: winbond: Fix locking support for w25q256jw

Quoted 23 lines · Eliav Farber

The Winbond w25q256jw device:
- Supports lock/unlock via SR.
- Has Top/Bottom (TB) protect bit.
- Uses Status Register bit 6 as the Top/Bottom (TB) protect bit.
- Supports four Block Protect (BP) bits.

Update the flash parameters by enabling SPI_NOR_HAS_LOCK, SPI_NOR_HAS_TB, SPI_NOR_TB_SR_BIT6 and SPI_NOR_4BIT_BP. Without these flags, the locking configuration is incorrect.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q256JW.1

---
 drivers/mtd/spi-nor/winbond.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/winbond.c +0 -0
index 55f1209936d5..6d325da121b4 100644

drivers/mtd/spi-nor/winbond.c static const struct flash_info winbond_nor_parts[] = { · line 280

Quoted 7 lines
drivers/mtd/spi-nor/winbond.c +1 -0
@@ -274,6 +274,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x60, 0x19),
 		.name = "w25q256jw",
 		.size = SZ_32M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
 		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x60, 0x20),

-michael

#5 lore raw

PATCH 3/4 mtd: spi-nor: winbond: Fix locking support for w25q64jvm

In reply to Eliav Farber

The Winbond w25q64jvm supports block protection through the Status Register (SR) and provides a Top/Bottom (TB) protection bit.

Enable SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB for this device to properly describe its locking capabilities.

The device uses Status Register bit 5 as the TB bit and supports only three Block Protect (BP) bits. Therefore, do not set SPI_NOR_TB_SR_BIT6 or SPI_NOR_4BIT_BP.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q64JV.1

---
 drivers/mtd/spi-nor/winbond.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/winbond.c +1 -0
index 6d325da121b4..eaa547d36aad 100644
@@ -296,6 +296,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x70, 0x17),
 		.name = "w25q64jvm",
 		.size = SZ_8M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
 		.no_sfdp_flags = SECT_4K,
 	}, {
 		.id = SNOR_ID(0xef, 0x70, 0x18),
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] mtd: spi-nor: winbond: Fix locking support for w25q64jvm

Quoted 23 lines · Eliav Farber

The Winbond w25q64jvm supports block protection through the Status Register (SR) and provides a Top/Bottom (TB) protection bit.

Enable SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB for this device to properly describe its locking capabilities.

The device uses Status Register bit 5 as the TB bit and supports only three Block Protect (BP) bits. Therefore, do not set SPI_NOR_TB_SR_BIT6 or SPI_NOR_4BIT_BP.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q64JV.1

---
 drivers/mtd/spi-nor/winbond.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/winbond.c +0 -0
index 6d325da121b4..eaa547d36aad 100644

drivers/mtd/spi-nor/winbond.c static const struct flash_info winbond_nor_parts[] = { · line 302

Quoted 7 lines
drivers/mtd/spi-nor/winbond.c +1 -0
@@ -296,6 +296,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.id = SNOR_ID(0xef, 0x70, 0x17),
 		.name = "w25q64jvm",
 		.size = SZ_8M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
 		.no_sfdp_flags = SECT_4K,
 	}, {
 		.id = SNOR_ID(0xef, 0x70, 0x18),

-michael

#7 lore raw

PATCH 4/4 mtd: spi-nor: winbond: Enable Dual and Quad support for w25q64jvm

In reply to Eliav Farber

The w25q64jvm supports Dual and Quad SPI operations.

Enable these capabilities by adding SPI_NOR_DUAL_READ and SPI_NOR_QUAD_READ to no_sfdp_flags.

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q64JV.1

---
 drivers/mtd/spi-nor/winbond.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/winbond.c +1 -1
index eaa547d36aad..cb35ec6f110e 100644
@@ -297,7 +297,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.name = "w25q64jvm",
 		.size = SZ_8M,
 		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
-		.no_sfdp_flags = SECT_4K,
+		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x70, 0x18),
 		.name = "w25q128jv",
Signature · 1 line
2.47.3
maintainer
#8 lore raw

Re: [PATCH 4/4] mtd: spi-nor: winbond: Enable Dual and Quad support for w25q64jvm

Quoted 4 lines · Eliav Farber

The w25q64jvm supports Dual and Quad SPI operations.

Enable these capabilities by adding SPI_NOR_DUAL_READ and SPI_NOR_QUAD_READ to no_sfdp_flags.

Let me guess, you have a flash that actually has SFDP but it's not parsed because the core (due to legacy reasons) skips it because neither DUAL_READ nor QUAD_READ is set.

See also [1]. I'd prefer to always try to parse SFDP instead of adding these legacy flags.

-michael

[1] https://lore.kernel.org/linux-mtd/[email protected]/

Quoted 22 lines

Reference:
https://www.winbond.com/hq/support/documentation/levelOne.jsp?__locale=en&DocNo=DA00-W25Q64JV.1

---
 drivers/mtd/spi-nor/winbond.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/winbond.c +1 -1
index eaa547d36aad..cb35ec6f110e 100644
@@ -297,7 +297,7 @@ static const struct flash_info winbond_nor_parts[] = {
 		.name = "w25q64jvm",
 		.size = SZ_8M,
 		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
-		.no_sfdp_flags = SECT_4K,
+		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
 	}, {
 		.id = SNOR_ID(0xef, 0x70, 0x18),
 		.name = "w25q128jv",
maintainer Reviewed-by on the v1 series
#9 lore raw
In reply to Eliav Farber

Hi Eliav,

Quoted 23 lines · Eliav Farber

This series fixes block protection handling for the following Winbond SPI-NOR devices:
- w25q256jwm
- w25q256jw
- w25q64jvm

The devices do not correctly describe their Status Register layout and protection capabilities (locking flags, TB bit, BP bit configuration). As a result, the spi-nor core rejects protection requests and locking operations fail with -EINVAL, e.g.:

flash_lock -l /dev/mtd29
flash_lock: error!: could not lock device: /dev/mtd29 error 22 (Invalid argument)

Update the device flags to match the actual hardware behavior so that locking and unlocking regions work correctly.

Additionally, enable Dual and Quad read support for w25q64jvm when SFDP is not used.

All changes were validated using flash_lock on the affected devices.

Quoted 8 lines

Eliav Farber (4):
mtd: spi-nor: winbond: Fix locking support for w25q256jwm
mtd: spi-nor: winbond: Fix locking support for w25q256jw
mtd: spi-nor: winbond: Fix locking support for w25q64jvm
mtd: spi-nor: winbond: Enable Dual and Quad support for w25q64jvm

 drivers/mtd/spi-nor/winbond.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Looks sensible, I was looking to find Fixes tags but due to the number of refactorings, these are hard to track, so I'm fine keeping the commits as they are.

Thanks,
Miquèl

maintainer
#10 lore raw
In reply to Eliav Farber
Quoted 15 lines · Eliav Farber

This series fixes block protection handling for the following Winbond SPI-NOR devices:
- w25q256jwm
- w25q256jw
- w25q64jvm

The devices do not correctly describe their Status Register layout and protection capabilities (locking flags, TB bit, BP bit configuration). As a result, the spi-nor core rejects protection requests and locking operations fail with -EINVAL, e.g.:

flash_lock -l /dev/mtd29
flash_lock: error!: could not lock device: /dev/mtd29 error 22 (Invalid argument)

Quoted 5 lines

Update the device flags to match the actual hardware behavior so that locking and unlocking regions work correctly.

Additionally, enable Dual and Quad read support for w25q64jvm when SFDP is not used.

Do you really have devices without SFDP tables?

Quoted 2 lines

All changes were validated using flash_lock on the affected devices.

Great thanks!

Could you also please dump the SFDP tables from all these devices, see [1].

Thanks,
-michael

[1] https://docs.kernel.org/driver-api/mtd/spi-nor.html