From f9189d5ada8d48932463dc1d56ea4d44c050ebbd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 7 Jul 2020 13:12:00 -0600 Subject: acpi: Add support for writing a Power Resource These are used in ACPI to disable power to various pats of the system when in sleep. Add a way to create a power resource, with the caller finishing off the details. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner Reviewed-by: Bin Meng --- lib/acpi/acpigen.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/acpi') diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index 4fd29cc..70d7342 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -328,6 +328,28 @@ int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid) return 0; } +void acpigen_write_power_res(struct acpi_ctx *ctx, const char *name, uint level, + uint order, const char *const dev_states[], + size_t dev_states_count) +{ + size_t i; + + for (i = 0; i < dev_states_count; i++) { + acpigen_write_name(ctx, dev_states[i]); + acpigen_write_package(ctx, 1); + acpigen_emit_simple_namestring(ctx, name); + acpigen_pop_len(ctx); /* Package */ + } + + acpigen_emit_ext_op(ctx, POWER_RES_OP); + + acpigen_write_len_f(ctx); + + acpigen_emit_simple_namestring(ctx, name); + acpigen_emit_byte(ctx, level); + acpigen_emit_word(ctx, order); +} + /* Sleep (ms) */ void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms) { -- cgit v1.1