diff options
author | Vic Yang <victoryang@chromium.org> | 2014-10-14 10:05:43 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-15 23:56:27 +0000 |
commit | f8fd63f135b5922900ceeb345857070e814f8877 (patch) | |
tree | d93f66806f14465810b263e30d49a3e610430acf /chip/stm32/flash-stm32l.c | |
parent | 847eb1ec44aa43c761799b522b0449bdfc31269a (diff) | |
download | chrome-ec-f8fd63f135b5922900ceeb345857070e814f8877.tar.gz |
Fix incorrect valid and writable flash flags
The valid and writable flags the EC sends back to the AP are incorrect.
They are a little bit different on differnt chips, so let's move it to
flash physical layer. This is not any causing problem, but we should fix
this.
BUG=chrome-os-partner:32745
TEST=make buildall
BRANCH=samus
Change-Id: Ibcda5ae770f5ea02cde094490997a5bc447df88f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222661
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/stm32/flash-stm32l.c')
-rw-r--r-- | chip/stm32/flash-stm32l.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/chip/stm32/flash-stm32l.c b/chip/stm32/flash-stm32l.c index 98f46565a3..106e436c80 100644 --- a/chip/stm32/flash-stm32l.c +++ b/chip/stm32/flash-stm32l.c @@ -400,6 +400,32 @@ int flash_physical_protect_now(int all) } } +uint32_t flash_physical_get_valid_flags(void) +{ + return EC_FLASH_PROTECT_RO_AT_BOOT | + EC_FLASH_PROTECT_RO_NOW | + EC_FLASH_PROTECT_ALL_NOW; +} + +uint32_t flash_physical_get_writable_flags(uint32_t cur_flags) +{ + uint32_t ret = 0; + + /* If RO protection isn't enabled, its at-boot state can be changed. */ + if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW)) + ret |= EC_FLASH_PROTECT_RO_AT_BOOT; + + /* + * If entire flash isn't protected at this boot, it can be enabled if + * the WP GPIO is asserted. + */ + if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) && + (cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED)) + ret |= EC_FLASH_PROTECT_ALL_NOW; + + return ret; +} + int flash_pre_init(void) { uint32_t reset_flags = system_get_reset_flags(); |