From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFliU-0001TQ-Ae for qemu-devel@nongnu.org; Fri, 08 Aug 2014 11:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFliO-00078J-2T for qemu-devel@nongnu.org; Fri, 08 Aug 2014 11:04:26 -0400 Received: from mail-we0-f178.google.com ([74.125.82.178]:47535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFliN-00077m-SW for qemu-devel@nongnu.org; Fri, 08 Aug 2014 11:04:19 -0400 Received: by mail-we0-f178.google.com with SMTP id w61so5861502wes.37 for ; Fri, 08 Aug 2014 08:04:19 -0700 (PDT) From: Eric Auger Date: Fri, 8 Aug 2014 16:03:46 +0100 Message-Id: <1407510229-28167-5-git-send-email-eric.auger@linaro.org> In-Reply-To: <1407510229-28167-1-git-send-email-eric.auger@linaro.org> References: <1407510229-28167-1-git-send-email-eric.auger@linaro.org> Subject: [Qemu-devel] [RFC v2 4/7] e500: Add support for eTSEC in device tree List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, a.rigo@virtualopensystems.com Cc: peter.maydell@linaro.org, eric.auger@linaro.org, patches@linaro.org, will.deacon@arm.com, agraf@suse.de, stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com, alex.williamson@redhat.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu From: Alexander Graf This patch adds support to expose eTSEC devices in the dynamically created guest facing device tree. This allows us to expose eTSEC devices into guests without changes in the machine file. Because we can now tell the guest about eTSEC devices this patch allows the user to specify eTSEC devices via -device at all. Signed-off-by: Alexander Graf --- hw/ppc/e500.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 0ee8cbf..7a23245 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -38,6 +38,7 @@ #include "hw/pci-host/ppce500.h" #include "qemu/error-report.h" #include "hw/misc/dyn_sysbus_binding.h" +#include "hw/net/fsl_etsec/etsec.h" #define EPAPR_MAGIC (0x45504150) #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" @@ -133,6 +134,37 @@ typedef struct PlatformDevtreeData { const char *node; } PlatformDevtreeData; +static int create_devtree_etsec(eTSEC *etsec, PlatformDevtreeData *data) +{ + Object *obj = OBJECT(etsec); + uint64_t mmio0 = object_property_get_int(obj, "mmio[0]", NULL); + uint64_t irq0 = object_property_get_int(obj, "irq[0]", NULL); + uint64_t irq1 = object_property_get_int(obj, "irq[1]", NULL); + uint64_t irq2 = object_property_get_int(obj, "irq[2]", NULL); + gchar *node = g_strdup_printf("/platform/ethernet@%"PRIx64, mmio0); + gchar *group = g_strdup_printf("%s/queue-group", node); + void *fdt = data->fdt; + + qemu_fdt_add_subnode(fdt, node); + qemu_fdt_setprop_string(fdt, node, "device_type", "network"); + qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,etsec2"); + qemu_fdt_setprop_string(fdt, node, "model", "eTSEC"); + qemu_fdt_setprop(fdt, node, "local-mac-address", etsec->conf.macaddr.a, 6); + qemu_fdt_setprop_cells(fdt, node, "fixed-link", 0, 1, 1000, 0, 0); + + qemu_fdt_add_subnode(fdt, group); + qemu_fdt_setprop_cells(fdt, group, "reg", mmio0, 0x1000); + qemu_fdt_setprop_cells(fdt, group, "interrupts", + data->irq_start + irq0, 0x2, + data->irq_start + irq1, 0x2, + data->irq_start + irq2, 0x2); + + g_free(node); + g_free(group); + + return 0; +} + static int sysbus_device_create_devtree(Object *obj, void *opaque) { PlatformDevtreeData *data = opaque; @@ -148,6 +180,11 @@ static int sysbus_device_create_devtree(Object *obj, void *opaque) return object_child_foreach(obj, sysbus_device_create_devtree, data); } + if (object_dynamic_cast(obj, TYPE_ETSEC_COMMON)) { + create_devtree_etsec(ETSEC_COMMON(dev), data); + matched = true; + } + if (!matched) { error_report("Device %s is not supported by this machine yet.", qdev_fw_name(DEVICE(dev))); -- 1.8.3.2