diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2013-10-10 04:01:11 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-10-19 17:32:50 -0400 |
commit | 45f394391f93596782c6a5ec14f0a5428f60f9b3 (patch) | |
tree | 12e3c0a5b9f141ce53131cfd47bfda5cd63b428a /Documentation/acpi | |
parent | e01f440a689aeb2d0e81c696fe2069f8d01d5d49 (diff) |
gpiolib / ACPI: document the GPIO descriptor based interface
In addition to the existing ACPI specific GPIO interface, document the new
descriptor based GPIO interface in Documentation/acpi/enumeration.txt, so
it is clear that this new interface is preferred over the ACPI specific
version.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/acpi')
-rw-r--r-- | Documentation/acpi/enumeration.txt | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt index aca4e69121b7..b994bcb32b92 100644 --- a/Documentation/acpi/enumeration.txt +++ b/Documentation/acpi/enumeration.txt | |||
@@ -295,10 +295,6 @@ These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" | |||
295 | specifies the path to the controller. In order to use these GPIOs in Linux | 295 | specifies the path to the controller. In order to use these GPIOs in Linux |
296 | we need to translate them to the Linux GPIO numbers. | 296 | we need to translate them to the Linux GPIO numbers. |
297 | 297 | ||
298 | The driver can do this by including <linux/acpi_gpio.h> and then calling | ||
299 | acpi_get_gpio(path, gpio). This will return the Linux GPIO number or | ||
300 | negative errno if there was no translation found. | ||
301 | |||
302 | In a simple case of just getting the Linux GPIO number from device | 298 | In a simple case of just getting the Linux GPIO number from device |
303 | resources one can use acpi_get_gpio_by_index() helper function. It takes | 299 | resources one can use acpi_get_gpio_by_index() helper function. It takes |
304 | pointer to the device and index of the GpioIo/GpioInt descriptor in the | 300 | pointer to the device and index of the GpioIo/GpioInt descriptor in the |
@@ -322,3 +318,25 @@ suitable to the gpiolib before passing them. | |||
322 | 318 | ||
323 | In case of GpioInt resource an additional call to gpio_to_irq() must be | 319 | In case of GpioInt resource an additional call to gpio_to_irq() must be |
324 | done before calling request_irq(). | 320 | done before calling request_irq(). |
321 | |||
322 | Note that the above API is ACPI specific and not recommended for drivers | ||
323 | that need to support non-ACPI systems. The recommended way is to use | ||
324 | the descriptor based GPIO interfaces. The above example looks like this | ||
325 | when converted to the GPIO desc: | ||
326 | |||
327 | #include <linux/gpio/consumer.h> | ||
328 | ... | ||
329 | |||
330 | struct gpio_desc *irq_desc, *power_desc; | ||
331 | |||
332 | irq_desc = gpiod_get_index(dev, NULL, 1); | ||
333 | if (IS_ERR(irq_desc)) | ||
334 | /* handle error */ | ||
335 | |||
336 | power_desc = gpiod_get_index(dev, NULL, 0); | ||
337 | if (IS_ERR(power_desc)) | ||
338 | /* handle error */ | ||
339 | |||
340 | /* Now we can use the GPIO descriptors */ | ||
341 | |||
342 | See also Documentation/gpio.txt. | ||