From patchwork Fri Aug 8 15:03:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 35139 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6AB8A2118A for ; Fri, 8 Aug 2014 15:04:25 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hq11sf15915561vcb.11 for ; Fri, 08 Aug 2014 08:04:25 -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=HNug4uuOEdGkTeuwur7X0ueI/NW1F8mAKe2uOObBaLw=; b=Mz17yyX3pey1GKQI2r8rjveRyUR4p7mDhGpw/sK9cqrBkici/HG2KaGg4nRLnWk/g0 tW/Hmu9yOkWv+yns7HuQmRF8dUqtySlClHl6aI4ysncs3IYRiQXPucW/hjNE1m0lyta4 DyoXQP9FD7Rk7HxMvCMHoS2oFwEC3R2jHmY/P5k83sDs038d2bqaxP0vMpX0TWbP/8VX aai9pmWhhoqhv9rZHdC+bi6WmQse3vRrYzHiHB0AP/8fFTWYw5bNx9UcYty1bPO15O4z URlXTAaOsrFWx6ppfvcW+Asmid9k4PNUQqpsl8Obbp+25XMFdKP3PN0aVJRMWHQtFlHE kajg== X-Gm-Message-State: ALoCoQmCaGyKWszm4Xod0xaHrLHc+UaxFsXW5oEiv+fO1z6exLRUogm7ChkEwVJPsmvo0+A7Vdvm X-Received: by 10.236.216.67 with SMTP id f63mr5057768yhp.10.1407510265228; Fri, 08 Aug 2014 08:04:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.242 with SMTP id m105ls513503qga.84.gmail; Fri, 08 Aug 2014 08:04:25 -0700 (PDT) X-Received: by 10.52.156.100 with SMTP id wd4mr7126097vdb.39.1407510265115; Fri, 08 Aug 2014 08:04:25 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id ym7si2958171vdb.76.2014.08.08.08.04.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so8297691vcb.40 for ; Fri, 08 Aug 2014 08:04:25 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr7183819vdz.24.1407510265042; Fri, 08 Aug 2014 08:04:25 -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 tc5csp130663vcb; Fri, 8 Aug 2014 08:04:24 -0700 (PDT) X-Received: by 10.180.108.13 with SMTP id hg13mr5021221wib.28.1407510263733; Fri, 08 Aug 2014 08:04:23 -0700 (PDT) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by mx.google.com with ESMTPS id w12si4891219wiv.0.2014.08.08.08.04.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.175 as permitted sender) client-ip=209.85.212.175; Received: by mail-wi0-f175.google.com with SMTP id ho1so1176143wib.14 for ; Fri, 08 Aug 2014 08:04:23 -0700 (PDT) X-Received: by 10.180.91.111 with SMTP id cd15mr4479390wib.69.1407510263214; Fri, 08 Aug 2014 08:04:23 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id ko8sm17950604wjc.11.2014.08.08.08.04.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:22 -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, will.deacon@arm.com, kvmarm@lists.cs.columbia.edu, alex.williamson@redhat.com, Bharat.Bhushan@freescale.com, agraf@suse.de, peter.maydell@linaro.org, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, patches@linaro.org Subject: [RFC v2 6/7] hw/arm/virt: add new add_fdt_xxx_node functions Date: Fri, 8 Aug 2014 16:03:48 +0100 Message-Id: <1407510229-28167-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1407510229-28167-1-git-send-email-eric.auger@linaro.org> References: <1407510229-28167-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.181 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 66103c2..1a18a5a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -337,18 +337,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", @@ -365,17 +362,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", @@ -388,22 +391,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; @@ -423,6 +424,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;