summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2011-05-19 12:52:53 -0700
committerVadim Bendebury <vbendeb@chromium.org>2011-05-19 13:39:40 -0700
commita3ec5c40f86f4c71305600ea25b58c1862d1c504 (patch)
treea018e93607292505b245fb936f0214ce358f28b2
parent8ba3d790e16c6e0759686b1bd8b25db778c3fc9f (diff)
downloadvboot-a3ec5c40f86f4c71305600ea25b58c1862d1c504.tar.gz
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 <vbendeb@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/1193 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--host/arch/arm/lib/crossystem_arch.c20
1 files 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) {