diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-11-30 14:51:09 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-01 19:59:11 -0800 |
commit | 57d8666fa137c2ab0b9c3d6c7e1d58b0a82645c2 (patch) | |
tree | 0963f18aa7d062f305ba75964a7795b6692fde48 /chip/npcx/flash.c | |
parent | 1bdf8584bb659f44512ec0c88a210d7e60b688bd (diff) | |
download | chrome-ec-57d8666fa137c2ab0b9c3d6c7e1d58b0a82645c2.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/415499
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'chip/npcx/flash.c')
-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 790fd77d97..a11679c231 100644 --- a/chip/npcx/flash.c +++ b/chip/npcx/flash.c @@ -297,7 +297,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(); @@ -312,6 +313,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); } @@ -576,10 +580,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. |