summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2012-08-16 01:59:33 -0700
committerGerrit <chrome-bot@google.com>2012-08-16 09:48:45 -0700
commit3afe5566ccee0df6c636ab6e9cf882106fe9245b (patch)
treec07dc0c16640b232e7127d7ddddb004b86b5e81d /host
parent12ef75d84d2e45884c150b65bb584c0bc4e3342b (diff)
downloadvboot-3afe5566ccee0df6c636ab6e9cf882106fe9245b.tar.gz
Make crossystem look for the write protect switch in the chromeos_arm device
The value of the ChromeOS write protect switch is now provided through the new chromeos_arm platform device which avoids the mismatch between U-Boot and kernel GPIO numbering. BUG=chrome-os-partner:11297 TEST=gmerge-ed onto a snow and verified that crossystem got the right value of the write protect switch. BRANCH=snow Change-Id: I466370e4f6bf2d14c067518a9d620e9e60142a0b Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://gerrit.chromium.org/gerrit/30534 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Ready: Randall Spangler <rspangler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'host')
-rw-r--r--host/arch/arm/lib/crossystem_arch.c22
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