summaryrefslogtreecommitdiffstats
path: root/spi25_statusreg.c
diff options
context:
space:
mode:
authorSergii Dmytruk <sergii.dmytruk@3mdeb.com>2021-11-27 15:14:27 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-11-19 06:54:20 +0000
commitf32f5e31d99531ee61bd31c64f41cc4baee68d57 (patch)
tree9bbd6bd0081abf32038f38c658018d54a121d8b1 /spi25_statusreg.c
parented351cc602e5f21a47ad3f06696a7fe72e82c198 (diff)
downloadflashrom-f32f5e31d99531ee61bd31c64f41cc4baee68d57.tar.gz
flashrom-f32f5e31d99531ee61bd31c64f41cc4baee68d57.tar.bz2
flashrom-f32f5e31d99531ee61bd31c64f41cc4baee68d57.zip
spi25_statusreg.c: support reading security register
Not to be confused with "secure registers" of OTP. Security register is a dedicated status register for security-related bits. You don't write its value directly, issuing special write commands with no data set separate OTP bits to 1 automatically (WRSCUR, WPSEL commands). No WREN is necessary, but at least some datasheets indicate BUSY state after those write commands. Unlike cases where OTP bit is part of SR and can only be written while in OTP mode, security register can only be written outside of the mode. The register is found in at least these chips by Macronix: * MX25L6436E * MX25L6445E * MX25L6465E * MX25L6473E Change-Id: Iae1753ca4cb051127a5bcbeba7f064053adb8dae Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59709 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'spi25_statusreg.c')
-rw-r--r--spi25_statusreg.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/spi25_statusreg.c b/spi25_statusreg.c
index d0ce8597a..2859b2320 100644
--- a/spi25_statusreg.c
+++ b/spi25_statusreg.c
@@ -100,6 +100,13 @@ int spi_write_register(const struct flashctx *flash, enum flash_reg reg, uint8_t
}
msg_cerr("Cannot write SR3: unsupported by chip\n");
return 1;
+ case SECURITY:
+ /*
+ * Security register doesn't have a normal write operation. Instead,
+ * there are separate commands that set individual OTP bits.
+ */
+ msg_cerr("Cannot write SECURITY: unsupported by design\n");
+ return 1;
default:
msg_cerr("Cannot write register: unknown register\n");
return 1;
@@ -195,6 +202,13 @@ int spi_read_register(const struct flashctx *flash, enum flash_reg reg, uint8_t
}
msg_cerr("Cannot read SR3: unsupported by chip\n");
return 1;
+ case SECURITY:
+ if (feature_bits & FEATURE_SCUR) {
+ read_cmd = JEDEC_RDSCUR;
+ break;
+ }
+ msg_cerr("Cannot read SECURITY: unsupported by chip\n");
+ return 1;
default:
msg_cerr("Cannot read register: unknown register\n");
return 1;