[Skiboot] [PATCH v8 08/10] platforms: Add OpenCAPI platform data and device tree nodes

Andrew Donnellan andrew.donnellan at au1.ibm.com
Thu Mar 1 18:54:08 AEDT 2018


Add OpenCAPI platform data for the zaius and zz platforms, as well as the
generic platform that's used for BML boots. Currently, all three platforms
are identical, but that won't always be the case (e.g. Witherspoon).

Additionally, for Zaius, hardcode link information and the I2C bus that's
required to reset OpenCAPI devices, because this currently can't be
extracted from HDAT. Eventually this will go away once Hostboot adds the
relevant data in HDAT. A later patch will add this for ZZ once we've done
more testing.

Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>

---

v1->v2:

  - Remove extraneous break that stops things after the first CPU (Fred)
  - Remove i2c odl01 data (Fred)
  - Remove i2c 1.8v hack (Fred)
  - Don't try to create device tree nodes on zaius if they already exist
    (Fred)

v2->v3:

  - Reverse bit order of lane masks

v6->v7:

  - Add default ibm,link-speed property of 25Gb/s for zaius

v7->v8:

  - Drop a stray #include that was accidentally left around (Fred)
---
 core/platform.c          | 11 +++++-
 platforms/astbmc/zaius.c | 97 +++++++++++++++++++++++++++++++++++++++++-
 platforms/ibm-fsp/zz.c   | 11 +++++-
 3 files changed, 119 insertions(+)

diff --git a/core/platform.c b/core/platform.c
index 6816fe58a252..f09ea3c132b6 100644
--- a/core/platform.c
+++ b/core/platform.c
@@ -168,6 +168,16 @@ static int generic_start_preload_resource(enum resource_id id, uint32_t subid,
 	return OPAL_EMPTY;
 }
 
+/* These values will work for a ZZ booted using BML */
+const struct platform_ocapi generic_ocapi = {
+	.i2c_engine	= 1,
+	.i2c_port	= 4,
+	.i2c_offset	= { 0x3, 0x1, 0x1 },
+	.i2c_odl0_data	= { 0xFD, 0xFD, 0xFF },
+	.i2c_odl1_data	= { 0xBF, 0xBF, 0xFF },
+	.odl_phy_swap	= true,
+};
+
 static struct bmc_platform generic_bmc = {
 	.name = "generic",
 };
@@ -183,6 +193,7 @@ static struct platform generic_platform = {
 	.cec_power_down	= generic_cec_power_down,
 	.start_preload_resource	= generic_start_preload_resource,
 	.resource_loaded	= generic_resource_loaded,
+	.ocapi		= &generic_ocapi,
 };
 
 const struct bmc_platform *bmc_platform = &generic_bmc;
diff --git a/platforms/astbmc/zaius.c b/platforms/astbmc/zaius.c
index 74c7f13e35e6..313c41e0c737 100644
--- a/platforms/astbmc/zaius.c
+++ b/platforms/astbmc/zaius.c
@@ -24,6 +24,99 @@
 
 #include "astbmc.h"
 
