stm32f0: flash: Don't check protect bits for flash that doesn't exist

Each pair of protect bits locks 4K, so for parts with 64K flash, don't
bother checking STM32_OPTB_WRP23.

BUG=chrome-os-partner:49354
TEST=Run flashrom to protect PD MCU (see repro steps on linked crbug),
reboot and verify system boots into dev mode with all_at_boot and
all_now protect flags set on PD MCU.
BRANCH=glados

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic375d97c30bfd68940350641c44d5535b0402a2f
Reviewed-on: https://chromium-review.googlesource.com/322823
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2016-01-20 18:50:25 -08:00
committed by chrome-bot
parent d83482a3b0
commit 89bcc93547

View File

@@ -21,13 +21,18 @@ uint32_t flash_physical_get_protect_flags(void)
{
uint32_t flags = 0;
uint32_t wrp01 = REG32(STM32_OPTB_BASE + STM32_OPTB_WRP01);
#if CONFIG_FLASH_SIZE > 64 * 1024
uint32_t wrp23 = REG32(STM32_OPTB_BASE + STM32_OPTB_WRP23);
#endif
if (STM32_FLASH_WRPR == 0)
flags |= EC_FLASH_PROTECT_ALL_NOW;
if (wrp01 == 0xff00ff00 && wrp23 == 0xff00ff00)
flags |= EC_FLASH_PROTECT_ALL_AT_BOOT;
if (wrp01 == 0xff00ff00)
#if CONFIG_FLASH_SIZE > 64 * 1024
if (wrp23 == 0xff00ff00)
#endif
flags |= EC_FLASH_PROTECT_ALL_AT_BOOT;
return flags;
}