linux-stable/drivers/mtd/spi-nor
Jungseung Lee 2d284768b4
mtd: spi-nor: Add generic formula for SR block protection handling
The current mainline locking was restricted and could only be applied
to flashes that have 3 block protection bits and fixed locking ratio.

A new method of normalization was reached at the end of the discussion [1].

    (1) - if bp slot is insufficient.
    (2) - if bp slot is sufficient.

    if (bp_slots_needed > bp_slots)    // (1)
        min_prot_length = sector_size << (bp_slots_needed - bp_slots);
    else                               // (2)
        min_prot_length = sector_size;

This patch changes logic to handle block protection based on min_prot_length.
It is suitable for the overall flashes with exception of some corner cases
(see EON and catalyst) and easy to extend and apply for the case of 2bit or
4bit block protection.

[1] http://lists.infradead.org/pipermail/linux-mtd/2020-February/093934.html

Signed-off-by: Jungseung Lee <js07.lee@samsung.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
2020-03-24 11:43:28 +02:00
..
controllers mtd: spi-nor: controllers: aspeed-smc: Replace zero-length array with flexible-array member 2020-03-23 20:01:15 +02:00
atmel.c mtd: spi-nor: Move Atmel bits out of core.c 2020-03-17 09:28:02 +02:00
catalyst.c mtd: spi-nor: Move Catalyst bits out of core.c 2020-03-17 09:28:05 +02:00
core.c mtd: spi-nor: Add generic formula for SR block protection handling 2020-03-24 11:43:28 +02:00
core.h mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
eon.c mtd: spi-nor: Move Eon bits out of core.c 2020-03-17 09:28:02 +02:00
esmt.c mtd: spi-nor: Move ESMT bits out of core.c 2020-03-17 09:28:02 +02:00
everspin.c mtd: spi-nor: Move Everspin bits out of core.c 2020-03-17 09:28:03 +02:00
fujitsu.c mtd: spi-nor: Move Fujitsu bits out of core.c 2020-03-17 09:28:03 +02:00
gigadevice.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
intel.c mtd: spi-nor: Move Intel bits out of core.c 2020-03-17 09:28:03 +02:00
issi.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
Kconfig mtd: spi-nor: Prepare core / manufacturer code split 2020-03-16 18:28:53 +02:00
macronix.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
Makefile mtd: spi-nor: Move XMC bits out of core.c 2020-03-17 09:28:06 +02:00
micron-st.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
sfdp.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
sfdp.h mtd: spi-nor: Move SFDP logic out of the core 2020-03-16 18:28:53 +02:00
spansion.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
sst.c mtd: spi-nor: Move SST bits out of core.c 2020-03-17 09:28:05 +02:00
winbond.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
xilinx.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
xmc.c mtd: spi-nor: Move XMC bits out of core.c 2020-03-17 09:28:06 +02:00