From patchwork Mon Jun 30 12:47:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 32741 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B208E203F4 for ; Mon, 30 Jun 2014 13:29:16 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kq14sf43985656pab.8 for ; Mon, 30 Jun 2014 06:29:16 -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: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=ar3NUNaXvSlHYxPqWiZxS0cVTt0TU1NS3ny6hg2cue8=; b=BPeSk8813ioqPQLaVE+wjiQJX9xUsv9CAyzPjZUH9w8Pe94JQuC+POIgdAcctsnfgC pDbtrPLNNP85l5pe2eXOYan/rYk4QhGH/aD770JAc/sTOSc8JE1XNO5AWF3L7zGtryGV Zm1tu7glGWPoI9d0e1iuF0mK20Jks4Gg9pLkSXe5IJU1Xuz9sxeati3cKFbDu3sfo3S5 lnlJuspFeSjQ+HdNepp9nffu6VAL032hSi6ZwQI89YxZp1x8/wxOBL6O/n4kk5Tm3lZa W1L9cjcVHpYf5qoThXytOnL234LvBhmps0b0XCux4PDJdWo6qRIZHTymOiMWzY940zTU bCjg== X-Gm-Message-State: ALoCoQkVsldQo6/cu1PtA+pVSDvlv1IxVep0LN9Es2BKmQC1e95ZElryBXW2yLhFNwkzR3mpi44b X-Received: by 10.68.230.193 with SMTP id ta1mr22004950pbc.6.1404134956026; Mon, 30 Jun 2014 06:29:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.132 with SMTP id u4ls1477783qga.36.gmail; Mon, 30 Jun 2014 06:29:15 -0700 (PDT) X-Received: by 10.52.84.162 with SMTP id a2mr5018398vdz.23.1404134955823; Mon, 30 Jun 2014 06:29:15 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id nh6si10032497vec.57.2014.06.30.06.29.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 06:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id la4so7658557vcb.0 for ; Mon, 30 Jun 2014 06:29:15 -0700 (PDT) X-Received: by 10.220.89.4 with SMTP id c4mr413100vcm.53.1404134955731; Mon, 30 Jun 2014 06:29:15 -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.221.37.5 with SMTP id tc5csp139026vcb; Mon, 30 Jun 2014 06:29:15 -0700 (PDT) X-Received: by 10.224.47.148 with SMTP id n20mr62162090qaf.90.1404134954947; Mon, 30 Jun 2014 06:29:14 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u6si25037622qae.106.2014.06.30.06.29.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 30 Jun 2014 06:29:14 -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]:34078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1b2M-0007lV-7v for patch@linaro.org; Mon, 30 Jun 2014 08:50:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1azm-0004F2-NG for qemu-devel@nongnu.org; Mon, 30 Jun 2014 08:47:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1azk-0005ti-PD for qemu-devel@nongnu.org; Mon, 30 Jun 2014 08:47:42 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1azk-0005rQ-Hr for qemu-devel@nongnu.org; Mon, 30 Jun 2014 08:47:40 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1X1azb-0008Sh-K2 for qemu-devel@nongnu.org; Mon, 30 Jun 2014 13:47:31 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 30 Jun 2014 13:47:24 +0100 Message-Id: <1404132451-32498-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404132451-32498-1-git-send-email-peter.maydell@linaro.org> References: <1404132451-32498-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 1/8] hw/arm/virt: Provide PL031 RTC 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: peter.maydell@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.220.169 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 UEFI mandates that the platform must include an RTC, so provide one in 'virt', using the PL031. This is also useful for directly booting Linux kernels which would otherwise have to run ntpdate. Signed-off-by: Peter Maydell Tested-by: Aurelien Jarno Reviewed-by: Aurelien Jarno --- hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 72fe030..405c61d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -65,6 +65,7 @@ enum { VIRT_GIC_CPU, VIRT_UART, VIRT_MMIO, + VIRT_RTC, }; typedef struct MemMapEntry { @@ -92,6 +93,8 @@ typedef struct VirtBoardInfo { * high memory region beyond 4GB). * This represents a compromise between how much RAM can be given to * a 32 bit VM and leaving space for expansion and in particular for PCI. + * Note that devices should generally be placed at multiples of 0x10000, + * to accommodate guests using 64K pages. */ static const MemMapEntry a15memmap[] = { /* Space up to 0x8000000 is reserved for a boot ROM */ @@ -101,6 +104,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_DIST] = { 0x8000000, 0x10000 }, [VIRT_GIC_CPU] = { 0x8010000, 0x10000 }, [VIRT_UART] = { 0x9000000, 0x1000 }, + [VIRT_RTC] = { 0x90010000, 0x1000 }, [VIRT_MMIO] = { 0xa000000, 0x200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */ @@ -109,6 +113,7 @@ static const MemMapEntry a15memmap[] = { static const int a15irqmap[] = { [VIRT_UART] = 1, + [VIRT_RTC] = 2, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ }; @@ -353,6 +358,29 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } +static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) +{ + char *nodename; + hwaddr base = vbi->memmap[VIRT_RTC].base; + hwaddr size = vbi->memmap[VIRT_RTC].size; + int irq = vbi->irqmap[VIRT_RTC]; + const char compat[] = "arm,pl031\0arm,primecell"; + + sysbus_create_simple("pl031", base, pic[irq]); + + nodename = g_strdup_printf("/pl031@%" PRIx64, base); + qemu_fdt_add_subnode(vbi->fdt, nodename); + qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat)); + qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", + 2, base, 2, size); + qemu_fdt_setprop_cells(vbi->fdt, nodename, "interrupts", + GIC_FDT_IRQ_TYPE_SPI, irq, + GIC_FDT_IRQ_FLAGS_EDGE_LO_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; @@ -469,6 +497,8 @@ static void machvirt_init(MachineState *machine) create_uart(vbi, pic); + create_rtc(vbi, pic); + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle.