Files
OpenBMC/meta-luxshare/meta-bhs/recipes-phosphor/chassis/x86-power-control/0009-Control-uidLed-in-uid-button-handler.patch
T
2026-04-23 17:07:55 +08:00

81 lines
2.6 KiB
Diff
Executable File

From c30e74c4dc90960f935401fe403c833eac3bb7fd Mon Sep 17 00:00:00 2001
From: wangjue <jue.wang2@luxshare-ict.com>
Date: Wed, 6 Nov 2024 15:18:08 +0800
Subject: [PATCH] Control uidLed in uid button handler
Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
---
src/power_control.cpp | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/power_control.cpp b/src/power_control.cpp
index bfb55ef..8d462be 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -118,6 +118,13 @@ static std::string buttonDbusName = "xyz.openbmc_project.Chassis.Buttons";
static std::string nmiDbusName = "xyz.openbmc_project.Control.Host.NMI";
static std::string rstCauseDbusName =
"xyz.openbmc_project.Control.Host.RestartCause";
+constexpr const char* uidLedPath = "/xyz/openbmc_project/led/groups/uid_btn";
+constexpr const char* ledIface = "xyz.openbmc_project.Led.Group";
+constexpr const char* ledAssertProp = "Asserted";
+constexpr const char* ledManagerBusname =
+ "xyz.openbmc_project.LED.GroupManager";
+static bool uidLastState = false;
+
static std::shared_ptr<sdbusplus::asio::dbus_interface> hostIface;
static std::shared_ptr<sdbusplus::asio::dbus_interface> chassisIface;
#ifdef CHASSIS_SYSTEM_RESET
@@ -580,7 +587,7 @@ static void powerStateLog(const PowerState state)
auto method =
bus.new_method_call(selService, selPath, selInterface, selMethod);
- method.append("SEL Entry");
+ method.append("SEL Entry");
if (stateStr == "xyz.openbmc_project.State.Chassis.PowerState.On")
{
@@ -845,7 +852,7 @@ static void powerButtonPressLog()
// LOG_INFO, "REDFISH_MESSAGE_ID=%s",
// "OpenBMC.0.1.PowerButtonPressed", NULL);
powerStateLog(PowerState::powerButtonPressed);
-
+
}
static void resetButtonPressLog()
@@ -2416,9 +2423,30 @@ static void nmiButtonHandler(bool state)
}
}
+static void setUidLed()
+{
+ conn->async_method_call(
+ [&uidLastState](const boost::system::error_code ec) {
+ if (ec)
+ {
+ std::cerr << "Cannot set uidLed to "
+ << std::boolalpha
+ << !uidLastState << "\n";
+ }
+
+ uidLastState = !uidLastState;
+ },
+ ledManagerBusname, uidLedPath,
+ "org.freedesktop.DBus.Properties", "Set", ledIface,
+ ledAssertProp, std::variant<bool>(!uidLastState));
+}
+
static void idButtonHandler(bool state)
{
idButtonIface->set_property("ButtonPressed", !state);
+ if(!state) {
+ setUidLed();
+ }
}
static void pltRstHandler(bool pltRst)
--
2.34.1