summaryrefslogtreecommitdiff
path: root/include/gpio.h
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 /include/gpio.h
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 'include/gpio.h')
-rw-r--r--include/gpio.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h
index 52638e4222..b588659a88 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -30,6 +30,7 @@
#define GPIO_INT_DSLEEP (1 << 14) /* Interrupt in deep sleep */
#define GPIO_INT_SHARED (1 << 15) /* Shared among multiple pins */
#define GPIO_SEL_1P8V (1 << 16) /* Support 1.8v */
+#define GPIO_ALTERNATE (1 << 17) /* GPIO used for alternate function. */
/* Common flag combinations */
#define GPIO_OUT_LOW (GPIO_OUTPUT | GPIO_LOW)
@@ -146,6 +147,24 @@ int gpio_is_implemented(enum gpio_signal signal);
*/
void gpio_set_flags(enum gpio_signal signal, int flags);
+#ifdef CONFIG_CMD_GPIO_EXTENDED
+/**
+ * Get the current flags for a signal.
+ *
+ * @param signal Signal to get flags for
+ * @returns The flags that are currently defined for this signal
+ */
+int gpio_get_flags(enum gpio_signal signal);
+
+/**
+ * Get flags for GPIO by port and mask.
+ *
+ * @param port GPIO port to set (GPIO_*)
+ * @param mask Bitmask of pins on that port to check: one only.
+ */
+int gpio_get_flags_by_mask(uint32_t port, uint32_t mask);
+#endif
+
/**
* Get the default flags for a signal.
*
@@ -211,6 +230,7 @@ int gpio_disable_interrupt(enum gpio_signal signal);
*/
void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags);
+
/**
* Set alternate function for GPIO(s).
*