From patchwork Tue Sep 9 07:54:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 37046 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EFA2D20491 for ; Tue, 9 Sep 2014 08:01:23 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf76001535igi.8 for ; Tue, 09 Sep 2014 01:01:23 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Ewmg8wPm+HVhr3juxGkiM4oNdDfZqpMhSjy4ETDTQ4Y=; b=gMOXrhLXorCLUizUKbU5mJXlqF2X6uXe6VooRVp4z/0Ob90hTuQzzoR2jSYHEQZfFw pmtcxX1aWmYymXKHu4p9qwS8jLnUNuj+trPHKW5Y+NYbIG8A5mG3WEx6mi5YtrtjXehi Q/hOA44CueOZ3aSLOSTMrl65n/d+TerDHZos2dIxOCrchM6MNo6NGNEwaymRQQpyqgDw Vu5B7fDfCr4kECtrge4woG+vNZd03ouBERlbl8jQAUP54TMV4wjyzwa49yQYHQXuLmyr YaR1AkZUGe6tHmN0umHK4k0ni0pd1V2XL+wDK1TrO5u1D/fIV0GyQWgMMSysMhZz4isi DjFw== X-Gm-Message-State: ALoCoQkqNNN03gcYMsIiPorVB1hOrc0F7Wgw2A/nCxSnmq+WVfVXksQdZf/QMXNOLAEnkb7cWJOZ X-Received: by 10.42.90.209 with SMTP id l17mr125444icm.34.1410249295931; Tue, 09 Sep 2014 00:54:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.239 with SMTP id o102ls1940716qge.70.gmail; Tue, 09 Sep 2014 00:54:55 -0700 (PDT) X-Received: by 10.52.245.101 with SMTP id xn5mr11881219vdc.32.1410249295855; Tue, 09 Sep 2014 00:54:55 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id yk10si5542169vdb.43.2014.09.09.00.54.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id im17so2263832vcb.38 for ; Tue, 09 Sep 2014 00:54:55 -0700 (PDT) X-Received: by 10.221.26.130 with SMTP id rm2mr4636438vcb.47.1410249295791; Tue, 09 Sep 2014 00:54:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp246179vcb; Tue, 9 Sep 2014 00:54:55 -0700 (PDT) X-Received: by 10.195.11.234 with SMTP id el10mr41162602wjd.95.1410249294862; Tue, 09 Sep 2014 00:54:54 -0700 (PDT) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx.google.com with ESMTPS id q3si16243302wjo.64.2014.09.09.00.54.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.176 as permitted sender) client-ip=209.85.212.176; Received: by mail-wi0-f176.google.com with SMTP id bs8so3924292wib.15 for ; Tue, 09 Sep 2014 00:54:54 -0700 (PDT) X-Received: by 10.180.94.161 with SMTP id dd1mr28820160wib.22.1410249294452; Tue, 09 Sep 2014 00:54:54 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id xt6sm13873858wjc.14.2014.09.09.00.54.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:53 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, kim.phillips@freescale.com, marc.zyngier@arm.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com, agraf@suse.de, peter.maydell@linaro.org, pbonzini@redhat.com, afaerber@suse.de Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, will.deacon@arm.com, Bharat.Bhushan@freescale.com, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, alex.williamson@redhat.com Subject: [PATCH v3 5/6] hw/arm/virt: new add_fdt_*_node functions Date: Tue, 9 Sep 2014 08:54:32 +0100 Message-Id: <1410249273-6063-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1410249273-6063-1-git-send-email-eric.auger@linaro.org> References: <1410249273-6063-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@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.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Create new functions: - add_fdt_uart_node - add_fdt_rtc_node - add_fdt_virtio_nodes They will be used for dynamic sysbus instantiation. Signed-off-by: Eric Auger --- v2 -> v3: reword title to avoid content violation --- hw/arm/virt.c | 67 +++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d6fffc7..9085b88 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -351,18 +351,15 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic) fdt_add_gic_node(vbi); } -static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) +static void fdt_add_uart_node(const VirtBoardInfo *vbi) { - char *nodename; hwaddr base = vbi->memmap[VIRT_UART].base; hwaddr size = vbi->memmap[VIRT_UART].size; int irq = vbi->irqmap[VIRT_UART]; const char compat[] = "arm,pl011\0arm,primecell"; const char clocknames[] = "uartclk\0apb_pclk"; + char *nodename = g_strdup_printf("/pl011@%" PRIx64, base); - sysbus_create_simple("pl011", base, pic[irq]); - - nodename = g_strdup_printf("/pl011@%" 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", @@ -379,17 +376,23 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } -static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) +static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) +{ + hwaddr base = vbi->memmap[VIRT_UART].base; + int irq = vbi->irqmap[VIRT_UART]; + + sysbus_create_simple("pl011", base, pic[irq]); + fdt_add_uart_node(vbi); +} + +static void fdt_add_rtc_node(const VirtBoardInfo *vbi) { - 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"; + char *nodename = g_strdup_printf("/pl031@%" PRIx64, base); - 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", @@ -402,22 +405,20 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } -static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) +static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) { - int i; - hwaddr size = vbi->memmap[VIRT_MMIO].size; + hwaddr base = vbi->memmap[VIRT_RTC].base; + int irq = vbi->irqmap[VIRT_RTC]; - /* Note that we have to create the transports in forwards order - * so that command line devices are inserted lowest address first, - * and then add dtb nodes in reverse order so that they appear in - * the finished device tree lowest address first. - */ - for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) { - int irq = vbi->irqmap[VIRT_MMIO] + i; - hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size; + sysbus_create_simple("pl031", base, pic[irq]); - sysbus_create_simple("virtio-mmio", base, pic[irq]); - } + fdt_add_rtc_node(vbi); +} + +static void fdt_add_virtio_nodes(const VirtBoardInfo *vbi) +{ + int i; + hwaddr size = vbi->memmap[VIRT_MMIO].size; for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) { char *nodename; @@ -437,6 +438,26 @@ static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) } } +static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) +{ + int i; + hwaddr size = vbi->memmap[VIRT_MMIO].size; + + /* Note that we have to create the transports in forwards order + * so that command line devices are inserted lowest address first, + * and then add dtb nodes in reverse order so that they appear in + * the finished device tree lowest address first. + */ + for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) { + int irq = vbi->irqmap[VIRT_MMIO] + i; + hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size; + + sysbus_create_simple("virtio-mmio", base, pic[irq]); + } + + fdt_add_virtio_nodes(vbi); +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;