linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* gpio-mxc gpio get always returns 0 for outputs for IMX6
@ 2014-07-11 15:34 Tim Harvey
  2014-07-11 16:02 ` Russell King - ARM Linux
  2014-07-14  7:04 ` Shawn Guo
  0 siblings, 2 replies; 12+ messages in thread
From: Tim Harvey @ 2014-07-11 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

Shawn,

I've noticed that for IMX6 the gpio-mxc gpio driver always returns 0
for gpio's configured as outputs regardless of if they are outputing
high or low.

Digging into gpio-mxc.c I see that the basic memory-mapped generic
gpio controller is used, but its configured to use GPIO_PSR to obtain
the gpio value. For the IMX6 (I can't speak for the other MXC/IMX
users of this driver) the reference manual indicates that GPIO_PSR is
appropriate only if the GPIO is an input and that GPIO_DR will read
the proper state if its configured as an output or an input.

Even before the driver was converted to use the basic memory-mapped
generic gpio controller this was the case (GPIO_PSR used for get). Is
there a reason for this, or is it simply a bug that has been around
since the driver's original creation as I suspect?

The following patch resolves the issue and causes gpio get to always
return the proper setting when configured for an input or output:

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 7176743..25b97db 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -458,8 +458,8 @@ static int mxc_gpio_probe(struct platform_device *pdev)
        }

        err = bgpio_init(&port->bgc, &pdev->dev, 4,
-                        port->base + GPIO_PSR,
-                        port->base + GPIO_DR, NULL,
+                        port->base + GPIO_DR,
+                        NULL, NULL,
                         port->base + GPIO_GDIR, NULL, 0);
        if (err)
                goto out_iounmap;

If this looks right to you for all IMX users let me know and I'll post
a properly formatted patch with commit message.

Regards,

Tim

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

end of thread, other threads:[~2014-07-17  2:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 15:34 gpio-mxc gpio get always returns 0 for outputs for IMX6 Tim Harvey
2014-07-11 16:02 ` Russell King - ARM Linux
2014-07-11 16:16   ` Alexander Shiyan
2014-07-11 16:22     ` Russell King - ARM Linux
2014-07-14  3:01   ` Fabio Estevam
2014-07-14  7:04 ` Shawn Guo
2014-07-14 12:56   ` Benoît Thébaudeau
2014-07-14 14:05     ` Shawn Guo
2014-07-15 17:28       ` Tim Harvey
2014-07-16  6:01         ` Shawn Guo
2014-07-16 19:14           ` Benoît Thébaudeau
2014-07-17  2:41             ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).