From: Jing Liu <jing2....@linux.intel.com> Hardware-reduced ACPI uses SLEEP_CONTROL_REG to enter S5 sleep state.
Cc: "Michael S. Tsirkin" <m...@redhat.com> Cc: Igor Mammedov <imamm...@redhat.com> Signed-off-by: Jing Liu <jing2....@linux.intel.com> --- hw/acpi/aml-build.c | 2 +- hw/acpi/reduced.c | 15 +++++++++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/acpi/reduced.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index f462bb8313..752642a67a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2922,7 +2922,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, } /* SLEEP_CONTROL_REG */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->sleep_control_reg); /* SLEEP_STATUS_REG */ build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); diff --git a/hw/acpi/reduced.c b/hw/acpi/reduced.c index 33d413a255..329d5112ca 100644 --- a/hw/acpi/reduced.c +++ b/hw/acpi/reduced.c @@ -80,6 +80,17 @@ static void acpi_dsdt_add_ged(Aml *scope, AcpiConfiguration *conf) conf->ged_events, conf->ged_events_size); } +static void acpi_dsdt_add_sleep_state(Aml *scope) +{ + Aml *pkg = aml_package(4); + + aml_append(pkg, aml_int(ACPI_REDUCED_SLEEP_LEVEL)); + aml_append(pkg, aml_int(0)); + aml_append(pkg, aml_int(0)); + aml_append(pkg, aml_int(0)); + aml_append(scope, aml_name_decl("_S5", pkg)); +} + /* DSDT */ static void build_dsdt(MachineState *ms, GArray *table_data, BIOSLinker *linker, @@ -98,6 +109,7 @@ static void build_dsdt(MachineState *ms, acpi_dsdt_add_memory_hotplug(ms, dsdt); acpi_dsdt_add_cpus(ms, dsdt, scope, smp_cpus, conf); acpi_dsdt_add_ged(dsdt, conf); + acpi_dsdt_add_sleep_state(scope); aml_append(dsdt, scope); /* copy AML table into ACPI tables blob and patch header there */ @@ -120,6 +132,9 @@ static void build_fadt_reduced(GArray *table_data, BIOSLinker *linker, .dsdt_tbl_offset = &dsdt_tbl_offset, .xdsdt_tbl_offset = &dsdt_tbl_offset, .arm_boot_arch = 0, + .sleep_control_reg = { .space_id = AML_AS_SYSTEM_IO, + .bit_width = 8, .bit_offset = 0, + .address = ACPI_REDUCED_SLEEP_CONTROL_IOPORT }, }; build_fadt(table_data, linker, &fadt, NULL, NULL); diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 6e1726e0a2..10b7bf9c98 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -112,6 +112,7 @@ typedef struct AcpiFadtData { unsigned *facs_tbl_offset; /* FACS offset in */ unsigned *dsdt_tbl_offset; unsigned *xdsdt_tbl_offset; + struct AcpiGenericAddress sleep_control_reg; /* SLEEP_CONTROL_REG */ } AcpiFadtData; #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) diff --git a/include/hw/acpi/reduced.h b/include/hw/acpi/reduced.h index b326af9bad..3d3c003353 100644 --- a/include/hw/acpi/reduced.h +++ b/include/hw/acpi/reduced.h @@ -19,6 +19,10 @@ #ifndef HW_ACPI_REDUCED_H #define HW_ACPI_REDUCED_H +#define ACPI_REDUCED_SLEEP_LEVEL 5 +#define ACPI_REDUCED_SLEEP_ENABLE (1 << 5) /* SLP_EN */ +#define ACPI_REDUCED_SLEEP_CONTROL_IOPORT 0x3B0 + typedef struct Aml Aml; typedef enum { -- 2.17.2