[RFC,01/12] witherspoon: Check for existing npu node

Message ID 20170801130007.8990-2-oohall@gmail.com
State RFC
Headers show

Commit Message

Oliver Aug. 1, 2017, 12:59 p.m.
Only create the npu@xyz nodes if we haven't created them already. In the
future we will populated the npu@xyz nodes and their child link@x nodes
based on the HDAT.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 platforms/astbmc/witherspoon.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/platforms/astbmc/witherspoon.c b/platforms/astbmc/witherspoon.c
index c5227398e401..8f7b15ce6a64 100644
--- a/platforms/astbmc/witherspoon.c
+++ b/platforms/astbmc/witherspoon.c
@@ -301,6 +301,9 @@  static void dt_create_npu2(void)
 
 static bool witherspoon_probe(void)
 {
+	struct dt_node *n;
+	bool found = false;
+
 	if (!dt_node_is_compatible(dt_root, "ibm,witherspoon"))
 		return false;
 
@@ -310,8 +313,12 @@  static bool witherspoon_probe(void)
 	/* Setup UART for use by OPAL (Linux hvc) */
 	uart_set_console_policy(UART_CONSOLE_OPAL);
 
-	/* Add NPU2 bindings */
-	dt_create_npu2();
+	/* Add NPU2 bindings if we didn't create them inside the HDAT already */
+	dt_for_each_compatible(dt_root, n, "ibm,power9-npu")
+		found = true;
+
+	if (!found)
+		dt_create_npu2();
 
 	slot_table_init(witherspoon_phb_table);