summaryrefslogtreecommitdiff
path: root/include/gpio.h
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-08-28 10:28:08 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-04 05:45:52 +0000
commit2270f2bb03c2031bad455ba5f8179a9d99cc3999 (patch)
tree496418ddfebf04e0b010c9916bb7b6f0c0036d5d /include/gpio.h
parentb99f91310721c50ea30fd204aa127928af37a41f (diff)
downloadchrome-ec-2270f2bb03c2031bad455ba5f8179a9d99cc3999.tar.gz
Fix a bug that GPIO cannot be set as input on stm32l
GPIO_INPUT is defined as 0, and any GPIO flag cannot be examined against GPIO_INPUT. Change GPIO_INPUT to non-zero value to avoid this. BUG=chrome-os-partner:22275 TEST=On Kirby, set a GPIO to output and pull it low, and then set it back to input. Check it can be pull high externally. TEST=Build all boards. TEST=Boot link and spring. BRANCH=None (unless this bug hits some other boards.) Change-Id: I84b9936c24af538ac59c36129fda27ca879bf9d1 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167190 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/gpio.h')
-rw-r--r--include/gpio.h48
1 files changed, 26 insertions, 22 deletions
diff --git a/include/gpio.h b/include/gpio.h
index eee7711ee3..ce2de2b126 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -12,32 +12,36 @@
/* Flag definitions for gpio_info and gpio_alt_func */
/* The following are valid for both gpio_info and gpio_alt_func: */
-#define GPIO_OPEN_DRAIN (1 << 0) /* Output type is open-drain */
-#define GPIO_PULL_UP (1 << 1) /* Enable on-chip pullup */
-#define GPIO_PULL_DOWN (1 << 2) /* Enable on-chip pulldown */
+#define GPIO_OPEN_DRAIN (1 << 0) /* Output type is open-drain */
+#define GPIO_PULL_UP (1 << 1) /* Enable on-chip pullup */
+#define GPIO_PULL_DOWN (1 << 2) /* Enable on-chip pulldown */
/* The following are valid for gpio_alt_func only */
-#define GPIO_ANALOG (1 << 3) /* Set pin to analog-mode */
+#define GPIO_ANALOG (1 << 3) /* Set pin to analog-mode */
/* The following are valid for gpio_info only */
-#define GPIO_INPUT 0 /* Input */
-#define GPIO_OUTPUT (1 << 4) /* Output */
-#define GPIO_LOW (1 << 5) /* If GPIO_OUTPUT, set level low */
-#define GPIO_HIGH (1 << 6) /* If GPIO_OUTPUT, set level high */
-#define GPIO_INT_RISING (1 << 7) /* Interrupt on rising edge */
-#define GPIO_INT_FALLING (1 << 8) /* Interrupt on falling edge */
-#define GPIO_INT_BOTH (1 << 9) /* Interrupt on both edges */
-#define GPIO_INT_LOW (1 << 10) /* Interrupt on low level */
-#define GPIO_INT_HIGH (1 << 11) /* Interrupt on high level */
-#define GPIO_DEFAULT (1 << 12) /* Don't set up on boot */
+#define GPIO_INPUT (1 << 4) /* Input */
+#define GPIO_OUTPUT (1 << 5) /* Output */
+#define GPIO_LOW (1 << 6) /* If GPIO_OUTPUT, set level low */
+#define GPIO_HIGH (1 << 7) /* If GPIO_OUTPUT, set level high */
+#define GPIO_INT_F_RISING (1 << 8) /* Interrupt on rising edge */
+#define GPIO_INT_F_FALLING (1 << 9) /* Interrupt on falling edge */
+#define GPIO_INT_F_BOTH (1 << 10) /* Interrupt on both edges */
+#define GPIO_INT_F_LOW (1 << 11) /* Interrupt on low level */
+#define GPIO_INT_F_HIGH (1 << 12) /* Interrupt on high level */
+#define GPIO_DEFAULT (1 << 13) /* Don't set up on boot */
/* Common flag combinations */
-#define GPIO_OUT_LOW (GPIO_OUTPUT | GPIO_LOW)
-#define GPIO_OUT_HIGH (GPIO_OUTPUT | GPIO_HIGH)
-#define GPIO_ODR_HIGH (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_HIGH)
-#define GPIO_ODR_LOW (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_LOW)
-#define GPIO_INT_EDGE (GPIO_INT_RISING | GPIO_INT_FALLING | GPIO_INT_BOTH)
-#define GPIO_INT_LEVEL (GPIO_INT_LOW | GPIO_INT_HIGH)
-#define GPIO_INT_ANY (GPIO_INT_EDGE | GPIO_INT_LEVEL)
-/* Note that if no flags are present, the signal is a high-Z input */
+#define GPIO_OUT_LOW (GPIO_OUTPUT | GPIO_LOW)
+#define GPIO_OUT_HIGH (GPIO_OUTPUT | GPIO_HIGH)
+#define GPIO_ODR_HIGH (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_HIGH)
+#define GPIO_ODR_LOW (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_LOW)
+#define GPIO_INT_RISING (GPIO_INPUT | GPIO_INT_F_RISING)
+#define GPIO_INT_FALLING (GPIO_INPUT | GPIO_INT_F_FALLING)
+#define GPIO_INT_BOTH (GPIO_INPUT | GPIO_INT_F_BOTH)
+#define GPIO_INT_LOW (GPIO_INPUT | GPIO_INT_F_LOW)
+#define GPIO_INT_HIGH (GPIO_INPUT | GPIO_INT_F_HIGH)
+#define GPIO_INT_EDGE (GPIO_INT_RISING | GPIO_INT_FALLING | GPIO_INT_BOTH)
+#define GPIO_INT_LEVEL (GPIO_INT_LOW | GPIO_INT_HIGH)
+#define GPIO_INT_ANY (GPIO_INT_EDGE | GPIO_INT_LEVEL)
/* GPIO signal definition structure, for use by board.c */
struct gpio_info {