Move looking at write protect GPIO to button/switches module

Since that already monitors the WP signal for reporting it as a
switch.  And if we have that code in two places and the WP signal
polarity changes, we'll inevitably forget to change it in the other
place...

BUG=chrome-os-partner:11150
TEST=manual

flashinfo -> WP pin asserted
remove WP screw
flashinfo -> WP pin deasserted

Change-Id: I6091c8bb470c357e02ede8a5b184b2a76b70dc60
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27720
This commit is contained in:
Randall Spangler
2012-07-17 15:52:56 -07:00
committed by Gerrit
parent 0255a72d07
commit 2223179cbc
3 changed files with 22 additions and 9 deletions

View File

@@ -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 */

View File

@@ -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
}

View File

@@ -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 */