From patchwork Mon Jul 7 07:08:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 33131 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9324720C88 for ; Mon, 7 Jul 2014 07:12:04 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h3sf16446026igd.5 for ; Mon, 07 Jul 2014 00:12:04 -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=4bVO4rM2L3EirZv+BTzmowXSlWX0hsQVD8LTsuCDyLo=; b=I4zhl4ZQNNuA3MVRc1xPoyRW/g8TNzesOREdrwh/xvdJ7652xeRkQffgcbAeO6ztqa 7iI5eqy3fTVGPSHlNGNwBDpPBgckstdqFHjA1yIlVe9rRo51/BzqOignDulGFWX4vjl2 qHt71hF/ayDuDSGFSLXD8qpkUzlk/i68oxbhc3O2jfXvjYCxj2FQUQtFtMztp+K45uWu kRnxiAam3GVu8WVetM7cii+WVLdnG9sh5dT0fQY/2qnxdmIH2P2WoCHiOUe6+wIKrjr6 89TF9u8EskDhh9WYEZYcLtxrIzT2vd+yCnOTr1sfLT2DGhB6Kj4QdVcu6vXeX4tk21K3 s25g== X-Gm-Message-State: ALoCoQlhgo1IpAqFvv35xrU0KpVsyMMz8VwX0VABhZynaIRPqRWbWcINFvOcZFrnM2xvsZU+bWQk X-Received: by 10.182.118.230 with SMTP id kp6mr13924098obb.42.1404717124168; Mon, 07 Jul 2014 00:12:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.104 with SMTP id u95ls1615125qgd.5.gmail; Mon, 07 Jul 2014 00:12:04 -0700 (PDT) X-Received: by 10.221.34.13 with SMTP id sq13mr2744776vcb.16.1404717124066; Mon, 07 Jul 2014 00:12:04 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id q6si18461271vcm.67.2014.07.07.00.12.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 00:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so3717192veb.28 for ; Mon, 07 Jul 2014 00:12:04 -0700 (PDT) X-Received: by 10.58.19.10 with SMTP id a10mr26577148vee.1.1404717123995; Mon, 07 Jul 2014 00:12:03 -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.37.5 with SMTP id tc5csp644878vcb; Mon, 7 Jul 2014 00:12:03 -0700 (PDT) X-Received: by 10.181.8.204 with SMTP id dm12mr35099414wid.67.1404717122995; Mon, 07 Jul 2014 00:12:02 -0700 (PDT) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx.google.com with ESMTPS id t4si12883835wiw.83.2014.07.07.00.12.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 00:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.182 as permitted sender) client-ip=74.125.82.182; Received: by mail-we0-f182.google.com with SMTP id q59so3850165wes.41 for ; Mon, 07 Jul 2014 00:12:02 -0700 (PDT) X-Received: by 10.194.171.68 with SMTP id as4mr30879930wjc.80.1404717122198; Mon, 07 Jul 2014 00:12:02 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id fb15sm111830218wid.23.2014.07.07.00.12.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 00:12:01 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, a.rigo@virtualopensystems.com Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, alex.williamson@redhat.com, agraf@suse.de, peter.maydell@linaro.org, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, patches@linaro.org Subject: [PATCH 3/7] hw/arm/virt: add new add_fdt_xxx_node functions Date: Mon, 7 Jul 2014 08:08:08 +0100 Message-Id: <1404716892-15600-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404716892-15600-1-git-send-email-eric.auger@linaro.org> References: <1404716892-15600-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.128.169 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 --- 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 405c61d..eeecdbf 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -330,18 +330,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", @@ -358,17 +355,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", @@ -381,22 +384,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; @@ -416,6 +417,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;