From a3ec5c40f86f4c71305600ea25b58c1862d1c504 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 19 May 2011 12:52:53 -0700 Subject: Ensure ARM crossystem gpio readings match u-boot. U-boot and crossystem interpret the same switch state differently for 'recovery mode' and 'write protect', This change adds the ability to invert certan GPIO readings such that crossystem and u-boot return the same values. BUG=chromium-os:15393 TEST=manual Running crossystem on the target with developer u-boot image: - observe that recoverysw_cur reading matches recoverysw_boot and wpsw_cur reading matches_wpsw_boot. - try rebooting with recovery or developer mode buttons pressed, observe the change in reported values of devsw_boot and recoverysw_boot. - observe reported values of devsw_cur and recoverysw_cur following pressing of the buttons. Change-Id: I628f59b60008719bbff1722d23154ce934af6c36 Signed-off-by: Vadim Bendebury Reviewed-on: http://gerrit.chromium.org/gerrit/1193 Reviewed-by: Randall Spangler --- host/arch/arm/lib/crossystem_arch.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 6d62e7c3..ded1724e 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -23,12 +23,13 @@ typedef struct { const char *signal_name; unsigned gpio_number; + uint8_t needs_inversion; } GpioMap; static const GpioMap vb_gpio_map_kaen[] = { - {"recoverysw_cur", 56}, + {"recoverysw_cur", 56, 1}, {"devsw_cur", 168}, - {"wpsw_cur", 59}, + {"wpsw_cur", 59, 1}, }; /* This is map is for kaen, function to gpio number mapping */ @@ -100,13 +101,16 @@ static int VbGetGpioStatus(unsigned gpio_number) { } static int VbGetVarGpio(const char* name) { - int i; + int i; + const GpioMap* pmap; - for (i = 0; i < ARRAY_SIZE(vb_gpio_map_kaen); i++) { - if (!strcmp(name, vb_gpio_map_kaen[i].signal_name)) - return VbGetGpioStatus(vb_gpio_map_kaen[i].gpio_number); - } - return 2; /* means not found */ + for (i = 0, pmap = vb_gpio_map_kaen; + i < ARRAY_SIZE(vb_gpio_map_kaen); + i++, pmap++) { + if (!strcmp(name, pmap->signal_name)) + return VbGetGpioStatus(pmap->gpio_number) ^ pmap->needs_inversion; + } + return 2; /* means not found */ } static int VbReadSharedMemory(void) { -- cgit v1.2.1