Re: [PATCH 2/2] gpio/mxc: implement reading output gpio value
From: Eduardo Valentin
Date: Wed Aug 05 2015 - 14:02:28 EST
Hello Fabio,
On Wed, Aug 05, 2015 at 02:43:05PM -0300, Fabio Estevam wrote:
> Hi Eduardo,
>
> On Wed, Aug 5, 2015 at 2:23 PM, Eduardo Valentin <edubezval@xxxxxxxxx> wrote:
> > In current implementation, reading the value of an output gpio
> > always return 0. The reason is because when a gpio is configured
>
> Have you tried setting the SION bit for the pad?
No, I haven't. From the bit description, it looks like it does a
different thing of what we would achieve with this patch. The SION bit
is a overwrite to the pad configuration. That is, the pin will be INPUT
always.
We don't want to force it to be input. We simply want to be able to read
the value of an output GPIO. That is achievable by reading a different
register. In case the GPIO is configured as output, the GPIO block
documentation states its value can be read from GPIO_PSR.
This approach works fine, as the GPIO will be output and we can still
read its value.
Spotting this is very simple. A quick try on /sys/class/gpio/export on
a spare gpio would do it:
# echo $SPARE_GPIO > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio$SPARE_GPIO/direction
# echo 1 > /sys/class/gpio/gpio$SPARE_GPIO/value
# cat /sys/class/gpio/gpio$SPARE_GPIO/value
without the patch it would always return 0. With the patch in, you see
the read value corresponding the output of that pin (checked on scope,
for instance).
>
> This should fix the problem.
>
> Regards,
>
> Fabio Estevam
BR,
Eduardo Valentin
Attachment:
signature.asc
Description: Digital signature