diff options
author | Simon Glass <sjg@chromium.org> | 2020-07-07 13:11:58 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-07-17 14:32:24 +0800 |
commit | 06679000493a07eb643287d1adfa4ffe6c3fc87c (patch) | |
tree | f9e716cfaec1b8ce5af787ed5ac8e6ed56bfc47d /lib/acpi | |
parent | 235723466628c32e30685363377e416696318e84 (diff) | |
download | u-boot-06679000493a07eb643287d1adfa4ffe6c3fc87c.tar.gz |
acpi: Support copying properties from device tree to ACPI
Some drivers in Linux support both device tree and ACPI. U-Boot itself
uses Linux device-tree bindings for its own configuration but does not use
ACPI.
It is convenient to copy these values over to the ACPI DP table for
passing to linux. Add some convenience functions to help with 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_dp.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index e8de5651c83..579cab47715 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -344,3 +344,59 @@ struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name, return gpio; } + +int acpi_dp_ofnode_copy_int(ofnode node, struct acpi_dp *dp, const char *prop) +{ + int ret; + u32 val = 0; + + ret = ofnode_read_u32(node, prop, &val); + if (ret) + return ret; + if (!acpi_dp_add_integer(dp, prop, val)) + return log_ret(-ENOMEM); + + return 0; +} + +int acpi_dp_ofnode_copy_str(ofnode node, struct acpi_dp *dp, const char *prop) +{ + const char *val; + + val = ofnode_read_string(node, prop); + if (!val) + return -EINVAL; + if (!acpi_dp_add_string(dp, prop, val)) + return log_ret(-ENOMEM); + + return 0; +} + +int acpi_dp_dev_copy_int(const struct udevice *dev, struct acpi_dp *dp, + const char *prop) +{ + int ret; + u32 val = 0; + + ret = dev_read_u32(dev, prop, &val); + if (ret) + return ret; + if (!acpi_dp_add_integer(dp, prop, val)) + return log_ret(-ENOMEM); + + return ret; +} + +int acpi_dp_dev_copy_str(const struct udevice *dev, struct acpi_dp *dp, + const char *prop) +{ + const char *val; + + val = dev_read_string(dev, prop); + if (!val) + return -EINVAL; + if (!acpi_dp_add_string(dp, prop, val)) + return log_ret(-ENOMEM); + + return 0; +} |