From patchwork Fri Aug 8 15:03:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 35135 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9E2E22118A for ; Fri, 8 Aug 2014 15:04:17 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id v10sf14598829qac.8 for ; Fri, 08 Aug 2014 08:04:17 -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=/fMTUMqFWzNnhiKJY4M/MKY8EK75mofOZwXNFCosL4M=; b=d5dL1lGgqdK4EjlDmV2Zz/nyaJlSPDCyNivudVk4iG7Hxpb5gjjxBVdkDM6zhTcg4K Z4mtJ7eeKG8dGqYKz7/NeyJ2Kn1HMu1m2x4nqKUvDGgmIqz3YHaq14+CXC5MUyGM54AE T5Ukf+wbGi2oDDex0p+aDz0+cZsEmLLI0SBLscD8t4Gnd1tVtEe8KsRj4OuwXRExaron UekPhLF/mb2MAr32plecI6WdF0yqWbNlS7ipsn82hZZMG20gyZijajPSibqhbpFRhHbO btCD987UE6z1v+6WepkcEmFIlWIwNb8iEfBg5bweW330eLlqpZF4XjPA0dmeX5d+qdPH hzvA== X-Gm-Message-State: ALoCoQl/Mb5YnSqarjt5K/uFYqYCCSSUM+V2C4GzvyqM3+YHI8+EBze6ZXMAduv+eWHLKEIkHrNM X-Received: by 10.52.186.103 with SMTP id fj7mr5126267vdc.8.1407510257507; Fri, 08 Aug 2014 08:04:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.148 with SMTP id 20ls571064qgt.86.gmail; Fri, 08 Aug 2014 08:04:17 -0700 (PDT) X-Received: by 10.220.131.207 with SMTP id y15mr660639vcs.71.1407510257426; Fri, 08 Aug 2014 08:04:17 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id w4si2967162vct.72.2014.08.08.08.04.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so8480526vcb.35 for ; Fri, 08 Aug 2014 08:04:17 -0700 (PDT) X-Received: by 10.52.144.14 with SMTP id si14mr12646vdb.95.1407510257350; Fri, 08 Aug 2014 08:04:17 -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 tc5csp130647vcb; Fri, 8 Aug 2014 08:04:16 -0700 (PDT) X-Received: by 10.180.99.65 with SMTP id eo1mr5024417wib.12.1407510256009; Fri, 08 Aug 2014 08:04:16 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by mx.google.com with ESMTPS id gs2si3623691wib.10.2014.08.08.08.04.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by mail-wi0-f169.google.com with SMTP id n3so2673705wiv.0 for ; Fri, 08 Aug 2014 08:04:15 -0700 (PDT) X-Received: by 10.194.71.52 with SMTP id r20mr4702622wju.113.1407510255490; Fri, 08 Aug 2014 08:04:15 -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.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:14 -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 2/7] hw/arm/dyn_sysbus_devtree: helpers for sysbus device dynamic dt node generation Date: Fri, 8 Aug 2014 16:03:44 +0100 Message-Id: <1407510229-28167-3-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.176 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: - 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 | 18 ++++++++++ 3 files changed, 85 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..56af62f --- /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" + +int 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, 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 platform_bus_create_devtree(DynSysbusParams *params, + void *fdt, const char *mpic) +{ + 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", mpic); + + /* Loop through all devices and create nodes for known ones */ + data.fdt = fdt; + data.mpic = mpic; + data.irq_start = irq_start; + data.node = node; + + container = container_get(qdev_get_machine(), "/peripheral"); + sysbus_device_create_devtree(container, &data); + container = container_get(qdev_get_machine(), "/peripheral-anon"); + 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..808d522 --- /dev/null +++ b/include/hw/arm/dyn_sysbus_devtree.h @@ -0,0 +1,18 @@ +#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 *mpic; + int irq_start; + const char *node; +} PlatformDevtreeData; + +int sysbus_device_create_devtree(Object *obj, void *opaque); + +void platform_bus_create_devtree(DynSysbusParams *params, + void *fdt, const char *mpic); + +#endif