Skip to content

Commit 87aa3c8

Browse files
Jakub Czapigabroonie
authored andcommitted
spi: intel: Allow writeable MTD partition with module param
The MTD device is blocked from writing to the SPI-NOR chip if any region of it is write-protected, even if "writeable=1" module parameter is set. Add ability to bypass this behaviour by introducing new module parameter "ignore_protestion_status" which allows to rely on the write protection mechanism of SPI-NOR chip itself, which most modern chips (since the 1990'+) have already implemented. Any erase/write operations performed on the write-protected section will be rejected by the chip. Signed-off-by: Jakub Czapiga <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f54b69a commit 87aa3c8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/spi/spi-intel.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ struct intel_spi_mem_op {
189189
static bool writeable;
190190
module_param(writeable, bool, 0);
191191
MODULE_PARM_DESC(writeable, "Enable write access to SPI flash chip (default=0)");
192+
static bool ignore_protection_status;
193+
module_param(ignore_protection_status, bool, 0);
194+
MODULE_PARM_DESC(
195+
ignore_protection_status,
196+
"Do not block SPI flash chip write access even if it is write-protected (default=0)");
192197

193198
static void intel_spi_dump_regs(struct intel_spi *ispi)
194199
{
@@ -1248,13 +1253,15 @@ static void intel_spi_fill_partition(struct intel_spi *ispi,
12481253
continue;
12491254

12501255
/*
1251-
* If any of the regions have protection bits set, make the
1252-
* whole partition read-only to be on the safe side.
1256+
* If any of the regions have protection bits set and
1257+
* the ignore protection status parameter is not set,
1258+
* make the whole partition read-only to be on the safe side.
12531259
*
12541260
* Also if the user did not ask the chip to be writeable
12551261
* mask the bit too.
12561262
*/
1257-
if (!writeable || intel_spi_is_protected(ispi, base, limit)) {
1263+
if (!writeable || (!ignore_protection_status &&
1264+
intel_spi_is_protected(ispi, base, limit))) {
12581265
part->mask_flags |= MTD_WRITEABLE;
12591266
ispi->protected = true;
12601267
}

0 commit comments

Comments
 (0)