public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Eliav Farber <farbere@amazon.com>
To: <tudor.ambarus@linaro.org>, <pratyush@kernel.org>,
	<mwalle@kernel.org>, <miquel.raynal@bootlin.com>,
	<richard@nod.at>, <vigneshr@ti.com>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Cc: <farbere@amazon.com>
Subject: [PATCH v2 1/3] mtd: spi-nor: winbond: Fix locking support for w25q256jwm
Date: Wed, 18 Feb 2026 14:35:21 +0000	[thread overview]
Message-ID: <20260218143523.17467-2-farbere@amazon.com> (raw)
In-Reply-To: <20260218143523.17467-1-farbere@amazon.com>

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

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

root@alpine:~# cat /sys/bus/spi/devices/spi3.0/spi-nor/partname
w25q256jwm
root@alpine:~# cat /sys/bus/spi/devices/spi3.0/spi-nor/jedec_id 
ef8019
root@alpine:~# cat /sys/bus/spi/devices/spi3.0/spi-nor/manufacturer 
winbond

root@alpine:~# xxd -p /sys/bus/spi/devices/spi3.0/spi-nor/sfdp 
53464450060101ff00060110800000ff84000102d00000ffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffe520fbffffffff0f44eb086b083b42bbfeffffffffff
0000ffff40eb0c200f5210d800003602a60082ea14d3e96376337a757a75
f7bdd55c19f75dffe970f9a5ffffffffffffffffffffffffffffffffff0a
f0ff21ffdcff 

root@alpine:~# cat /sys/kernel/debug/spi-nor/spi3.0/capabilities
Supported read modes by the flash
 1S-1S-1S
  opcode        0x13
  mode cycles   0
  dummy cycles  0
 1S-1S-2S
  opcode        0x3c
  mode cycles   0
  dummy cycles  8
 1S-2S-2S
  opcode        0xbc
  mode cycles   2
  dummy cycles  2
 1S-1S-4S
  opcode        0x6c
  mode cycles   0
  dummy cycles  8
 1S-4S-4S
  opcode        0xec
  mode cycles   2
  dummy cycles  4
 4S-4S-4S
  opcode        0xec
  mode cycles   2
  dummy cycles  0

Supported page program modes by the flash
 1S-1S-1S
  opcode        0x12
 1S-1S-4S
  opcode        0x34

root@alpine:~# cat /sys/kernel/debug/spi-nor/spi3.0/params
name            w25q256jwm
id              ef 80 19 00 00 00
size            32.0 MiB
write size      1
page size       256
address nbytes  4
flags           HAS_SR_TB | 4B_OPCODES | HAS_4BAIT | HAS_LOCK | HAS_16BIT_SR | HAS_SR_TB_BIT6 | HAS_4BIT_BP | SOFT_RESET

opcodes
 read           0x13
  dummy cycles  0
 erase          0x21
 program        0x12
 8D extension   none

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

erase commands
 21 (4.00 KiB) [1]
 dc (64.0 KiB) [3]
 c7 (32.0 MiB)

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

root@alpine:~# dd if=/dev/urandom of=./spi_test bs=65536 count=1
1+0 records in
1+0 records out
65536 bytes (66 kB, 64 KiB) copied, 0.0002316 s, 283 MB/s

root@alpine:~# mtd_debug erase /dev/mtd22 0 65536
Erased 65536 bytes from address 0x00000000 in flash

root@alpine:~# mtd_debug read /dev/mtd22 0 65536 spi_read
Copied 65536 bytes from address 0x00000000 in flash to spi_read

root@alpine:~# hexdump spi_read
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
0010000

root@alpine:~# sha256sum spi_read
71189f7fb6aed638640078fba3a35fda6c39c8962e74dcc75935aac948da9063  spi_read

root@alpine:~# mtd_debug write /dev/mtd22 0 65536 spi_test
Copied 65536 bytes from spi_test to address 0x00000000 in flash

root@alpine:~# mtd_debug read /dev/mtd22 0 65536 spi_read
Copied 65536 bytes from address 0x00000000 in flash to spi_read	

root@alpine:~# sha256sum spi*
b16b45f0cb74ba65d81766e9007d8cd1fbd3ac7ca7fbbd76fa4d181c3c1d52c0  spi_read
b16b45f0cb74ba65d81766e9007d8cd1fbd3ac7ca7fbbd76fa4d181c3c1d52c0  spi_test

root@alpine:~# mtd_debug erase /dev/mtd22 0 65536
Erased 65536 bytes from address 0x00000000 in flash

root@alpine:~# mtd_debug read /dev/mtd22 0 65536 spi_read
Copied 65536 bytes from address 0x00000000 in flash to spi_read

root@alpine:~# sha256sum spi*
71189f7fb6aed638640078fba3a35fda6c39c8962e74dcc75935aac948da9063  spi_read
b16b45f0cb74ba65d81766e9007d8cd1fbd3ac7ca7fbbd76fa4d181c3c1d52c0  spi_test

root@alpine:~# mtd_debug info /dev/mtd22
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 65536 (64K)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1 
mtd.oobsize = 0 
regions = 0

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

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


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

  reply	other threads:[~2026-02-18 14:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 14:35 [PATCH v2 0/3] mtd: spi-nor: winbond: Fix protection handling Eliav Farber
2026-02-18 14:35 ` Eliav Farber [this message]
2026-02-18 14:35 ` [PATCH v2 2/3] mtd: spi-nor: winbond: Fix locking support for w25q256jw Eliav Farber
2026-02-18 14:35 ` [PATCH v2 3/3] mtd: spi-nor: winbond: Fix locking support for w25q64jvm Eliav Farber
2026-02-19  7:51 ` [PATCH v2 0/3] mtd: spi-nor: winbond: Fix protection handling Michael Walle
2026-02-19  8:59   ` Farber, Eliav
2026-02-19  9:05     ` Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260218143523.17467-2-farbere@amazon.com \
    --to=farbere@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@linaro.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox