]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mtd: spi-nor: swp: Add support for the complement feature
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 26 May 2026 14:56:45 +0000 (16:56 +0200)
committerPratyush Yadav <pratyush@kernel.org>
Wed, 27 May 2026 12:36:02 +0000 (14:36 +0200)
commite3fb31d8847fef2ce37c5f60bc77d3f731a2419b
tree210cf7efd84bb4b153b5089f08493984decde1bc
parent6000eab4515a2a381557a48c35e248a3418f2bc6
mtd: spi-nor: swp: Add support for the complement feature

The current locking implementation allows to select a power of two
number of blocks, which is going to be the protected amount, as well as
telling whether this is the data at the top (end of the device) or the
bottom (beginning of the device). This means at most we can cover half
of the device or the entire device, but nothing in between.

The complement feature allows a much finer grain of configuration, by
allowing to invert what is considered locked and unlocked.

Add support for this feature. The only known position for the CMP bit is
bit 6 of the configuration register.

The locking and unlocking logics are kept unchanged if the CMP bit is
unavailable. Otherwise, once the regular logic has been applied, we
check if we already found an optimal configuration. If not, we try with
the CMP bit set. If the coverage is closer to the request, we use it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/debugfs.c
drivers/mtd/spi-nor/swp.c
include/linux/mtd/spi-nor.h