All of lore.kernel.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 3/3] mtd: spi-nor: winbond: Fix locking support for w25q64jvm
Date: Wed, 18 Feb 2026 14:35:23 +0000	[thread overview]
Message-ID: <20260218143523.17467-4-farbere@amazon.com> (raw)
In-Reply-To: <20260218143523.17467-1-farbere@amazon.com>

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@amazon.com>
---
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


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

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

Thread overview: 10+ 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 ` [PATCH v2 1/3] mtd: spi-nor: winbond: Fix locking support for w25q256jwm Eliav Farber
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 ` Eliav Farber [this message]
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
2026-03-30 14:10 ` Pratyush Yadav
2026-03-30 14:22   ` Miquel Raynal
2026-03-30 14:59     ` Pratyush Yadav

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-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.