diff options
author | Dawid Niedzwiecki <dn@semihalf.com> | 2022-02-07 14:50:09 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-11 00:38:24 +0000 |
commit | 74a02c2ff082d70608064f4b09f8ecf08a77e685 (patch) | |
tree | 1b59c3e9265f7a6fa0a39f76083f03aa2b419095 /common/cbi_eeprom.c | |
parent | 4b10d2b2d093a43d9ef46ab4024cf38e13bb8f67 (diff) | |
download | chrome-ec-74a02c2ff082d70608064f4b09f8ecf08a77e685.tar.gz |
write protect: extract checking write protect
The write-protect state can be checked on 2 pins GPIO_WP or GPIO_WP_L.
The CONFIG_WP_ACTIVE_HIGH config is used to distinguish these two cases.
Move the checking the config and pin state to a separate header file.
For Zephyr, start using the gpio_get_level function that takes into
account the GPIO_ACTIVE_LOW flag. Also, use 'gpio-wp' alias to the WP
pin instead of the legacy enum-name property and 'int-wp' alias to the
WP GPIO interrupt.
BUG=b:211779766
TEST=zmake testall & make sure WP works
BRANCH=main
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I70bfbcd5e539fcc8cd157f2feae1a6c8e25083a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3447404
Reviewed-by: Andrew McRae <amcrae@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/cbi_eeprom.c')
-rw-r--r-- | common/cbi_eeprom.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/common/cbi_eeprom.c b/common/cbi_eeprom.c index 2761f0b977..ef20fdc7e2 100644 --- a/common/cbi_eeprom.c +++ b/common/cbi_eeprom.c @@ -12,6 +12,7 @@ #include "system.h" #include "timer.h" #include "util.h" +#include "write_protect.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, "CBI " format, ## args) @@ -33,11 +34,8 @@ static int eeprom_is_write_protected(void) { if (IS_ENABLED(CONFIG_BYPASS_CBI_EEPROM_WP_CHECK)) return 0; -#if defined(CONFIG_WP_ACTIVE_HIGH) - return gpio_get_level(GPIO_WP); -#else - return !gpio_get_level(GPIO_WP_L); -#endif + + return write_protect_is_asserted(); } static int eeprom_write(uint8_t *cbi) |