From patchwork Fri Jun 20 22:32:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 362362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C4F8A1400A3 for ; Sat, 21 Jun 2014 08:33:14 +1000 (EST) Received: from localhost ([::1]:43052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wy7Mu-0001Vz-VT for incoming@patchwork.ozlabs.org; Fri, 20 Jun 2014 18:33:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wy7Me-0001Ef-Jx for qemu-devel@nongnu.org; Fri, 20 Jun 2014 18:32:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wy7Mc-0005zr-1M for qemu-devel@nongnu.org; Fri, 20 Jun 2014 18:32:55 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:101::1]:47257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wy7Mb-0005zf-Rh for qemu-devel@nongnu.org; Fri, 20 Jun 2014 18:32:53 -0400 Received: from [2001:470:d4ed:0:ea11:32ff:fea1:831a] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Wy7MZ-0004Iy-6N; Sat, 21 Jun 2014 00:32:51 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.80) (envelope-from ) id 1Wy7MY-0006vw-2Y; Sat, 21 Jun 2014 00:32:50 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Sat, 21 Jun 2014 00:32:46 +0200 Message-Id: <1403303566-26618-1-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:bc8:30d7:101::1 Cc: Peter Maydell , Aurelien Jarno Subject: [Qemu-devel] [PATCH] hw/arm: add a PL031 driver to the virt machine 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We currently do no have a virtio device for the real time clock. Instead of having to fetch the date and time from an NTP server, provide a PL031 device in the virt machine. Cc: Peter Maydell Signed-off-by: Aurelien Jarno --- hw/arm/virt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 72fe030..617f509 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -64,6 +64,7 @@ enum { VIRT_GIC_DIST, VIRT_GIC_CPU, VIRT_UART, + VIRT_RTC, VIRT_MMIO, }; @@ -101,6 +102,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_DIST] = { 0x8000000, 0x10000 }, [VIRT_GIC_CPU] = { 0x8010000, 0x10000 }, [VIRT_UART] = { 0x9000000, 0x1000 }, + [VIRT_RTC] = { 0x9010000, 0x1000 }, [VIRT_MMIO] = { 0xa000000, 0x200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */ @@ -109,6 +111,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 +356,34 @@ 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"; + const char clocknames[] = "apb_pclk"; + + sysbus_create_simple("pl031", base, pic[irq]); + + nodename = g_strdup_printf("/pl031@%" PRIx64, base); + qemu_fdt_add_subnode(vbi->fdt, nodename); + /* Note that we can't use setprop_string because of the embedded NUL */ + 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_cells(vbi->fdt, nodename, "clocks", + vbi->clock_phandle); + qemu_fdt_setprop(vbi->fdt, nodename, "clock-names", + clocknames, sizeof(clocknames)); + g_free(nodename); +} + static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) { int i; @@ -469,6 +500,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.