[Skiboot] [PATCH v4 2/4] ast-bmc: Use the mbox driver

Michael Neuling mikey at neuling.org
Wed Feb 22 20:31:00 AEDT 2017


From: Cyril Bur <cyril.bur at au1.ibm.com>

The mbox registers are accessed via superIO, these need to be
initialised.

The mbox device node won't be present in the device tree hostboot passes
us, so fixup the device tree.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 hw/ast-bmc/ast-io.c       | 19 +++++++++++++++++++
 include/ast.h             |  3 +++
 platforms/astbmc/common.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/hw/ast-bmc/ast-io.c b/hw/ast-bmc/ast-io.c
index a3c5c9f7c6..41234fbb23 100644
--- a/hw/ast-bmc/ast-io.c
+++ b/hw/ast-bmc/ast-io.c
@@ -469,3 +469,22 @@ void ast_disable_sio_uart1(void)
 
 	bmc_sio_put(true);
 }
+
+void ast_setup_sio_mbox(uint16_t io_base, uint8_t irq)
+{
+	bmc_sio_get(BMC_SIO_DEV_MBOX);
+
+	/* Disable for configuration */
+	bmc_sio_outb(0x00, 0x30);
+
+	bmc_sio_outb(io_base >> 8, 0x60);
+	bmc_sio_outb(io_base & 0xff, 0x61);
+	bmc_sio_outb(irq, 0x70);
+	bmc_sio_outb(0x01, 0x71); /* level low */
+
+	/* Enable MailBox */
+	bmc_sio_outb(0x01, 0x30);
+
+	bmc_sio_put(true);
+}
+
diff --git a/include/ast.h b/include/ast.h
index c7bf0cb3a7..43c5989f5d 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -85,6 +85,9 @@ void ast_disable_sio_uart1(void);
 /* BT configuration */
 void ast_setup_ibt(uint16_t io_base, uint8_t irq);
 
+/* MBOX configuration */
+void ast_setup_sio_mbox(uint16_t io_base, uint8_t irq);
+
 #endif /* __SKIBOOT__ */
 
 /*
diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c
index 18b425b0ed..6f29e61a39 100644
--- a/platforms/astbmc/common.c
+++ b/platforms/astbmc/common.c
@@ -39,6 +39,11 @@
 #define BT_IO_COUNT	3
 #define BT_LPC_IRQ	10
 
+/* MBOX config */
+#define MBOX_IO_BASE 0x1000
+#define MBOX_IO_COUNT 6
+#define MBOX_LPC_IRQ 9
+
 void astbmc_ext_irq_serirq_cpld(unsigned int chip_id)
 {
 	lpc_all_interrupts(chip_id);
@@ -191,6 +196,36 @@ static void astbmc_fixup_dt_bt(struct dt_node *lpc)
 	dt_add_property_cells(bt, "interrupt-parent", lpc->phandle);
 }
 
+static void astbmc_fixup_dt_mbox(struct dt_node *lpc)
+{
+	struct dt_node *mbox;
+	char namebuf[32];
+
+	/* All P9 machines have this and no earlier machines do */
+	if (proc_gen != proc_gen_p9)
+		return;
+
+	/* First check if the mbox interface is already there */
+	dt_for_each_child(lpc, mbox) {
+		if (dt_node_is_compatible(mbox, "mbox"))
+			return;
+	}
+
+	snprintf(namebuf, sizeof(namebuf), "mbox at i%x", MBOX_IO_BASE);
+	mbox = dt_new(lpc, namebuf);
+
+	dt_add_property_cells(mbox, "reg",
+			      1, /* IO space */
+			      MBOX_IO_BASE, MBOX_IO_COUNT);
+	dt_add_property_strings(mbox, "compatible", "mbox");
+
+	/* Mark it as reserved to avoid Linux trying to claim it */
+	dt_add_property_strings(mbox, "status", "reserved");
+
+	dt_add_property_cells(mbox, "interrupts", MBOX_LPC_IRQ);
+	dt_add_property_cells(mbox, "interrupt-parent", lpc->phandle);
+}
+
 static void astbmc_fixup_dt_uart(struct dt_node *lpc)
 {
 	/*
@@ -294,6 +329,9 @@ static void astbmc_fixup_dt(void)
 	/* BT is not in HB either */
 	astbmc_fixup_dt_bt(primary_lpc);
 
+	/* MBOX is not in HB */
+	astbmc_fixup_dt_mbox(primary_lpc);
+
 	/* The pel logging code needs a system-id property to work so
 	   make sure we have one. */
 	astbmc_fixup_dt_system_id();
@@ -361,9 +399,13 @@ void astbmc_early_init(void)
 	/* Similarly, some BMCs don't configure the BT interrupt properly */
 	ast_setup_ibt(BT_IO_BASE, BT_LPC_IRQ);
 
+	ast_setup_sio_mbox(MBOX_IO_BASE, MBOX_LPC_IRQ);
+
 	/* Setup UART and use it as console */
 	uart_init();
 
+	mbox_init();
+
 	prd_init();
 }
 
-- 
2.9.3



More information about the Skiboot mailing list