summaryrefslogtreecommitdiff
path: root/board/nvidia
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2011-10-17 13:50:25 -0400
committerSean Paul <seanpaul@chromium.org>2011-10-17 12:31:10 -0700
commit78c42c6a7987169b67248efe27239d6389ca4c69 (patch)
treed3a0221ebe6d0f0b39ec2450a77507a2dc574415 /board/nvidia
parent644f14b121f76d55267e1fc6930a02c6cc10c26d (diff)
CHROMIUM: Clean up cros gpio code
This CL simplifies how cros gpios are handled by moving the required logic out of cros_gpio.c and into the application logic. This means that cros_gpio.c assumes that none of the gpios are required, and just returns an error when fetch is called. It's up to the caller of fetch to determine whether or not they should ignore the error or act upon it. BUG=chromium-os:21700 TEST=Tested on asymptote, ensured gpio access worked as expected. Change-Id: Ief3f1915026bfe981d345b9cc4709fef19edc7bf Signed-off-by: Sean Paul <seanpaul@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/10174 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'board/nvidia')
-rw-r--r--board/nvidia/chromeos/cros_gpio.c52
1 files changed, 10 insertions, 42 deletions
diff --git a/board/nvidia/chromeos/cros_gpio.c b/board/nvidia/chromeos/cros_gpio.c
index 9be80dd7168..1aed5319c94 100644
--- a/board/nvidia/chromeos/cros_gpio.c
+++ b/board/nvidia/chromeos/cros_gpio.c
@@ -22,24 +22,12 @@
DECLARE_GLOBAL_DATA_PTR;
-struct cros_gpio {
- char *name;
- int default_value;
-};
-
-/*
- * This list provides names matching the dts files and the default value that
- * the gpio should take. If the gpio is strictly required, use
- * FDT_GPIO_NONE to fail out on the gpio functions. To use a default value
- * for a gpio (in the case where it's not specified in the dts file), fill in
- * a 1 or 0 in the default value field.
- */
-static struct cros_gpio gpios[CROS_GPIO_MAX_GPIO] = {
- { "write-protect-switch", FDT_GPIO_NONE },
- { "recovery-switch", FDT_GPIO_NONE },
- { "developer-switch", FDT_GPIO_NONE },
- { "lid-switch", 1 },
- { "power-switch", 0 },
+static char *gpio_name[CROS_GPIO_MAX_GPIO] = {
+ "write-protect-switch",
+ "recovery-switch",
+ "developer-switch",
+ "lid-switch",
+ "power-switch",
};
static int g_config_node = -1;
@@ -55,18 +43,8 @@ int misc_init_r(void)
return -1;
for (i = 0; i < CROS_GPIO_MAX_GPIO; i++) {
- if (fdt_decode_gpio(gd->blob, config_node, gpios[i].name,
- &gs)) {
- /*
- * If the gpio has a default value (ie. not required,
- * just ignore it)
- */
- if (gpios[i].default_value == FDT_GPIO_NONE)
- return -1;
- else
- continue;
- }
- fdt_setup_gpio(&gs);
+ if (!fdt_decode_gpio(gd->blob, config_node, gpio_name[i], &gs))
+ fdt_setup_gpio(&gs);
}
/*
@@ -96,18 +74,8 @@ int cros_gpio_fetch(enum cros_gpio_index index, cros_gpio_t *gpio)
assert(g_config_node >= 0);
assert(index >= 0 && index < CROS_GPIO_MAX_GPIO);
- if (fdt_decode_gpio(gd->blob, g_config_node, gpios[index].name, &gs)) {
- if (gpios[index].default_value == FDT_GPIO_NONE) {
- VBDEBUG(PREFIX "fail to decode gpio: %d\n", index);
- return -1;
- } else {
- gpio->index = -1;
- gpio->port = -1;
- gpio->polarity = CROS_GPIO_ACTIVE_HIGH;
- gpio->value = gpios[index].default_value;
- return 0;
- }
- }
+ if (fdt_decode_gpio(gd->blob, g_config_node, gpio_name[index], &gs))
+ return -1;
gpio->index = index;
gpio->port = gs.gpio;