diff options
author | Simon Glass <sjg@chromium.org> | 2020-07-07 22:11:57 +0300 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-07-17 09:32:24 +0300 |
commit | 235723466628c32e30685363377e416696318e84 (patch) | |
tree | 352647edf82dab916aa65253cdc3187f07de9800 /lib | |
parent | 0e5a0a00d6e44dc0c7e1466ceb3e452b43ceeb1b (diff) | |
download | u-boot-235723466628c32e30685363377e416696318e84.tar.xz |
acpi: Support writing a GPIO
Allowing writing out a reference to a GPIO within the ACPI output. This
can be used by ACPI code to access a GPIO at runtime.
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')
-rw-r--r-- | lib/acpi/acpi_dp.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index 32528e1ec4..e8de5651c8 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -321,3 +321,26 @@ struct acpi_dp *acpi_dp_add_integer_array(struct acpi_dp *dp, const char *name, return dp_array; } + +struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name, + const char *ref, int index, int pin, + enum acpi_irq_polarity polarity) +{ + struct acpi_dp *gpio; + + assert(dp); + gpio = acpi_dp_new_table(name); + if (!gpio) + return NULL; + + if (!acpi_dp_add_reference(gpio, NULL, ref) || + !acpi_dp_add_integer(gpio, NULL, index) || + !acpi_dp_add_integer(gpio, NULL, pin) || + !acpi_dp_add_integer(gpio, NULL, polarity == ACPI_IRQ_ACTIVE_LOW)) + return NULL; + + if (!acpi_dp_add_array(dp, gpio)) + return NULL; + + return gpio; +} |