diff options
author | Olof Johansson <olofj@chromium.org> | 2011-07-14 17:07:28 -0700 |
---|---|---|
committer | Olof Johansson <olofj@chromium.org> | 2011-07-14 21:50:42 -0700 |
commit | 7994d07d565d11557a1701ff16e892d7ab8e0d41 (patch) | |
tree | fa362b4a4ad4c94924c608095f2b1bfec6a361b2 | |
parent | 7d1c22b75ad4173f5d319e049e766e04cea110f8 (diff) | |
download | vboot-7994d07d565d11557a1701ff16e892d7ab8e0d41.tar.gz |
crossystem: arm: use proper gpio references
BUG=none
TEST=make sure developer switch and recovery switch runtime reading works as expected (manually)
Change-Id: I3b17ac66f88b2b789bebe4e7d271666f8c63a8b0
Reviewed-on: http://gerrit.chromium.org/gerrit/4127
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Olof Johansson <olofj@chromium.org>
-rw-r--r-- | host/arch/arm/lib/crossystem_arch.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 581184e3..d74c2d10 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -147,19 +147,32 @@ static int VbGetGpioStatus(unsigned gpio_number) { static int VbGetVarGpio(const char* name) { int polarity, gpio_num; - char prop_polarity[FNAME_SIZE]; - char prop_gpio_num[FNAME_SIZE]; - - snprintf(prop_polarity, sizeof(prop_polarity), "%s-polarity", name); - snprintf(prop_gpio_num, sizeof(prop_gpio_num), "%s-gpio", name); - - polarity = ReadFdtInt(prop_polarity); - gpio_num = ReadFdtInt(prop_gpio_num); + void *pp = NULL; + int *prop; + size_t proplen = 0; + int ret = 0; + + /* TODO: This should at some point in the future use the phandle + * to find the gpio chip and thus the base number. Assume 0 now, + * which isn't 100% future-proof (i.e. if one of the switches gets + * moved to an offchip gpio controller. + */ + + ret = ReadFdtBlock(name, &pp, &proplen); + if (ret || !pp || proplen != 12) { + ret = 2; + goto out; + } + prop = pp; + gpio_num = ntohl(prop[1]); + polarity = ntohl(prop[2]); - if (polarity == -1 || gpio_num == -1) - return 2; + ret = VbGetGpioStatus(gpio_num) ^ polarity ^ 1; +out: + if (pp) + free(pp); - return VbGetGpioStatus(gpio_num) ^ polarity ^ 1; + return ret; } int VbReadNvStorage(VbNvContext* vnc) { |