diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2020-06-22 11:55:56 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-24 12:07:04 +0000 |
commit | 0c476173dd95f7626c3e34ce5a0bc308869e6e2f (patch) | |
tree | 70ae7c32a234cdafc1f76b8cc73d1fd919666788 | |
parent | e6636517406afa7115825de36ac52b5498ca70c4 (diff) | |
download | chrome-ec-0c476173dd95f7626c3e34ce5a0bc308869e6e2f.tar.gz |
test/flash_write_protect: Handle different WP polarity
Also handle the hard-coded case (mirrored from common/flash.c).
BRANCH=none
BUG=b:159571683
TEST=make BOARD=krane -j tests
Change-Id: I0bbdb4b6cc86226f01653c5a2dad569b6282e5b4
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256633
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
-rw-r--r-- | test/flash_write_protect.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/flash_write_protect.c b/test/flash_write_protect.c index 5e34b1735b..2b69484e93 100644 --- a/test/flash_write_protect.c +++ b/test/flash_write_protect.c @@ -12,12 +12,22 @@ test_static int check_image_and_hardware_write_protect(void) { + int wp; + if (system_get_image_copy() != EC_IMAGE_RO) { ccprintf("This test is only works when running RO\n"); return EC_ERROR_UNKNOWN; } - if (gpio_get_level(GPIO_WP) != 1) { +#ifdef CONFIG_WP_ALWAYS + wp = 1; +#elif defined(CONFIG_WP_ACTIVE_HIGH) + wp = gpio_get_level(GPIO_WP); +#else + wp = !gpio_get_level(GPIO_WP_L); +#endif + + if (!wp) { ccprintf("Hardware write protect (GPIO_WP) must be enabled\n"); return EC_ERROR_UNKNOWN; } |