Re: PIXIS gpio controller and gpio flags
From: Trent Piepho
Date: Mon Jul 21 2008 - 17:13:12 EST
On Mon, 21 Jul 2008, Anton Vorontsov wrote:
> On Sat, Jul 19, 2008 at 02:08:01PM -0700, Trent Piepho wrote:
>> It doesn't look like you have any way to unset the active low flag. What if
>> I unload the leds-gpio driver (or another gpio user) and then try to use the
>> gpio with something else? The active low flag is stuck on!
> Why would you want to unset the flags? It is specified in the device
> tree, and can't be changed. Specifying different flags for the same GPIO
> would be an error (plus, Linux forbids shared gpios, so you simply can't
> specify one gpio for several devices).
You can't use the same gpio for two different things at the same time, but you
can load a driver, unload it, and then load another.
>> Most gpio users, including leds-gpio, can handle gpios being busy. If
>> leds-gpio can't get one of the gpios, it rolls back all the leds it did
>> create, doesn't drive the device and returns EBUSY. Except with
>> of_get_gpio() setting the flags, it will change the flags out from under
>> whatever had the gpio already allocated!
> You're still assuming that something was allocated. It wasn't. The flag
> was set, and it should not change. It is irrelevant if request() failed
> or not.
Another driver has requested the gpio with active low NOT set. Then the led
driver looks up the property with active low set, which changes the flags.
When it tries to request the gpio it fails since the gpio is already in use.
The led driver handles this failure. Except the active low flag is now set
and the driver that was using the gpio before will now mysteriously stop
working. Perhaps by erasing flash instead of reading it or something nasty
Is this the proper way to handle a dts mistake that has two drivers trying to
use the same gpio? Without the gpio flags getting set when looking up the
gpio, this situation is handled without any difficulty.
And is having a gpio used twice in the device tree really a mistake? What if
there are two different devices that can be attached to the gpios? For
example, an LED bank that can be unplugged and a serial console attached in
its place, sharing the same connector and gpios. Other than gpio flags
getting set when looking up a gpio, it works fine to list both devices in the
device tree as long as userspace has the correct driver loaded first.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/