Remove Legacy code from P10 and future code

Remove Occ control code that supports older hardware models P8 and P9.
This is in preparation for occ control taking over occ poll handling.

Change-Id: Iff99ac8ff3a3fe6e9a6af994b20b06793ead50fc
Signed-off-by: Sheldon Bailey <baileysh@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 3ae11f6..302a733 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -2,7 +2,6 @@
 
 #include "occ_manager.hpp"
 
-#include "i2c_occ.hpp"
 #include "occ_dbus.hpp"
 #include "occ_errors.hpp"
 #include "utils.hpp"
@@ -58,7 +57,6 @@
 
 void Manager::createPldmHandle()
 {
-#ifdef PLDM
     pldmHandle = std::make_unique<pldm::Interface>(
         std::bind(std::mem_fn(&Manager::updateOCCActive), this,
                   std::placeholders::_1, std::placeholders::_2),
@@ -67,7 +65,6 @@
         std::bind(std::mem_fn(&Manager::updateOccSafeMode), this,
                   std::placeholders::_1),
         std::bind(std::mem_fn(&Manager::hostPoweredOff), this), event);
-#endif
 }
 
 // findAndCreateObjects():
@@ -80,14 +77,6 @@
 // - restart discoverTimer if all data is not available yet
 void Manager::findAndCreateObjects()
 {
-#ifndef POWER10
-    for (auto id = 0; id < MAX_CPUS; ++id)
-    {
-        // Create one occ per cpu
-        auto occ = std::string(OCC_NAME) + std::to_string(id);
-        createObjects(occ);
-    }
-#else
     if (!pmode)
     {
         // Create the power mode object
@@ -164,7 +153,7 @@
                     tracedHostWait = true;
                 }
                 discoverTimer->restartOnce(30s);
-#ifdef PLDM
+
                 if (throttlePldmTraceTimer->isEnabled())
                 {
                     // Host is no longer running, disable throttle timer and
@@ -173,7 +162,6 @@
                     throttlePldmTraceTimer->setEnabled(false);
                     pldmHandle->setTraceThrottle(false);
                 }
-#endif
             }
         }
     }
@@ -184,10 +172,8 @@
             "FILE", HOST_ON_FILE);
         discoverTimer->restartOnce(10s);
     }
-#endif
 }
 
-#ifdef POWER10
 // Check if all occActive sensors are available
 void Manager::checkAllActiveSensors()
 {
@@ -229,22 +215,18 @@
                             "checkAllActiveSensors(): Waiting on OCC{INST} Active sensor",
                             "INST", instance);
                         tracedSensorWait = true;
-#ifdef PLDM
                         // Make sure PLDM traces are not throttled
                         pldmHandle->setTraceThrottle(false);
                         // Start timer to throttle PLDM traces when timer
                         // expires
                         onPldmTimeoutCreatePel = false;
                         throttlePldmTraceTimer->restartOnce(5min);
-#endif
                     }
-#ifdef PLDM
                     // Ignore active sensor check if the OCCs are being reset
                     if (!resetInProgress)
                     {
                         pldmHandle->checkActiveSensor(obj->getOccInstanceID());
                     }
-#endif
                     break;
                 }
             }
@@ -256,7 +238,6 @@
         {
             waitingForHost = true;
             lg2::info("checkAllActiveSensors(): Waiting for host to start");
-#ifdef PLDM
             if (throttlePldmTraceTimer->isEnabled())
             {
                 // Host is no longer running, disable throttle timer and
@@ -265,7 +246,6 @@
                 throttlePldmTraceTimer->setEnabled(false);
                 pldmHandle->setTraceThrottle(false);
             }
-#endif
         }
     }
 
@@ -276,14 +256,12 @@
         {
             discoverTimer->setEnabled(false);
         }
-#ifdef PLDM
         if (throttlePldmTraceTimer->isEnabled())
         {
             // Disable throttle timer and make sure traces are not throttled
             throttlePldmTraceTimer->setEnabled(false);
             pldmHandle->setTraceThrottle(false);
         }
-#endif
         if (waitingForAllOccActiveSensors)
         {
             lg2::info(
@@ -319,7 +297,6 @@
         discoverTimer->restartOnce(10s);
     }
 }
