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

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