Add HpmStbyEn signal

HpmStbyEn signal is a special signal that can be found on AMD boards.
It indicates that all DC-SCM STBY power rails are enabled and good.
The signal enables STBY power rails on the HPM.
It is a level GPIO, and if it is not activated, onboard CPLD wouldn't
relinquish control of power control GPIOs to BMC making it impossible
to power on the host.
Therefore if this GPIO is present in the JSON configuration activate it
in the main function.

Tested on the AMD EthanolX/Onyx CRB
   Onyx verification: power on/off, application restart at power on/off
                      and bmc reboot.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
Change-Id: I3a21c2e5214dfcf05cdae8efc2ebbb21c4b4e080
diff --git a/src/power_control.cpp b/src/power_control.cpp
index 8ceac4f..34b3c53 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -85,6 +85,7 @@
 static ConfigData idButtonConfig;
 static ConfigData nmiButtonConfig;
 static ConfigData slotPowerConfig;
+static ConfigData hpmStbyEnConfig;
 
 // map for storing list of gpio parameters whose config are to be read from x86
 // power control json config
@@ -101,7 +102,8 @@
     {"ResetButton", &resetButtonConfig},
     {"IdButton", &idButtonConfig},
     {"NMIButton", &nmiButtonConfig},
-    {"SlotPower", &slotPowerConfig}};
+    {"SlotPower", &slotPowerConfig},
+    {"HpmStbyEn", &hpmStbyEnConfig}};
 
 static std::string hostDbusName = "xyz.openbmc_project.State.Host";
 static std::string chassisDbusName = "xyz.openbmc_project.State.Chassis";
@@ -3462,6 +3464,18 @@
 
     currentHostStateMonitor();
 
+    if (!hpmStbyEnConfig.lineName.empty())
+    {
+        // Set to indicate BMC's power control module is ready to take
+        // the inputs [PWR_GOOD] from the HPM FPGA
+        gpiod::line hpmLine;
+        if (!setGPIOOutput(hpmStbyEnConfig.lineName, hpmStbyEnConfig.polarity,
+                           hpmLine))
+        {
+            return -1;
+        }
+    }
+
     io.run();
 
     return 0;