All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] dm: gpio: mxc: implement xlate function
Date: Tue, 15 Mar 2016 13:48:57 +0800	[thread overview]
Message-ID: <1458020937-994-2-git-send-email-van.freenix@gmail.com> (raw)
In-Reply-To: <1458020937-994-1-git-send-email-van.freenix@gmail.com>

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 <van.freenix@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 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 <common.h>
 #include <errno.h>
 #include <dm.h>
+#include <fdtdec.h>
 #include <malloc.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dt-bindings/gpio/gpio.h>
 
 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

  reply	other threads:[~2016-03-15  5:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15  5:48 [U-Boot] [PATCH 1/2] dm: gpio: mxc: fix mxc_gpio_bank_get_value Peng Fan
2016-03-15  5:48 ` Peng Fan [this message]
2016-03-16  3:32   ` [U-Boot] [PATCH 2/2] dm: gpio: mxc: implement xlate function Simon Glass
2016-04-11  5:28     ` Peng Fan
2016-04-11 14:56       ` Eric Nelson
2016-03-15 12:53 ` [U-Boot] [PATCH 1/2] dm: gpio: mxc: fix mxc_gpio_bank_get_value Fabio Estevam
2016-03-16  1:27   ` Peng Fan
2016-03-16 12:48     ` Fabio Estevam
2016-03-17  1:44       ` Peng Fan
2016-04-03 18:09         ` Stefano Babic
2016-04-05  5:04           ` Peng Fan
2016-04-09 18:35             ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458020937-994-2-git-send-email-van.freenix@gmail.com \
    --to=van.freenix@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.