aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:12:08 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit01694589af589212d6f2a6241821896ef9e334d3 (patch)
tree54085627056cd2bc0c8e89adcf7361af5bd80870 /drivers
parent351fef5c579b4cabbd2976e61d1f8a9ef7c06b53 (diff)
downloadu-boot-01694589af589212d6f2a6241821896ef9e334d3.zip
u-boot-01694589af589212d6f2a6241821896ef9e334d3.tar.gz
u-boot-01694589af589212d6f2a6241821896ef9e334d3.tar.bz2
acpi: Add support for DSDT generation
Some devices need to inject extra code into the Differentiated System Descriptor Table (DSDT). Add a method 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> [bmeng: correct one typo in inject_dsdt() comments] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/acpi.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index a9b7fc1..7b32694 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -22,12 +22,14 @@
enum gen_type_t {
TYPE_NONE,
TYPE_SSDT,
+ TYPE_DSDT,
};
/* Type of method to call */
enum method_t {
METHOD_WRITE_TABLES,
METHOD_FILL_SSDT,
+ METHOD_INJECT_DSDT,
};
/* Prototype for all methods */
@@ -144,7 +146,9 @@ static int sort_acpi_item_type(struct acpi_ctx *ctx, void *start,
void *end = ctx->current;
ptr = start;
- order = ofnode_read_chosen_prop("u-boot,acpi-ssdt-order", &size);
+ order = ofnode_read_chosen_prop(type == TYPE_DSDT ?
+ "u-boot,acpi-dsdt-order" :
+ "u-boot,acpi-ssdt-order", &size);
if (!order) {
log_warning("Failed to find ordering, leaving as is\n");
return 0;
@@ -198,6 +202,8 @@ acpi_method acpi_get_method(struct udevice *dev, enum method_t method)
return aops->write_tables;
case METHOD_FILL_SSDT:
return aops->fill_ssdt;
+ case METHOD_INJECT_DSDT:
+ return aops->inject_dsdt;
}
}
@@ -256,6 +262,23 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx)
return ret;
}
+int acpi_inject_dsdt(struct acpi_ctx *ctx)
+{
+ void *start = ctx->current;
+ int ret;
+
+ log_debug("Writing DSDT tables\n");
+ item_count = 0;
+ ret = acpi_recurse_method(ctx, dm_root(), METHOD_INJECT_DSDT,
+ TYPE_DSDT);
+ log_debug("Writing DSDT finished, err=%d\n", ret);
+ ret = sort_acpi_item_type(ctx, start, TYPE_DSDT);
+ if (ret)
+ return log_msg_ret("build", ret);
+
+ return ret;
+}
+
int acpi_write_dev_tables(struct acpi_ctx *ctx)
{
int ret;