aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe RICARD <christophe.ricard@gmail.com>2015-12-23 17:25:34 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-12-31 21:20:25 -0500
commit52044723cd27aed6dad655a3bdf6142a8239ce74 (patch)
treec0a6afa0467086e9f09887618cb7ec92f53132ec
parent55a93417c27c6ad1022d5f1121004c494735e8fa (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>
-rw-r--r--drivers/gpio/gpiolib-acpi.c33
-rw-r--r--drivers/gpio/gpiolib.c4
-rw-r--r--drivers/gpio/gpiolib.h3
3 files changed, 31 insertions, 9 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,
595int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) 600int 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}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4e4c3083ae56..5d8d7ab96916 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1879,7 +1879,7 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
1879 return desc; 1879 return desc;
1880 } 1880 }
1881 1881
1882 if (info.active_low) 1882 if (info.polarity == GPIO_ACTIVE_LOW)
1883 *flags |= GPIO_ACTIVE_LOW; 1883 *flags |= GPIO_ACTIVE_LOW;
1884 1884
1885 return desc; 1885 return desc;
@@ -2217,7 +2217,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
2217 2217
2218 desc = acpi_node_get_gpiod(fwnode, propname, 0, &info); 2218 desc = acpi_node_get_gpiod(fwnode, propname, 0, &info);
2219 if (!IS_ERR(desc)) 2219 if (!IS_ERR(desc))
2220 active_low = info.active_low; 2220 active_low = info.polarity == GPIO_ACTIVE_LOW;
2221 } 2221 }
2222 2222
2223 if (IS_ERR(desc)) 2223 if (IS_ERR(desc))
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 98ab08c0aa2d..5ac3b88a2e0a 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -26,7 +26,8 @@ struct acpi_device;
26 */ 26 */
27struct acpi_gpio_info { 27struct acpi_gpio_info {
28 bool gpioint; 28 bool gpioint;
29 bool active_low; 29 int polarity;
30 int triggering;
30}; 31};
31 32
32/* gpio suffixes used for ACPI and device tree lookup */ 33/* gpio suffixes used for ACPI and device tree lookup */