diff mbox

[1/6] plat/qemu: move platform definition to astbmc

Message ID 1459960212-23890-2-git-send-email-clg@fr.ibm.com
State Changes Requested
Headers show

Commit Message

Cédric Le Goater April 6, 2016, 4:30 p.m. UTC
This patch a simple move of the code towards the AST BMC platform
directory to make future changes easier. The qemu and the AST BMC
(palmetto, etc) platforms have a lot in common.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 platforms/Makefile.inc        |   3 +-
 platforms/astbmc/Makefile.inc |   4 +-
 platforms/astbmc/qemu.c       | 148 ++++++++++++++++++++++++++++++++++++++++++
 platforms/qemu/Makefile.inc   |   6 --
 platforms/qemu/qemu.c         | 148 ------------------------------------------
 5 files changed, 152 insertions(+), 157 deletions(-)
 create mode 100644 platforms/astbmc/qemu.c
 delete mode 100644 platforms/qemu/Makefile.inc
 delete mode 100644 platforms/qemu/qemu.c

Comments

Stewart Smith May 10, 2016, 5:14 a.m. UTC | #1
Cédric Le Goater <clg@fr.ibm.com> writes:
> This patch a simple move of the code towards the AST BMC platform
> directory to make future changes easier. The qemu and the AST BMC
> (palmetto, etc) platforms have a lot in common.
>
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>

With the possibility of a powernv qemu hooked up to an openbmc qemu, it
makes me wonder if this is the right direction to take....

I'd prefer extending things where they are now, which leaves us open to
take the qemu platform down two different routes depending on what kind of
session you launch (unless, of course, those two approaches are
represented differently in the device tree coming from qemu, in which
case it may make sense to have two qemu platforms in skiboot).

Thoughts?
diff mbox

Patch

diff --git a/platforms/Makefile.inc b/platforms/Makefile.inc
index 90cd0f1c3762..12c82c8eaaa8 100644
--- a/platforms/Makefile.inc
+++ b/platforms/Makefile.inc
@@ -7,6 +7,5 @@  include $(SRC)/$(PLATDIR)/ibm-fsp/Makefile.inc
 include $(SRC)/$(PLATDIR)/rhesus/Makefile.inc
 include $(SRC)/$(PLATDIR)/astbmc/Makefile.inc
 include $(SRC)/$(PLATDIR)/mambo/Makefile.inc
-include $(SRC)/$(PLATDIR)/qemu/Makefile.inc
 
-$(PLATFORMS): $(IBM_FSP) $(RHESUS) $(ASTBMC) $(MAMBO) $(QEMU)
+$(PLATFORMS): $(IBM_FSP) $(RHESUS) $(ASTBMC) $(MAMBO)
diff --git a/platforms/astbmc/Makefile.inc b/platforms/astbmc/Makefile.inc
index 46befc18aff4..064184d023e4 100644
--- a/platforms/astbmc/Makefile.inc
+++ b/platforms/astbmc/Makefile.inc
@@ -1,6 +1,8 @@ 
 SUBDIRS += $(PLATDIR)/astbmc
 
-ASTBMC_OBJS = palmetto.o habanero.o firestone.o garrison.o barreleye.o pnor.o common.o slots.o
+ASTBMC_OBJS  = palmetto.o habanero.o firestone.o garrison.o barreleye.o
+ASTBMC_OBJS += qemu.o
+ASTBMC_OBJS += pnor.o common.o slots.o
 ASTBMC = $(PLATDIR)/astbmc/built-in.o
 $(ASTBMC): $(ASTBMC_OBJS:%=$(PLATDIR)/astbmc/%)
 
