summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-05 20:05:28 -0700
committerSimon Glass <sjg@chromium.org>2015-01-29 17:09:50 -0700
commit0dac4d51f50e9252dbc00075cf65eeba57017926 (patch)
tree2d31e477c73b0de6a3604092b02e4f5b8ef5a06b /drivers
parentae7123f876357a81fc4c393239a378f1058cad5e (diff)
downloadu-boot-imx-0dac4d51f50e9252dbc00075cf65eeba57017926.zip
u-boot-imx-0dac4d51f50e9252dbc00075cf65eeba57017926.tar.gz
u-boot-imx-0dac4d51f50e9252dbc00075cf65eeba57017926.tar.bz2
dm: gpio: Add a driver GPIO translation method
Only the GPIO driver knows about the full GPIO device tree binding used by a device. Add a method to allow the driver to provide this information to the uclass, including the GPIO offset within the device and flags such as the polarity. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpio-uclass.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 2f3c36b..0a4d9e4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <dm.h>
#include <errno.h>
+#include <fdtdec.h>
#include <malloc.h>
#include <asm/gpio.h>
#include <linux/ctype.h>
@@ -91,6 +92,21 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
return 0;
}
+int gpio_find_and_xlate(struct gpio_desc *desc,
+ struct fdtdec_phandle_args *args)
+{
+ struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
+
+ /* Use the first argument as the offset by default */
+ if (args->args_count > 0)
+ desc->offset = args->args[0];
+ else
+ desc->offset = -1;
+ desc->flags = 0;
+
+ return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+}
+
static int dm_gpio_request(struct gpio_desc *desc, const char *label)
{
struct udevice *dev = desc->dev;