From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Tue, 15 Mar 2016 13:48:57 +0800 Subject: [U-Boot] [PATCH 2/2] dm: gpio: mxc: implement xlate function In-Reply-To: <1458020937-994-1-git-send-email-van.freenix@gmail.com> References: <1458020937-994-1-git-send-email-van.freenix@gmail.com> Message-ID: <1458020937-994-2-git-send-email-van.freenix@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de To i.MX controller, we use such as "<&gpio1 3 GPIO_ACTIVE_LOW>" for a device to refer a gpio pin in device tree. So need to implement xlate function, to correctly handle gpio flags and offset. Signed-off-by: Peng Fan Cc: Simon Glass Cc: Stefano Babic Cc: Fabio Estevam --- drivers/gpio/mxc_gpio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index b6ae3fc..15449d7 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include enum mxc_gpio_direction { MXC_GPIO_DIRECTION_IN, @@ -263,12 +265,22 @@ static int mxc_gpio_get_function(struct udevice *dev, unsigned offset) return GPIOF_INPUT; } +static int mxc_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, + struct fdtdec_phandle_args *args) +{ + desc->offset = args->args[0]; + desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0; + + return 0; +} + static const struct dm_gpio_ops gpio_mxc_ops = { .direction_input = mxc_gpio_direction_input, .direction_output = mxc_gpio_direction_output, .get_value = mxc_gpio_get_value, .set_value = mxc_gpio_set_value, .get_function = mxc_gpio_get_function, + .xlate = mxc_gpio_xlate, }; static int mxc_gpio_probe(struct udevice *dev) -- 2.6.2