qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Cc: qemu-ppc Mailing List <qemu-ppc@nongnu.org>
Subject: [Qemu-devel] [PATCH 16/31] PPC: e500: dt: create serial nodes dynamically
Date: Tue, 19 Jun 2012 21:15:09 +0200	[thread overview]
Message-ID: <1340133324-352-17-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1340133324-352-1-git-send-email-agraf@suse.de>

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v2 -> v3:

  - use snprintf
  - use new multi-cell setting api
---
 hw/ppce500_mpc8544ds.c |   35 +++++++++++++++++++++++++++++++++++
 pc-bios/mpc8544ds.dts  |   26 --------------------------
 2 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index c7c16c1..c68e994 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -81,6 +81,8 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
     char compatible[] = "MPC8544DS\0MPC85xxDS";
     char model[] = "MPC8544DS";
     char soc[128];
+    char ser0[128];
+    char ser1[128];
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
@@ -182,6 +184,7 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
         }
     }
 
+    qemu_devtree_add_subnode(fdt, "/aliases");
     /* XXX These should go into their respective devices' code */
     snprintf(soc, sizeof(soc), "/soc8544@%x", MPC8544_CCSRBAR_BASE);
     qemu_devtree_add_subnode(fdt, soc);
@@ -196,6 +199,38 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
     /* XXX should contain a reasonable value */
     qemu_devtree_setprop_cell(fdt, soc, "bus-frequency", 0);
 
