summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-05 20:05:33 -0700
committerSimon Glass <sjg@chromium.org>2015-01-29 17:09:51 -0700
commit838aa5c94adc0da95c858ef70271078fd18dc4c9 (patch)
tree45057746758a6303ce920f26e3ecf254d7a8e584 /drivers/gpio
parent32f8a19f6d9aa551dc64868fac4b662c088dfb1f (diff)
downloadtalos-obmc-uboot-838aa5c94adc0da95c858ef70271078fd18dc4c9.tar.gz
talos-obmc-uboot-838aa5c94adc0da95c858ef70271078fd18dc4c9.zip
dm: tegra: Add a GPIO translation function
This deals with the polarity bit and selecting the correct bank device given a GPIO number. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/tegra_gpio.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index 88f7ef5bf0..43928b8812 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -21,6 +21,7 @@
#include <asm/arch/tegra.h>
#include <asm/gpio.h>
#include <dm/device-internal.h>
+#include <dt-bindings/gpio/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -251,6 +252,22 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset)
return GPIOF_INPUT;
}
+static int tegra_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+ struct fdtdec_phandle_args *args)
+{
+ int gpio, port, ret;
+
+ gpio = args->args[0];
+ port = gpio / TEGRA_GPIOS_PER_PORT;
+ ret = device_get_child(dev, port, &desc->dev);
+ if (ret)
+ return ret;
+ desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
+ desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
+
+ return 0;
+}
+
static const struct dm_gpio_ops gpio_tegra_ops = {
.request = tegra_gpio_request,
.direction_input = tegra_gpio_direction_input,
@@ -258,6 +275,7 @@ static const struct dm_gpio_ops gpio_tegra_ops = {
.get_value = tegra_gpio_get_value,
.set_value = tegra_gpio_set_value,
.get_function = tegra_gpio_get_function,
+ .xlate = tegra_gpio_xlate,
};
/**
OpenPOWER on IntegriCloud