From patchwork Wed Mar 13 08:01:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liguang X-Patchwork-Id: 227180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 920F02C0292 for ; Wed, 13 Mar 2013 19:05:17 +1100 (EST) Received: from localhost ([::1]:43265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFggV-0002v7-NK for incoming@patchwork.ozlabs.org; Wed, 13 Mar 2013 04:05:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFgeL-0007Sh-B7 for qemu-devel@nongnu.org; Wed, 13 Mar 2013 04:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFgeH-0001nr-8s for qemu-devel@nongnu.org; Wed, 13 Mar 2013 04:03:01 -0400 Received: from [222.73.24.84] (port=2302 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFgeG-0001jZ-Rs for qemu-devel@nongnu.org; Wed, 13 Mar 2013 04:02:57 -0400 X-IronPort-AV: E=Sophos;i="4.84,834,1355068800"; d="scan'208";a="6864296" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 13 Mar 2013 16:00:21 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r2D82kwl009977 for ; Wed, 13 Mar 2013 16:02:47 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.233.147]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013031316013320-831300 ; Wed, 13 Mar 2013 16:01:33 +0800 From: liguang To: qemu-devel@nongnu.org Date: Wed, 13 Mar 2013 16:01:14 +0800 Message-Id: <1363161681-13878-8-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1363161681-13878-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1363161681-13878-1-git-send-email-lig.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/03/13 16:01:33, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/03/13 16:01:33, Serialize complete at 2013/03/13 16:01:33 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: liguang Subject: [Qemu-devel] [PATCH][RFC 07/14] acpi: refactor acpi wakeup function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org realize wakeup function for ICH9-LPC device Signed-off-by: liguang --- hw/acpi.c | 20 +++++++++----------- hw/acpi.h | 3 ++- hw/lpc_ich9.c | 11 ++++++++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 8c9dcc5..c0e07d4 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -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); } diff --git a/hw/acpi.h b/hw/acpi.h index c3628d0..98f7c5f 100644 --- a/hw/acpi.h +++ b/hw/acpi.h @@ -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 */ diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index eceb052..42f2dfa 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -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 = {