From 28292ae66332ecca9e6ea8b98cd3eadf57f36e8a Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Wed, 11 Apr 2012 14:04:08 -0700 Subject: [PATCH] add more explicit GPIO types This patch adds explicit handling of open-drain outputs and adds Hi-Z for high-impedence state (floating) outputs. Signed-off-by: David Hendricks BUG=none TEST=compile tested Change-Id: I1a0c2e8366f6a82cd9cd7e83e57122944f2bdc2d --- include/gpio.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/gpio.h b/include/gpio.h index 4a351346eb..6eab4f1583 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -13,21 +13,26 @@ /* 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 */ + + /* Common flag combinations */ #define GPIO_OUT_LOW GPIO_OUTPUT #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) #define GPIO_INT_ANY (GPIO_INT_EDGE | GPIO_INT_LEVEL)