From 7cdd6a24aad8fcf33c1527ebdbe5a10547258b41 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 19 Aug 2021 14:54:52 -0700 Subject: crossystem: arm: support active-high WP and RECOVERY GPIOs Some systems have an active-high GPIO for reading WP status, so support an inverted name for that. While we're at it, do this for recovery too, just in case someone needs it. BRANCH=none BUG=b:197258688 TEST=play with servo's `fw_wp_state`, check `crossystem wpsw_cur` on kevin-kernelnext + DTS change Signed-off-by: Brian Norris Change-Id: I28ad566568d6dc62843d0bc9b75cca1fc1a35633 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3108068 Reviewed-by: Julius Werner --- host/arch/arm/lib/crossystem_arch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 0223b70c..116f8fc2 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -35,7 +35,9 @@ #define PLATFORM_DEV_PATH "/sys/devices/platform/chromeos_arm" /* These should match the Linux GPIO name (i.e., 'gpio-line-names'). */ #define GPIO_NAME_RECOVERY_SW_L "RECOVERY_SW_L" +#define GPIO_NAME_RECOVERY_SW "RECOVERY_SW" #define GPIO_NAME_WP_L "AP_FLASH_WP_L" +#define GPIO_NAME_WP "AP_FLASH_WP" /* Device for NVCTX write */ #define NVCTX_PATH "/dev/mmcblk%d" /* Base name for GPIO files */ @@ -479,6 +481,9 @@ int VbGetArchPropertyInt(const char* name) int value; /* Try GPIO chardev API first. */ value = gpiod_read(GPIO_NAME_RECOVERY_SW_L, true); + if (value != -1) + return value; + value = gpiod_read(GPIO_NAME_RECOVERY_SW, false); if (value != -1) return value; /* Try the deprecated chromeos_arm platform device next. */ @@ -487,6 +492,9 @@ int VbGetArchPropertyInt(const char* name) int value; /* Try GPIO chardev API first. */ value = gpiod_read(GPIO_NAME_WP_L, true); + if (value != -1) + return value; + value = gpiod_read(GPIO_NAME_WP, false); if (value != -1) return value; /* Try the deprecated chromeos_arm platform device next. */ -- cgit v1.2.1