All of lore.kernel.org
 help / color / mirror / Atom feed
* Incorrect GPIO value with Kernel 3.14.28
@ 2015-05-20 12:40 Yannick Calmettes
  2015-05-20 12:50 ` Otavio Salvador
  2015-05-20 12:50 ` Fabio Estevam
  0 siblings, 2 replies; 12+ messages in thread
From: Yannick Calmettes @ 2015-05-20 12:40 UTC (permalink / raw)
  To: meta-freescale

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

Dear all,

I'm currently use Kernel 3.14.28 with release BSP_3.14.28-1.0.1_patch 
(on a IMx6 DualLite). When I read the value of a GPIO it give me the bus 
value instead of the pin value.
For example when I read GPIO41 it returns me "0" or "512" (the pin is 
toggled every seconds), 512 corresponds to the bit 9 (41 - 32) of the bus.
The GPIO value was correct with kernel 3.10.53.

Regards,

Yannick
**

 

[-- Attachment #2: Type: text/html, Size: 1392 bytes --]

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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 12:40 Incorrect GPIO value with Kernel 3.14.28 Yannick Calmettes
@ 2015-05-20 12:50 ` Otavio Salvador
  2015-05-20 12:50 ` Fabio Estevam
  1 sibling, 0 replies; 12+ messages in thread
From: Otavio Salvador @ 2015-05-20 12:50 UTC (permalink / raw)
  To: Yannick Calmettes; +Cc: meta-freescale

On Wed, May 20, 2015 at 9:40 AM, Yannick Calmettes
<yannick.calmettes@analogway.com> wrote:
> I'm currently use Kernel 3.14.28 with release BSP_3.14.28-1.0.1_patch (on a
> IMx6 DualLite). When I read the value of a GPIO it give me the bus value
> instead of the pin value.
> For example when I read GPIO41 it returns me "0" or "512" (the pin is
> toggled every seconds), 512 corresponds to the bit 9 (41 - 32) of the bus.
> The GPIO value was correct with kernel 3.10.53.

You are likely missing the SION bit on the pin.

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 12:40 Incorrect GPIO value with Kernel 3.14.28 Yannick Calmettes
  2015-05-20 12:50 ` Otavio Salvador
@ 2015-05-20 12:50 ` Fabio Estevam
  2015-05-20 12:59   ` Yannick Calmettes
  1 sibling, 1 reply; 12+ messages in thread
From: Fabio Estevam @ 2015-05-20 12:50 UTC (permalink / raw)
  To: Yannick Calmettes; +Cc: meta-freescale

On Wed, May 20, 2015 at 9:40 AM, Yannick Calmettes
<yannick.calmettes@analogway.com> wrote:
> Dear all,
>
> I'm currently use Kernel 3.14.28 with release BSP_3.14.28-1.0.1_patch (on a
> IMx6 DualLite). When I read the value of a GPIO it give me the bus value
> instead of the pin value.
> For example when I read GPIO41 it returns me "0" or "512" (the pin is
> toggled every seconds), 512 corresponds to the bit 9 (41 - 32) of the bus.
> The GPIO value was correct with kernel 3.10.53.

Are you setting the SION bit in the pad configuration?

Regards,

Fabio Estevam


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 12:50 ` Fabio Estevam
@ 2015-05-20 12:59   ` Yannick Calmettes
  2015-05-20 13:07     ` Fabio Estevam
  0 siblings, 1 reply; 12+ messages in thread
From: Yannick Calmettes @ 2015-05-20 12:59 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: meta-freescale

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

Dear Fabio,

I read the value through sysfs. In DTS file i have configured the GPIO 
with value 0x80000000 (no configuration normally)

Yannick
**
Le 20/05/2015 14:50, Fabio Estevam a écrit :
> On Wed, May 20, 2015 at 9:40 AM, Yannick Calmettes
> <yannick.calmettes@analogway.com> wrote:
>> Dear all,
>>
>> I'm currently use Kernel 3.14.28 with release BSP_3.14.28-1.0.1_patch (on a
>> IMx6 DualLite). When I read the value of a GPIO it give me the bus value
>> instead of the pin value.
>> For example when I read GPIO41 it returns me "0" or "512" (the pin is
>> toggled every seconds), 512 corresponds to the bit 9 (41 - 32) of the bus.
>> The GPIO value was correct with kernel 3.10.53.
> Are you setting the SION bit in the pad configuration?
>
> Regards,
>
> Fabio Estevam
>
>
>
>


 

