RE: [PATCH] mtd: spi-nor: spansion: add SPI_NOR_HAS_LOCK to s25fl064k

From: Takahiro.Kuwano

Date: Thu Dec 03 2026 - 01:41:00 EST


Hi,

> The s25fl064k entry also matches the Winbond W25Q64, which has the same
> ID. Both protect blocks with the BP0-2 and TB bits of the status
> register. Commit 3b1fba74306b ("mtd: spi-nor: winbond: W25Q64JV-Q/N:
> Fill locking information") set SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB on
> the winbond w25q64 entry, but that entry is never used for this ID, as
> the spansion table is searched first. Set both flags on the s25fl064k
> entry too.

Why don't we remove the redundant entry?
We need to keep "s25fl064k" name as it is in spi_nor_dev_ids[].

>
> Without SPI_NOR_HAS_LOCK the block protection is never cleared, so on a
> W25Q64 that ships fully protected, erases and writes silently fail.
>
> Signed-off-by: Naresh Solanki <naresh.solanki.2011@xxxxxxxxx>
> ---
> Tested on a Tenda AC10 V5 router (Siflower SF19A2890, Winbond W25Q64,
> OpenWrt with a 6.18 kernel). The flash ships with BP2-0 = 111: without
> this patch every erase and write to it is silently ignored. With it,
> the protection is cleared at probe (the BP bits are non-volatile, so
> with CONFIG_MTD_SPI_NOR_SWP_DISABLE), and sysupgrade and the JFFS2
> overlay work.
>
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id
> ef4017
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer
> spansion
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/partname
> s25fl064k
> $ sha256sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> ad4c59a94e6205cf237f8734d01ca45d67d34ed35404b364595ff420b6259d32
> $ hexdump -Cv /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> 00000000 53 46 44 50 05 01 00 ff 00 05 01 10 80 00 00 ff |SFDP............|
> 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
> *
> 00000080 e5 20 f9 ff ff ff ff 03 44 eb 08 6b 08 3b 42 bb |. ......D..k.;B.|
> 00000090 fe ff ff ff ff ff 00 00 ff ff 40 eb 0c 20 0f 52 |..........@.. .R|
> 000000a0 10 d8 00 00 36 02 a6 00 82 ea 14 c4 e9 63 76 33 |....6........cv3|
> 000000b0 7a 75 7a 75 f7 a2 d5 5c 19 f7 4d ff e9 30 f8 80 |zuzu...\..M..0..|
> 000000c0
>
> drivers/mtd/spi-nor/spansion.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
> index b1b14ed..9712ed3 100644
> --- a/drivers/mtd/spi-nor/spansion.c
> +++ b/drivers/mtd/spi-nor/spansion.c
> @@ -1065,6 +1065,7 @@ static const struct flash_info spansion_nor_parts[] = {
> .id = SNOR_ID(0xef, 0x40, 0x17),
> .name = "s25fl064k",
> .size = SZ_8M,
> + .flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,

Do we also need to add HAS_CMP and QUAD_PP?

> .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
> }
> };
> --
> 2.53.0

Thanks,
Takahiro