diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2013-10-10 04:01:09 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-10-19 17:31:37 -0400 |
commit | 81f59e9d138c3ba0bd0f97d4e14f856d987e3f1d (patch) | |
tree | 5f7eaefa918749407da0958a97096eba56a42500 /drivers/gpio | |
parent | 936e15dd2128eb5aa71251766f1176552b45f43c (diff) |
gpiolib / ACPI: add ACPI support for gpiod_get_index()
gpiod_get_index() and gpiod_get() are now the new preferred way to request
GPIOs. Add support for finding the corresponding GPIO descriptor from ACPI
namespace.
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 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9263c7b359b7..bee93c8c2361 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/seq_file.h> | 10 | #include <linux/seq_file.h> |
11 | #include <linux/gpio.h> | 11 | #include <linux/gpio.h> |
12 | #include <linux/of_gpio.h> | 12 | #include <linux/of_gpio.h> |
13 | #include <linux/acpi_gpio.h> | ||
13 | #include <linux/idr.h> | 14 | #include <linux/idr.h> |
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
15 | 16 | ||
@@ -2260,6 +2261,12 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
2260 | } | 2261 | } |
2261 | #endif | 2262 | #endif |
2262 | 2263 | ||
2264 | static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | ||
2265 | unsigned int idx, unsigned long *flags) | ||
2266 | { | ||
2267 | return acpi_get_gpiod_by_index(dev, idx, NULL); | ||
2268 | } | ||
2269 | |||
2263 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, | 2270 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, |
2264 | unsigned int idx, unsigned long *flags) | 2271 | unsigned int idx, unsigned long *flags) |
2265 | { | 2272 | { |
@@ -2361,6 +2368,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, | |||
2361 | if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) { | 2368 | if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) { |
2362 | dev_dbg(dev, "using device tree for GPIO lookup\n"); | 2369 | dev_dbg(dev, "using device tree for GPIO lookup\n"); |
2363 | desc = of_find_gpio(dev, con_id, idx, &flags); | 2370 | desc = of_find_gpio(dev, con_id, idx, &flags); |
2371 | } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { | ||
2372 | dev_dbg(dev, "using ACPI for GPIO lookup\n"); | ||
2373 | desc = acpi_find_gpio(dev, con_id, idx, &flags); | ||
2364 | } else { | 2374 | } else { |
2365 | dev_dbg(dev, "using lookup tables for GPIO lookup"); | 2375 | dev_dbg(dev, "using lookup tables for GPIO lookup"); |
2366 | desc = gpiod_find(dev, con_id, idx, &flags); | 2376 | desc = gpiod_find(dev, con_id, idx, &flags); |