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