lkml.org 
[lkml]   [2009]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 1/2] cs5535-gpio: add AMD CS5535/CS5536 GPIO driver support
Date
On Thursday 11 June 2009, Andres Salomon wrote:
>
> > I mentioned this in an ealier mail too. When I request the GPIO from
> > userspace the direction file always contains "in", so I thought
> > this is the standard direction after resetting as I should be in a
> > defined state after requesting. But I didn't found anything
> > about this in GPIO lib documentation, so I would be fine to change
> > this if there is any common default behavoir.
>
> To be honest, I'd have to play around with it a bit before I
> knew whether it actually breaks anything or not. I'm not sure if
> it would break anything on OLPC, and I don't have any other geode
> machines that do anything interesting w/ GPIOs.
>
> Maybe David can clear up whether this behavior is correct from the
> userspace GPIO usage standpoint..

Correct-but-annoying ... and maybe worth changing. The
direction *displayed* may not reflect the actual hardware
until after that GPIO signal is initialized. Boot firmware
may well have set the direction; Linux shouldn't change it
without explicit instructions to do so.

The issue is that when it first comes up, nobody has tod
Linux that direction ... so instead of defining an "unknown"
state, that code applies a heuristic. In gpiochip_add():

for (id = base; id < base + chip->ngpio; id++) {
gpio_desc[id].chip = chip;

/* REVISIT: most hardware initializes GPIOs as
* inputs (often with pullups enabled) so power
* usage is minimized. Linux code should set the
* gpio direction first thing; but until it does,
* we may expose the wrong direction in sysfs.
*/
gpio_desc[id].flags = !chip->direction_input
? (1 << FLAG_IS_OUT)
: 0;
}

Now, as far as heuristics go that one seems to cover most
of the common cases. But like all heuristics, the result
produced may be wrong.

So it would be nice to remove the heuristic. The best
way would be to add a new method to query gpio direction.
Then that when it's available, instead of the heuristic.

- Dave



\
 
 \ /
  Last update: 2009-07-02 00:35    [W:0.086 / U:1.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site