diff mbox

[3/7] hw/arm/virt-acpi-build: Add power button device in ACPI DSDT table

Message ID 1431404656-7180-4-git-send-email-shannon.zhao@linaro.org
State New
Headers show

Commit Message

Shannon Zhao May 12, 2015, 4:24 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Add power button device in ACPI DSDT table.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/arm/virt-acpi-build.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e505c16..b582047 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -319,6 +319,18 @@  static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
     aml_append(scope, dev);
 }
 
+static void acpi_dsdt_add_power_button(Aml *scope)
+{
+    Aml *dev = aml_device("PWRB");
+    aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C")));
+    aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
+    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
+    Aml *method = aml_method("_STA", 0);
+    aml_append(method, aml_return(aml_int(0x0F)));
+    aml_append(dev, method);
+    aml_append(scope, dev);
+}
+
 /* RSDP */
 static GArray *
 build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
@@ -475,6 +487,7 @@  build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
                                 irqmap[VIRT_MMIO], NUM_VIRTIO_TRANSPORTS);
     acpi_dsdt_add_pci(scope, guest_info->pcie_info, irqmap[VIRT_PCIE]);
     acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], irqmap[VIRT_GPIO]);
+    acpi_dsdt_add_power_button(scope);
 
     aml_append(dsdt, scope);