diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-11-30 14:51:09 -0800 |
---|---|---|
committer | Philip Chen <philipchen@chromium.org> | 2016-12-01 03:13:21 +0000 |
commit | 707c461e7e3b6f05f5a555a9428cd3d0ef095126 (patch) | |
tree | 0158bb8ae2eed3aeb8d43a81231165cc640643aa | |
parent | a825399498fe045b7abbf46153c545a8a0130676 (diff) | |
download | chrome-ec-707c461e7e3b6f05f5a555a9428cd3d0ef095126.tar.gz |
npcx: flash: Set SRP0 when enabling RO write protection
HW protection can be overridden unless SRP0 is set with WP asserted.
BUG=chrome-os-partner:60029
BRANCH=gru
TEST=Manual on kevin, deassert WP:
> flashrom -p ec --wp-enable
> flashrom -p ec --wp-disable
SUCCESS
assert WP:
> flashrom -p ec --wp-enable
> flashrom -p ec --wp-disable
FAILED: RO_AT_BOOT is not clear.
Change-Id: I67c1ec086704cd5be4518b6dc3dc87146cbd2d99
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/415465
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 3025b40df5c7744dde44336cc11f520667a92268)
Reviewed-on: https://chromium-review.googlesource.com/415546
Reviewed-by: Philip Chen <philipchen@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
-rw-r--r-- | chip/npcx/flash.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/chip/npcx/flash.c b/chip/npcx/flash.c index fd6d5055d3..a541e5df3c 100644 --- a/chip/npcx/flash.c +++ b/chip/npcx/flash.c @@ -257,7 +257,8 @@ static int flash_check_prot_reg(unsigned int offset, unsigned int bytes) } -static int flash_write_prot_reg(unsigned int offset, unsigned int bytes) +static int flash_write_prot_reg(unsigned int offset, unsigned int bytes, + int hw_protect) { int rv; uint8_t sr1 = flash_get_status1(); @@ -272,6 +273,9 @@ static int flash_write_prot_reg(unsigned int offset, unsigned int bytes) if (rv) return rv; + if (hw_protect) + sr1 |= SPI_FLASH_SR1_SRP0; + return flash_set_status_for_prot(sr1, sr2); } @@ -526,10 +530,12 @@ int flash_physical_protect_at_boot(enum flash_wp_range range) case FLASH_WP_RO: /* Protect read-only */ return flash_write_prot_reg(CONFIG_WP_STORAGE_OFF, - CONFIG_WP_STORAGE_SIZE); + CONFIG_WP_STORAGE_SIZE, + 1); case FLASH_WP_ALL: flash_write_prot_reg(CONFIG_WP_STORAGE_OFF, - CONFIG_WP_STORAGE_SIZE); + CONFIG_WP_STORAGE_SIZE, + 1); /* * Set UMA_LOCK bit for locking all UMA transaction. |