@@ -62,6 +62,7 @@ static inline int con_is_present(void)
#ifdef CONFIG_SERIAL_SUNHV
void sunhv_migrate_hvcons_irq(int cpu);
+#define SUNHV_CONSOLE_NAME "ttyHV"
#endif
#endif
void sun_do_break(void);
@@ -695,3 +695,65 @@ void sun_do_break(void)
int stop_a_enabled = 1;
EXPORT_SYMBOL(stop_a_enabled);
+
+#ifdef CONFIG_SERIAL_SUNHV
+
+/*
+ * Unregister boot console (prom_early_console), only when ttyHV console is
+ * registered. But, only if prom_early_console is using "virtual-console"
+ * output device, as that means it is the same device that ttyHV is using.
+ */
+bool plat_unregister_bootcon(struct console *newcon, struct console *bcon)
+{
+ bool unreg = bcon &&
+ (newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV;
+ static enum {
+ FIRST_TIME = 0, /* first time here */
+ NOT_VC, /* output device is not 'virtual-console' */
+ VC, /* output device is 'virtual-console' */
+ HV /* ttyHV is registered */
+ } virt_con = FIRST_TIME;
+
+ if (tlb_type != hypervisor)
+ return unreg;
+
+ if (&prom_early_console == newcon)
+ return false;
+
+ /*
+ * read output-device property value from /options, the default value
+ * is virtual-console, which means send output to ILOM, or the same
+ * device that hypervisor is using.
+ */
+ if (virt_con == FIRST_TIME) {
+ char *output_dev_name = NULL;
+ struct device_node *dp;
+ int len;
+
+ virt_con = NOT_VC;
+ dp = of_find_node_by_path("/options");
+ if (dp)
+ output_dev_name = (char *)of_get_property(dp,
+ "output-device", &len);
+
+ if (output_dev_name)
+ if (!strncmp("virtual-console", output_dev_name, len))
+ virt_con = VC;
+ }
+
+ if (virt_con == NOT_VC || virt_con == HV)
+ return unreg;
+
+ if (!strcmp(newcon->name, SUNHV_CONSOLE_NAME)) {
+ virt_con = HV;
+ /*
+ * We know ttyHV and prom_early_console are using the same
+ * output device, do not print everything out again
+ */
+ newcon->flags &= ~CON_PRINTBUFFER;
+ return true;
+ }
+
+ return false;
+}
+#endif
@@ -512,7 +512,7 @@ static void sunhv_console_write_bychar(struct console *con, const char *s, unsig
}
static struct console sunhv_console = {
- .name = "ttyHV",
+ .name = SUNHV_CONSOLE_NAME,
.write = sunhv_console_write_bychar,
.device = uart_console_device,
.flags = CON_PRINTBUFFER,