aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorEnrico Granata <egranata@chromium.org>2019-02-11 14:01:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-12 04:36:49 -0500
commitdaaef255dc96834aaaad627d3271504cba3ac2dc (patch)
tree7aca979c0f93f168e293a0b941e510e575abec6f /drivers/base/platform.c
parent4417967bf2479020652049155c11a2d5b3a0136e (diff)
driver: platform: Support parsing GpioInt 0 in platform_get_irq()
ACPI 5 added support for GpioInt resources as a way to provide information about interrupts mediated via a GPIO controller. Several device buses (e.g. SPI, I2C) have support for retrieving an IRQ specified via this type of resource, and providing it directly to the driver as an IRQ number. This is not currently done for the platform drivers, as platform_get_irq() does not try to parse GpioInt() resources. This requires drivers to either have to support only one possible IRQ resource, or to have code in place to try both as a failsafe. While there is a possibility of ambiguity for devices that exposes multiple IRQs, it is easy and feasible to support the common case of devices that only expose one IRQ which would be of either type depending on the underlying system's architecture. This commit adds support for parsing a GpioInt resource in order to fulfill a request for the index 0 IRQ for a platform device. Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Acked-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c958eb33ef4..0d3611cd1b3b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -127,7 +127,20 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
127 irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); 127 irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
128 } 128 }
129 129
130 return r ? r->start : -ENXIO; 130 if (r)
131 return r->start;
132
133 /*
134 * For the index 0 interrupt, allow falling back to GpioInt
135 * resources. While a device could have both Interrupt and GpioInt
136 * resources, making this fallback ambiguous, in many common cases
137 * the device will only expose one IRQ, and this fallback
138 * allows a common code path across either kind of resource.
139 */
140 if (num == 0 && has_acpi_companion(&dev->dev))
141 return acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
142
143 return -ENXIO;
131#endif 144#endif
132} 145}
133EXPORT_SYMBOL_GPL(platform_get_irq); 146EXPORT_SYMBOL_GPL(platform_get_irq);