aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorEnrico Granata <[email protected]>2019-02-11 19:01:12 +0000
committerGreg Kroah-Hartman <[email protected]>2019-02-12 09:36:49 +0000
commitdaaef255dc96834aaaad627d3271504cba3ac2dc (patch)
tree7aca979c0f93f168e293a0b941e510e575abec6f /drivers/base/platform.c
parentMerge tag 'topic/component-typed-2019-02-11' of git://anongit.freedesktop.org... (diff)
downloadkernel-daaef255dc96834aaaad627d3271504cba3ac2dc.tar.gz
kernel-daaef255dc96834aaaad627d3271504cba3ac2dc.zip
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 <[email protected]> Reviewed-by: Dmitry Torokhov <[email protected]> Acked-by: Hans de Goede <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
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)
irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
}
- return r ? r->start : -ENXIO;
+ if (r)
+ return r->start;
+
+ /*
+ * For the index 0 interrupt, allow falling back to GpioInt
+ * resources. While a device could have both Interrupt and GpioInt
+ * resources, making this fallback ambiguous, in many common cases
+ * the device will only expose one IRQ, and this fallback
+ * allows a common code path across either kind of resource.
+ */
+ if (num == 0 && has_acpi_companion(&dev->dev))
+ return acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
+
+ return -ENXIO;
#endif
}
EXPORT_SYMBOL_GPL(platform_get_irq);