Add SIO Enabled change
Modified the power-control state machine to equip x86-power-conrol to support
for the system which does not have sioPowerGood support.
TESTED: Tested and verified in Tiogapass. The existing functionality
is not broken after adding the changes in Tiogapass.
Signed-off-by: Priyatharshan P <priyatharshanp@hcl.com>
Change-Id: I6520c22474124f1dbd903e7522ab2ae5959d4ff5
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index 2f04885..7377767 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -85,6 +85,7 @@
const static constexpr std::string_view powerStateFile = "power-state";
static bool nmiEnabled = true;
+static bool sioEnabled = true;
// Timers
// Time holding GPIOs asserted
@@ -1462,12 +1463,21 @@
switch (event)
{
case Event::psPowerOKAssert:
+ {
// Cancel any GPIO assertions held during the transition
gpioAssertTimer.cancel();
psPowerOKWatchdogTimer.cancel();
- sioPowerGoodWatchdogTimerStart();
- setPowerState(PowerState::waitForSIOPowerGood);
+ if (sioEnabled == true)
+ {
+ sioPowerGoodWatchdogTimerStart();
+ setPowerState(PowerState::waitForSIOPowerGood);
+ }
+ else
+ {
+ setPowerState(PowerState::on);
+ }
break;
+ }
case Event::psPowerOKWatchdogTimerExpired:
setPowerState(PowerState::off);
psPowerOKFailedLog();
@@ -1509,8 +1519,17 @@
switch (event)
{
case Event::psPowerOKAssert:
- setPowerState(PowerState::waitForSIOPowerGood);
+ {
+ if (sioEnabled == true)
+ {
+ setPowerState(PowerState::waitForSIOPowerGood);
+ }
+ else
+ {
+ setPowerState(PowerState::on);
+ }
break;
+ }
case Event::sioS5DeAssert:
setPowerState(PowerState::waitForPSPowerOK);
break;
@@ -1575,9 +1594,18 @@
switch (event)
{
case Event::psPowerOKAssert:
+ {
powerCycleTimer.cancel();
- setPowerState(PowerState::waitForSIOPowerGood);
+ if (sioEnabled == true)
+ {
+ setPowerState(PowerState::waitForSIOPowerGood);
+ }
+ else
+ {
+ setPowerState(PowerState::on);
+ }
break;
+ }
case Event::sioS5DeAssert:
powerCycleTimer.cancel();
setPowerState(PowerState::waitForPSPowerOK);
@@ -2144,6 +2172,14 @@
power_control::conn->request_name(
"xyz.openbmc_project.Control.Host.RestartCause");
+ if (power_control::sioPwrGoodName.empty() ||
+ power_control::sioOnControlName.empty() ||
+ power_control::sioS5Name.empty())
+ {
+ power_control::sioEnabled = false;
+ std::cerr << "SIO control GPIOs not defined, disable SIO support.\n";
+ }
+
// Request PS_PWROK GPIO events
if (!power_control::powerOkName.empty())
{
@@ -2161,9 +2197,9 @@
return -1;
}
- // Request SIO_POWER_GOOD GPIO events
- if (!power_control::sioPwrGoodName.empty())
+ if (power_control::sioEnabled == true)
{
+ // Request SIO_POWER_GOOD GPIO events
if (!power_control::requestGPIOEvents(
power_control::sioPwrGoodName,
power_control::sioPowerGoodHandler,
@@ -2172,17 +2208,8 @@
{
return -1;
}
- }
- else
- {
- std::cerr
- << "sioPwrGood name should be configured from json config file\n";
- return -1;
- }
- // Request SIO_ONCONTROL GPIO events
- if (!power_control::sioOnControlName.empty())
- {
+ // Request SIO_ONCONTROL GPIO events
if (!power_control::requestGPIOEvents(
power_control::sioOnControlName,
power_control::sioOnControlHandler,
@@ -2191,17 +2218,8 @@
{
return -1;
}
- }
- else
- {
- std::cerr
- << "sioOnControl name should be configured from json config file\n";
- return -1;
- }
- // Request SIO_S5 GPIO events
- if (!power_control::sioS5Name.empty())
- {
+ // Request SIO_S5 GPIO events
if (!power_control::requestGPIOEvents(
power_control::sioS5Name, power_control::sioS5Handler,
power_control::sioS5Line, power_control::sioS5Event))
@@ -2209,11 +2227,6 @@
return -1;
}
}
- else
- {
- std::cerr << "sioS5 name should be configured from json config file\n";
- return -1;
- }
// Request POWER_BUTTON GPIO events
if (!power_control::powerButtonName.empty())