diff --git a/platforms/astbmc/qemu.c b/platforms/astbmc/qemu.c
new file mode 100644
index 000000000000..66a6aa3970c2
--- /dev/null
+++ b/platforms/astbmc/qemu.c
@@ -0,0 +1,148 @@ 
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 	http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <skiboot.h>
+#include <device.h>
+#include <lpc.h>
+#include <console.h>
+#include <opal.h>
+#include <psi.h>
+
+static void qemu_init(void)
+{
+	/* Setup UART console for use by Linux via OPAL API */
+	if (!dummy_console_enabled())
+		uart_setup_opal_console();
+
+	/* Setup LPC RTC and use it as time source. Call after
+	 * chiptod_init()
+	 */
+	lpc_rtc_init();
+}
+
+static void qemu_dt_fixup_uart(struct dt_node *lpc)
+{
+	/*
+	 * The official OF ISA/LPC binding is a bit odd, it prefixes
+	 * the unit address for IO with "i". It uses 2 cells, the first
+	 * one indicating IO vs. Memory space (along with bits to
+	 * represent aliasing).
+	 *
+	 * We pickup that binding and add to it "2" as a indication
+	 * of FW space.
+	 *
+	 * TODO: Probe the UART instead if the LPC bus allows for it
+	 */
+	struct dt_node *uart;
+	char namebuf[32];
+#define UART_IO_BASE	0x3f8
+#define UART_IO_COUNT	8
+#define UART_LPC_IRQ	4
+
+	snprintf(namebuf, sizeof(namebuf), "serial@i%x", UART_IO_BASE);
+	uart = dt_new(lpc, namebuf);
+
+	dt_add_property_cells(uart, "reg",
+			      1, /* IO space */
+			      UART_IO_BASE, UART_IO_COUNT);
+	dt_add_property_strings(uart, "compatible",
+				"ns16550",
+				"pnpPNP,501");
+	dt_add_property_cells(uart, "clock-frequency", 1843200);
+	dt_add_property_cells(uart, "current-speed", 115200);
+	dt_add_property_cells(uart, "interrupts", UART_LPC_IRQ);
+	dt_add_property_cells(uart, "interrupt-parent", lpc->phandle);
+
+	/*
+	 * This is needed by Linux for some obscure reasons,
+	 * we'll eventually need to sanitize it but in the meantime
+	 * let's make sure it's there
+	 */
+	dt_add_property_strings(uart, "device_type", "serial");
+}
+
+/*
+ * This adds the legacy RTC device to the device-tree
+ * for Linux to use
+ */
+static void qemu_dt_fixup_rtc(struct dt_node *lpc)
+{
+	struct dt_node *rtc;
+	char namebuf[32];
+
+	/*
+	 * Follows the structure expected by the kernel file
+	 * arch/powerpc/sysdev/rtc_cmos_setup.c
+	 */
+	snprintf(namebuf, sizeof(namebuf), "rtc@i%x", 0x70);
+	rtc = dt_new(lpc, namebuf);
+	dt_add_property_string(rtc, "compatible", "pnpPNP,b00");
+	dt_add_property_cells(rtc, "reg",
+			      1, /* IO space */
+			      0x70, 2);
+}
+
+static void qemu_dt_fixup(void)
+{
+	struct dt_node *n, *primary_lpc = NULL;
+
+	/* Find the primary LPC bus */
+	dt_for_each_compatible(dt_root, n, "ibm,power8-lpc") {
+		if (!primary_lpc || dt_has_node_property(n, "primary", NULL))
+			primary_lpc = n;
+		if (dt_has_node_property(n, "#address-cells", NULL))
+			break;
+	}
+
+	if (!primary_lpc)
+		return;
+
+	qemu_dt_fixup_rtc(primary_lpc);
+	qemu_dt_fixup_uart(primary_lpc);
+}
+
+static void qemu_ext_irq_serirq_cpld(unsigned int chip_id)
+{
+	lpc_all_interrupts(chip_id);
+}
+
+static bool qemu_probe(void)
+{
+	if (!dt_node_is_compatible(dt_root, "qemu,powernv"))
+		return false;
+
+	/* Add missing bits of device-tree such as the UART */
+	qemu_dt_fixup();
+
+	psi_set_external_irq_policy(EXTERNAL_IRQ_POLICY_SKIBOOT);
+
+	/*
+	 * Setup UART and use it as console. For now, we
+	 * don't expose the interrupt as we know it's not
+	 * working properly yet
+	 */
+	uart_init(true);
+
+	return true;
+}
+
+DECLARE_PLATFORM(qemu) = {
+	.name		= "Qemu",
+	.probe		= qemu_probe,
+	.init		= qemu_init,
+	.external_irq   = qemu_ext_irq_serirq_cpld,
+};
diff --git a/platforms/qemu/Makefile.inc b/platforms/qemu/Makefile.inc
deleted file mode 100644
index 11a44dbd28f5..000000000000
--- a/platforms/qemu/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@ 
-SUBDIRS += $(PLATDIR)/qemu
-
-QEMU_OBJS = qemu.o
-QEMU = $(PLATDIR)/qemu/built-in.o
-$(QEMU): $(QEMU_OBJS:%=$(PLATDIR)/qemu/%)
-
diff --git a/platforms/qemu/qemu.c b/platforms/qemu/qemu.c
deleted file mode 100644
index 66a6aa3970c2..000000000000
--- a/platforms/qemu/qemu.c
+++ /dev/null
@@ -1,148 +0,0 @@ 
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <skiboot.h>
-#include <device.h>
-#include <lpc.h>
-#include <console.h>
-#include <opal.h>
-#include <psi.h>
-
-static void qemu_init(void)
-{
-	/* Setup UART console for use by Linux via OPAL API */
-	if (!dummy_console_enabled())
-		uart_setup_opal_console();
-
-	/* Setup LPC RTC and use it as time source. Call after
-	 * chiptod_init()
-	 */
-	lpc_rtc_init();
-}
-
-static void qemu_dt_fixup_uart(struct dt_node *lpc)
-{
-	/*
-	 * The official OF ISA/LPC binding is a bit odd, it prefixes
-	 * the unit address for IO with "i". It uses 2 cells, the first
-	 * one indicating IO vs. Memory space (along with bits to
-	 * represent aliasing).
-	 *
-	 * We pickup that binding and add to it "2" as a indication
-	 * of FW space.
-	 *
-	 * TODO: Probe the UART instead if the LPC bus allows for it
-	 */
-	struct dt_node *uart;
-	char namebuf[32];
-#define UART_IO_BASE	0x3f8
-#define UART_IO_COUNT	8
-#define UART_LPC_IRQ	4
-
-	snprintf(namebuf, sizeof(namebuf), "serial@i%x", UART_IO_BASE);
-	uart = dt_new(lpc, namebuf);
-
-	dt_add_property_cells(uart, "reg",
-			      1, /* IO space */
-			      UART_IO_BASE, UART_IO_COUNT);
-	dt_add_property_strings(uart, "compatible",
-				"ns16550",
-				"pnpPNP,501");
-	dt_add_property_cells(uart, "clock-frequency", 1843200);
-	dt_add_property_cells(uart, "current-speed", 115200);
-	dt_add_property_cells(uart, "interrupts", UART_LPC_IRQ);
-	dt_add_property_cells(uart, "interrupt-parent", lpc->phandle);
-
-	/*
-	 * This is needed by Linux for some obscure reasons,
-	 * we'll eventually need to sanitize it but in the meantime
-	 * let's make sure it's there
-	 */
-	dt_add_property_strings(uart, "device_type", "serial");
-}
-
-/*
- * This adds the legacy RTC device to the device-tree
- * for Linux to use
- */
-static void qemu_dt_fixup_rtc(struct dt_node *lpc)
-{
-	struct dt_node *rtc;
-	char namebuf[32];
-
-	/*
-	 * Follows the structure expected by the kernel file
-	 * arch/powerpc/sysdev/rtc_cmos_setup.c
-	 */
-	snprintf(namebuf, sizeof(namebuf), "rtc@i%x", 0x70);
-	rtc = dt_new(lpc, namebuf);
-	dt_add_property_string(rtc, "compatible", "pnpPNP,b00");
-	dt_add_property_cells(rtc, "reg",
-			      1, /* IO space */
-			      0x70, 2);
-}
-
-static void qemu_dt_fixup(void)
-{
-	struct dt_node *n, *primary_lpc = NULL;
-
-	/* Find the primary LPC bus */
-	dt_for_each_compatible(dt_root, n, "ibm,power8-lpc") {
-		if (!primary_lpc || dt_has_node_property(n, "primary", NULL))
-			primary_lpc = n;
-		if (dt_has_node_property(n, "#address-cells", NULL))
-			break;
-	}
-
-	if (!primary_lpc)
-		return;
-
-	qemu_dt_fixup_rtc(primary_lpc);
-	qemu_dt_fixup_uart(primary_lpc);
-}
-
-static void qemu_ext_irq_serirq_cpld(unsigned int chip_id)
-{
-	lpc_all_interrupts(chip_id);
-}
-
-static bool qemu_probe(void)
-{
-	if (!dt_node_is_compatible(dt_root, "qemu,powernv"))
-		return false;
-
-	/* Add missing bits of device-tree such as the UART */
-	qemu_dt_fixup();
-
-	psi_set_external_irq_policy(EXTERNAL_IRQ_POLICY_SKIBOOT);
-
-	/*
-	 * Setup UART and use it as console. For now, we
-	 * don't expose the interrupt as we know it's not
-	 * working properly yet
-	 */
-	uart_init(true);
-
-	return true;
-}
-
-DECLARE_PLATFORM(qemu) = {
-	.name		= "Qemu",
-	.probe		= qemu_probe,
-	.init		= qemu_init,
-	.external_irq   = qemu_ext_irq_serirq_cpld,
-};