Blame SOURCES/0014-devtree-Add-capabilites-to-the-OPAL-Firmware.patch

e67e1d
From 29f69ac618fd5ace9ed9aae7839b5cfdc1fb5130 Mon Sep 17 00:00:00 2001
e67e1d
From: Shivaprasad G Bhat <sbhat@linux.ibm.com>
e67e1d
Date: Wed, 1 Apr 2020 09:25:52 -0500
e67e1d
Subject: [PATCH 14/17] devtree: Add capabilites to the OPAL Firmware
e67e1d
e67e1d
On OpenPower systems, the presence of the "/ibm,opal" entry in the device tree
e67e1d
signifies machines are running under OPAL firmware (i.e skiboot). Under this
e67e1d
node OPAL exports certain available interfaces. And also this node have a
e67e1d
compatible property listing "ibm,opal-v<X> which denotes the OPAL compatability.
e67e1d
e67e1d
This change adds a function to parse information about those OPAL firmware
e67e1d
capabilities and add it to skiboot firmware node. With a current OpenPower
e67e1d
machine, we get something like this:
e67e1d
e67e1d
     *-firmware:0
e67e1d
          description: skiboot
e67e1d
          product: OPAL firmware
e67e1d
          physical id: 2
e67e1d
          version: 5.4.3-35bf9d9
e67e1d
          capabilities: opal-v2 opal-v3 prd ipmi
e67e1d
e67e1d
e67e1d
Signed-off-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
e67e1d
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
e67e1d
---
e67e1d
 src/core/device-tree.cc | 42 +++++++++++++++++++++++++++++++++++++++++
e67e1d
 1 file changed, 42 insertions(+)
e67e1d
e67e1d
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
e67e1d
index af665a4d8e1a..e7227e1f74b7 100644
e67e1d
--- a/src/core/device-tree.cc
e67e1d
+++ b/src/core/device-tree.cc
e67e1d
@@ -219,11 +219,48 @@ static void scan_devtree_bootrom(hwNode & core)
e67e1d
   }
e67e1d
 }
e67e1d
 
e67e1d
+static hwNode *add_base_opal_node(hwNode & core)
e67e1d
+{
e67e1d
+  vector < string >:: iterator it;
e67e1d
+  vector < string > compat;
e67e1d
+  string basepath = DEVICETREE "/ibm,opal";
e67e1d
+  hwNode opal("firmware");
e67e1d
+
e67e1d
+  if (!exists(basepath))
e67e1d
+    return NULL;
e67e1d
+
e67e1d
+  pushd(basepath);
e67e1d
+
e67e1d
+  opal.setProduct("OPAL firmware");
e67e1d
+  opal.setDescription("skiboot");
e67e1d
+
e67e1d
+  compat = get_strings(basepath + "/compatible");
e67e1d
+  for (it = compat.begin(); it != compat.end(); ++it) {
e67e1d
+    if (matches(*it, "^ibm,opal-v"))
e67e1d
+      opal.addCapability((*it).erase(0,4));
e67e1d
+  }
e67e1d
+
e67e1d
+  if (exists(basepath + "/ipmi/compatible") &&
e67e1d
+    matches(get_string(basepath + "/ipmi/compatible"), "^ibm,opal-ipmi"))
e67e1d
+    opal.addCapability("ipmi");
e67e1d
+
e67e1d
+  if (exists(basepath + "/diagnostics/compatible") &&
e67e1d
+    matches(get_string(basepath + "/diagnostics/compatible"), "^ibm,opal-prd"))
e67e1d
+    opal.addCapability("prd");
e67e1d
+
e67e1d
+  popd();
e67e1d
+
e67e1d
+  opal.claim();
e67e1d
+  return core.addChild(opal);
e67e1d
+}
e67e1d
+
e67e1d
 static void scan_devtree_firmware_powernv(hwNode & core)
e67e1d
 {
e67e1d
   int n;
e67e1d
   struct dirent **namelist;
e67e1d
 
e67e1d
+  hwNode *opal = add_base_opal_node(core);
e67e1d
+
e67e1d
   if (!exists(DEVICETREE "/ibm,firmware-versions"))
e67e1d
     return;
e67e1d
 
e67e1d
@@ -245,6 +282,11 @@ static void scan_devtree_firmware_powernv(hwNode & core)
e67e1d
       fwnode.setDescription(sname);
e67e1d
       fwnode.setVersion(hw::strip(get_string(fullpath)));
e67e1d
       fwnode.claim();
e67e1d
+      if (opal && sname == "skiboot") {
e67e1d
+        opal->merge(fwnode);
e67e1d
+        free(namelist[i]);
e67e1d
+        continue;
e67e1d
+      }
e67e1d
       core.addChild(fwnode);
e67e1d
     }
e67e1d
     free(namelist[i]);
e67e1d
-- 
e67e1d
2.17.1
e67e1d