+const struct platform_ocapi zaius_ocapi = {
+	.i2c_engine	= 1,
+	.i2c_port	= 4,
+	.i2c_offset	= { 0x3, 0x1, 0x1 },
+	.i2c_odl0_data	= { 0xFD, 0xFD, 0xFF },
+	.i2c_odl1_data	= { 0xBF, 0xBF, 0xFF },
+	.odl_phy_swap	= true,
+};
+
+#define NPU_BASE 0x5011000
+#define NPU_SIZE 0x2c
+#define NPU_INDIRECT0	0x8000000009010c3f /* OB0 - no OB3 on Zaius */
+
+/* OpenCAPI only */
+static void create_link(struct dt_node *npu, int group, int index)
+{
+	struct dt_node *link;
+	uint32_t lane_mask;
+	char namebuf[32];
+
+	snprintf(namebuf, sizeof(namebuf), "link@%x", index);
+	link = dt_new(npu, namebuf);
+
+	dt_add_property_string(link, "compatible", "ibm,npu-link-opencapi");
+	dt_add_property_cells(link, "ibm,npu-link-index", index);
+
+	switch (index) {
+	case 2:
+		lane_mask = 0xf1e000; /* 0-3, 7-10 */
+		break;
+	case 3:
+		lane_mask = 0x00078f; /* 13-16, 20-23 */
+		break;
+	default:
+		assert(0);
+	}
+
+	dt_add_property_u64s(link, "ibm,npu-phy", NPU_INDIRECT0);
+	dt_add_property_cells(link, "ibm,npu-lane-mask", lane_mask);
+	dt_add_property_cells(link, "ibm,npu-group-id", group);
+	dt_add_property_u64s(link, "ibm,link-speed", 25000000000ul);
+}
+
+/* FIXME: Get rid of this after we get NPU information properly via HDAT/MRW */
+static void zaius_create_npu(void)
+{
+	struct dt_node *xscom, *npu;
+	int npu_index = 0;
+	int phb_index = 7;
+	char namebuf[32];
+
+	/* Abort if there's already an NPU in the device tree */
+	if (dt_find_compatible_node(dt_root, NULL, "ibm,power9-npu"))
+		return;
+
+	prlog(PR_DEBUG, "OCAPI: Adding NPU device nodes\n");
+	dt_for_each_compatible(dt_root, xscom, "ibm,xscom") {
+		snprintf(namebuf, sizeof(namebuf), "npu@%x", NPU_BASE);
+		npu = dt_new(xscom, namebuf);
+		dt_add_property_cells(npu, "reg", NPU_BASE, NPU_SIZE);
+		dt_add_property_strings(npu, "compatible", "ibm,power9-npu");
+		dt_add_property_cells(npu, "ibm,npu-index", npu_index++);
+		dt_add_property_cells(npu, "ibm,phb-index", phb_index++);
+		dt_add_property_cells(npu, "ibm,npu-links", 2);
+		create_link(npu, 1, 2);
+		create_link(npu, 2, 3);
+	}
+}
+
+/* FIXME: Get rid of this after we get NPU information properly via HDAT/MRW */
+static void zaius_create_ocapi_i2c_bus(void)
+{
+	struct dt_node *xscom, *i2cm, *i2c_bus;
+	prlog(PR_DEBUG, "OCAPI: Adding I2C bus device node for OCAPI reset\n");
+	dt_for_each_compatible(dt_root, xscom, "ibm,xscom") {
+		i2cm = dt_find_by_name(xscom, "i2cm at a1000");
+		if (!i2cm) {
+			prlog(PR_ERR, "OCAPI: Failed to add I2C bus device node\n");
+			continue;
+		}
+
+		if (dt_find_by_name(i2cm, "i2c-bus at 4"))
+			continue;
+
+		i2c_bus = dt_new_addr(i2cm, "i2c-bus", 4);
+		dt_add_property_cells(i2c_bus, "reg", 4);
+		dt_add_property_cells(i2c_bus, "bus-frequency", 0x61a80);
+		dt_add_property_strings(i2c_bus, "compatible",
+					"ibm,opal-i2c", "ibm,power8-i2c-port",
+					"ibm,power9-i2c-port");
+	}
+}
+
 static bool zaius_probe(void)
 {
 	if (!dt_node_is_compatible(dt_root, "ingrasys,zaius"))
@@ -35,6 +128,9 @@ static bool zaius_probe(void)
 	/* Setup UART for direct use by Linux */
 	uart_set_console_policy(UART_CONSOLE_OS);
 
+	zaius_create_npu();
+	zaius_create_ocapi_i2c_bus();
+
 	return true;
 }
 
@@ -52,4 +148,5 @@ DECLARE_PLATFORM(zaius) = {
 	.elog_commit		= ipmi_elog_commit,
 	.exit			= ipmi_wdt_final_reset,
 	.terminate		= ipmi_terminate,
+	.ocapi			= &zaius_ocapi,
 };
diff --git a/platforms/ibm-fsp/zz.c b/platforms/ibm-fsp/zz.c
index a8150b81363a..9a8492907a7e 100644
--- a/platforms/ibm-fsp/zz.c
+++ b/platforms/ibm-fsp/zz.c
@@ -27,6 +27,16 @@
 #include "ibm-fsp.h"
 #include "lxvpd.h"
 
+/* We don't yet create NPU device nodes on ZZ, but these values are correct */
+const struct platform_ocapi zz_ocapi = {
+	.i2c_engine	= 1,
+	.i2c_port	= 4,
+	.i2c_offset	= { 0x3, 0x1, 0x1 },
+	.i2c_odl0_data	= { 0xFD, 0xFD, 0xFF },
+	.i2c_odl1_data	= { 0xBF, 0xBF, 0xFF },
+	.odl_phy_swap	= true,
+};
+
 static bool zz_probe(void)
 {
 	/* FIXME: make this neater when the dust settles */
@@ -71,4 +81,5 @@ DECLARE_PLATFORM(zz) = {
 	.resource_loaded	= fsp_resource_loaded,
 	.sensor_read		= ibm_fsp_sensor_read,
 	.terminate		= ibm_fsp_terminate,
+	.ocapi			= &zz_ocapi,
 };
-- 
git-series 0.9.1



More information about the Skiboot mailing list