diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index 55bc92e041..93dd42e944 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -345,6 +345,11 @@ int power_lid_open_debounced(void) return debounced_lid_open; } +int write_protect_asserted(void) +{ + return gpio_get_level(GPIO_WRITE_PROTECT); +} + /*****************************************************************************/ /* Task / state machine */ diff --git a/common/flash_common.c b/common/flash_common.c index c9fb74aebf..5ee966e06a 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -8,8 +8,8 @@ #include "config.h" #include "console.h" #include "flash.h" -#include "gpio.h" #include "host_command.h" +#include "power_button.h" #include "registers.h" #include "shared_mem.h" #include "system.h" @@ -40,19 +40,22 @@ int stuck_locked; /* Is physical flash stuck protected? */ static struct persist_state pstate; /* RAM copy of pstate data */ - /* Return non-zero if the write protect pin is asserted */ static int wp_pin_asserted(void) { -#ifdef CHIP_stm32 +#ifdef BOARD_link + return write_protect_asserted(); +#elif defined(CHIP_stm32) /* TODO (vpalatin) : write protect scheme for stm32 */ - return 1; /* Always enable write protect until we have WP pin. - * For developer to unlock WP, please use stm32mon -u and - * immediately re-program the pstate sector (so that - * apply_pstate() has no chance to run). - */ + /* + * Always enable write protect until we have WP pin. For developer to + * unlock WP, please use stm32mon -u and immediately re-program the + * pstate sector (so that apply_pstate() has no chance to run). + */ + return 1; #else - return gpio_get_level(GPIO_WRITE_PROTECT); + /* Other boards don't have a WP pin */ + return 0; #endif } diff --git a/include/power_button.h b/include/power_button.h index 7e99690185..bc80bfb54c 100644 --- a/include/power_button.h +++ b/include/power_button.h @@ -29,4 +29,9 @@ int power_ac_present(void); */ int power_lid_open_debounced(void); +/** + * Return non-zero if write protect signal is asserted. + */ +int write_protect_asserted(void); + #endif /* __CROS_EC_POWER_BUTTON_H */