summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-04-12 15:07:58 -0700
committerChromeBot <chrome-bot@google.com>2013-04-15 14:27:45 -0700
commit108235225d2536f75a3100cd535f44f732b486c3 (patch)
tree3f111879d86eddbc6979af513ed466dc20faf13d /include
parent27459f8600d76d5a7ccc4cc1c396ef59cb26ff19 (diff)
downloadchrome-ec-108235225d2536f75a3100cd535f44f732b486c3.tar.gz
Refactor gpio_set_level() and gpio_pre_init()
gpio_set_level() now allows setting the pin level if GPIO_LOW or GPIO_HIGH is specified. Previously, stm32 platforms did this even though the definition of gpio_set_level() said it wouldn't work. Fixed gpio_set_level() not setting level after warm reboot on stm32 because it was checking the GPIO_DEFAULT flag in the wrong place. Fixed LM4 still mucking with alternate function settings and levels even if GPIO_DEFAULT was specified. And checked gpio_list[] and all of the calls to gpio_set_flags() to make sure everything still behaves the same way it did before (or better, in the case of actual bugs). BUG=chrome-os-partner:18718 BRANCH=none TEST=build all platforms; boot spring and link Change-Id: I4b84815f76060252df235ff9a37da52c54a8eac5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48058 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/gpio.h29
1 files changed, 12 insertions, 17 deletions
diff --git a/include/gpio.h b/include/gpio.h
index fca33231e0..793b54575d 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -13,23 +13,21 @@
/* Flag definitions for gpio_info. */
#define GPIO_INPUT 0x0000 /* Input */
#define GPIO_OUTPUT 0x0001 /* Output */
-#define GPIO_PULL 0x0002 /* Input with on-chip pullup/pulldown */
-#define GPIO_HIGH 0x0004 /* If GPIO_OUTPUT, default high; if GPIO_PULL,
- * pull up (otherwise default low / pull
- * down) */
-#define GPIO_OPEN_DRAIN 0x0008 /* Output type is open-drain */
-#define GPIO_INT_RISING 0x0010 /* Interrupt on rising edge */
-#define GPIO_INT_FALLING 0x0020 /* Interrupt on falling edge */
-#define GPIO_INT_BOTH 0x0040 /* Interrupt on both edges */
-#define GPIO_INT_LOW 0x0080 /* Interrupt on low level */
-#define GPIO_INT_HIGH 0x0100 /* Interrupt on high level */
-#define GPIO_DEFAULT 0x0200 /* Don't set up on boot */
+#define GPIO_OPEN_DRAIN 0x0002 /* Output type is open-drain */
+#define GPIO_PULL_UP 0x0004 /* Enable on-chip pullup */
+#define GPIO_PULL_DOWN 0x0008 /* Enable on-chip pulldown */
+#define GPIO_LOW 0x0010 /* If GPIO_OUTPUT, set level low */
+#define GPIO_HIGH 0x0020 /* If GPIO_OUTPUT, set level high */
+#define GPIO_INT_RISING 0x0040 /* Interrupt on rising edge */
+#define GPIO_INT_FALLING 0x0080 /* Interrupt on falling edge */
+#define GPIO_INT_BOTH 0x0100 /* Interrupt on both edges */
+#define GPIO_INT_LOW 0x0200 /* Interrupt on low level */
+#define GPIO_INT_HIGH 0x0400 /* Interrupt on high level */
+#define GPIO_DEFAULT 0x0800 /* Don't set up on boot */
/* Common flag combinations */
-#define GPIO_OUT_LOW GPIO_OUTPUT
+#define GPIO_OUT_LOW (GPIO_OUTPUT | GPIO_LOW)
#define GPIO_OUT_HIGH (GPIO_OUTPUT | GPIO_HIGH)
-#define GPIO_PULL_DOWN GPIO_PULL
-#define GPIO_PULL_UP (GPIO_PULL | GPIO_HIGH)
#define GPIO_HI_Z (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_HIGH)
#define GPIO_INT_EDGE (GPIO_INT_RISING | GPIO_INT_FALLING | GPIO_INT_BOTH)
#define GPIO_INT_LEVEL (GPIO_INT_LOW | GPIO_INT_HIGH)
@@ -99,9 +97,6 @@ const char *gpio_get_name(enum gpio_signal signal);
/**
* Set the flags for a signal.
*
- * Note that this does not set the signal level based on the presence/absence
- * of GPIO_HIGH; call gpio_set_level() afterwards to do that if needed.
- *
* @param signal Signal to set flags for
* @param flags New flags for the signal
*/