From patchwork Tue Jul 1 21:49:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 366210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 14B4D14009E for ; Wed, 2 Jul 2014 07:50:43 +1000 (EST) Received: from localhost ([::1]:50113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X25wn-0007QW-0c for incoming@patchwork.ozlabs.org; Tue, 01 Jul 2014 17:50:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X25vw-0006JU-3S for qemu-devel@nongnu.org; Tue, 01 Jul 2014 17:49:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X25vp-0003k2-0e for qemu-devel@nongnu.org; Tue, 01 Jul 2014 17:49:48 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51455 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X25vo-0003jk-Qq; Tue, 01 Jul 2014 17:49:40 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 63603AD03; Tue, 1 Jul 2014 21:49:39 +0000 (UTC) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Tue, 1 Jul 2014 23:49:38 +0200 Message-Id: <1404251378-5242-7-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1404251378-5242-1-git-send-email-agraf@suse.de> References: <1404251378-5242-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, eric.auger@linaro.org, qemu-devel@nongnu.org, sean.stalley@intel.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 6/6] e500: Add support for eTSEC in device tree X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index bf704b0..bebff6f 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -37,6 +37,7 @@ #include "qemu/host-utils.h" #include "hw/pci-host/ppce500.h" #include "qemu/error-report.h" +#include "hw/net/fsl_etsec/etsec.h" #define EPAPR_MAGIC (0x45504150) #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" @@ -139,6 +140,34 @@ typedef struct PlatformDevtreeData { int id; } PlatformDevtreeData; +static int create_devtree_etsec(eTSEC *etsec, PlatformDevtreeData *data) +{ + SysBusDevice *sbdev = &etsec->busdev; + gchar *node = g_strdup_printf("/platform/ethernet@%d", data->id); + 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", sbdev->user_mmios[0], 0x1000); + qemu_fdt_setprop_phandle(fdt, group, "interrupt-parent", data->mpic); + qemu_fdt_setprop_cells(fdt, group, "interrupts", + data->irq_start + sbdev->user_irqs[0], 0x0, + data->irq_start + sbdev->user_irqs[1], 0x0, + data->irq_start + sbdev->user_irqs[2], 0x0); + + g_free(node); + g_free(group); + + return 0; +} + static int sysbus_device_create_devtree(Object *obj, void *opaque) { PlatformDevtreeData *data = opaque; @@ -154,6 +183,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) { data->id++; } else {