[-- Attachment #2: Type: text/html, Size: 2134 bytes --]

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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 12:59   ` Yannick Calmettes
@ 2015-05-20 13:07     ` Fabio Estevam
  2015-05-20 13:17       ` Yannick Calmettes
  0 siblings, 1 reply; 12+ messages in thread
From: Fabio Estevam @ 2015-05-20 13:07 UTC (permalink / raw)
  To: Yannick Calmettes; +Cc: meta-freescale

On Wed, May 20, 2015 at 9:59 AM, Yannick Calmettes
<yannick.calmettes@analogway.com> wrote:
> Dear Fabio,
>
> I read the value through sysfs. In DTS file i have configured the GPIO with
> value 0x80000000 (no configuration normally)

Please try 0xc0000000 instead.

Regards,

Fabio Estevam


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 13:07     ` Fabio Estevam
@ 2015-05-20 13:17       ` Yannick Calmettes
  2015-05-20 13:25         ` Fabio Estevam
  0 siblings, 1 reply; 12+ messages in thread
From: Yannick Calmettes @ 2015-05-20 13:17 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: meta-freescale

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

Sorry Fabio, it stills return 512.
**
Le 20/05/2015 15:07, Fabio Estevam a écrit :
> On Wed, May 20, 2015 at 9:59 AM, Yannick Calmettes
> <yannick.calmettes@analogway.com> wrote:
>> Dear Fabio,
>>
>> I read the value through sysfs. In DTS file i have configured the GPIO with
>> value 0x80000000 (no configuration normally)
> Please try 0xc0000000 instead.
>
> Regards,
>
> Fabio Estevam
>
>
>
>


 

[-- Attachment #2: Type: text/html, Size: 1712 bytes --]

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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 13:25         ` Fabio Estevam
@ 2015-05-20 13:23           ` Yannick Calmettes
  2015-05-20 13:34           ` Gary Thomas
  1 sibling, 0 replies; 12+ messages in thread
From: Yannick Calmettes @ 2015-05-20 13:23 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: meta-freescale

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

You can see below all the things I do related to this GPIO.
In 3.10.53 it returns "1".

*In DTS :*
MX6QDL_PAD_SD4_DAT1__GPIO2_IO09 0xC0000000

*At startup :*
echo 41 > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio41/direction

*On Terminal :*
root@mx6dl-rev0-main:~# cat /sys/class/gpio/gpio41/value
512

Yannick

**
Le 20/05/2015 15:25, Fabio Estevam a écrit :
> On Wed, May 20, 2015 at 10:17 AM, Yannick Calmettes
> <yannick.calmettes@analogway.com> wrote:
>> Sorry Fabio, it stills return 512.
> How do you read the pins exactly? From kernel or from userspace?
>
> What was the response in 3.10.53?
>
> Regards,
>
> Fabio Estevam
>
>
>
>


 

[-- Attachment #2: Type: text/html, Size: 2127 bytes --]

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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 13:17       ` Yannick Calmettes
@ 2015-05-20 13:25         ` Fabio Estevam
  2015-05-20 13:23           ` Yannick Calmettes
  2015-05-20 13:34           ` Gary Thomas
  0 siblings, 2 replies; 12+ messages in thread
From: Fabio Estevam @ 2015-05-20 13:25 UTC (permalink / raw)
  To: Yannick Calmettes; +Cc: meta-freescale

On Wed, May 20, 2015 at 10:17 AM, Yannick Calmettes
<yannick.calmettes@analogway.com> wrote:
> Sorry Fabio, it stills return 512.

How do you read the pins exactly? From kernel or from userspace?

What was the response in 3.10.53?

Regards,

Fabio Estevam


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 13:25         ` Fabio Estevam
  2015-05-20 13:23           ` Yannick Calmettes
@ 2015-05-20 13:34           ` Gary Thomas
  2015-05-20 15:15             ` Yannick Calmettes
  1 sibling, 1 reply; 12+ messages in thread
From: Gary Thomas @ 2015-05-20 13:34 UTC (permalink / raw)
  To: meta-freescale

On 2015-05-20 07:25, Fabio Estevam wrote:
> On Wed, May 20, 2015 at 10:17 AM, Yannick Calmettes
> <yannick.calmettes@analogway.com> wrote:
>> Sorry Fabio, it stills return 512.
>
> How do you read the pins exactly? From kernel or from userspace?
>
> What was the response in 3.10.53?

I assume he's using SYSFS

The GPIO driver (drivers/gpio/gpiolib.c) changed behaviour between
these two versions.  In 3.10.53, it will show either 0 or 1.  In
3.14.28 it will show the exact bit value as Yannick is experiencing.

You could try this patch (untested):

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 50c4922..45aa695 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -376,7 +376,7 @@ static ssize_t gpio_value_show(struct device *dev,
         if (!test_bit(FLAG_EXPORT, &desc->flags))
                 status = -EIO;
         else
-               status = sprintf(buf, "%d\n", gpiod_get_value_cansleep(desc));
+               status = sprintf(buf, "%d\n", !!gpiod_get_value_cansleep(desc));

         mutex_unlock(&sysfs_lock);
         return status;


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 13:34           ` Gary Thomas
@ 2015-05-20 15:15             ` Yannick Calmettes
  2015-05-20 15:32               ` Gary Thomas
  0 siblings, 1 reply; 12+ messages in thread
From: Yannick Calmettes @ 2015-05-20 15:15 UTC (permalink / raw)
  To: meta-freescale

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

Thank you Gary and Fabio, it works.

Yannick
**
Le 20/05/2015 15:34, Gary Thomas a écrit :
> On 2015-05-20 07:25, Fabio Estevam wrote:
>> On Wed, May 20, 2015 at 10:17 AM, Yannick Calmettes
>> <yannick.calmettes@analogway.com> wrote:
>>> Sorry Fabio, it stills return 512.
>>
>> How do you read the pins exactly? From kernel or from userspace?
>>
>> What was the response in 3.10.53?
>
> I assume he's using SYSFS
>
> The GPIO driver (drivers/gpio/gpiolib.c) changed behaviour between
> these two versions.  In 3.10.53, it will show either 0 or 1.  In
> 3.14.28 it will show the exact bit value as Yannick is experiencing.
>
> You could try this patch (untested):
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 50c4922..45aa695 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -376,7 +376,7 @@ static ssize_t gpio_value_show(struct device *dev,
>         if (!test_bit(FLAG_EXPORT, &desc->flags))
>                 status = -EIO;
>         else
> -               status = sprintf(buf, "%d\n", 
> gpiod_get_value_cansleep(desc));
> +               status = sprintf(buf, "%d\n", 
> !!gpiod_get_value_cansleep(desc));
>
>         mutex_unlock(&sysfs_lock);
>         return status;
>
>


 

[-- Attachment #2: Type: text/html, Size: 3039 bytes --]

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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 15:15             ` Yannick Calmettes
@ 2015-05-20 15:32               ` Gary Thomas
  2015-05-20 15:36                 ` Fabio Estevam
  0 siblings, 1 reply; 12+ messages in thread
From: Gary Thomas @ 2015-05-20 15:32 UTC (permalink / raw)
  To: meta-freescale

On 2015-05-20 09:15, Yannick Calmettes wrote:
> Thank you Gary and Fabio, it works.

Good to hear.

Fabio et al, what's the best way to push this?  Should it be pushed?

> **
> Le 20/05/2015 15:34, Gary Thomas a écrit :
>> On 2015-05-20 07:25, Fabio Estevam wrote:
>>> On Wed, May 20, 2015 at 10:17 AM, Yannick Calmettes
>>> <yannick.calmettes@analogway.com> wrote:
>>>> Sorry Fabio, it stills return 512.
>>>
>>> How do you read the pins exactly? From kernel or from userspace?
>>>
>>> What was the response in 3.10.53?
>>
>> I assume he's using SYSFS
>>
>> The GPIO driver (drivers/gpio/gpiolib.c) changed behaviour between
>> these two versions.  In 3.10.53, it will show either 0 or 1.  In
>> 3.14.28 it will show the exact bit value as Yannick is experiencing.
>>
>> You could try this patch (untested):
>>
>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>> index 50c4922..45aa695 100644
>> --- a/drivers/gpio/gpiolib.c
>> +++ b/drivers/gpio/gpiolib.c
>> @@ -376,7 +376,7 @@ static ssize_t gpio_value_show(struct device *dev,
>>         if (!test_bit(FLAG_EXPORT, &desc->flags))
>>                 status = -EIO;
>>         else
>> -               status = sprintf(buf, "%d\n", gpiod_get_value_cansleep(desc));
>> +               status = sprintf(buf, "%d\n", !!gpiod_get_value_cansleep(desc));
>>
>>         mutex_unlock(&sysfs_lock);
>>         return status;
>>
>>
>
>
>
>
>
>
>

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


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

* Re: Incorrect GPIO value with Kernel 3.14.28
  2015-05-20 15:32               ` Gary Thomas
@ 2015-05-20 15:36                 ` Fabio Estevam
  0 siblings, 0 replies; 12+ messages in thread
From: Fabio Estevam @ 2015-05-20 15:36 UTC (permalink / raw)
  To: Gary Thomas; +Cc: meta-freescale

On Wed, May 20, 2015 at 12:32 PM, Gary Thomas <gary@mlbassoc.com> wrote:
> On 2015-05-20 09:15, Yannick Calmettes wrote:
>>
>> Thank you Gary and Fabio, it works.
>
>
> Good to hear.
>
> Fabio et al, what's the best way to push this?  Should it be pushed?

I think it does as we should not break userspace.

Please preapare a patch for the 3.14 kernel and send it here.

Regards,

Fabio Estevam


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

end of thread, other threads:[~2015-05-20 15:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 12:40 Incorrect GPIO value with Kernel 3.14.28 Yannick Calmettes
2015-05-20 12:50 ` Otavio Salvador
2015-05-20 12:50 ` Fabio Estevam
2015-05-20 12:59   ` Yannick Calmettes
2015-05-20 13:07     ` Fabio Estevam
2015-05-20 13:17       ` Yannick Calmettes
2015-05-20 13:25         ` Fabio Estevam
2015-05-20 13:23           ` Yannick Calmettes
2015-05-20 13:34           ` Gary Thomas
2015-05-20 15:15             ` Yannick Calmettes
2015-05-20 15:32               ` Gary Thomas
2015-05-20 15:36                 ` 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.