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

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