Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation / ACPI: update to GPIO descriptor API

Update the documentation also to reflect the fact that there are no ACPI
specific GPIO interfaces anymore but drivers should instead use the
descriptor based GPIO APIs.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Mika Westerberg and committed by
Linus Walleij
ccb6fbb9 5ccff852

+7 -29
+7 -29
Documentation/acpi/enumeration.txt
··· 293 293 294 294 These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 295 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 299 - resources one can use acpi_get_gpio_by_index() helper function. It takes 300 - pointer to the device and index of the GpioIo/GpioInt descriptor in the 301 - device resources list. For example: 298 + There is a standard GPIO API for that and is documented in 299 + Documentation/gpio.txt. 302 300 303 - int gpio_irq, gpio_power; 304 - int ret; 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: 301 + In the above example we can get the corresponding two GPIO descriptors with 302 + a code like this: 326 303 327 304 #include <linux/gpio/consumer.h> 328 305 ... ··· 316 339 317 340 /* Now we can use the GPIO descriptors */ 318 341 319 - See also Documentation/gpio.txt. 342 + There are also devm_* versions of these functions which release the 343 + descriptors once the device is released.