2019-02-07 18:51:33

by Enrico Granata

[permalink] [raw]
Subject: [PATCH] driver: platform: Add support for GpioInt() ACPI to platform_get_irq()

From: Enrico Granata <[email protected]>

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 commit adds that functionality.

Signed-off-by: Enrico Granata <[email protected]>
---
drivers/base/platform.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c958eb33ef4d..c50c4f9033aef 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -127,7 +127,17 @@ 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;
+
+ /*
+ * If no IRQ was found, try to parse ACPI GpioInt resources
+ * as a last resort.
+ */
+ if (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);
--
2.20.1.611.gfbb209baf1-goog



2019-02-07 18:59:30

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] driver: platform: Add support for GpioInt() ACPI to platform_get_irq()

On Thu, Feb 7, 2019 at 7:50 PM <[email protected]> wrote:
>
> From: Enrico Granata <[email protected]>
>
> 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 commit adds that functionality.
>
> Signed-off-by: Enrico Granata <[email protected]>

Please resend this patch with a CC to the [email protected]
mailing list.

Thanks!

> ---
> drivers/base/platform.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 1c958eb33ef4d..c50c4f9033aef 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -127,7 +127,17 @@ 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;
> +
> + /*
> + * If no IRQ was found, try to parse ACPI GpioInt resources
> + * as a last resort.
> + */
> + if (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);
> --
> 2.20.1.611.gfbb209baf1-goog
>