From patchwork Fri Dec 11 03:21:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 58250 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp890396lbb; Thu, 10 Dec 2015 19:23:03 -0800 (PST) X-Received: by 10.140.240.196 with SMTP id l187mr11791391qhc.69.1449804182087; Thu, 10 Dec 2015 19:23:02 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p69si18202672qge.103.2015.12.10.19.23.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 Dec 2015 19:23:02 -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]:45609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EIP-0008BP-K2 for patch@linaro.org; Thu, 10 Dec 2015 22:23:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EHq-0007c9-Jm 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-0008FQ-Jq for qemu-devel@nongnu.org; Thu, 10 Dec 2015 22:22:26 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:9819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7EHj-0008DB-Hw; Thu, 10 Dec 2015 22:22:20 -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 CXU92695; 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:55 +0800 From: Shannon Zhao To: , , , , Date: Fri, 11 Dec 2015 11:21:26 +0800 Message-ID: <1449804086-3464-11-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.566A4160.0126, 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: 75c15f57147bec9c87b3fb43306deba6 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 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT 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 Add a gpio-keys node. This is used for Poweroff for the systems which use DT not ACPI. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Tested-by: Wei Huang --- hw/arm/virt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.0.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cb1d45b..bd6781bd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -52,6 +52,7 @@ #include "kvm_arm.h" #include "hw/smbios/smbios.h" #include "qapi/visitor.h" +#include /* Number of external interrupt lines to configure the GIC with */ #define NUM_IRQS 256 @@ -561,6 +562,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); + uint32_t phandle = qemu_fdt_alloc_phandle(vbi->fdt); nodename = g_strdup_printf("/pl061@%" PRIx64, base); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", @@ -573,6 +575,20 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) GIC_FDT_IRQ_FLAGS_LEVEL_HI); qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle); qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk"); + qemu_fdt_setprop_cell(vbi->fdt, nodename, "phandle", phandle); + + qemu_fdt_add_subnode(vbi->fdt, "/gpio-keys"); + qemu_fdt_setprop_string(vbi->fdt, "/gpio-keys", "compatible", "gpio-keys"); + qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys", "#size-cells", 0); + qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys", "#address-cells", 1); + + qemu_fdt_add_subnode(vbi->fdt, "/gpio-keys/poweroff"); + qemu_fdt_setprop_string(vbi->fdt, "/gpio-keys/poweroff", + "label", "GPIO Key Poweroff"); + qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys/poweroff", "linux,code", + KEY_POWER); + qemu_fdt_setprop_cells(vbi->fdt, "/gpio-keys/poweroff", + "gpios", phandle, 3, 0); /* connect powerdown request */ qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);