
Hi Bin,
On Sun, 28 Jun 2020 at 23:39, Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Sun, Jun 14, 2020 at 10:55 AM Simon Glass sjg@chromium.org wrote:
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
Changes in v3:
- Fix 'THe' typo
- Rename build_type() to sort_acpi_item_type()
Changes in v1:
- Generalise the ACPI function recursion with acpi_recurse_method()
arch/sandbox/dts/test.dts | 2 ++ drivers/core/acpi.c | 25 +++++++++++++++++++++- include/dm/acpi.h | 23 ++++++++++++++++++++ test/dm/acpi.c | 44 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 993082763d..caf935cfdf 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -257,6 +257,7 @@ acpi_test1: acpi-test { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "ab";
acpi-dsdt-test-data = "hi"; child { compatible = "denx,u-boot-acpi-test"; };
@@ -265,6 +266,7 @@ acpi_test2: acpi-test2 { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "cd";
acpi-dsdt-test-data = "jk"; }; clocks {
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 4719a5c4e4..c1fc364550 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;
@@ -189,6 +193,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; } }
@@ -247,6 +253,23 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx) return ret; }
+int acpi_inject_dsdt(struct acpi_ctx *ctx)
For naming consistency, this should be acpi_fill_dsdt(), or change the ssdt one to: acpi_inject_ssdt() otherwise.
This method injects contents into an existing DSDT, hence the naming.
It is also better I think, since SSDT and DSDT only differ by one character and it is easy to get them confused otherwise.
Will update the comment.
Regards, Simon