From patchwork Tue Sep 9 07:54:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 37047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1A37520566 for ; Tue, 9 Sep 2014 08:02:50 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id m1sf82302826oag.3 for ; Tue, 09 Sep 2014 01:02:49 -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=/sfuVEg356Tuq+4CCjsyRcoMS9Jv8hUl7ol+qWZqHHc=; b=VtNJONvNIGBJ0rC6/WnRXGFiKx3jPiw2t2tuDjy3Rh+ghRJ2wCV1mtp0IXKtyuCgu8 PAR4LOyf80DKVcYL7h+431nWXcUozW+azKyuQmgX/sloNarlFuaNQ7np8Qgelb+IEPVJ SswHIRS8OJr9/Sz/6W+YEuwPCkTmS273NSrPM6lKvKgsN/wPzOz4q+8IbDge8WU/2aW6 Zs3LXM+2I7AnY33H+LTLkqbrhoumw0qkw8qJfCh1h76rIBG7tjEptB6JCgTL3/2oqSLc UmdyygK7aBjyb6rndWHWnhRCOzLZCGK22zdv+uiP8pp+HHYS3+ATf62GXQmezn7v/BYb EW5Q== X-Gm-Message-State: ALoCoQnCG0vrdAGje0Vr/OXN3Sho7a76hdOPiyh8F1Il2KIu4DOapGayMuNC8b+2kDUtOt+kjgQ2 X-Received: by 10.182.115.229 with SMTP id jr5mr21639805obb.38.1410249290148; Tue, 09 Sep 2014 00:54:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.87 with SMTP id l81ls1204132qga.51.gmail; Tue, 09 Sep 2014 00:54:50 -0700 (PDT) X-Received: by 10.52.246.198 with SMTP id xy6mr24592454vdc.7.1410249290073; Tue, 09 Sep 2014 00:54:50 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id dx5si5579686vdb.10.2014.09.09.00.54.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id le20so2604472vcb.27 for ; Tue, 09 Sep 2014 00:54:50 -0700 (PDT) X-Received: by 10.52.156.100 with SMTP id wd4mr11558588vdb.39.1410249289952; Tue, 09 Sep 2014 00:54:49 -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 uj3csp246171vcb; Tue, 9 Sep 2014 00:54:49 -0700 (PDT) X-Received: by 10.180.186.230 with SMTP id fn6mr28568358wic.44.1410249288944; Tue, 09 Sep 2014 00:54:48 -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 nd11si17035791wic.25.2014.09.09.00.54.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:48 -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 ex7so3771320wid.8 for ; Tue, 09 Sep 2014 00:54:48 -0700 (PDT) X-Received: by 10.194.219.34 with SMTP id pl2mr28560336wjc.48.1410249288555; Tue, 09 Sep 2014 00:54:48 -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.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 00:54:47 -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 2/6] hw/arm/dyn_sysbus_devtree: helpers for sysbus device dynamic dt node generation Date: Tue, 9 Sep 2014 08:54:29 +0100 Message-Id: <1410249273-6063-3-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.182 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: , This module will be used by ARM machine files to generate device tree nodes of dynamically instantiated sysbus devices (ie. those instantiated with -device option). Signed-off-by: Alexander Graf Signed-off-by: Eric Auger --- v2 -> v3: - add arm_ prefix - arm_sysbus_device_create_devtree becomes static v1 -> v2: - Code moved in an arch specific file to accomodate architecture dependent specificities. - remove platform_bus_base from PlatformDevtreeData v1: code originally written by Alex Graf in e500.c and reused for ARM [Eric Auger] code originally moved in hw/misc/platform_devices and device itself --- hw/arm/Makefile.objs | 1 + hw/arm/dyn_sysbus_devtree.c | 66 +++++++++++++++++++++++++++++++++++++ include/hw/arm/dyn_sysbus_devtree.h | 16 +++++++++ 3 files changed, 83 insertions(+) create mode 100644 hw/arm/dyn_sysbus_devtree.c create mode 100644 include/hw/arm/dyn_sysbus_devtree.h diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index 6088e53..bc5e014 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o +obj-y += dyn_sysbus_devtree.o obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o obj-$(CONFIG_DIGIC) += digic.o diff --git a/hw/arm/dyn_sysbus_devtree.c b/hw/arm/dyn_sysbus_devtree.c new file mode 100644 index 0000000..6375024 --- /dev/null +++ b/hw/arm/dyn_sysbus_devtree.c @@ -0,0 +1,66 @@ +#include "hw/arm/dyn_sysbus_devtree.h" +#include "qemu/error-report.h" +#include "sysemu/device_tree.h" + +static int arm_sysbus_device_create_devtree(Object *obj, void *opaque) +{ + PlatformDevtreeData *data = opaque; + Object *dev; + SysBusDevice *sbdev; + bool matched = false; + + dev = object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE); + sbdev = (SysBusDevice *)dev; + + if (!sbdev) { + /* Container, traverse it for children */ + return object_child_foreach(obj, + arm_sysbus_device_create_devtree, data); + } + + if (!matched) { + error_report("Device %s is not supported by this machine yet.", + qdev_fw_name(DEVICE(dev))); + exit(1); + } + + return 0; +} + +void arm_platform_bus_create_devtree(DynSysbusParams *params, + void *fdt, const char *intc) +{ + gchar *node = g_strdup_printf("/platform@%"PRIx64, + params->platform_bus_base); + const char platcomp[] = "qemu,platform\0simple-bus"; + PlatformDevtreeData data; + Object *container; + uint64_t addr = params->platform_bus_base; + uint64_t size = params->platform_bus_size; + int irq_start = params->platform_bus_first_irq; + + /* Create a /platform node that we can put all devices into */ + qemu_fdt_add_subnode(fdt, node); + qemu_fdt_setprop(fdt, node, "compatible", platcomp, sizeof(platcomp)); + + /* Our platform bus region is less than 32bit big, so 1 cell is enough for + address and size */ + qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1); + qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1); + qemu_fdt_setprop_cells(fdt, node, "ranges", 0, addr >> 32, addr, size); + + qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", intc); + + /* Loop through all devices and create nodes for known ones */ + data.fdt = fdt; + data.intc = intc; + data.irq_start = irq_start; + data.node = node; + + container = container_get(qdev_get_machine(), "/peripheral"); + arm_sysbus_device_create_devtree(container, &data); + container = container_get(qdev_get_machine(), "/peripheral-anon"); + arm_sysbus_device_create_devtree(container, &data); + + g_free(node); +} diff --git a/include/hw/arm/dyn_sysbus_devtree.h b/include/hw/arm/dyn_sysbus_devtree.h new file mode 100644 index 0000000..b072365 --- /dev/null +++ b/include/hw/arm/dyn_sysbus_devtree.h @@ -0,0 +1,16 @@ +#ifndef HW_ARM_DYN_SYSBUS_DEVTREE_H +#define HW_ARM_DYN_SYSBUS_DEVTREE_H + +#include "hw/misc/dyn_sysbus_binding.h" + +typedef struct PlatformDevtreeData { + void *fdt; + const char *intc; + int irq_start; + const char *node; +} PlatformDevtreeData; + +void arm_platform_bus_create_devtree(DynSysbusParams *params, + void *fdt, const char *intc); + +#endif