Message ID | 1458020937-994-2-git-send-email-van.freenix@gmail.com |
---|---|
State | Superseded |
Delegated to: | Stefano Babic |
Headers | show |
On 14 March 2016 at 23:48, Peng Fan <van.freenix@gmail.com> wrote: > 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(+) Reviewed-by: Simon Glass <sjg@chromium.org>
On Tue, Mar 15, 2016 at 09:32:51PM -0600, Simon Glass wrote: >On 14 March 2016 at 23:48, Peng Fan <van.freenix@gmail.com> wrote: >> 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(+) > >Reviewed-by: Simon Glass <sjg@chromium.org> Will this patch be picked up? Or droped, since Eric is trying to add a common way. Thanks, Peng.
Hi Peng, On 04/10/2016 10:28 PM, Peng Fan wrote: > On Tue, Mar 15, 2016 at 09:32:51PM -0600, Simon Glass wrote: >> On 14 March 2016 at 23:48, Peng Fan <van.freenix@gmail.com> wrote: >>> 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(+) >> >> Reviewed-by: Simon Glass <sjg@chromium.org> > > Will this patch be picked up? Or droped, since Eric is trying to add a > common way. > I think this patch should be dropped.
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)
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(+)