From 4a9cabc3f9e8cfbeee857180c8a0b400ef7c8092 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Thu, 9 Oct 2014 14:04:32 -0700 Subject: Factor out common flash code for STM32F and STM32F0 This is a preparatory work for the following change for write protection support on STM32F0. BUG=chrome-os-partner:32745 TEST=make buildall BRANCH=samus Change-Id: Ic4deea06e26c4a6ac024a5388e1a5783b40e9876 Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/222660 Reviewed-by: Randall Spangler --- include/flash.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'include/flash.h') diff --git a/include/flash.h b/include/flash.h index 2079032a0a..dff1be7948 100644 --- a/include/flash.h +++ b/include/flash.h @@ -28,6 +28,13 @@ #define PSTATE_BANK (PSTATE_OFFSET / CONFIG_FLASH_BANK_SIZE) #define PSTATE_BANK_COUNT (PSTATE_SIZE / CONFIG_FLASH_BANK_SIZE) +/* Range of write protection */ +enum flash_wp_range { + FLASH_WP_NONE = 0, + FLASH_WP_RO, + FLASH_WP_ALL, +}; + /*****************************************************************************/ /* Low-level methods, for use by flash_common. */ @@ -70,12 +77,12 @@ int flash_physical_get_protect(int bank); uint32_t flash_physical_get_protect_flags(void); /** - * Enable/disable protecting RO firmware and pstate at boot. + * Enable/disable protecting firmware/pstate at boot. * - * @param enable Enable (non-zero) or disable (zero) protection + * @param range The range to protect * @return non-zero if error. */ -int flash_physical_protect_ro_at_boot(int enable); +int flash_physical_protect_at_boot(enum flash_wp_range range); /** * Protect flash now. @@ -96,6 +103,13 @@ int flash_physical_protect_now(int all); */ int flash_physical_force_reload(void); +/** + * Restore flash physical layer state after sysjump. + * + * @return non-zero if restored. + */ +int flash_physical_restore_state(void); + /*****************************************************************************/ /* Low-level common code for use by flash modules. */ -- cgit v1.2.1