1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-02 01:02:19 +02:00

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>
This commit is contained in:
Simon Glass
2020-07-07 13:11:58 -06:00
committed by Bin Meng
parent 2357234666
commit 0667900049
4 changed files with 174 additions and 0 deletions

View File

@@ -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;
}