qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 29/33] e500: Add support for eTSEC in device tree
Date: Tue,  4 Nov 2014 20:26:47 +0100	[thread overview]
Message-ID: <1415129211-9740-30-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1415129211-9740-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>
---
 hw/ppc/e500.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 123379d..2832fc0 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/platform-bus.h"
+#include "hw/net/fsl_etsec/etsec.h"
 
 #define EPAPR_MAGIC                (0x45504150)
 #define BINARY_DEVICE_TREE_FILE    "mpc8544ds.dtb"
@@ -162,11 +163,53 @@ typedef struct PlatformDevtreeData {
     PlatformBusDevice *pbus;
 } PlatformDevtreeData;
 
+static int create_devtree_etsec(SysBusDevice *sbdev, PlatformDevtreeData *data)
+{
+    eTSEC *etsec = ETSEC_COMMON(sbdev);
+    PlatformBusDevice *pbus = data->pbus;
+    hwaddr mmio0 = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+    int irq0 = platform_bus_get_irqn(pbus, sbdev, 0);
+    int irq1 = platform_bus_get_irqn(pbus, sbdev, 1);
+    int irq2 = platform_bus_get_irqn(pbus, sbdev, 2);
+    gchar *node = g_strdup_printf("/platform/ethernet@%"PRIx64, mmio0);
+    gchar *group = g_strdup_printf("%s/queue-group", node);
+    void *fdt = data->fdt;
+
+    assert((int64_t)mmio0 >= 0);
+    assert(irq0 >= 0);
+    assert(irq1 >= 0);
+    assert(irq2 >= 0);
+
+    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(SysBusDevice *sbdev, void *opaque)
 {
     PlatformDevtreeData *data = opaque;
     bool matched = false;
 
+    if (object_dynamic_cast(OBJECT(sbdev), TYPE_ETSEC_COMMON)) {
+        create_devtree_etsec(sbdev, data);
+        matched = true;
+    }
+
     if (!matched) {
         error_report("Device %s is not supported by this machine yet.",
                      qdev_fw_name(DEVICE(sbdev)));
-- 
1.8.1.4

  parent reply	other threads:[~2014-11-04 19:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 19:26 [Qemu-devel] [PULL 2.2 00/33] ppc patch queue 2014-11-04 for 2.2 Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 01/33] ppc: fix monitor access to CR Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 02/33] ppc: use CRF_* in int_helper.c Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 03/33] ppc: fix result of DLMZB when no zero bytes are found Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 04/33] ppc: rename gen_set_cr6_from_fpscr Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 05/33] ppc: compute mask from BI using right shift Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 06/33] target-ppc: Fix kvmppc_set_compat to use negotiated cpu-version Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 07/33] target-ppc: Implement IVOR[59] By Default for Book E Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 08/33] target-ppc: virtex-ml507 machine type should depend on CONFIG_XILINX Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 09/33] spapr: Cleanup machine naming conventions, and prepare for 2.2 release Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 10/33] PPC: openpic_kvm: Only map first occurence in address space Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 11/33] target-ppc : Allow fc[tf]id[*] mnemonics for non TARGET_PPC64 Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 12/33] target-ppc : Add new processor type 440x5wDFPU Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 13/33] hw/pci/ppc4xx_pci.c: Remove unused pci4xx_cfgaddr_read/write/ops Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 14/33] target-ppc: Use macros in opcodes table handling code Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 15/33] target-ppc: Fix an invalid free in opcode " Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 16/33] PPC: Add MPC8XXX gpio controller Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 17/33] PPC: E500: Instantiate MPC8XXX gpio controller on virt machine Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 18/33] PPC: E500: Hook up power off GPIO to GPIO controller Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 19/33] spapr_nvram: Enable migration Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 20/33] target-ppc: kvm: Fix memory overflow issue about strncat() Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 21/33] ppc: do not look at the MMU index to detect PR/HV mode Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 22/33] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*) Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 23/33] sysbus: Add dynamic sysbus device search Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 24/33] sysbus: Make devices spawnable via -device Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 25/33] sysbus: Expose IRQ enumeration helpers Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 26/33] sysbus: Expose MMIO enumeration helper Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 27/33] sysbus: Add new platform bus helper device Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 28/33] PPC: e500: Support dynamically spawned sysbus devices Alexander Graf
2014-11-04 19:26 ` Alexander Graf [this message]
2014-11-04 19:26 ` [Qemu-devel] [PULL 30/33] target-ppc: simplify AES emulation Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 31/33] target-ppc: Fix Altivec Shifts Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 32/33] target-ppc: Fix vcmpbfp. Unordered Case Alexander Graf
2014-11-04 19:26 ` [Qemu-devel] [PULL 33/33] target-ppc: Fix Altivec Round Opcodes Alexander Graf
2014-11-04 21:34 ` [Qemu-devel] [PULL 2.2 00/33] ppc patch queue 2014-11-04 for 2.2 Peter Maydell
2014-11-05 12:48 ` Peter Maydell

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=1415129211-9740-30-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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).