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

From: Eliav Farber

Date: Wed Feb 18 2026 - 09:36:55 EST


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

Signed-off-by: Eliav Farber <farbere@xxxxxxxxxx>
---
This flash is populated on the al10_k2v5_jrd_aio_makalu board and was
tested at 35700000 frequency using the amazon,alpine-dw-apb-ssi SPI
controller.

~ # cat /sys/bus/spi/devices/spi0.2/spi-nor/partname
w25q64jvm
~ # cat /sys/bus/spi/devices/spi0.2/spi-nor/jedec_id
ef7017
~ # cat /sys/bus/spi/devices/spi0.2/spi-nor/manufacturer
winbond

~ # xxd -p /sys/bus/spi/devices/spi0.2/spi-nor/sfdp
53464450050100ff00050110800000ffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffe520f9ffffffff0344eb086b083b42bbfeffffffffff
0000ffff40eb0c200f5210d800003602a60082ea14c4e96376337a757a75
f7a2d55c19f74dffe930f880

~ # cat /sys/kernel/debug/spi-nor/spi0.2/capabilities
Supported read modes by the flash
1S-1S-1S
opcode 0x03
mode cycles 0
dummy cycles 0
1S-1S-2S
opcode 0x3b
mode cycles 0
dummy cycles 8
1S-2S-2S
opcode 0xbb
mode cycles 2
dummy cycles 2
1S-1S-4S
opcode 0x6b
mode cycles 0
dummy cycles 8
1S-4S-4S
opcode 0xeb
mode cycles 2
dummy cycles 4
4S-4S-4S
opcode 0xeb
mode cycles 2
dummy cycles 0

Supported page program modes by the flash
1S-1S-1S
opcode 0x02

~ # cat /sys/kernel/debug/spi-nor/spi0.2/params
name w25q64jvm
id ef 70 17 00 00 00
size 8.00 MiB
write size 1
page size 256
address nbytes 3
flags HAS_SR_TB | HAS_LOCK | HAS_16BIT_SR | NO_READ_CR | SOFT_RESET

opcodes
read 0x03
dummy cycles 0
erase 0x20
program 0x02
8D extension none

protocols
read 1S-1S-1S
write 1S-1S-1S
register 1S-1S-1S

erase commands
20 (4.00 KiB) [1]
52 (32.0 KiB) [2]
d8 (64.0 KiB) [3]
c7 (8.00 MiB)

sector map
region (in hex) | erase mask | overlaid
------------------+------------+----------
00000000-007fffff | [ 1 ] | no

/tmp # dd if=/dev/urandom of=./spi_test bs=1M count=2
2+0 records in
2+0 records out
2097152 bytes (2.0MB) copied, 0.010381 seconds, 192.7MB/s

/tmp # ./mtd_debug erase /dev/mtd2 0 2097152
Erased 2097152 bytes from address 0x00000000 in flash

/tmp # ./mtd_debug read /dev/mtd2 0 2097152 spi_read
Copied 2097152 bytes from address 0x00000000 in flash to spi_read

/tmp # hexdump spi_read
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
0200000
/tmp # sha256sum spi_read
4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 spi_read

/tmp # mtd_debug write /dev/mtd0 0 2097152 spi_test
-sh: mtd_debug: not found
/tmp # ./mtd_debug write /dev/mtd2 0 2097152 spi_test
Copied 2097152 bytes from spi_test to address 0x00000000 in flash

/tmp # ./mtd_debug read /dev/mtd2 0 2097152 spi_read
Copied 2097152 bytes from address 0x00000000 in flash to spi_read

/tmp # sha256sum spi*
555b3718aa92b1313ff7f93e75306267a8ed0c5f4d92cc63c1eac4366731059b spi_read
555b3718aa92b1313ff7f93e75306267a8ed0c5f4d92cc63c1eac4366731059b spi_test

/tmp # ./mtd_debug erase /dev/mtd2 0 2097152
Erased 2097152 bytes from address 0x00000000 in flash

/tmp # ./mtd_debug read /dev/mtd2 0 2097152 spi_read
Copied 2097152 bytes from address 0x00000000 in flash to spi_read

/tmp # sha256sum spi*
4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 spi_read
555b3718aa92b1313ff7f93e75306267a8ed0c5f4d92cc63c1eac4366731059b spi_test

/tmp # ./mtd_debug info /dev/mtd2
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 8388608 (8M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

drivers/mtd/spi-nor/winbond.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c
index 6d325da121b4..eaa547d36aad 100644
--- a/drivers/mtd/spi-nor/winbond.c
+++ b/drivers/mtd/spi-nor/winbond.c
@@ -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),
--
2.47.3