diff mbox series

[RFC,01/12] platform/mambo: Add a mambo OPAL console driver

Message ID 20200519054633.113238-2-oohall@gmail.com
State RFC
Headers show
Series [RFC,01/12] platform/mambo: Add a mambo OPAL console driver | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (0f1937ef40fca0c3212a9dff1010b832a24fb063)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Oliver O'Halloran May 19, 2020, 5:46 a.m. UTC
Add a "real" opal_con_driver for the mambo platform instead of using the
dummy console. This gets mambo using the same console IO path as every
other platform and leaves the dummy console only being used for cronus
booted systems.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
Yoinked out of Nick's raw console patch set.
---
 include/console.h         |  1 +
 platforms/mambo/console.c | 64 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/console.h b/include/console.h
index 02fc7a4b60a5..c14a2e598191 100644
--- a/include/console.h
+++ b/include/console.h
@@ -85,6 +85,7 @@  struct dt_node *add_opal_console_node(int index, const char *type,
 extern struct opal_con_ops uart_opal_con;
 extern struct opal_con_ops fsp_opal_con;
 extern struct opal_con_ops dummy_opal_con;
+extern struct opal_con_ops mambo_opal_con;
 
 void mprintf(const char *fmt, ...);
 
diff --git a/platforms/mambo/console.c b/platforms/mambo/console.c
index 6d5b20b56e60..f46272d6973c 100644
--- a/platforms/mambo/console.c
+++ b/platforms/mambo/console.c
@@ -3,6 +3,7 @@ 
 
 #include <skiboot.h>
 #include <console.h>
+#include <opal-api.h>
 
 #include "mambo.h"
 
@@ -42,9 +43,8 @@  size_t mambo_console_write(const char *buf, size_t len)
 	return len;
 }
 
+/* used to write out the internal console */
 static struct con_ops mambo_con_driver = {
-	.poll_read = mambo_console_poll,
-	.read = mambo_console_read,
 	.write = mambo_console_write,
 };
 
@@ -54,6 +54,66 @@  void enable_mambo_console(void)
 	set_console(&mambo_con_driver);
 }
 
+
+/* OPAL call interface into the underlying mambo console */
+static int64_t mambo_opal_write(int64_t term_number, __be64 *__length,
+			       const uint8_t *buffer)
+{
+	size_t len = be64_to_cpu(*__length);
+
+	if (term_number != 0)
+		return OPAL_PARAMETER;
+
+	mambo_console_write(buffer, len);
+
+	return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_write_buffer_space(int64_t term_number,
+					    __be64 *__length)
+{
+	if (term_number != 0)
+		return OPAL_PARAMETER;
+
+	*__length = cpu_to_be64(256);
+
+	return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_read(int64_t term_number, __be64 *__length,
+			      uint8_t *buffer)
+{
+	size_t req_count = be64_to_cpu(*__length), read_cnt = 0;
+
+	if (term_number != 0)
+		return OPAL_PARAMETER;
+
+	read_cnt = mambo_console_read(buffer, req_count);
+	*__length = cpu_to_be64(read_cnt);
+
+	return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_flush(int64_t term_number)
+{
+	if (term_number != 0)
+		return OPAL_PARAMETER;
+	return OPAL_SUCCESS;
+}
+
+static void mambo_init_opal_console(void)
+{
+}
+
+struct opal_con_ops mambo_opal_con = {
+	.name = "OPAL Mambo console",
+	.init = mambo_init_opal_console,
+	.read = mambo_opal_read,
+	.write = mambo_opal_write,
+	.space = mambo_opal_write_buffer_space,
+	.flush = mambo_opal_flush,
+};
+
 /*
  * mambo console based printf(), this is useful for debugging the console
  * since mambo_console_write() can be safely called from anywhere.