diff options
-rw-r--r-- | Documentation/acpi/enumeration.txt | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt index b994bcb32b92..2a1519b87177 100644 --- a/Documentation/acpi/enumeration.txt +++ b/Documentation/acpi/enumeration.txt | |||
@@ -293,36 +293,13 @@ the device to the driver. For example: | |||
293 | 293 | ||
294 | These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" | 294 | 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 corresponding Linux GPIO descriptors. |
297 | 297 | ||
298 | In a simple case of just getting the Linux GPIO number from device | 298 | There is a standard GPIO API for that and is documented in |
299 | resources one can use acpi_get_gpio_by_index() helper function. It takes | 299 | Documentation/gpio.txt. |
300 | pointer to the device and index of the GpioIo/GpioInt descriptor in the | ||
301 | device resources list. For example: | ||
302 | 300 | ||
303 | int gpio_irq, gpio_power; | 301 | In the above example we can get the corresponding two GPIO descriptors with |
304 | int ret; | 302 | a code like this: |
305 | |||
306 | gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL); | ||
307 | if (gpio_irq < 0) | ||
308 | /* handle error */ | ||
309 | |||
310 | gpio_power = acpi_get_gpio_by_index(dev, 0, NULL); | ||
311 | if (gpio_power < 0) | ||
312 | /* handle error */ | ||
313 | |||
314 | /* Now we can use the GPIO numbers */ | ||
315 | |||
316 | Other GpioIo parameters must be converted first by the driver to be | ||
317 | suitable to the gpiolib before passing them. | ||
318 | |||
319 | In case of GpioInt resource an additional call to gpio_to_irq() must be | ||
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 | 303 | ||
327 | #include <linux/gpio/consumer.h> | 304 | #include <linux/gpio/consumer.h> |
328 | ... | 305 | ... |
@@ -339,4 +316,5 @@ when converted to the GPIO desc: | |||
339 | 316 | ||
340 | /* Now we can use the GPIO descriptors */ | 317 | /* Now we can use the GPIO descriptors */ |
341 | 318 | ||
342 | See also Documentation/gpio.txt. | 319 | There are also devm_* versions of these functions which release the |
320 | descriptors once the device is released. | ||