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>
This commit is contained in:
parent
e663651740
commit
0c476173dd
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue