summaryrefslogtreecommitdiffstats
path: root/include/of_gpio.h
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-07-02 20:14:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-05 08:26:57 +0200
commit61bb8bfc7cf12a32d547c0084a2999712bef6443 (patch)
treec7fc71cc80d506ffdad4fb7b4b35ad4c4bf75a6f /include/of_gpio.h
parent483424e0276309264f5a517f2d7be217557349fb (diff)
downloadbarebox-61bb8bfc7cf12a32d547c0084a2999712bef6443.tar.gz
barebox-61bb8bfc7cf12a32d547c0084a2999712bef6443.tar.xz
OF: gpio: convert DT based gpio handling to new OF API
This creates a Linux OF API compatible counterpart of of_get_named_gpio_flags. Existing of_get_named_gpio is converted to a static inline function, which is in the corresponding of_gpio.h include. While at it, drivers/of/gpio.c is also renamed to drivers/of/of_gpio.c to follow the of_ prefix naming scheme. The new include is also added to existing users of of_get_named_gpio. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/of_gpio.h')
-rw-r--r--include/of_gpio.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/of_gpio.h b/include/of_gpio.h
new file mode 100644
index 0000000000..50536a8a38
--- /dev/null
+++ b/include/of_gpio.h
@@ -0,0 +1,44 @@
+/*
+ * OF helpers for the GPIO API
+ *
+ * based on Linux OF_GPIO API
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __OF_GPIO_H
+#define __OF_GPIO_H
+
+/*
+ * This is Linux-specific flags. By default controllers' and Linux' mapping
+ * match, but GPIO controllers are free to translate their own flags to
+ * Linux-specific in their .xlate callback. Though, 1:1 mapping is recommended.
+ */
+enum of_gpio_flags {
+ OF_GPIO_ACTIVE_LOW = 0x1,
+};
+
+#ifdef CONFIG_OFTREE
+extern int of_get_named_gpio_flags(struct device_node *np,
+ const char *list_name, int index, enum of_gpio_flags *flags);
+
+#else /* CONFIG_OFTREE */
+
+static inline int of_get_named_gpio_flags(struct device_node *np,
+ const char *list_name, int index, enum of_gpio_flags *flags)
+{
+ return -ENOSYS;
+}
+
+#endif /* CONFIG_OFTREE */
+
+static inline int of_get_named_gpio(struct device_node *np,
+ const char *list_name, int index)
+{
+ return of_get_named_gpio_flags(np, list_name, index, NULL);
+}
+
+#endif