Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "chassis_state_manager.hpp" |
| 4 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 5 | #include "utils.hpp" |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Common/error.hpp" |
| 7 | #include "xyz/openbmc_project/State/Shutdown/Power/error.hpp" |
| 8 | |
| 9 | #include <cereal/archives/json.hpp> |
| 10 | #include <phosphor-logging/elog-errors.hpp> |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 11 | #include <phosphor-logging/lg2.hpp> |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 12 | #include <sdbusplus/bus.hpp> |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 13 | #include <sdbusplus/exception.hpp> |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 14 | #include <sdeventplus/event.hpp> |
| 15 | #include <sdeventplus/exception.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 16 | |
Andrew Geissler | f2b22e8 | 2021-03-12 14:47:03 -0600 | [diff] [blame] | 17 | #include <filesystem> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 18 | #include <fstream> |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 19 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 20 | namespace phosphor |
| 21 | { |
| 22 | namespace state |
| 23 | { |
| 24 | namespace manager |
| 25 | { |
| 26 | |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 27 | PHOSPHOR_LOG2_USING; |
| 28 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 29 | // When you see server:: you know we're referencing our base class |
| 30 | namespace server = sdbusplus::xyz::openbmc_project::State::server; |
| 31 | |
| 32 | using namespace phosphor::logging; |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 33 | using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
Aatir Manzur | 27115ae | 2019-07-23 16:25:38 -0500 | [diff] [blame] | 34 | using sdbusplus::xyz::openbmc_project::State::Shutdown::Power::Error::Blackout; |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 35 | using sdbusplus::xyz::openbmc_project::State::Shutdown::Power::Error::Regulator; |
Josh D. King | 6838ea9 | 2017-04-11 13:39:18 -0500 | [diff] [blame] | 36 | constexpr auto CHASSIS_STATE_POWEROFF_TGT = "obmc-chassis-poweroff@0.target"; |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 37 | constexpr auto CHASSIS_STATE_HARD_POWEROFF_TGT = |
| 38 | "obmc-chassis-hard-poweroff@0.target"; |
Josh D. King | 6838ea9 | 2017-04-11 13:39:18 -0500 | [diff] [blame] | 39 | constexpr auto CHASSIS_STATE_POWERON_TGT = "obmc-chassis-poweron@0.target"; |
Matthew Barth | be6efab | 2022-03-01 13:21:45 -0600 | [diff] [blame] | 40 | constexpr auto RESET_HOST_SENSORS_SVC = |
| 41 | "phosphor-reset-sensor-states@0.service"; |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 42 | |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 43 | constexpr auto ACTIVE_STATE = "active"; |
| 44 | constexpr auto ACTIVATING_STATE = "activating"; |
| 45 | |
Andrew Geissler | 2cf2a26 | 2022-02-02 14:38:41 -0600 | [diff] [blame] | 46 | // Details at https://upower.freedesktop.org/docs/Device.html |
| 47 | constexpr uint TYPE_UPS = 3; |
| 48 | constexpr uint STATE_FULLY_CHARGED = 4; |
| 49 | constexpr uint BATTERY_LVL_FULL = 8; |
| 50 | |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 51 | /* Map a transition to it's systemd target */ |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 52 | const std::map<server::Chassis::Transition, std::string> SYSTEMD_TARGET_TABLE = |
| 53 | { |
Andrew Geissler | 8cf2f9a | 2017-07-21 11:58:04 -0500 | [diff] [blame] | 54 | // Use the hard off target to ensure we shutdown immediately |
| 55 | {server::Chassis::Transition::Off, CHASSIS_STATE_HARD_POWEROFF_TGT}, |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 56 | {server::Chassis::Transition::On, CHASSIS_STATE_POWERON_TGT}}; |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 57 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 58 | constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1"; |
| 59 | constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1"; |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 60 | constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager"; |
| 61 | |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 62 | constexpr auto SYSTEMD_PROPERTY_IFACE = "org.freedesktop.DBus.Properties"; |
| 63 | constexpr auto SYSTEMD_INTERFACE_UNIT = "org.freedesktop.systemd1.Unit"; |
| 64 | |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 65 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; |
| 66 | constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; |
| 67 | constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; |
| 68 | constexpr auto UPOWER_INTERFACE = "org.freedesktop.UPower.Device"; |
| 69 | constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties"; |
| 70 | |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 71 | void Chassis::subscribeToSystemdSignals() |
Andrew Geissler | 2ec3a7e | 2016-12-13 22:01:28 -0600 | [diff] [blame] | 72 | { |
Andrew Geissler | 3a30b05 | 2019-05-14 15:54:37 -0500 | [diff] [blame] | 73 | try |
| 74 | { |
| 75 | auto method = this->bus.new_method_call( |
| 76 | SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH, SYSTEMD_INTERFACE, "Subscribe"); |
Andrew Geissler | 5b95027 | 2019-05-24 12:27:51 -0500 | [diff] [blame] | 77 | this->bus.call(method); |
Andrew Geissler | 3a30b05 | 2019-05-14 15:54:37 -0500 | [diff] [blame] | 78 | } |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 79 | catch (const sdbusplus::exception::exception& e) |
Andrew Geissler | 3a30b05 | 2019-05-14 15:54:37 -0500 | [diff] [blame] | 80 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 81 | error("Failed to subscribe to systemd signals: {ERROR}", "ERROR", e); |
Andrew Geissler | 3a30b05 | 2019-05-14 15:54:37 -0500 | [diff] [blame] | 82 | elog<InternalFailure>(); |
| 83 | } |
Andrew Geissler | 2ec3a7e | 2016-12-13 22:01:28 -0600 | [diff] [blame] | 84 | |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 85 | return; |
Andrew Geissler | 2ec3a7e | 2016-12-13 22:01:28 -0600 | [diff] [blame] | 86 | } |
| 87 | |
Andrew Geissler | dff50ed | 2016-12-13 20:39:04 -0600 | [diff] [blame] | 88 | // TODO - Will be rewritten once sdbusplus client bindings are in place |
| 89 | // and persistent storage design is in place and sdbusplus |
| 90 | // has read property function |
| 91 | void Chassis::determineInitialState() |
| 92 | { |
Andrew Geissler | 2cf2a26 | 2022-02-02 14:38:41 -0600 | [diff] [blame] | 93 | |
| 94 | // Monitor for any properties changed signals on UPower device path |
| 95 | uPowerPropChangeSignal = std::make_unique<sdbusplus::bus::match_t>( |
| 96 | bus, |
| 97 | sdbusplus::bus::match::rules::propertiesChangedNamespace( |
| 98 | "/org/freedesktop/UPower", UPOWER_INTERFACE), |
| 99 | [this](auto& msg) { this->uPowerChangeEvent(msg); }); |
| 100 | |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 101 | determineStatusOfPower(); |
| 102 | |
Patrick Williams | 2975e26 | 2020-05-13 18:01:09 -0500 | [diff] [blame] | 103 | std::variant<int> pgood = -1; |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 104 | auto method = this->bus.new_method_call( |
| 105 | "org.openbmc.control.Power", "/org/openbmc/control/power0", |
| 106 | "org.freedesktop.DBus.Properties", "Get"); |
Andrew Geissler | dff50ed | 2016-12-13 20:39:04 -0600 | [diff] [blame] | 107 | |
| 108 | method.append("org.openbmc.control.Power", "pgood"); |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 109 | try |
| 110 | { |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 111 | auto reply = this->bus.call(method); |
Anthony Wilson | 32c532e | 2018-10-25 21:56:07 -0500 | [diff] [blame] | 112 | reply.read(pgood); |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 113 | |
Patrick Williams | 37413dc | 2020-05-13 11:29:54 -0500 | [diff] [blame] | 114 | if (std::get<int>(pgood) == 1) |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 115 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 116 | info("Initial Chassis State will be On"); |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 117 | server::Chassis::currentPowerState(PowerState::On); |
| 118 | server::Chassis::requestedPowerTransition(Transition::On); |
| 119 | return; |
| 120 | } |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 121 | else |
| 122 | { |
| 123 | // The system is off. If we think it should be on then |
| 124 | // we probably lost AC while up, so set a new state |
| 125 | // change time. |
| 126 | uint64_t lastTime; |
| 127 | PowerState lastState; |
| 128 | |
| 129 | if (deserializeStateChangeTime(lastTime, lastState)) |
| 130 | { |
Andrew Geissler | 7ed3623 | 2022-01-26 13:49:28 -0600 | [diff] [blame] | 131 | // If power was on before the BMC reboot and the reboot reason |
| 132 | // was not a pinhole reset, log an error |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 133 | if (lastState == PowerState::On) |
| 134 | { |
Andrew Geissler | 7ed3623 | 2022-01-26 13:49:28 -0600 | [diff] [blame] | 135 | info( |
| 136 | "Chassis power was on before the BMC reboot and it is off now"); |
Matthew Barth | be6efab | 2022-03-01 13:21:45 -0600 | [diff] [blame] | 137 | |
| 138 | // Reset host sensors since system is off now |
| 139 | startUnit(RESET_HOST_SENSORS_SVC); |
| 140 | |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 141 | setStateChangeTime(); |
Andrew Geissler | 7ed3623 | 2022-01-26 13:49:28 -0600 | [diff] [blame] | 142 | |
| 143 | if (phosphor::state::manager::utils::getGpioValue( |
| 144 | "reset-cause-pinhole") != 1) |
| 145 | { |
| 146 | if (standbyVoltageRegulatorFault()) |
| 147 | { |
| 148 | report<Regulator>(); |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | report<Blackout>(); |
| 153 | } |
| 154 | } |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | } |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 158 | } |
Patrick Williams | 0a67521 | 2021-09-02 09:49:43 -0500 | [diff] [blame] | 159 | catch (const sdbusplus::exception::exception& e) |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 160 | { |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 161 | // It's acceptable for the pgood state service to not be available |
| 162 | // since it will notify us of the pgood state when it comes up. |
| 163 | if (e.name() != nullptr && |
| 164 | strcmp("org.freedesktop.DBus.Error.ServiceUnknown", e.name()) == 0) |
| 165 | { |
| 166 | goto fail; |
| 167 | } |
Andrew Geissler | dff50ed | 2016-12-13 20:39:04 -0600 | [diff] [blame] | 168 | |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 169 | // Only log for unexpected error types. |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 170 | error("Error performing call to get pgood: {ERROR}", "ERROR", e); |
William A. Kennington III | 9a2f37c | 2018-06-28 16:18:37 -0700 | [diff] [blame] | 171 | goto fail; |
Andrew Geissler | dff50ed | 2016-12-13 20:39:04 -0600 | [diff] [blame] | 172 | } |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 173 | |
| 174 | fail: |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 175 | info("Initial Chassis State will be Off"); |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 176 | server::Chassis::currentPowerState(PowerState::Off); |
| 177 | server::Chassis::requestedPowerTransition(Transition::Off); |
Andrew Geissler | dff50ed | 2016-12-13 20:39:04 -0600 | [diff] [blame] | 178 | |
| 179 | return; |
| 180 | } |
| 181 | |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 182 | void Chassis::determineStatusOfPower() |
| 183 | { |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 184 | // Default PowerStatus to good |
| 185 | server::Chassis::currentPowerStatus(PowerStatus::Good); |
| 186 | |
| 187 | // Find all implementations of the UPower interface |
| 188 | auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH, |
| 189 | MAPPER_INTERFACE, "GetSubTree"); |
| 190 | |
| 191 | mapper.append("/", 0, std::vector<std::string>({UPOWER_INTERFACE})); |
| 192 | |
| 193 | std::map<std::string, std::map<std::string, std::vector<std::string>>> |
| 194 | mapperResponse; |
| 195 | |
| 196 | try |
| 197 | { |
| 198 | auto mapperResponseMsg = bus.call(mapper); |
| 199 | mapperResponseMsg.read(mapperResponse); |
| 200 | } |
| 201 | catch (const sdbusplus::exception::exception& e) |
| 202 | { |
| 203 | error("Error in mapper GetSubTree call for UPS: {ERROR}", "ERROR", e); |
| 204 | throw; |
| 205 | } |
| 206 | |
| 207 | if (mapperResponse.empty()) |
| 208 | { |
| 209 | debug("No UPower devices found in system"); |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | // Iterate through all returned Upower interfaces and look for UPS's |
| 213 | for (const auto& [path, services] : mapperResponse) |
| 214 | { |
| 215 | for (const auto& serviceIter : services) |
| 216 | { |
| 217 | const std::string& service = serviceIter.first; |
| 218 | |
| 219 | try |
| 220 | { |
| 221 | auto method = bus.new_method_call(service.c_str(), path.c_str(), |
| 222 | PROPERTY_INTERFACE, "GetAll"); |
| 223 | method.append(UPOWER_INTERFACE); |
| 224 | |
| 225 | auto response = bus.call(method); |
| 226 | using Property = std::string; |
| 227 | using Value = std::variant<bool, uint>; |
| 228 | using PropertyMap = std::map<Property, Value>; |
| 229 | PropertyMap properties; |
| 230 | response.read(properties); |
| 231 | |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 232 | if (std::get<uint>(properties["Type"]) != TYPE_UPS) |
| 233 | { |
| 234 | info("UPower device {OBJ_PATH} is not a UPS device", |
| 235 | "OBJ_PATH", path); |
| 236 | continue; |
| 237 | } |
| 238 | |
Andrew Geissler | 2cf2a26 | 2022-02-02 14:38:41 -0600 | [diff] [blame] | 239 | if (std::get<bool>(properties["IsPresent"]) != true) |
| 240 | { |
| 241 | // There is a UPS detected but it is not officially |
| 242 | // "present" yet. Monitor it for state change. |
| 243 | info("UPower device {OBJ_PATH} is not present", "OBJ_PATH", |
| 244 | path); |
| 245 | continue; |
| 246 | } |
| 247 | |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 248 | if (std::get<uint>(properties["State"]) == STATE_FULLY_CHARGED) |
| 249 | { |
| 250 | info("UPS is fully charged"); |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | info("UPS is not fully charged: {UPS_STATE}", "UPS_STATE", |
| 255 | std::get<uint>(properties["State"])); |
| 256 | server::Chassis::currentPowerStatus( |
| 257 | PowerStatus::UninterruptiblePowerSupply); |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | if (std::get<uint>(properties["BatteryLevel"]) == |
| 262 | BATTERY_LVL_FULL) |
| 263 | { |
| 264 | info("UPS Battery Level is Full"); |
Andrew Geissler | 2cf2a26 | 2022-02-02 14:38:41 -0600 | [diff] [blame] | 265 | // Only one UPS per system, we've found it and it's all |
| 266 | // good so exit function |
| 267 | return; |
Andrew Geissler | 8b1f862 | 2022-01-28 16:37:07 -0600 | [diff] [blame] | 268 | } |
| 269 | else |
| 270 | { |
| 271 | info("UPS Battery Level is Low: {UPS_BAT_LEVEL}", |
| 272 | "UPS_BAT_LEVEL", |
| 273 | std::get<uint>(properties["BatteryLevel"])); |
| 274 | server::Chassis::currentPowerStatus( |
| 275 | PowerStatus::UninterruptiblePowerSupply); |
| 276 | return; |
| 277 | } |
| 278 | } |
| 279 | catch (const sdbusplus::exception::exception& e) |
| 280 | { |
| 281 | error("Error reading UPS property, error: {ERROR}, " |
| 282 | "service: {SERVICE} path: {PATH}", |
| 283 | "ERROR", e, "SERVICE", service, "PATH", path); |
| 284 | throw; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | return; |
| 289 | } |
| 290 | |
Andrew Geissler | 2cf2a26 | 2022-02-02 14:38:41 -0600 | [diff] [blame] | 291 | void Chassis::uPowerChangeEvent(sdbusplus::message::message& msg) |
| 292 | { |
| 293 | debug("UPS Property Change Event Triggered"); |
| 294 | std::string statusInterface; |
| 295 | std::map<std::string, std::variant<uint, bool>> msgData; |
| 296 | msg.read(statusInterface, msgData); |
| 297 | |
| 298 | // If the change is to any of the three properties we are interested in |
| 299 | // then call determineStatusOfPower() to see if a power status change |
| 300 | // is needed |
| 301 | auto propertyMap = msgData.find("IsPresent"); |
| 302 | if (propertyMap != msgData.end()) |
| 303 | { |
| 304 | info("UPS presence changed to {UPS_PRES_INFO}", "UPS_PRES_INFO", |
| 305 | std::get<bool>(propertyMap->second)); |
| 306 | determineStatusOfPower(); |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | propertyMap = msgData.find("State"); |
| 311 | if (propertyMap != msgData.end()) |
| 312 | { |
| 313 | info("UPS State changed to {UPS_STATE}", "UPS_STATE", |
| 314 | std::get<uint>(propertyMap->second)); |
| 315 | determineStatusOfPower(); |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | propertyMap = msgData.find("BatteryLevel"); |
| 320 | if (propertyMap != msgData.end()) |
| 321 | { |
| 322 | info("UPS BatteryLevel changed to {UPS_BAT_LEVEL}", "UPS_BAT_LEVEL", |
| 323 | std::get<uint>(propertyMap->second)); |
| 324 | determineStatusOfPower(); |
| 325 | return; |
| 326 | } |
| 327 | return; |
| 328 | } |
| 329 | |
Matthew Barth | be6efab | 2022-03-01 13:21:45 -0600 | [diff] [blame] | 330 | void Chassis::startUnit(const std::string& sysdUnit) |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 331 | { |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 332 | auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH, |
| 333 | SYSTEMD_INTERFACE, "StartUnit"); |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 334 | |
Matthew Barth | be6efab | 2022-03-01 13:21:45 -0600 | [diff] [blame] | 335 | method.append(sysdUnit); |
Andrew Geissler | ce80f24 | 2017-01-24 13:25:33 -0600 | [diff] [blame] | 336 | method.append("replace"); |
| 337 | |
| 338 | this->bus.call_noreply(method); |
| 339 | |
| 340 | return; |
| 341 | } |
| 342 | |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 343 | bool Chassis::stateActive(const std::string& target) |
| 344 | { |
Patrick Williams | 2975e26 | 2020-05-13 18:01:09 -0500 | [diff] [blame] | 345 | std::variant<std::string> currentState; |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 346 | sdbusplus::message::object_path unitTargetPath; |
| 347 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 348 | auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH, |
| 349 | SYSTEMD_INTERFACE, "GetUnit"); |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 350 | |
| 351 | method.append(target); |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 352 | |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 353 | try |
| 354 | { |
Anthony Wilson | 32c532e | 2018-10-25 21:56:07 -0500 | [diff] [blame] | 355 | auto result = this->bus.call(method); |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 356 | result.read(unitTargetPath); |
| 357 | } |
Patrick Williams | 0a67521 | 2021-09-02 09:49:43 -0500 | [diff] [blame] | 358 | catch (const sdbusplus::exception::exception& e) |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 359 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 360 | error("Error in GetUnit call: {ERROR}", "ERROR", e); |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 361 | return false; |
| 362 | } |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 363 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 364 | method = this->bus.new_method_call( |
| 365 | SYSTEMD_SERVICE, |
| 366 | static_cast<const std::string&>(unitTargetPath).c_str(), |
| 367 | SYSTEMD_PROPERTY_IFACE, "Get"); |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 368 | |
| 369 | method.append(SYSTEMD_INTERFACE_UNIT, "ActiveState"); |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 370 | |
Anthony Wilson | 32c532e | 2018-10-25 21:56:07 -0500 | [diff] [blame] | 371 | try |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 372 | { |
Anthony Wilson | 32c532e | 2018-10-25 21:56:07 -0500 | [diff] [blame] | 373 | auto result = this->bus.call(method); |
| 374 | result.read(currentState); |
| 375 | } |
Patrick Williams | 0a67521 | 2021-09-02 09:49:43 -0500 | [diff] [blame] | 376 | catch (const sdbusplus::exception::exception& e) |
Anthony Wilson | 32c532e | 2018-10-25 21:56:07 -0500 | [diff] [blame] | 377 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 378 | error("Error in ActiveState Get: {ERROR}", "ERROR", e); |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 379 | return false; |
| 380 | } |
| 381 | |
Patrick Williams | 37413dc | 2020-05-13 11:29:54 -0500 | [diff] [blame] | 382 | const auto& currentStateStr = std::get<std::string>(currentState); |
William A. Kennington III | 7a0689a | 2018-11-12 17:19:33 -0800 | [diff] [blame] | 383 | return currentStateStr == ACTIVE_STATE || |
| 384 | currentStateStr == ACTIVATING_STATE; |
Josh D. King | 697474c | 2017-03-02 11:15:55 -0600 | [diff] [blame] | 385 | } |
| 386 | |
Patrick Williams | 8f8ba39 | 2017-05-05 15:47:39 -0500 | [diff] [blame] | 387 | int Chassis::sysStateChange(sdbusplus::message::message& msg) |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 388 | { |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 389 | sdbusplus::message::object_path newStateObjPath; |
| 390 | std::string newStateUnit{}; |
| 391 | std::string newStateResult{}; |
| 392 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 393 | // Read the msg and populate each variable |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 394 | try |
| 395 | { |
Andrew Geissler | 9b8af4f | 2019-09-12 14:19:14 -0500 | [diff] [blame] | 396 | // newStateID is a throwaway that is needed in order to read the |
| 397 | // parameters that are useful out of the dbus message |
| 398 | uint32_t newStateID{}; |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 399 | msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult); |
| 400 | } |
Patrick Williams | 0a67521 | 2021-09-02 09:49:43 -0500 | [diff] [blame] | 401 | catch (const sdbusplus::exception::exception& e) |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 402 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 403 | error("Error in state change - bad encoding: {ERROR} {REPLY_SIG}", |
| 404 | "ERROR", e, "REPLY_SIG", msg.get_signature()); |
William A. Kennington III | 09568ff | 2018-05-11 00:03:12 -0700 | [diff] [blame] | 405 | return 0; |
| 406 | } |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 407 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 408 | if ((newStateUnit == CHASSIS_STATE_POWEROFF_TGT) && |
| 409 | (newStateResult == "done") && (!stateActive(CHASSIS_STATE_POWERON_TGT))) |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 410 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 411 | info("Received signal that power OFF is complete"); |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 412 | this->currentPowerState(server::Chassis::PowerState::Off); |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 413 | this->setStateChangeTime(); |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 414 | } |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 415 | else if ((newStateUnit == CHASSIS_STATE_POWERON_TGT) && |
| 416 | (newStateResult == "done") && |
| 417 | (stateActive(CHASSIS_STATE_POWERON_TGT))) |
| 418 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 419 | info("Received signal that power ON is complete"); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 420 | this->currentPowerState(server::Chassis::PowerState::On); |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 421 | this->setStateChangeTime(); |
Andrew Geissler | f2b22e8 | 2021-03-12 14:47:03 -0600 | [diff] [blame] | 422 | |
| 423 | // Remove temporary file which is utilized for scenarios where the |
| 424 | // BMC is rebooted while the chassis power is still on. |
| 425 | // This file is used to indicate to chassis related systemd services |
| 426 | // that the chassis is already on and they should skip running. |
| 427 | // Once the chassis state is back to on we can clear this file. |
| 428 | auto size = std::snprintf(nullptr, 0, CHASSIS_ON_FILE, 0); |
| 429 | size++; // null |
| 430 | std::unique_ptr<char[]> chassisFile(new char[size]); |
| 431 | std::snprintf(chassisFile.get(), size, CHASSIS_ON_FILE, 0); |
| 432 | if (std::filesystem::exists(chassisFile.get())) |
| 433 | { |
| 434 | std::filesystem::remove(chassisFile.get()); |
| 435 | } |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 436 | } |
Andrew Geissler | 0029a5d | 2017-01-24 14:48:35 -0600 | [diff] [blame] | 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 441 | Chassis::Transition Chassis::requestedPowerTransition(Transition value) |
| 442 | { |
| 443 | |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 444 | info("Change to Chassis Requested Power State: {REQ_POWER_TRAN}", |
| 445 | "REQ_POWER_TRAN", value); |
Matthew Barth | be6efab | 2022-03-01 13:21:45 -0600 | [diff] [blame] | 446 | startUnit(SYSTEMD_TARGET_TABLE.find(value)->second); |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 447 | return server::Chassis::requestedPowerTransition(value); |
| 448 | } |
| 449 | |
| 450 | Chassis::PowerState Chassis::currentPowerState(PowerState value) |
| 451 | { |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 452 | PowerState chassisPowerState; |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 453 | info("Change to Chassis Power State: {CUR_POWER_STATE}", "CUR_POWER_STATE", |
| 454 | value); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 455 | |
| 456 | chassisPowerState = server::Chassis::currentPowerState(value); |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 457 | pohTimer.setEnabled(chassisPowerState == PowerState::On); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 458 | return chassisPowerState; |
| 459 | } |
| 460 | |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 461 | uint32_t Chassis::pohCounter(uint32_t value) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 462 | { |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 463 | if (value != pohCounter()) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 464 | { |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 465 | ChassisInherit::pohCounter(value); |
Matt Spinler | 8195784 | 2018-07-11 10:37:12 -0500 | [diff] [blame] | 466 | serializePOH(); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 467 | } |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 468 | return pohCounter(); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 469 | } |
| 470 | |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 471 | void Chassis::pohCallback() |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 472 | { |
| 473 | if (ChassisInherit::currentPowerState() == PowerState::On) |
| 474 | { |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 475 | pohCounter(pohCounter() + 1); |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 476 | } |
| 477 | } |
| 478 | |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 479 | void Chassis::restorePOHCounter() |
| 480 | { |
| 481 | uint32_t counter; |
Matt Spinler | 8195784 | 2018-07-11 10:37:12 -0500 | [diff] [blame] | 482 | if (!deserializePOH(POH_COUNTER_PERSIST_PATH, counter)) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 483 | { |
| 484 | // set to default value |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 485 | pohCounter(0); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 486 | } |
| 487 | else |
| 488 | { |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 489 | pohCounter(counter); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
Matt Spinler | 8195784 | 2018-07-11 10:37:12 -0500 | [diff] [blame] | 493 | fs::path Chassis::serializePOH(const fs::path& path) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 494 | { |
| 495 | std::ofstream os(path.c_str(), std::ios::binary); |
| 496 | cereal::JSONOutputArchive oarchive(os); |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 497 | oarchive(pohCounter()); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 498 | return path; |
| 499 | } |
| 500 | |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 501 | bool Chassis::deserializePOH(const fs::path& path, uint32_t& pohCounter) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 502 | { |
| 503 | try |
| 504 | { |
| 505 | if (fs::exists(path)) |
| 506 | { |
| 507 | std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); |
| 508 | cereal::JSONInputArchive iarchive(is); |
Patrick Williams | 45a1ed7 | 2021-04-30 21:02:43 -0500 | [diff] [blame] | 509 | iarchive(pohCounter); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 510 | return true; |
| 511 | } |
| 512 | return false; |
| 513 | } |
Patrick Williams | 8583b3b | 2021-10-06 12:19:20 -0500 | [diff] [blame] | 514 | catch (const cereal::Exception& e) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 515 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 516 | error("deserialize exception: {ERROR}", "ERROR", e); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 517 | fs::remove(path); |
| 518 | return false; |
| 519 | } |
| 520 | catch (const fs::filesystem_error& e) |
| 521 | { |
| 522 | return false; |
| 523 | } |
| 524 | |
| 525 | return false; |
| 526 | } |
| 527 | |
| 528 | void Chassis::startPOHCounter() |
| 529 | { |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 530 | auto dir = fs::path(POH_COUNTER_PERSIST_PATH).parent_path(); |
| 531 | fs::create_directories(dir); |
| 532 | |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 533 | try |
| 534 | { |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 535 | auto event = sdeventplus::Event::get_default(); |
| 536 | bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); |
| 537 | event.loop(); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 538 | } |
William A. Kennington III | d998f82 | 2018-10-17 23:17:57 -0700 | [diff] [blame] | 539 | catch (const sdeventplus::SdEventError& e) |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 540 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 541 | error("Error occurred during the sdeventplus loop: {ERROR}", "ERROR", |
| 542 | e); |
Nagaraju Goruganti | cb781fe | 2018-04-06 13:41:01 -0500 | [diff] [blame] | 543 | phosphor::logging::commit<InternalFailure>(); |
| 544 | } |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 545 | } |
| 546 | |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 547 | void Chassis::serializeStateChangeTime() |
| 548 | { |
| 549 | fs::path path{CHASSIS_STATE_CHANGE_PERSIST_PATH}; |
| 550 | std::ofstream os(path.c_str(), std::ios::binary); |
| 551 | cereal::JSONOutputArchive oarchive(os); |
| 552 | |
| 553 | oarchive(ChassisInherit::lastStateChangeTime(), |
| 554 | ChassisInherit::currentPowerState()); |
| 555 | } |
| 556 | |
| 557 | bool Chassis::deserializeStateChangeTime(uint64_t& time, PowerState& state) |
| 558 | { |
| 559 | fs::path path{CHASSIS_STATE_CHANGE_PERSIST_PATH}; |
| 560 | |
| 561 | try |
| 562 | { |
| 563 | if (fs::exists(path)) |
| 564 | { |
| 565 | std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); |
| 566 | cereal::JSONInputArchive iarchive(is); |
| 567 | iarchive(time, state); |
| 568 | return true; |
| 569 | } |
| 570 | } |
Patrick Williams | 8583b3b | 2021-10-06 12:19:20 -0500 | [diff] [blame] | 571 | catch (const std::exception& e) |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 572 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 573 | error("deserialize exception: {ERROR}", "ERROR", e); |
Matt Spinler | 9eab986 | 2018-07-11 14:13:52 -0500 | [diff] [blame] | 574 | fs::remove(path); |
| 575 | } |
| 576 | |
| 577 | return false; |
| 578 | } |
| 579 | |
| 580 | void Chassis::restoreChassisStateChangeTime() |
| 581 | { |
| 582 | uint64_t time; |
| 583 | PowerState state; |
| 584 | |
| 585 | if (!deserializeStateChangeTime(time, state)) |
| 586 | { |
| 587 | ChassisInherit::lastStateChangeTime(0); |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | ChassisInherit::lastStateChangeTime(time); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | void Chassis::setStateChangeTime() |
| 596 | { |
| 597 | using namespace std::chrono; |
| 598 | uint64_t lastTime; |
| 599 | PowerState lastState; |
| 600 | |
| 601 | auto now = |
| 602 | duration_cast<milliseconds>(system_clock::now().time_since_epoch()) |
| 603 | .count(); |
| 604 | |
| 605 | // If power is on when the BMC is rebooted, this function will get called |
| 606 | // because sysStateChange() runs. Since the power state didn't change |
| 607 | // in this case, neither should the state change time, so check that |
| 608 | // the power state actually did change here. |
| 609 | if (deserializeStateChangeTime(lastTime, lastState)) |
| 610 | { |
| 611 | if (lastState == ChassisInherit::currentPowerState()) |
| 612 | { |
| 613 | return; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | ChassisInherit::lastStateChangeTime(now); |
| 618 | serializeStateChangeTime(); |
| 619 | } |
| 620 | |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 621 | bool Chassis::standbyVoltageRegulatorFault() |
| 622 | { |
| 623 | bool regulatorFault = false; |
| 624 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 625 | // find standby voltage regulator fault via gpiog |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 626 | |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 627 | auto gpioval = utils::getGpioValue("regulator-standby-faulted"); |
| 628 | |
| 629 | if (-1 == gpioval) |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 630 | { |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 631 | error("Failed reading regulator-standby-faulted GPIO"); |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 632 | } |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 633 | |
| 634 | if (1 == gpioval) |
| 635 | { |
| 636 | info("Detected standby voltage regulator fault"); |
| 637 | regulatorFault = true; |
| 638 | } |
| 639 | |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 640 | return regulatorFault; |
| 641 | } |
| 642 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 643 | } // namespace manager |
| 644 | } // namespace state |
Andrew Geissler | a965cf0 | 2018-08-31 08:37:05 -0700 | [diff] [blame] | 645 | } // namespace phosphor |