@@ -241,12 +241,11 @@ int acpi_table_add(const char *t)
}
-static void acpi_notify_wakeup(Notifier *notifier, void *data)
+void acpi_power_wakeup(ACPIREGS *ar)
{
- ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
- WakeupReason *reason = data;
+ WakeupReason reason = power_management_wakeup_reason();
- switch (*reason) {
+ switch (reason) {
case QEMU_WAKEUP_REASON_RTC:
ar->pm1.evt.sts |=
(ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_RT_CLOCK_STATUS);
@@ -288,9 +287,9 @@ static void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)
static void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val)
{
ar->pm1.evt.en = val;
- qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_RTC,
+ power_management_wakeup_capability(QEMU_WAKEUP_REASON_RTC,
val & ACPI_BITMASK_RT_CLOCK_ENABLE);
- qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_PMTIMER,
+ power_management_wakeup_capability(QEMU_WAKEUP_REASON_PMTIMER,
val & ACPI_BITMASK_TIMER_ENABLE);
}
@@ -306,8 +305,8 @@ void acpi_pm1_evt_reset(ACPIREGS *ar)
{
ar->pm1.evt.sts = 0;
ar->pm1.evt.en = 0;
- qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_RTC, 0);
- qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_PMTIMER, 0);
+ power_management_wakeup_capability(QEMU_WAKEUP_REASON_RTC, false);
+ power_management_wakeup_capability(QEMU_WAKEUP_REASON_PMTIMER, false);
}
static uint64_t acpi_pm_evt_read(void *opaque, hwaddr addr, unsigned width)
@@ -385,7 +384,8 @@ static uint32_t acpi_pm_tmr_get(ACPIREGS *ar)
static void acpi_pm_tmr_timer(void *opaque)
{
ACPIREGS *ar = opaque;
- qemu_system_wakeup_request(QEMU_WAKEUP_REASON_PMTIMER);
+ power_management_wakeup_reason_set(QEMU_WAKEUP_REASON_PMTIMER);
+ power_management_set(POWER_WAKEUP);
ar->tmr.update_sci(ar);
}
@@ -474,8 +474,6 @@ static const MemoryRegionOps acpi_pm_cnt_ops = {
void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent)
{
- ar->wakeup.notify = acpi_notify_wakeup;
- qemu_register_wakeup_notifier(&ar->wakeup);
memory_region_init_io(&ar->pm1.cnt.io, &acpi_pm_cnt_ops, ar, "acpi-cnt", 2);
memory_region_add_subregion(parent, 4, &ar->pm1.cnt.io);
}
@@ -117,7 +117,6 @@ struct ACPIREGS {
ACPIPM1EVT evt;
ACPIPM1CNT cnt;
} pm1;
- Notifier wakeup;
};
/* PM_TMR */
@@ -154,4 +153,6 @@ void acpi_gpe_reset(ACPIREGS *ar);
void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val);
uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);
+void acpi_power_wakeup(ACPIREGS *ar);
+
#endif /* !QEMU_HW_ACPI_H */
@@ -467,6 +467,8 @@ static void ich9_lpc_reset(DeviceState *qdev)
lpc->sci_level = 0;
lpc->rst_cnt = 0;
+
+ pm_reset(&lpc->pm);
}
static const MemoryRegionOps rbca_mmio_ops = {
@@ -595,6 +597,13 @@ static const VMStateDescription vmstate_ich9_lpc = {
}
};
+static void ich9_lpc_power_wakeup(DeviceState *dev)
+{
+ ICH9LPCState *lpc = ICH9_LPC_DEVICE(PCI_DEVICE(dev));
+
+ acpi_power_wakeup(&lpc->pm.acpi_regs);
+}
+
static void ich9_lpc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -604,13 +613,13 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
k->init = ich9_lpc_initfn;
dc->vmsd = &vmstate_ich9_lpc;
dc->no_user = 1;
+ dc->wakeup = ich9_lpc_power_wakeup;
k->config_write = ich9_lpc_config_write;
dc->desc = "ICH9 LPC bridge";
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ICH9_8;
k->revision = ICH9_A2_LPC_REVISION;
k->class_id = PCI_CLASS_BRIDGE_ISA;
-
}
static const TypeInfo ich9_lpc_info = {
realize wakeup function for ICH9-LPC device Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- hw/acpi.c | 20 +++++++++----------- hw/acpi.h | 3 ++- hw/lpc_ich9.c | 11 ++++++++++- 3 files changed, 21 insertions(+), 13 deletions(-)