All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
@ 2022-04-05 10:29 Christoph Fritz
  2022-04-23 20:37 ` Christoph Fritz
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Fritz @ 2022-04-05 10:29 UTC (permalink / raw)
  To: Stefano Babic, Tom Rini; +Cc: u-boot, Peng Fan, Fabio Estevam

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(&regs->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(&regs->gpio_pdir) >> offset) & 0x01;
+	if (imx_rgpio2p_bank_get_direction(regs, offset) ==
+	    IMX_RGPIO2P_DIRECTION_IN)
+		return (readl(&regs->gpio_pdir) >> offset) & 0x01;
+
+	return (readl(&regs->gpio_pdor) >> offset) & 0x01;
 }
 
 static int  imx_rgpio2p_direction_input(struct udevice *dev, unsigned offset)
-- 
2.30.2




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
  2022-04-05 10:29 [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value Christoph Fritz
@ 2022-04-23 20:37 ` Christoph Fritz
  2022-05-21  0:17   ` Christoph Fritz
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Fritz @ 2022-04-23 20:37 UTC (permalink / raw)
  To: Stefano Babic; +Cc: u-boot, Peng Fan, Fabio Estevam, Tom Rini

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(&regs->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(&regs->gpio_pdir) >> offset) & 0x01;
> +       if (imx_rgpio2p_bank_get_direction(regs, offset) ==
> +           IMX_RGPIO2P_DIRECTION_IN)
> +               return (readl(&regs->gpio_pdir) >> offset) & 0x01;
> +
> +       return (readl(&regs->gpio_pdor) >> offset) & 0x01;
>  }
>  
>  static int  imx_rgpio2p_direction_input(struct udevice *dev,
> unsigned offset)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
  2022-04-23 20:37 ` Christoph Fritz
@ 2022-05-21  0:17   ` Christoph Fritz
  2022-05-21 13:35     ` Stefano Babic
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Fritz @ 2022-05-21  0:17 UTC (permalink / raw)
  To: Stefano Babic; +Cc: u-boot, Peng Fan, Fabio Estevam, Tom Rini

*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(&regs->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(&regs->gpio_pdir) >> offset) & 0x01;
> > +       if (imx_rgpio2p_bank_get_direction(regs, offset) ==
> > +           IMX_RGPIO2P_DIRECTION_IN)
> > +               return (readl(&regs->gpio_pdir) >> offset) & 0x01;
> > +
> > +       return (readl(&regs->gpio_pdor) >> offset) & 0x01;
> >  }
> >  
> >  static int  imx_rgpio2p_direction_input(struct udevice *dev,
> > unsigned offset)
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
  2022-05-21  0:17   ` Christoph Fritz
@ 2022-05-21 13:35     ` Stefano Babic
  0 siblings, 0 replies; 7+ messages in thread
From: Stefano Babic @ 2022-05-21 13:35 UTC (permalink / raw)
  To: chf.fritz, Stefano Babic; +Cc: u-boot, Peng Fan, Fabio Estevam, Tom Rini

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(&regs->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(&regs->gpio_pdir) >> offset) & 0x01;
>>> +       if (imx_rgpio2p_bank_get_direction(regs, offset) ==
>>> +           IMX_RGPIO2P_DIRECTION_IN)
>>> +               return (readl(&regs->gpio_pdir) >> offset) & 0x01;
>>> +
>>> +       return (readl(&regs->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

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
@ 2022-05-23 11:33 sbabic
  0 siblings, 0 replies; 7+ messages in thread
From: sbabic @ 2022-05-23 11:33 UTC (permalink / raw)
  To: Christoph Fritz, u-boot

> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
  2022-03-24 15:11 Christoph Fritz
@ 2022-03-24 16:00 ` Fabio Estevam
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Estevam @ 2022-03-24 16:00 UTC (permalink / raw)
  To: Christoph Fritz; +Cc: u-boot, Stefano Babic, Peng Fan

On Thu, Mar 24, 2022 at 12:11 PM Christoph Fritz
<chf.fritz@googlemail.com> 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>
> Cc: Fabio Estevam <festevam@gmail.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>

Reviewed-by: Fabio Estevam <festevam@denx.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value
@ 2022-03-24 15:11 Christoph Fritz
  2022-03-24 16:00 ` Fabio Estevam
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Fritz @ 2022-03-24 15:11 UTC (permalink / raw)
  To: u-boot, Stefano Babic; +Cc: Peng Fan, Fabio Estevam

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>
Cc: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
 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(&regs->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(&regs->gpio_pdir) >> offset) & 0x01;
+	if (imx_rgpio2p_bank_get_direction(regs, offset) ==
+	    IMX_RGPIO2P_DIRECTION_IN)
+		return (readl(&regs->gpio_pdir) >> offset) & 0x01;
+
+	return (readl(&regs->gpio_pdor) >> offset) & 0x01;
 }
 
 static int  imx_rgpio2p_direction_input(struct udevice *dev, unsigned offset)
-- 
2.30.2




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-23 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 10:29 [RESEND PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value Christoph Fritz
2022-04-23 20:37 ` Christoph Fritz
2022-05-21  0:17   ` Christoph Fritz
2022-05-21 13:35     ` Stefano Babic
  -- strict thread matches above, loose matches on Subject: below --
2022-05-23 11:33 sbabic
2022-03-24 15:11 Christoph Fritz
2022-03-24 16:00 ` Fabio Estevam

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.