Move flash_get_protect() and flash_set_protect() to flash_common.c

Much more flash code is now common between platforms, for more
consistent behavior and easier testing.

Also change STM32L to use pstate, the same way LM4 and STM32F do.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=build pit, link, spring; do

 - flashinfo -> (no flags)
 - enable WP (via screw or dut-control)
 - flashinfo -> wp_gpio_asserted
 - flashwp enable
 - flashinfo -> wp_gpio_asserted ro_at_boot
 - flashwp now
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now (and possibly ro_now)
 - flashwp disable -> fails
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now
 - reboot ap-off
 - flashinfo -> wp_gpio_asserted ro_at_boot ro_now
 - disable WP (via screw or dut-control)
 - reboot
 - flashinfo -> ro_at_boot
 - flashwp disable
 - flashinfo -> (no flags)

Change-Id: Iccd098786454ad9b72b4e5f9f312d86819a0c8eb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56109
This commit is contained in:
Randall Spangler
2013-05-21 12:34:11 -07:00
committed by ChromeBot
parent b144a584af
commit 1d28ca7cf1
5 changed files with 233 additions and 301 deletions

View File

@@ -88,9 +88,13 @@ int flash_physical_erase(int offset, int size);
int flash_physical_get_protect(int bank);
/**
* Return non-zero if entire flash is locked for the current boot.
* Return flash protect state flags from the physical layer.
*
* This should only be called by flash_get_protect().
*
* Uses the EC_FLASH_PROTECT_* flags from ec_commands.h
*/
int flash_physical_get_all_protect_now(void);
uint32_t flash_physical_get_protect_flags(void);
/**
* Set physical write protect status for the next boot.
@@ -103,6 +107,14 @@ int flash_physical_get_all_protect_now(void);
int flash_physical_set_protect_at_boot(int start_bank, int bank_count,
int enable);
/**
* Protect flash now.
*
* @param all Protect all (=1) or just read-only and pstate (=0).
* @return non-zero if error.
*/
int flash_physical_protect_now(int all);
/**
* Force reload of flash protection bits.
*
@@ -117,11 +129,6 @@ int flash_physical_force_reload(void);
/*****************************************************************************/
/* Low-level persistent state code for use by flash modules. */
/**
* Return non-zero if RO flash should be protected at boot.
*/
int flash_get_protect_ro_at_boot(void);
/**
* Enable write protect for the read-only code.
*