lkml.org 
[lkml]   [2014]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: GPIO bindings guidelines (Was: Re: [PATCH v5 10/12] gpio: Support for unified device properties interface)
On Wed, Oct 22, 2014 at 04:07:08PM +0200, Rafael J. Wysocki wrote:
> Moreover, we need to clarify what situation we're really talking about.
>
> For one, drivers using the unified interface only will always use names for
> GPIOs, because they have to assume that either a DT or ACPI w/ _DSD is present.
> This is the cost of keeping those drivers firmware interface agnostic.
>
> So it looks like we're not talking about this case here.

We are talking about the case of rfkill-gpio.c where it definitely wants
to use properties for the GPIOs but it cannot be sure if the underlying
firmware provides _DSD or not.

> Now, if there's no DT or no _DSD in the ACPI tables for the given device
> *and* the driver wants to use its GPIOs anyway, it has to be ACPI-aware to
> some extent, because in that case the device ID it has been matched against
> tells it what the meaning of the GpioIo resources in the _CRS is.
>
> Then, the driver needs to do something like:
>
> if (!device_property_present(dev, "known_property_that_should_be_present")
> && ACPI_COMPANION(dev))
> acpi_probe_gpios(dev);

Indeed we can use similar pattern to detect if we have _DSD present or
not.

> and in the acpi_probe_gpios() routine there may be checks like:
>
> if (device_has_id(dev, "MARY0001")) {
> The first pin in the first GpioIo resource in _CRS is "fred" and
> it is active-low.
> The third pin in the second GpioIo resource in _CRS is "steve"
> and it is not active-low.
> } else if (device_has_id(dev, "JANE0002")) {
> The first pin in the second GpioIo resource in _CRS is "fred" and
> it is not active-low.
> The second pin in the first GpioIo resource in _CRS is "steve"
> and it is active-low.
> }
>
> and so on. Of course, there may be drivers knowing that the meaning of the
> GpioIo resources in _CRS is the same for all devices handled by them, in which
> case they will not need to check device IDs, but the core has now way of
> knowing that. Only the drivers have that information and the core has now
> way to figure out what to do for a given specific device.
>
> So here's a radical idea: Why don't we introduce something like
>
> acpi_enumerate_gpio(dev, name, GpioIo_index, pin_index, active_low)
>
> such that after calling, say, acpi_enumerate_gpio(dev, "fred", 0, 0, true) the
> driver can do something like:
>
> desc = get_gpiod_by_name(dev, "fred");
>
> and it'll all work. Then, the only part of the driver that really needs to be
> ACPI-specific will be the acpi_probe_gpios() function calling acpi_enumerate_gpio()
> in accordance with what the device ID is.
>
> Thoughts?

I think this is good idea. It solves the rfkill-gpio.c problem with just
small amount of ACPI specific code.


\
 
 \ /
  Last update: 2014-10-22 17:41    [W:0.119 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site