From patchwork Fri Dec 11 03:21:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 58252 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp890701lbb; Thu, 10 Dec 2015 19:23:57 -0800 (PST) X-Received: by 10.140.102.35 with SMTP id v32mr20669787qge.72.1449804237742; Thu, 10 Dec 2015 19:23:57 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 200si18214296qhm.3.2015.12.10.19.23.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 Dec 2015 19:23:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:45619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EJJ-0001K9-Bn for patch@linaro.org; Thu, 10 Dec 2015 22:23:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EHq-0007c8-GN for qemu-devel@nongnu.org; Thu, 10 Dec 2015 22:22:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7EHp-0008FL-HX for qemu-devel@nongnu.org; Thu, 10 Dec 2015 22:22:26 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:9812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EHk-0008D9-RL; Thu, 10 Dec 2015 22:22:21 -0500 Received: from 172.24.1.48 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.48]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CXU92710; Fri, 11 Dec 2015 11:22:07 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Fri, 11 Dec 2015 11:21:54 +0800 From: Shannon Zhao To: , , , , Date: Fri, 11 Dec 2015 11:21:25 +0800 Message-ID: <1449804086-3464-10-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1449804086-3464-1-git-send-email-zhaoshenglong@huawei.com> References: <1449804086-3464-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.566A4161.0143, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 99caf3b7b6e6b2d9bdef9b4531d523fe X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: peter.huangpeng@huawei.com, zhaoshenglong@huawei.com, qemu-devel@nongnu.org, graeme.gregory@linaro.org, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v5 09/10] ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Shannon Zhao Currently mach-virt model doesn't support powerdown request. Guest VM doesn't react to system_powerdown from monitor console (or QMP) because there is no communication mechanism for such requests. This patch registers GPIO Pin 3 with powerdown notification. So guest VM can receive notification when such powerdown request is triggered. Signed-off-by: Wei Huang Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Wei Huang Tested-by: Wei Huang --- hw/arm/virt.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.0.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7977e3c..cb1d45b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -540,6 +540,17 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } +static DeviceState *pl061_dev; +static void virt_powerdown_req(Notifier *n, void *opaque) +{ + /* use gpio Pin 3 for power button event */ + qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 1); +} + +static Notifier virt_system_powerdown_notifier = { + .notify = virt_powerdown_req +}; + static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) { char *nodename; @@ -548,7 +559,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) int irq = vbi->irqmap[VIRT_GPIO]; const char compat[] = "arm,pl061\0arm,primecell"; - sysbus_create_simple("pl061", base, pic[irq]); + pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); nodename = g_strdup_printf("/pl061@%" PRIx64, base); qemu_fdt_add_subnode(vbi->fdt, nodename); @@ -563,6 +574,9 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle); qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk"); + /* connect powerdown request */ + qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); + g_free(nodename); }