summaryrefslogtreecommitdiff
path: root/common/gpio.c
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2016-04-13 22:15:02 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-27 14:04:07 -0700
commit4e52ae607c569e9d240e3ce3363659c840f1aa87 (patch)
tree6824faac11c4b35ebce8599f41e39c28351eb816 /common/gpio.c
parentd18cb0e81f2ba3c71349d17c7d84e7e10066711e (diff)
downloadchrome-ec-4e52ae607c569e9d240e3ce3363659c840f1aa87.tar.gz
servo_micro: add gpio mode get and set
GPIO console commands currently only show input voltage level, and can only set level on predefined outputs. This change allows GPIOs to be cycled between output, input, and alternate function, as well as displaying the mode and asserted level (if any) in gpioget. This change creates CONFIG_CMD_GPIO_EXTENDED as the internal gpio interface needs to be changed to support this, and I can't test the other architectures. It may be worthwhile to add this for all, or not. This change is also necessary also for servo micro JTAG and PD UART support, as several pins are tied together on the flex and stm32 outputs need to be variously active or in high-z depending on mode. BUG=chromium:571477 TEST=gpioget <0|1|IN|A|ALT>; gpioget; BRANCH=None Change-Id: Iba32992db6244ee1e654db840d1c9c11dd2a0993 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/338885 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/gpio.c')
-rw-r--r--common/gpio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/gpio.c b/common/gpio.c
index 817662f743..f4e3cfe2b8 100644
--- a/common/gpio.c
+++ b/common/gpio.c
@@ -113,6 +113,15 @@ void gpio_set_flags(enum gpio_signal signal, int flags)
gpio_set_flags_by_mask(g->port, g->mask, flags);
}
+#ifdef CONFIG_CMD_GPIO_EXTENDED
+int gpio_get_flags(enum gpio_signal signal)
+{
+ const struct gpio_info *g = gpio_list + signal;
+
+ return gpio_get_flags_by_mask(g->port, g->mask);
+}
+#endif
+
int gpio_get_default_flags(enum gpio_signal signal)
{
return gpio_list[signal].flags;