From patchwork Tue May 12 04:24:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48327 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7572621550 for ; Tue, 12 May 2015 04:26:29 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf43305661lbb.3 for ; Mon, 11 May 2015 21:26:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=tyAe6IsohEAVqMNfZfpmnXim9Q0MwBhWL7Jp7JWIT6I=; b=DaBOTwfkT9aSwPJ5UHAhgTZYiynsc2GWyBh5QWeSmpFad/NeTryDKNSOf+hL8btmUh cWTMVpEEPUYySbimQ1LZ4PyVyxb6MyGVIZlgWmg5/RtSsJe2bObj2XHg+W4rGtjDT/ee WJ2xtrrGbF5lKSTK293zTDPbE+StYnboCBYvKCtL/i60lUf54txoWBUsIfIxEj+3PH+D 9bkxC38zS1ohhHOMALys9qbcK5dH9rTLYonm3yx1UJdZj+QyjPMIGXUBEIAI5DLOWxdv Ao498Fyu7Ye3egqME2tTBKsgoZegSVPNPqeHOZJhF4zsbZAskin4v46FnHVkVh1peSVP sekA== X-Gm-Message-State: ALoCoQmRO23vT4QAXjMFWfiLBm3k90BaP5fyelYZvnFh/f768ZpTmGF/Xpqj/phnKpjEVRfmzdWM X-Received: by 10.180.7.138 with SMTP id j10mr9913650wia.2.1431404788281; Mon, 11 May 2015 21:26:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.34 with SMTP id n2ls681196laj.15.gmail; Mon, 11 May 2015 21:26:27 -0700 (PDT) X-Received: by 10.152.1.4 with SMTP id 4mr10469905lai.25.1431404787959; Mon, 11 May 2015 21:26:27 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id rk8si9546756lac.100.2015.05.11.21.26.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 21:26:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laat2 with SMTP id t2so107887126laa.1 for ; Mon, 11 May 2015 21:26:27 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr10505502lbc.86.1431404787821; Mon, 11 May 2015 21:26:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1855624lbb; Mon, 11 May 2015 21:26:26 -0700 (PDT) X-Received: by 10.55.31.7 with SMTP id f7mr29447686qkf.9.1431404785325; Mon, 11 May 2015 21:26:25 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w19si7936649qha.85.2015.05.11.21.26.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:26:25 -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; Received: from localhost ([::1]:40781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1lv-0007nI-OZ for patch@linaro.org; Tue, 12 May 2015 00:26:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1kA-0005Hr-Cu for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys1k6-0006oL-BN for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:34 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1k6-0006nu-5z for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:30 -0400 Received: by pacyx8 with SMTP id yx8so130621465pac.1 for ; Mon, 11 May 2015 21:24:29 -0700 (PDT) X-Received: by 10.70.130.198 with SMTP id og6mr24475965pdb.153.1431404669630; Mon, 11 May 2015 21:24:29 -0700 (PDT) Received: from localhost ([180.150.141.243]) by mx.google.com with ESMTPSA id ez1sm14604978pbd.0.2015.05.11.21.24.27 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:24:28 -0700 (PDT) From: shannon.zhao@linaro.org To: qemu-devel@nongnu.org, peter.maydell@linaro.org, imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com, wei@redhat.com, arnd@arndb.de, christoffer.dall@linaro.org Date: Tue, 12 May 2015 12:24:10 +0800 Message-Id: <1431404656-7180-2-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> References: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.49 Cc: hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH 1/7] hw/arm/virt: Add a GPIO controller 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Shannon Zhao ACPI 5.0 supports GPIO-signaled ACPI Events. This can be used for powerdown, hotplug evnets. Add a GPIO controller in machine virt, to support powerdown, maybe can be used for cpu hotplug. And here we use pl061. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 31 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3951326..3511903 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -111,6 +111,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, [VIRT_FW_CFG] = { 0x09020000, 0x0000000a }, + [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* @@ -128,6 +129,7 @@ static const int a15irqmap[] = { [VIRT_UART] = 1, [VIRT_RTC] = 2, [VIRT_PCIE] = 3, /* ... to 6 */ + [VIRT_GPIO] = 7, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ }; @@ -430,6 +432,32 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } +static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) +{ + char *nodename; + hwaddr base = vbi->memmap[VIRT_GPIO].base; + hwaddr size = vbi->memmap[VIRT_GPIO].size; + int irq = vbi->irqmap[VIRT_GPIO]; + const char compat[] = "arm,pl061"; + + sysbus_create_simple("pl061", base, pic[irq]); + + nodename = g_strdup_printf("/pl061@%" PRIx64, base); + qemu_fdt_add_subnode(vbi->fdt, nodename); + qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", + 2, base, 2, size); + qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat)); + qemu_fdt_setprop_cell(vbi->fdt, nodename, "#gpio-cells", 2); + qemu_fdt_setprop(vbi->fdt, nodename, "gpio-controller", NULL, 0); + qemu_fdt_setprop_cells(vbi->fdt, nodename, "interrupts", + GIC_FDT_IRQ_TYPE_SPI, irq, + 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"); + + g_free(nodename); +} + static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) { int i; @@ -821,6 +849,8 @@ static void machvirt_init(MachineState *machine) create_rtc(vbi, pic); + create_gpio(vbi, pic); + guest_info->pcie_info = create_pcie(vbi, pic, gic_phandle); /* Create mmio transports, so the user can create virtio backends diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index ba7fe0b..31b7eba 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -50,6 +50,7 @@ enum { VIRT_RTC, VIRT_FW_CFG, VIRT_PCIE, + VIRT_GPIO, }; typedef struct MemMapEntry {