aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/acpi/enumeration.txt
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2013-04-03 06:56:54 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-04-11 18:31:18 -0400
commit12028d2d216220618f76284af5f8ed510b11da55 (patch)
tree9ecd94ba19b7a39354b4fdd5d85cf8e6a246ab90 /Documentation/acpi/enumeration.txt
parent2ce7c62d1b18dca13c715c6bc2eea17f723576ff (diff)
gpiolib-acpi: introduce acpi_get_gpio_by_index() helper
Instead of open-coding ACPI GPIO resource lookup in each driver, we provide a helper function analogous to Device Tree version that allows drivers to specify which GPIO resource they are interested (using an index to the GPIO resources). The function then finds out the correct resource, translates the ACPI GPIO number to the corresponding Linux GPIO number and returns that. 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>
Diffstat (limited to 'Documentation/acpi/enumeration.txt')
-rw-r--r--Documentation/acpi/enumeration.txt32
1 files changed, 31 insertions, 1 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index 94a656131885..b0d541042ac6 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -199,6 +199,8 @@ the device to the driver. For example:
199 { 199 {
200 Name (SBUF, ResourceTemplate() 200 Name (SBUF, ResourceTemplate()
201 { 201 {
202 ...
203 // Used to power on/off the device
202 GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, 204 GpioIo (Exclusive, PullDefault, 0x0000, 0x0000,
203 IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", 205 IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
204 0x00, ResourceConsumer,,) 206 0x00, ResourceConsumer,,)
@@ -206,10 +208,20 @@ the device to the driver. For example:
206 // Pin List 208 // Pin List
207 0x0055 209 0x0055
208 } 210 }
211
212 // Interrupt for the device
213 GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone,
214 0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,)
215 {
216 // Pin list
217 0x0058
218 }
219
209 ... 220 ...
210 221
211 Return (SBUF)
212 } 222 }
223
224 Return (SBUF)
213 } 225 }
214 226
215These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 227These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
@@ -220,6 +232,24 @@ The driver can do this by including <linux/acpi_gpio.h> and then calling
220acpi_get_gpio(path, gpio). This will return the Linux GPIO number or 232acpi_get_gpio(path, gpio). This will return the Linux GPIO number or
221negative errno if there was no translation found. 233negative errno if there was no translation found.
222 234
235In a simple case of just getting the Linux GPIO number from device
236resources one can use acpi_get_gpio_by_index() helper function. It takes
237pointer to the device and index of the GpioIo/GpioInt descriptor in the
238device resources list. For example:
239
240 int gpio_irq, gpio_power;
241 int ret;
242
243 gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
244 if (gpio_irq < 0)
245 /* handle error */
246
247 gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
248 if (gpio_power < 0)
249 /* handle error */
250
251 /* Now we can use the GPIO numbers */
252
223Other GpioIo parameters must be converted first by the driver to be 253Other GpioIo parameters must be converted first by the driver to be
224suitable to the gpiolib before passing them. 254suitable to the gpiolib before passing them.
225 255