diff options
author | Simon Glass <sjg@chromium.org> | 2020-07-07 13:11:47 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-07-17 14:32:24 +0800 |
commit | 4ebc940b39b6a43de9d1fa74653321cd6fdb4d3a (patch) | |
tree | 879e368605d9dae2a7cf4ba960711554c9b28eba /lib/acpi | |
parent | a9e0a077df5509c3d4b49e745c746c38a4f9a7a1 (diff) | |
download | u-boot-4ebc940b39b6a43de9d1fa74653321cd6fdb4d3a.tar.gz u-boot-4ebc940b39b6a43de9d1fa74653321cd6fdb4d3a.tar.xz u-boot-4ebc940b39b6a43de9d1fa74653321cd6fdb4d3a.zip |
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 <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib/acpi')
-rw-r--r-- | lib/acpi/acpi_device.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index bbe1cfc57a..c93af2e583 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -354,5 +354,34 @@ int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, if (ret < 0) return log_msg_ret("gpio", ret); - return 0; + return ret; +} + +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx, + struct udevice *dev, const char *prop) +{ + struct irq req_irq; + int pin; + int ret; + + ret = irq_get_by_index(dev, 0, &req_irq); + if (!ret) { + ret = acpi_device_write_interrupt_irq(ctx, &req_irq); + if (ret < 0) + return log_msg_ret("irq", ret); + pin = ret; + } else { + struct gpio_desc req_gpio; + + ret = gpio_request_by_name(dev, prop, 0, &req_gpio, + GPIOD_IS_IN); + if (ret) + return log_msg_ret("no gpio", ret); + ret = acpi_device_write_gpio_desc(ctx, &req_gpio); + if (ret < 0) + return log_msg_ret("gpio", ret); + pin = ret; + } + + return pin; } |