[PATCH 27/38] MIPS: SGI-IP27: dispatch the early console between IOC3 and IOC4
From: Imre Kaloz
Date: Thu Oct 01 2026 - 13:04:25 EST
ip27-console.c casts the console UART to struct ioc3 unconditionally,
wrong for a Tezro's IOC4, whose UARTs sit at other offsets.
console_t.type reads back 0x0300fafa there, neither chip's PCI id, so on
IP35 dispatch on uart_base, which both chips populate correctly. A Hub
keeps the IOC3 path.
Signed-off-by: Imre Kaloz <kaloz@xxxxxxxxxx>
---
arch/mips/sgi-ip27/ip27-console.c | 47 ++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/arch/mips/sgi-ip27/ip27-console.c b/arch/mips/sgi-ip27/ip27-console.c
index 7737a88c6569..a1bcb4376f66 100644
--- a/arch/mips/sgi-ip27/ip27-console.c
+++ b/arch/mips/sgi-ip27/ip27-console.c
@@ -12,6 +12,7 @@
#include <asm/sn/agent.h>
#include <asm/sn/klconfig.h>
#include <asm/sn/ioc3.h>
+#include <asm/sn/ioc4.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
@@ -32,9 +33,53 @@ static inline struct ioc3_uartregs *console_uart(void)
return &ioc3->sregs.uarta;
}
+/*
+ * On IP35 a Tezro drives its console off IOC4, a Fuel off IOC3.
+ * console_t.type cannot tell them apart -- a Tezro reads it back as
+ * 0x0300fafa, which is neither chip's PCI id -- while uart_base is
+ * populated on both, so dispatch on whether that lands on IOC3's own UART.
+ */
+static inline bool console_is_ioc4(nasid_t nasid)
+{
+ unsigned long uart_base;
+
+ if (!system_is_ip35)
+ return false;
+
+ uart_base = KL_CONFIG_CH_CONS_INFO(nasid)->uart_base;
+ if (!uart_base)
+ return false;
+
+ /* NODE_SWIN_ADDR() aliases widget 0 away; the console sits on 0xf. */
+ if (uart_base < RAW_NODE_SWIN_BASE(nasid, 0) ||
+ uart_base >= RAW_NODE_SWIN_BASE(nasid, SWIN_WIDGET_MASK) +
+ SWIN_SIZE)
+ return false;
+
+ return uart_base != (unsigned long)console_uart();
+}
+
+static inline struct ioc4_uartregs *console_uart_ioc4(nasid_t nasid)
+{
+ return (struct ioc4_uartregs *)KL_CONFIG_CH_CONS_INFO(nasid)->uart_base;
+}
+
void prom_putchar(char c)
{
- struct ioc3_uartregs *uart = console_uart();
+ struct ioc3_uartregs *uart;
+ nasid_t nasid;
+
+ nasid = (master_nasid == INVALID_NASID) ? get_nasid() : master_nasid;
+ if (console_is_ioc4(nasid)) {
+ struct ioc4_uartregs *ioc4_uart = console_uart_ioc4(nasid);
+
+ while ((readb(&ioc4_uart->i4u_lsr) & 0x20) == 0)
+ ;
+ writeb(c, &ioc4_uart->i4u_thr);
+ return;
+ }
+
+ uart = console_uart();
while ((readb(&uart->iu_lsr) & 0x20) == 0)
;
--
2.47.3