All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, eric.auger@linaro.org
Subject: [Qemu-devel] [PATCH 5/5] PPC: e500: Add support for platform serial devices
Date: Wed,  4 Jun 2014 14:28:56 +0200	[thread overview]
Message-ID: <1401884936-12907-6-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1401884936-12907-1-git-send-email-agraf@suse.de>

The guest only becomes aware of platform devices when we describe them inside
the device tree.

This patch adds description support for platform serial devices in device tree,
allowing us to specify a serial port on the command line with -device.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 default-configs/ppc-softmmu.mak   |  1 +
 default-configs/ppc64-softmmu.mak |  1 +
 hw/ppc/e500.c                     | 28 ++++++++++++++++++++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index d6ec8b9..63e7949 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -46,6 +46,7 @@ CONFIG_MAC=y
 CONFIG_E500=y
 CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM))
 CONFIG_PLATFORM=y
+CONFIG_SERIAL_PLATFORM=y
 # For PReP
 CONFIG_MC146818RTC=y
 CONFIG_ETSEC=y
diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-softmmu.mak
index 06677bf..b72fb45 100644
--- a/default-configs/ppc64-softmmu.mak
+++ b/default-configs/ppc64-softmmu.mak
@@ -46,6 +46,7 @@ CONFIG_PREP=y
 CONFIG_MAC=y
 CONFIG_E500=y
 CONFIG_PLATFORM=y
+CONFIG_SERIAL_PLATFORM=y
 CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM))
 # For pSeries
 CONFIG_XICS=$(CONFIG_PSERIES)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index bc26215..39f028f 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 "hw/platform/device.h"
+#include "hw/char/serial-platform.h"
 
 #define EPAPR_MAGIC                (0x45504150)
 #define BINARY_DEVICE_TREE_FILE    "mpc8544ds.dtb"
@@ -110,7 +111,7 @@ static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot,
 }
 
 static void dt_serial_create(void *fdt, unsigned long long offset,
-                             const char *soc, const char *mpic,
+                             const char *soc, const char *mpic, int irq,
                              const char *alias, int idx, bool defcon)
 {
     char ser[128];
@@ -122,7 +123,7 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
     qemu_fdt_setprop_cells(fdt, ser, "reg", offset, 0x100);
     qemu_fdt_setprop_cell(fdt, ser, "cell-index", idx);
     qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", 0);
-    qemu_fdt_setprop_cells(fdt, ser, "interrupts", 42, 2);
+    qemu_fdt_setprop_cells(fdt, ser, "interrupts", irq, 2);
     qemu_fdt_setprop_phandle(fdt, ser, "interrupt-parent", mpic);
     qemu_fdt_setprop_string(fdt, "/aliases", alias, ser);
 
@@ -135,6 +136,7 @@ typedef struct PlatformDevtreeData {
     void *fdt;
     const char *mpic;
     int irq_start;
+    int serial_idx;
     const char *node;
 } PlatformDevtreeData;
 
@@ -152,9 +154,30 @@ static int platform_device_create_devtree(Object *obj, void *opaque)
         return object_child_foreach(obj, platform_device_create_devtree, data);
     }
 
+    if (PLATFORM_SERIAL(dev)) {
+        char *alias = g_strdup_printf("serial%d", data->serial_idx);
+        dt_serial_create(data->fdt, pdev->plat_region_addrs[0], data->node,
+                         data->mpic, data->irq_start + pdev->plat_irqs[0],
+                         alias, data->serial_idx, data->serial_idx == 0);
+        data->serial_idx++;
+    }
+
     return 0;
 }
 
+static int count_serial_hds(void)
+{
+    int r = 0, i;
+
+    for (i = 0; i < 2; i++) {
+        if (serial_hds[i]) {
+            r++;
+        }
+    }
+
+    return r;
+}
+
 static void platform_create_devtree(void *fdt, const char *node, uint64_t addr,
                                     const char *mpic, int irq_start,
                                     int nr_irqs)
@@ -180,6 +203,7 @@ static void platform_create_devtree(void *fdt, const char *node, uint64_t addr,
     /* Loop through all devices and create nodes for known ones */
 
     data.fdt = fdt;
+    data.serial_idx = count_serial_hds();
     data.mpic = mpic;
     data.irq_start = irq_start;
     data.node = node;
-- 
1.8.1.4

  parent reply	other threads:[~2014-06-04 12:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 12:28 [Qemu-devel] [PATCH 0/5] Platform device support Alexander Graf
2014-06-04 12:28 ` [Qemu-devel] [PATCH 1/5] Platform: Add platform device class Alexander Graf
2014-06-19 14:51   ` Eric Auger
2014-06-04 12:28 ` [Qemu-devel] [PATCH 2/5] Platform: Add serial device Alexander Graf
2014-06-04 12:28 ` [Qemu-devel] [PATCH 3/5] PPC: e500: Only create dt entries for existing serial ports Alexander Graf
2014-06-04 12:28 ` [Qemu-devel] [PATCH 4/5] PPC: e500: Support platform devices Alexander Graf
2014-06-13  8:58   ` Bharat.Bhushan
2014-06-13  9:46     ` Alexander Graf
2014-06-19 14:56   ` Eric Auger
2014-06-19 21:40     ` Alexander Graf
2014-06-27  9:29   ` Eric Auger
2014-06-27 11:30     ` Alexander Graf
2014-06-27 16:50       ` Eric Auger
2014-06-04 12:28 ` Alexander Graf [this message]
2014-06-19 20:54 ` [Qemu-devel] [PATCH 0/5] Platform device support Paolo Bonzini
2014-06-19 21:38   ` Alexander Graf
2014-06-20  6:43 ` Peter Crosthwaite
2014-06-20  7:39   ` Paolo Bonzini
2014-06-26 12:01   ` Alexander Graf
2014-06-27 10:30     ` Andreas Färber
2014-06-27 10:54       ` Peter Crosthwaite
2014-06-27 11:17         ` Andreas Färber
2014-06-27 11:24           ` Alexander Graf
2014-06-27 11:48             ` Paolo Bonzini
2014-06-27 11:52               ` Peter Maydell
2014-06-27 12:00                 ` Paolo Bonzini
2014-06-27 11:41         ` Alexander Graf
2014-06-27 11:40       ` 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=1401884936-12907-6-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=eric.auger@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.