-#endif
 
 std::vector<int> Manager::findOCCsInDev()
 {
@@ -364,20 +341,13 @@
     auto path = fs::path(OCC_CONTROL_ROOT) / occ;
 
     statusObjects.emplace_back(std::make_unique<Status>(
-        event, path.c_str(), *this,
-#ifdef POWER10
-        pmode,
-#endif
+        event, path.c_str(), *this, pmode,
         std::bind(std::mem_fn(&Manager::statusCallBack), this,
-                  std::placeholders::_1, std::placeholders::_2)
-#ifdef PLDM
-            ,
+                  std::placeholders::_1, std::placeholders::_2),
         // Callback will set flag indicating reset needs to be done
         // instead of immediately issuing a reset via PLDM.
         std::bind(std::mem_fn(&Manager::resetOccRequest), this,
-                  std::placeholders::_1)
-#endif
-            ));
+                  std::placeholders::_1)));
 
     // Create the power cap monitor object
     if (!pcap)
@@ -392,19 +362,12 @@
                   statusObjects.back()->getOccInstanceID());
         _pollTimer->setEnabled(false);
 
-#ifdef POWER10
         // Set the master OCC on the PowerMode object
         pmode->setMasterOcc(path);
-#endif
     }
 
-    passThroughObjects.emplace_back(std::make_unique<PassThrough>(
-        path.c_str()
-#ifdef POWER10
-            ,
-        pmode
-#endif
-        ));
+    passThroughObjects.emplace_back(
+        std::make_unique<PassThrough>(path.c_str(), pmode));
 }
 
 // If a reset is not already outstanding, set a flag to indicate that a reset is
@@ -447,9 +410,7 @@
             }
         }
 
-#ifdef PLDM
         pldmHandle->resetOCC(instance);
-#endif
         resetRequired = false;
     }
     else
@@ -475,17 +436,14 @@
         // OCC went active
         ++activeCount;
 
-#ifdef POWER10
         if (activeCount == 1)
         {
             // First OCC went active (allow some time for all OCCs to go active)
             waitForAllOccsTimer->restartOnce(60s);
         }
-#endif
 
         if (activeCount == statusObjects.size())
         {
-#ifdef POWER10
             // All OCCs are now running
             if (waitForAllOccsTimer->isEnabled())
             {
@@ -511,10 +469,6 @@
                 // Verify master OCC and start presence monitor
                 validateOccMaster();
             }
-#else
-            // Verify master OCC and start presence monitor
-            validateOccMaster();
-#endif
         }
 
         // Start poll timer if not already started (since at least one OCC is
@@ -574,13 +528,11 @@
                 _pollTimer->setEnabled(false);
             }
 
-#ifdef POWER10
             // stop wait timer
             if (waitForAllOccsTimer->isEnabled())
             {
                 waitForAllOccsTimer->setEnabled(false);
             }
-#endif
         }
         else if (resetInProgress)
         {
@@ -588,13 +540,10 @@
                 "statusCallBack: Skipping clear of resetInProgress (activeCount={COUNT}, OCC{INST}, status={STATUS})",
                 "COUNT", activeCount, "INST", instance, "STATUS", status);
         }
-#ifdef READ_OCC_SENSORS
         // Clear OCC sensors
         setSensorValueToNaN(instance);
-#endif
     }
 
-#ifdef POWER10
     if (waitingForAllOccActiveSensors)
     {
         if (utils::isHostRunning())
@@ -602,37 +551,8 @@
             checkAllActiveSensors();
         }
     }
-#endif
 }
 
-#ifdef I2C_OCC
-void Manager::initStatusObjects()
-{
-    // Make sure we have a valid path string
-    static_assert(sizeof(DEV_PATH) != 0);
-
-    auto deviceNames = i2c_occ::getOccHwmonDevices(DEV_PATH);
-    for (auto& name : deviceNames)
-    {
-        i2c_occ::i2cToDbus(name);
-        name = std::string(OCC_NAME) + '_' + name;
-        auto path = fs::path(OCC_CONTROL_ROOT) / name;
-        statusObjects.emplace_back(
-            std::make_unique<Status>(event, path.c_str(), *this));
-    }
-    // The first device is master occ
-    pcap = std::make_unique<open_power::occ::powercap::PowerCap>(
-        *statusObjects.front());
-#ifdef POWER10
-    pmode = std::make_unique<powermode::PowerMode>(*this, powermode::PMODE_PATH,
-                                                   powermode::PIPS_PATH);
-    // Set the master OCC on the PowerMode object
-    pmode->setMasterOcc(path);
-#endif
-}
-#endif
-
-#ifdef PLDM
 void Manager::sbeTimeout(unsigned int instance)
 {
     auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
@@ -678,9 +598,7 @@
                     "updateOCCActive: Waiting for Host and all OCC Active Sensors");
                 waitingForAllOccActiveSensors = true;
             }
