summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2012-10-25 16:31:06 +0000
committerGerald Van Baren <gvb@unssw.com>2012-11-12 23:14:57 -0500
commit202ff7537558edfd759b400cfe9e56c56fc7868c (patch)
tree3a24471fde372eeb2da00b04d3a8d6522e407159 /lib
parentaadef0a1bc3db81708471c9d18eb6c756659196f (diff)
downloadu-boot-imx-202ff7537558edfd759b400cfe9e56c56fc7868c.zip
u-boot-imx-202ff7537558edfd759b400cfe9e56c56fc7868c.tar.gz
u-boot-imx-202ff7537558edfd759b400cfe9e56c56fc7868c.tar.bz2
fdt: Add polarity-aware gpio functions to fdtdec
Add get and set gpio functions to fdtdec that take into account the polarity field in fdtdec_gpio_state.flags. Signed-off-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/fdtdec.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 150512e..e1b17a5 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -487,6 +487,26 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
return err == 1 ? 0 : err;
}
+int fdtdec_get_gpio(struct fdt_gpio_state *gpio)
+{
+ int val;
+
+ if (!fdt_gpio_isvalid(gpio))
+ return -1;
+
+ val = gpio_get_value(gpio->gpio);
+ return gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
+}
+
+int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val)
+{
+ if (!fdt_gpio_isvalid(gpio))
+ return -1;
+
+ val = gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
+ return gpio_set_value(gpio->gpio, val);
+}
+
int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
{
/*