gpiolib / ACPI: allow passing GPIOF_ACTIVE_LOW for GpioInt resources
authorMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 10 Oct 2013 08:01:10 +0000 (11:01 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 19 Oct 2013 21:32:14 +0000 (23:32 +0200)
The ACPI GpioInt resources contain polarity field that is used to specify
whether the interrupt is active high or low. Since gpiolib supports
GPIOF_ACTIVE_LOW we can pass this information in the flags field in
acpi_find_gpio(), analogous to the DeviceTree 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>
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib.c
include/linux/acpi_gpio.h

index 03187d0a30453786b7f8a560d5981cdb08da4975..ae0ffdce8bd57d4857b46cdc963f708923839982 100644 (file)
@@ -253,6 +253,8 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
                                              agpio->pin_table[0]);
                lookup->info.gpioint =
                        agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT;
+               lookup->info.active_low =
+                       agpio->polarity == ACPI_ACTIVE_LOW;
        }
 
        return 1;
index bee93c8c236169406441f403b8cf95d19774e403..9f3326b95e6063ddd4b718791253bdb705451f70 100644 (file)
@@ -2264,7 +2264,17 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
                                        unsigned int idx, unsigned long *flags)
 {
-       return acpi_get_gpiod_by_index(dev, idx, NULL);
+       struct acpi_gpio_info info;
+       struct gpio_desc *desc;
+
+       desc = acpi_get_gpiod_by_index(dev, idx, &info);
+       if (IS_ERR(desc))
+               return desc;
+
+       if (info.gpioint && info.active_low)
+               *flags |= GPIOF_ACTIVE_LOW;
+
+       return desc;
 }
 
 static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
index b6ce601e55a218ef1c6de236fa38374f73623417..d875bc3dba3cd044181e29be75084f328234d129 100644 (file)
 /**
  * struct acpi_gpio_info - ACPI GPIO specific information
  * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
+ * @active_low: in case of @gpioint, the pin is active low
  */
 struct acpi_gpio_info {
        bool gpioint;
+       bool active_low;
 };
 
 #ifdef CONFIG_GPIO_ACPI