+    /*
+     * We have to generate ser1 first, because Linux takes the first
+     * device it finds in the dt as serial output device. And we generate
+     * devices in reverse order to the dt.
+     */
+    snprintf(ser1, sizeof(ser1), "%s/serial@%x", soc,
+             MPC8544_SERIAL1_REGS_BASE - MPC8544_CCSRBAR_BASE);
+    qemu_devtree_add_subnode(fdt, ser1);
+    qemu_devtree_setprop_string(fdt, ser1, "device_type", "serial");
+    qemu_devtree_setprop_string(fdt, ser1, "compatible", "ns16550");
+    qemu_devtree_setprop_cells(fdt, ser1, "reg", MPC8544_SERIAL1_REGS_BASE -
+                               MPC8544_CCSRBAR_BASE, 0x100);
+    qemu_devtree_setprop_cell(fdt, ser1, "cell-index", 1);
+    qemu_devtree_setprop_cell(fdt, ser1, "clock-frequency", 0);
+    qemu_devtree_setprop_cells(fdt, ser1, "interrupts", 42, 2);
+    qemu_devtree_setprop_phandle(fdt, ser1, "interrupt-parent", mpic);
+    qemu_devtree_setprop_string(fdt, "/aliases", "serial1", ser1);
+
+    snprintf(ser0, sizeof(ser0), "%s/serial@%x", soc,
+             MPC8544_SERIAL0_REGS_BASE - MPC8544_CCSRBAR_BASE);
+    qemu_devtree_add_subnode(fdt, ser0);
+    qemu_devtree_setprop_string(fdt, ser0, "device_type", "serial");
+    qemu_devtree_setprop_string(fdt, ser0, "compatible", "ns16550");
+    qemu_devtree_setprop_cells(fdt, ser0, "reg", MPC8544_SERIAL0_REGS_BASE -
+                               MPC8544_CCSRBAR_BASE, 0x100);
+    qemu_devtree_setprop_cell(fdt, ser0, "cell-index", 0);
+    qemu_devtree_setprop_cell(fdt, ser0, "clock-frequency", 0);
+    qemu_devtree_setprop_cells(fdt, ser0, "interrupts", 42, 2);
+    qemu_devtree_setprop_phandle(fdt, ser0, "interrupt-parent", mpic);
+    qemu_devtree_setprop_string(fdt, "/aliases", "serial0", ser0);
+    qemu_devtree_setprop_string(fdt, "/chosen", "linux,stdout-path", ser0);
+
     ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
     if (ret < 0) {
         goto out;
diff --git a/pc-bios/mpc8544ds.dts b/pc-bios/mpc8544ds.dts
index 01b53ba..e536ab1 100644
--- a/pc-bios/mpc8544ds.dts
+++ b/pc-bios/mpc8544ds.dts
@@ -12,32 +12,10 @@
 /dts-v1/;
 / {
 	aliases {
-		serial0 = &serial0;
-		serial1 = &serial1;
 		pci0 = &pci0;
 	};
 
 	soc8544@e0000000 {
-		serial0: serial@4500 {
-			cell-index = <0>;
-			device_type = "serial";
-			compatible = "ns16550";
-			reg = <0x4500 0x100>;
-			clock-frequency = <0>;
-			interrupts = <42 2>;
-			interrupt-parent = <&mpic>;
-		};
-
-		serial1: serial@4600 {
-			cell-index = <1>;
-			device_type = "serial";
-			compatible = "ns16550";
-			reg = <0x4600 0x100>;
-			clock-frequency = <0>;
-			interrupts = <42 2>;
-			interrupt-parent = <&mpic>;
-		};
-
 		mpic: pic@40000 {
 			interrupt-controller;
 			#address-cells = <0>;
@@ -85,8 +63,4 @@
 		#address-cells = <3>;
 		reg = <0xe0008000 0x1000>;
 	};
-
-	chosen {
-		linux,stdout-path = "/soc8544@e0000000/serial@4500";
-	};
 };
-- 
1.6.0.2

  parent reply	other threads:[~2012-06-19 19:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19 19:14 [Qemu-devel] [PATCH 00/31] PPC: mpc8544ds: Create device tree dynamically Alexander Graf
2012-06-19 19:14 ` [Qemu-devel] [PATCH 01/31] dt: allow add_subnode to create root subnodes Alexander Graf
2012-06-19 19:14 ` [Qemu-devel] [PATCH 02/31] dt: add helpers for multi-cell adds Alexander Graf
2012-06-21  4:28   ` Peter Crosthwaite
2012-06-19 19:14 ` [Qemu-devel] [PATCH 03/31] dt: add helper for phandle references Alexander Graf
2012-06-21  4:30   ` Peter Crosthwaite
2012-06-19 19:14 ` [Qemu-devel] [PATCH 04/31] dt: temporarily disable subtree creation failure check Alexander Graf
2012-06-19 19:14 ` [Qemu-devel] [PATCH 05/31] dt: add helper for phandle enumeration Alexander Graf
2012-06-21  4:31   ` Peter Crosthwaite
2012-06-19 19:14 ` [Qemu-devel] [PATCH 06/31] dt: add helper for empty dt creation Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 07/31] dt: add helper for phandle allocation Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 08/31] dt: add helper for 64bit cell adds Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 09/31] PPC: e500: require libfdt Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 10/31] PPC: e500: dt: create memory node dynamically Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 11/31] PPC: e500: dt: create /cpus " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 12/31] PPC: e500: dt: create /hypervisor " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 13/31] PPC: e500: dt: create / " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 14/31] PPC: e500: dt: create /chosen " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 15/31] PPC: e500: dt: create /soc8544 " Alexander Graf
2012-06-19 19:15 ` Alexander Graf [this message]
2012-06-19 19:15 ` [Qemu-devel] [PATCH 17/31] PPC: e500: dt: create mpic " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 18/31] PPC: e500: dt: create global-utils " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 19/31] PPC: e500: dt: create pci " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 20/31] PPC: e500: dt: start with empty device tree Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 21/31] dt: Add -machine dumpdtb option to dump the current dtb Alexander Graf
2012-06-19 20:51   ` Peter Maydell
2012-06-19 21:02     ` Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 22/31] PPC: e500: dt: use 64bit cell helper Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 23/31] PPC: e500: dt: use target_phys_addr_t for ramsize Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 24/31] PPC: e500: enable manual loading of dtb blob Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 25/31] Revert "dt: temporarily disable subtree creation failure check" Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 26/31] PPC: e500: Use new MPIC dt format Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 27/31] PPC: e500: Use new SOC " Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 28/31] PPC: e500: Define addresses as always 64bit Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 29/31] PPC: e500: Extend address/size of / to 64bit Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 30/31] dt: Add global option to set phandle start offset Alexander Graf
2012-06-19 19:15 ` [Qemu-devel] [PATCH 31/31] PPC: e500: Refactor serial dt generation Alexander Graf
2012-06-19 21:27 ` [Qemu-devel] [PATCH 00/31] PPC: mpc8544ds: Create device tree dynamically Andreas Färber
  -- strict thread matches above, loose matches on Subject: below --
2012-06-05 23:52 Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 16/31] PPC: e500: dt: create serial nodes dynamically 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=1340133324-352-17-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --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).