diff options
author | Christophe RICARD <christophe.ricard@gmail.com> | 2015-12-23 17:25:34 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-31 21:20:25 -0500 |
commit | 52044723cd27aed6dad655a3bdf6142a8239ce74 (patch) | |
tree | c0a6afa0467086e9f09887618cb7ec92f53132ec /drivers/gpio/gpiolib-acpi.c | |
parent | 55a93417c27c6ad1022d5f1121004c494735e8fa (diff) |
ACPI / gpio: Add irq_type when a GPIO is used as an interrupt
When a GPIO is used as an interrupt in ACPI, the irq_type was not
available for device driver.
Make available polarity and triggering information in acpi_find_gpio by
renaming acpi_gpio_info field active_low to polarity and adding triggering
field (edge/level).
For sanity, in gpiolib.c replace info.active_low by
"info.polarity == GPIO_ACTIVE_LOW".
Set the irq_type if necessary in acpi_dev_gpio_irq_get.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/gpio/gpiolib-acpi.c')
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 16a7b6816744..cbbb67a6f1d6 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -417,10 +417,15 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data) | |||
417 | * ActiveLow is only specified for GpioInt resource. If | 417 | * ActiveLow is only specified for GpioInt resource. If |
418 | * GpioIo is used then the only way to set the flag is | 418 | * GpioIo is used then the only way to set the flag is |
419 | * to use _DSD "gpios" property. | 419 | * to use _DSD "gpios" property. |
420 | * Note: we expect here: | ||
421 | * - ACPI_ACTIVE_LOW == GPIO_ACTIVE_LOW | ||
422 | * - ACPI_ACTIVE_HIGH == GPIO_ACTIVE_HIGH | ||
420 | */ | 423 | */ |
421 | if (lookup->info.gpioint) | 424 | if (lookup->info.gpioint) { |
422 | lookup->info.active_low = | 425 | lookup->info.polarity = agpio->polarity; |
423 | agpio->polarity == ACPI_ACTIVE_LOW; | 426 | lookup->info.triggering = agpio->triggering; |
427 | } | ||
428 | |||
424 | } | 429 | } |
425 | 430 | ||
426 | return 1; | 431 | return 1; |
@@ -447,7 +452,7 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup, | |||
447 | if (info) { | 452 | if (info) { |
448 | *info = lookup->info; | 453 | *info = lookup->info; |
449 | if (lookup->active_low) | 454 | if (lookup->active_low) |
450 | info->active_low = lookup->active_low; | 455 | info->polarity = lookup->active_low; |
451 | } | 456 | } |
452 | return 0; | 457 | return 0; |
453 | } | 458 | } |
@@ -595,6 +600,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, | |||
595 | int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | 600 | int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) |
596 | { | 601 | { |
597 | int idx, i; | 602 | int idx, i; |
603 | unsigned int irq_flags; | ||
598 | 604 | ||
599 | for (i = 0, idx = 0; idx <= index; i++) { | 605 | for (i = 0, idx = 0; idx <= index; i++) { |
600 | struct acpi_gpio_info info; | 606 | struct acpi_gpio_info info; |
@@ -603,8 +609,23 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | |||
603 | desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); | 609 | desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); |
604 | if (IS_ERR(desc)) | 610 | if (IS_ERR(desc)) |
605 | break; | 611 | break; |
606 | if (info.gpioint && idx++ == index) | 612 | if (info.gpioint && idx++ == index) { |
607 | return gpiod_to_irq(desc); | 613 | int irq = gpiod_to_irq(desc); |
614 | |||
615 | if (irq < 0) | ||
616 | return irq; | ||
617 | |||
618 | irq_flags = acpi_dev_get_irq_type(info.triggering, | ||
619 | info.polarity); | ||
620 | |||
621 | /* Set type if specified and different than the current one */ | ||
622 | if (irq_flags != IRQ_TYPE_NONE && | ||
623 | irq_flags != irq_get_trigger_type(irq)) | ||
624 | irq_set_irq_type(irq, irq_flags); | ||
625 | |||
626 | return irq; | ||
627 | } | ||
628 | |||
608 | } | 629 | } |
609 | return -ENOENT; | 630 | return -ENOENT; |
610 | } | 631 | } |