Skip to content

Commit

Permalink
gpiolib / ACPI: allow passing GPIOF_ACTIVE_LOW for GpioInt resources
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mika Westerberg authored and Linus Walleij committed Oct 19, 2013
1 parent 81f59e9 commit e01f440
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions drivers/gpio/gpiolib-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions include/linux/acpi_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
/**
* 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
Expand Down

0 comments on commit e01f440

Please sign in to comment.