diff options
-rw-r--r-- | host/arch/arm/lib/crossystem_arch.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 3ccb0baf..f9606745 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -23,6 +23,8 @@ #define FDT_BASE_PATH "/proc/device-tree/firmware/chromeos" /* Path to compatible FDT entry */ #define FDT_COMPATIBLE_PATH "/proc/device-tree/compatible" +/* Path to the chromeos_arm platform device */ +#define PLATFORM_DEV_PATH "/sys/devices/platform/chromeos_arm" /* Device for NVCTX write */ #define NVCTX_PATH "/dev/mmcblk%d" /* Base name for GPIO files */ @@ -179,6 +181,17 @@ static char * ReadFdtPlatformFamily(void) { return NULL; } +static int VbGetPlatformGpioStatus(const char* name) { + char gpio_name[FNAME_SIZE]; + int value; + + snprintf(gpio_name, sizeof(gpio_name), "%s/%s/value", + PLATFORM_DEV_PATH, name); + value = ReadFileInt(gpio_name); + + return value; +} + static int VbGetGpioStatus(unsigned gpio_number) { char gpio_name[FNAME_SIZE]; int value; @@ -358,9 +371,14 @@ int VbGetArchPropertyInt(const char* name) { return VbGetVarGpio("developer-switch"); else if (!strcasecmp(name, "recoverysw_cur")) return VbGetVarGpio("recovery-switch"); - else if (!strcasecmp(name, "wpsw_cur")) + else if (!strcasecmp(name, "wpsw_cur")) { + int value; + /* Try finding the GPIO through the chromeos_arm platform device first. */ + value = VbGetPlatformGpioStatus("write-protect"); + if (value != -1) + return value; return VbGetVarGpio("write-protect-switch"); - else if (!strcasecmp(name, "recoverysw_ec_boot")) + } else if (!strcasecmp(name, "recoverysw_ec_boot")) /* TODO: read correct value using ectool */ return 0; else |