Message ID | 9be9017e32432390c565202b1e61a81eb66a6b27.camel@googlemail.com |
---|---|
State | Accepted |
Commit | 0539d16d22f65b5958800489701249f990531073 |
Delegated to: | Stefano Babic |
Headers | show |
Series | [RESEND] gpio: rgpio2p: Enhance reading of GPIO pin value | expand |
Hello Stefano, could you please pick up this patch? bye -- Christoph On Tue, 2022-04-05 at 12:29 +0200, Christoph Fritz wrote: > Add support for reading GPIO pin value when function is output. > With this patch applied, gpio toggle command is working. > > Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> > Reviewed-by: Peng Fan <peng.fan@nxp.com> > Reviewed-by: Fabio Estevam <festevam@denx.de> > --- > drivers/gpio/imx_rgpio2p.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c > index 0e2874ca95c..175e460aff5 100644 > --- a/drivers/gpio/imx_rgpio2p.c > +++ b/drivers/gpio/imx_rgpio2p.c > @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs > *regs, int offset) > return val & (1 << offset) ? 1 : 0; > } > > +static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, > int offset) > +{ > + if ((readl(®s->gpio_pddr) >> offset) & 0x01) > + return IMX_RGPIO2P_DIRECTION_OUT; > + > + return IMX_RGPIO2P_DIRECTION_IN; > +} > + > static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int > offset, > enum imx_rgpio2p_direction > direction) > { > @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct > gpio_regs *regs, int offset, > > static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int > offset) > { > - return (readl(®s->gpio_pdir) >> offset) & 0x01; > + if (imx_rgpio2p_bank_get_direction(regs, offset) == > + IMX_RGPIO2P_DIRECTION_IN) > + return (readl(®s->gpio_pdir) >> offset) & 0x01; > + > + return (readl(®s->gpio_pdor) >> offset) & 0x01; > } > > static int imx_rgpio2p_direction_input(struct udevice *dev, > unsigned offset)
*ping* On Sat, 2022-04-23 at 22:37 +0200, Christoph Fritz wrote: > Hello Stefano, > > could you please pick up this patch? > > bye > -- Christoph > > On Tue, 2022-04-05 at 12:29 +0200, Christoph Fritz wrote: > > Add support for reading GPIO pin value when function is output. > > With this patch applied, gpio toggle command is working. > > > > Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> > > Reviewed-by: Peng Fan <peng.fan@nxp.com> > > Reviewed-by: Fabio Estevam <festevam@denx.de> > > --- > > drivers/gpio/imx_rgpio2p.c | 14 +++++++++++++- > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c > > index 0e2874ca95c..175e460aff5 100644 > > --- a/drivers/gpio/imx_rgpio2p.c > > +++ b/drivers/gpio/imx_rgpio2p.c > > @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs > > *regs, int offset) > > return val & (1 << offset) ? 1 : 0; > > } > > > > +static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, > > int offset) > > +{ > > + if ((readl(®s->gpio_pddr) >> offset) & 0x01) > > + return IMX_RGPIO2P_DIRECTION_OUT; > > + > > + return IMX_RGPIO2P_DIRECTION_IN; > > +} > > + > > static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int > > offset, > > enum imx_rgpio2p_direction > > direction) > > { > > @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct > > gpio_regs *regs, int offset, > > > > static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int > > offset) > > { > > - return (readl(®s->gpio_pdir) >> offset) & 0x01; > > + if (imx_rgpio2p_bank_get_direction(regs, offset) == > > + IMX_RGPIO2P_DIRECTION_IN) > > + return (readl(®s->gpio_pdir) >> offset) & 0x01; > > + > > + return (readl(®s->gpio_pdor) >> offset) & 0x01; > > } > > > > static int imx_rgpio2p_direction_input(struct udevice *dev, > > unsigned offset) >
On 21.05.22 02:17, Christoph Fritz wrote: > *ping* > > On Sat, 2022-04-23 at 22:37 +0200, Christoph Fritz wrote: >> Hello Stefano, >> >> could you please pick up this patch? >> >> bye >> -- Christoph >> >> On Tue, 2022-04-05 at 12:29 +0200, Christoph Fritz wrote: >>> Add support for reading GPIO pin value when function is output. >>> With this patch applied, gpio toggle command is working. >>> >>> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> >>> Reviewed-by: Peng Fan <peng.fan@nxp.com> >>> Reviewed-by: Fabio Estevam <festevam@denx.de> >>> --- >>> drivers/gpio/imx_rgpio2p.c | 14 +++++++++++++- >>> 1 file changed, 13 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c >>> index 0e2874ca95c..175e460aff5 100644 >>> --- a/drivers/gpio/imx_rgpio2p.c >>> +++ b/drivers/gpio/imx_rgpio2p.c >>> @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs >>> *regs, int offset) >>> return val & (1 << offset) ? 1 : 0; >>> } >>> >>> +static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, >>> int offset) >>> +{ >>> + if ((readl(®s->gpio_pddr) >> offset) & 0x01) >>> + return IMX_RGPIO2P_DIRECTION_OUT; >>> + >>> + return IMX_RGPIO2P_DIRECTION_IN; >>> +} >>> + >>> static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int >>> offset, >>> enum imx_rgpio2p_direction >>> direction) >>> { >>> @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct >>> gpio_regs *regs, int offset, >>> >>> static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int >>> offset) >>> { >>> - return (readl(®s->gpio_pdir) >> offset) & 0x01; >>> + if (imx_rgpio2p_bank_get_direction(regs, offset) == >>> + IMX_RGPIO2P_DIRECTION_IN) >>> + return (readl(®s->gpio_pdir) >> offset) & 0x01; >>> + >>> + return (readl(®s->gpio_pdor) >> offset) & 0x01; >>> } >>> >>> static int imx_rgpio2p_direction_input(struct udevice *dev, >>> unsigned offset) >> > Picked up, it will go in next MR Best regards, Stefano Babic
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c index 0e2874ca95c..175e460aff5 100644 --- a/drivers/gpio/imx_rgpio2p.c +++ b/drivers/gpio/imx_rgpio2p.c @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs *regs, int offset) return val & (1 << offset) ? 1 : 0; } +static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, int offset) +{ + if ((readl(®s->gpio_pddr) >> offset) & 0x01) + return IMX_RGPIO2P_DIRECTION_OUT; + + return IMX_RGPIO2P_DIRECTION_IN; +} + static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int offset, enum imx_rgpio2p_direction direction) { @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct gpio_regs *regs, int offset, static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int offset) { - return (readl(®s->gpio_pdir) >> offset) & 0x01; + if (imx_rgpio2p_bank_get_direction(regs, offset) == + IMX_RGPIO2P_DIRECTION_IN) + return (readl(®s->gpio_pdir) >> offset) & 0x01; + + return (readl(®s->gpio_pdor) >> offset) & 0x01; } static int imx_rgpio2p_direction_input(struct udevice *dev, unsigned offset)