From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
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 v2 8/9] e500: Add support for eTSEC in device tree
Date: Wed, 2 Jul 2014 20:01:32 +0200 [thread overview]
Message-ID: <1404324093-19225-9-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1404324093-19225-1-git-send-email-agraf@suse.de>
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 <agraf@suse.de>
---
v1 -> v2:
- fix device name (base on reg for value after @)
- use qom properties to fetch mmio and irq props
- remove useless interrupt-parent
- make interrupts level triggered
---
hw/ppc/e500.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index f7fe41c..cbabcdf 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"
@@ -132,6 +133,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;
@@ -147,6 +179,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.1.4
next prev parent reply other threads:[~2014-07-02 18:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 18:01 [Qemu-devel] [PATCH v2 0/9] Dynamic sysbus device allocation support Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 1/9] qom: Move property helpers to own file Alexander Graf
2014-07-31 13:46 ` Peter Crosthwaite
2014-07-31 14:12 ` Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 2/9] qom: macroify integer property helpers Alexander Graf
2014-07-31 13:44 ` Peter Crosthwaite
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 3/9] qom: Expose property helpers for get/set of integers Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 4/9] qom: Add generic object property g_free helper Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 5/9] sysbus: Add user map hints Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 6/9] sysbus: Make devices spawnable via -device Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 7/9] PPC: e500: Support dynamically spawned sysbus devices Alexander Graf
2014-07-30 14:55 ` Peter Maydell
2014-07-31 4:07 ` Peter Crosthwaite
2014-07-02 18:01 ` Alexander Graf [this message]
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 9/9] PPC: Fix default config ordering and add eTSEC for ppc64 Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404324093-19225-9-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=afaerber@suse.de \
--cc=eric.auger@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sean.stalley@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).