From 4ebc940b39b6a43de9d1fa74653321cd6fdb4d3a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 7 Jul 2020 13:11:47 -0600 Subject: acpi: Support generation of a GPIO/irq for a device Some devices use interrupts but some use GPIOs. Since these are fully specified in the device tree we can automatically produce the correct ACPI descriptor for a device. Add a function to handle this. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner Reviewed-by: Bin Meng --- include/acpi/acpi_device.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/acpi') diff --git a/include/acpi/acpi_device.h b/include/acpi/acpi_device.h index 002e835644..67a242eb75 100644 --- a/include/acpi/acpi_device.h +++ b/include/acpi/acpi_device.h @@ -255,4 +255,19 @@ int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio); int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, const struct gpio_desc *desc); +/** + * acpi_device_write_interrupt_or_gpio() - Write interrupt or GPIO to ACPI + * + * This reads an interrupt from the device tree "interrupts-extended" property, + * if available. If not it reads the first GPIO with the name @prop. + * + * If an interrupt is found, an ACPI interrupt descriptor is written to the ACPI + * output. If not, but if a GPIO is found, a GPIO descriptor is written. + * + * @return irq or GPIO pin number if OK, -ve if neither an interrupt nor a GPIO + * could be found, or some other error occurred + */ +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx, + struct udevice *dev, const char *prop); + #endif -- cgit