From patchwork Fri Aug 8 15:03:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 35137 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8725C2118A for ; Fri, 8 Aug 2014 15:04:21 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id uq10sf4269654igb.3 for ; Fri, 08 Aug 2014 08:04:21 -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=fsVKwT7oN7kLO2GLBiNkrStQQjdMfTDcKD1ZoqgYRCY=; b=bbry2bgaJ4mcwEmTt4KRmlOnbCjowGyN944rRPraqmdfmW72hleXkpOyCq4+yJCWiw WYd98N7qhbIXZUYOfBWTwANZSieS3UouUay6yS8scA2rqiHM1ebH076+l7dcpzVvtjv3 Sn4VRqtLzXUmxBr7mb1rrPeDdSpmCJBadm3ZDm03qM0VnqXYK/4aOHDPffD+8q7gwkqy IYm8p+n1BPnznv4+fzK0IpCZ6tbZQ0bdnXv3gSMCupOuw+28+NexbKghWeGKPYhOFmcx hYwSn39AJsGSL15NwcyIYFALNsZ1f2Lo/sFQclLf0xucXtioHWlzwOOlMxp7aVjU2nrF dm1A== X-Gm-Message-State: ALoCoQnC0K2/tvjU3Mn/BVvXCnaX67ajaUM10HjfnRZxgBZ4aNmnVQlX4v6ozAn8Kf4zirh60uVZ X-Received: by 10.42.177.5 with SMTP id bg5mr4818276icb.27.1407510261110; Fri, 08 Aug 2014 08:04:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.108 with SMTP id 99ls592601qgg.29.gmail; Fri, 08 Aug 2014 08:04:21 -0700 (PDT) X-Received: by 10.52.147.15 with SMTP id tg15mr1659950vdb.53.1407510260962; Fri, 08 Aug 2014 08:04:20 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id xi6si1701374vdb.85.2014.08.08.08.04.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so8438776vcb.2 for ; Fri, 08 Aug 2014 08:04:20 -0700 (PDT) X-Received: by 10.52.73.202 with SMTP id n10mr506560vdv.86.1407510260764; Fri, 08 Aug 2014 08:04:20 -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 tc5csp130656vcb; Fri, 8 Aug 2014 08:04:20 -0700 (PDT) X-Received: by 10.180.205.168 with SMTP id lh8mr4670769wic.33.1407510259729; Fri, 08 Aug 2014 08:04:19 -0700 (PDT) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by mx.google.com with ESMTPS id d2si3602470wix.49.2014.08.08.08.04.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:19 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.170 as permitted sender) client-ip=74.125.82.170; Received: by mail-we0-f170.google.com with SMTP id w62so5795189wes.15 for ; Fri, 08 Aug 2014 08:04:19 -0700 (PDT) X-Received: by 10.180.221.65 with SMTP id qc1mr5052572wic.28.1407510259216; Fri, 08 Aug 2014 08:04:19 -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.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 08:04:18 -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 4/7] e500: Add support for eTSEC in device tree Date: Fri, 8 Aug 2014 16:03:46 +0100 Message-Id: <1407510229-28167-5-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.171 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: , 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)));