summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-17 15:52:56 -0700
committerGerrit <chrome-bot@google.com>2012-07-18 15:51:36 -0700
commit2223179cbcd49743b345ca313df99bfa41a57eeb (patch)
tree17f4437dd11cd0b32f75a96a547219e62fd0848a
parent0255a72d0784ff9557a5f0da7484c9c796299617 (diff)
downloadchrome-ec-2223179cbcd49743b345ca313df99bfa41a57eeb.tar.gz
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
-rw-r--r--chip/lm4/power_button.c5
-rw-r--r--common/flash_common.c21
-rw-r--r--include/power_button.h5
3 files changed, 22 insertions, 9 deletions
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 */