96 lines
3.3 KiB
Diff
96 lines
3.3 KiB
Diff
|
|
diff --git a/src/power_control.cpp b/src/power_control.cpp
|
||
|
|
index 586d1e3..b671b23 100644
|
||
|
|
--- a/src/power_control.cpp
|
||
|
|
+++ b/src/power_control.cpp
|
||
|
|
@@ -558,6 +558,58 @@ static constexpr std::string_view getChassisState(const PowerState state)
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
+
|
||
|
|
+static void powerStateLog(const PowerState state)
|
||
|
|
+{
|
||
|
|
+ constexpr const char* selService = "xyz.openbmc_project.Logging.IPMI";
|
||
|
|
+ constexpr const char* selPath = "/xyz/openbmc_project/Logging/IPMI";
|
||
|
|
+ constexpr const char* selInterface = "xyz.openbmc_project.Logging.IPMI";
|
||
|
|
+ constexpr const char* selMethod = "IpmiSelAdd";
|
||
|
|
+ constexpr const char* sensorPath =
|
||
|
|
+ "/xyz/openbmc_project/inventory/system/board/Lux_Baseboard/ACPI_State";
|
||
|
|
+
|
||
|
|
+ auto bus = sdbusplus::bus::new_default();
|
||
|
|
+ std::string stateStr = std::string(getChassisState(state));
|
||
|
|
+
|
||
|
|
+ auto method =
|
||
|
|
+ bus.new_method_call(selService, selPath, selInterface, selMethod);
|
||
|
|
+
|
||
|
|
+ method.append("SEL Entry");
|
||
|
|
+ method.append(sensorPath);
|
||
|
|
+
|
||
|
|
+ if (stateStr == "xyz.openbmc_project.State.Chassis.PowerState.On")
|
||
|
|
+ {
|
||
|
|
+ std::cerr << "Send Power State On SEL Log\n";
|
||
|
|
+ method.append(
|
||
|
|
+ std::array<uint8_t, 3>({0x00, 0xFF, 0xFF})); // S0/G0: working
|
||
|
|
+ }
|
||
|
|
+ else if (stateStr == "xyz.openbmc_project.State.Chassis.PowerState.Off")
|
||
|
|
+ {
|
||
|
|
+ std::cerr << "Send Power State Off SEL Log\n";
|
||
|
|
+ method.append(
|
||
|
|
+ std::array<uint8_t, 3>({0x06, 0xFF, 0xFF})); // S4/S5: soft-off
|
||
|
|
+ }
|
||
|
|
+ else
|
||
|
|
+ {
|
||
|
|
+ std::cerr << "Send Power State SEL Log Error\n";
|
||
|
|
+ return;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ method.append(true); // assert is true and deassert is false
|
||
|
|
+ method.append(uint16_t(0x0020)); // generator ID
|
||
|
|
+ try
|
||
|
|
+ {
|
||
|
|
+ bus.call_noreply(method);
|
||
|
|
+ }
|
||
|
|
+ catch (const sdbusplus::exception::SdBusError& ex)
|
||
|
|
+ {
|
||
|
|
+ lg2::error(
|
||
|
|
+ "Failed to call sel log {SELPATH}, {SELINTERFACE}, {SELMRTHOD}",
|
||
|
|
+ "SELPATH", selPath, "SELINTERFACE", selInterface, "SELMRTHOD",
|
||
|
|
+ selMethod);
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
#ifdef CHASSIS_SYSTEM_RESET
|
||
|
|
enum class SlotPowerState
|
||
|
|
{
|
||
|
|
@@ -1890,6 +1942,7 @@ static void powerStateWaitForPSPowerOK(const Event event)
|
||
|
|
else
|
||
|
|
{
|
||
|
|
setPowerState(PowerState::on);
|
||
|
|
+ powerStateLog(PowerState::on);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
@@ -1941,6 +1994,7 @@ static void powerStateOff(const Event event)
|
||
|
|
else
|
||
|
|
{
|
||
|
|
setPowerState(PowerState::on);
|
||
|
|
+ powerStateLog(PowerState::on);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
@@ -1975,6 +2029,7 @@ static void powerStateTransitionToOff(const Event event)
|
||
|
|
// Cancel any GPIO assertions held during the transition
|
||
|
|
gpioAssertTimer.cancel();
|
||
|
|
setPowerState(PowerState::off);
|
||
|
|
+ powerStateLog(PowerState::off);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
lg2::info("No action taken.");
|
||
|
|
@@ -2064,6 +2119,7 @@ static void powerStateTransitionToCycleOff(const Event event)
|
||
|
|
// Cancel any GPIO assertions held during the transition
|
||
|
|
gpioAssertTimer.cancel();
|
||
|
|
setPowerState(PowerState::cycleOff);
|
||
|
|
+ powerStateLog(PowerState::cycleOff);
|
||
|
|
powerCycleTimerStart();
|
||
|
|
break;
|
||
|
|
default:
|