From patchwork Thu Oct 29 14:27:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 55787 Delivered-To: patch@linaro.org Received: by 10.202.175.130 with SMTP id y124csp458482oie; Thu, 29 Oct 2015 07:36:24 -0700 (PDT) X-Received: by 10.55.78.204 with SMTP id c195mr2566259qkb.69.1446129384604; Thu, 29 Oct 2015 07:36:24 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 34si1488096qkv.5.2015.10.29.07.36.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Oct 2015 07:36:24 -0700 (PDT) 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; dkim=fail header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([::1]:44450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroJU-0001ah-2Q for patch@linaro.org; Thu, 29 Oct 2015 10:36:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCw-0000gh-Lz for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZroCs-0000Wt-Sq for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:38 -0400 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:33649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCs-0000WP-MA for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:34 -0400 Received: by padhy1 with SMTP id hy1so36672649pad.0 for ; Thu, 29 Oct 2015 07:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MecsEWih1JR1eF0U5naxTPAY2SVXnnCOnYP/QGbCbZA=; b=cRW55BLAiznxxmbKaa+myJJJIwYBZDfoHdyCjw+q8wAf8Vy28MhtAPGbC3rUUNPql3 4fJ+OTrlmMUBUOo4NHxjH/yKiK/tAeA1k4xe3RCETgfN0XW8H4qGFW2J278SB/BNhHlJ QH2C2fD4L+uH+ckY7OdhuFKNAWPez11ZxGTQofh3P1oHZT6vav7YmVxkNbQJAQPxLpxI riwSGc0yPBVm+AtpxdiiSoUg2LhUgj/3KXrnq4aZI4CvuY04VJRbZv9STWQNrIg1Ybwa qqqt3yWVRRnpOLC15OtP0ivYT5FxljxL2Ao7i21FrqRnOSyQt9KapBZFkQdKLaSEz8DH kISA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MecsEWih1JR1eF0U5naxTPAY2SVXnnCOnYP/QGbCbZA=; b=RKHKJTwF36ZAz2/r1HcbRCUvDwYXSRTW9uCM9zP1EFq7B3oatcRP8HX3rJL2teQinz RxpHDTYjAHSKrM9DxVs52AyPGRnkcniU41CD4gK/l+s+T2rQgxlXjYxxrSuY5aqmZ4YS PqNmCV1nn2dTCPFrR0t4mBUncqE8kLtfey9+l6sjhUhkc/S1uyk6GNfIQ5Eio19MQcay Fq4PKiTNYuBzZeaofuC/CBcx2rHGf5+nyMWx7BtW+ieIm1Kp6M7huOL4Km1Mr+5Rc1Tq 17DgwdPAYrV1aYBHfXWGgHPpycwZBKyl+IrLaZjrPws01LGXszLhAujfxZeZVXkFmcXd hgJQ== X-Gm-Message-State: ALoCoQllaoerXAenGV6Cyds/kUJYIr1b86tyESBxxCRKoWEGehnPI0C1pZB2oZbUSFLnu5dyZQHB X-Received: by 10.66.182.131 with SMTP id ee3mr2156965pac.81.1446128974286; Thu, 29 Oct 2015 07:29:34 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by smtp.gmail.com with ESMTPSA id a5sm1805986pbu.55.2015.10.29.07.29.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 07:29:33 -0700 (PDT) From: Shannon Zhao To: qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, imammedo@redhat.com Date: Thu, 29 Oct 2015 22:27:35 +0800 Message-Id: <1446128855-26637-9-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> References: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22d Cc: zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2 8/8] hw/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 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 --- hw/arm/virt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.1.0 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6f1b9d6..75a3a5c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -562,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", @@ -574,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_setprop(vbi->fdt, "/gpio-keys", "autorepeat", NULL, 0); + + 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", 116); + qemu_fdt_setprop_cells(vbi->fdt, "/gpio-keys/poweroff", + "gpios", phandle, 3, 0); /* connect powerdown request */ qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);