diff mbox series

[RFC,v4,10/16] hdata/spira.c: Create ibm, ultravisor dt node

Message ID 20200227122042.32692-11-grimm@linux.ibm.com
State Superseded
Headers show
Series Ultravisor support in skiboot | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (82aed17a5468aff6b600ee1694a10a60f942c018)
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

Ryan Grimm Feb. 27, 2020, 12:20 p.m. UTC
Create ibm,ultravisor node if secure memory exists.  See
doc/opal-uv-abi.rst for details.

Signed-off-by: Ryan Grimm <grimm@us.ibm.com>
---
 hdata/spira.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/hdata/spira.c b/hdata/spira.c
index 7c5918d2..1435d175 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -1712,6 +1712,36 @@  static void update_spirah_addr(void)
 #endif
 }
 
+#define UV_LOAD_MAX_SIZE        0x200000
+
+static void add_uv(void)
+{
+	struct dt_node *uv_node, *secure_mem_node, *uv_fw_node;
+	uint64_t uv_fw_start;
+	char fw_name[64];
+
+	secure_mem_node = dt_find_compatible_node_on_chip(dt_root, NULL,
+						"ibm,secure-memory", 0);
+	if (!secure_mem_node) {
+		prlog(PR_DEBUG, "HDAT: No ibm,secure-memory found\n");
+		return;
+	}
+
+	uv_node = dt_new_check(dt_root, "ibm,ultravisor");
+	dt_add_property_string(uv_node, "compatible", "ibm,ultravisor");
+	dt_add_property_cells(uv_node, "#address-cells", 2);
+	dt_add_property_cells(uv_node, "#size-cells", 2);
+
+	uv_fw_start = dt_get_address(secure_mem_node, 0, NULL);
+
+	snprintf(fw_name, 64, "firmware@%llx", (unsigned long long)uv_fw_start);
+	uv_fw_node = dt_new_check(uv_node, fw_name);
+	dt_add_property_string(uv_fw_node, "compatible", "ibm,uv-firmware");
+	dt_add_property_cells(uv_fw_node, "reg", uv_fw_start >> 32,
+			uv_fw_start & 0xffffffff, UV_LOAD_MAX_SIZE >> 23,
+			UV_LOAD_MAX_SIZE & 0xffffffff);
+}
+
 int parse_hdat(bool is_opal)
 {
 	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
@@ -1753,6 +1783,9 @@  int parse_hdat(bool is_opal)
 	/* Parse MS VPD */
 	memory_parse();
 
+	/* Add UV node if secure memory exists */
+	add_uv();
+
 	/* Add any FSPs */
 	fsp_parse();