-#ifdef POWER10
             discoverTimer->restartOnce(30s);
-#endif
             return false;
         }
         else
@@ -727,9 +645,7 @@
 // Called upon pldm event To set powermode Safe Mode State for system.
 void Manager::updateOccSafeMode(bool safeMode)
 {
-#ifdef POWER10
     pmode->updateDbusSafeMode(safeMode);
-#endif
     // Update the processor throttle status on dbus
     for (auto& obj : statusObjects)
     {
@@ -899,7 +815,6 @@
     return nullptr;
 }
 #endif
-#endif
 
 void Manager::pollerTimerExpired()
 {
@@ -909,7 +824,6 @@
         return;
     }
 
-#ifdef POWER10
     if (resetRequired)
     {
         lg2::error("pollerTimerExpired() - Initiating PM Complex reset");
@@ -923,27 +837,22 @@
         }
         return;
     }
-#endif
 
     for (auto& obj : statusObjects)
     {
         if (!obj->occActive())
         {
             // OCC is not running yet
-#ifdef READ_OCC_SENSORS
             auto id = obj->getOccInstanceID();
             setSensorValueToNaN(id);
-#endif
             continue;
         }
 
         // Read sysfs to force kernel to poll OCC
         obj->readOccState();
 
-#ifdef READ_OCC_SENSORS
         // Read occ sensor values
         getSensorValues(obj);
-#endif
     }
 
     if (activeCount > 0)
@@ -959,7 +868,6 @@
     }
 }
 
-#ifdef READ_OCC_SENSORS
 void Manager::readTempSensors(const fs::path& path, uint32_t occInstance)
 {
     // There may be more than one sensor with the same FRU type
@@ -1475,7 +1383,6 @@
 
     return;
 }
-#endif
 
 // Read the altitude from DBus
 void Manager::readAltitude()
@@ -1571,7 +1478,7 @@
 
         lg2::debug("ambientCallback: Ambient: {TEMP}C, altitude: {ALT}m",
                    "TEMP", ambient, "ALT", altitude);
-#ifdef POWER10
+
         // Send ambient and altitude to all OCCs
         for (auto& obj : statusObjects)
         {
@@ -1580,7 +1487,6 @@
                 obj->sendAmbient(ambient, altitude);
             }
         }
-#endif // POWER10
     }
 }
 
@@ -1598,7 +1504,6 @@
     }
 }
 
-#ifdef POWER10
 // Called when waitForAllOccsTimer expires
 // After the first OCC goes active, this timer will be started (60 seconds)
 void Manager::occsNotAllRunning()
@@ -1635,7 +1540,6 @@
     }
 }
 
-#ifdef PLDM
 // Called when throttlePldmTraceTimer expires.
 // If this timer expires, that indicates there are no OCC active sensor PDRs
 // found which will trigger pldm traces to be throttled.
@@ -1712,8 +1616,6 @@
                    e.what());
     }
 }
-#endif // PLDM
-#endif // POWER10
 
 // Verify single master OCC and start presence monitor
 void Manager::validateOccMaster()
@@ -1722,7 +1624,7 @@
     for (auto& obj : statusObjects)
     {
         auto instance = obj->getOccInstanceID();
-#ifdef POWER10
+
         if (!obj->occActive())
         {
             if (utils::isHostRunning())
@@ -1739,9 +1641,7 @@
                 else
                 {
                     // OCC does not appear to be active yet, check active sensor
-#ifdef PLDM
                     pldmHandle->checkActiveSensor(instance);
-#endif
                     if (obj->occActive())
                     {
                         lg2::info(
@@ -1758,7 +1658,6 @@
                 return;
             }
         }
-#endif // POWER10
 
         if (obj->isMasterOcc())
         {
@@ -1791,9 +1690,8 @@
     {
         lg2::info("validateOccMaster: OCC{INST} is master of {COUNT} OCCs",
                   "INST", masterInstance, "COUNT", activeCount);
-#ifdef POWER10
+
         pmode->updateDbusSafeMode(false);
-#endif
     }
 }