blob: fa34bf41a02f29a6057733d7cf02b1076baabc07 [file] [log] [blame]
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05301#pragma once
2
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05303#include "occ_pass_through.hpp"
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05304#include "occ_status.hpp"
Tom Joseph815f9f52020-07-27 12:12:13 +05305#ifdef PLDM
6#include "pldm.hpp"
Eddie Jamescbad2192021-10-07 09:39:39 -05007
Chris Cain720a3842025-01-09 10:23:36 -06008#ifdef PHAL_SUPPORT
Eddie Jamescbad2192021-10-07 09:39:39 -05009#include <libphal.H>
Tom Joseph815f9f52020-07-27 12:12:13 +053010#endif
Chris Cain720a3842025-01-09 10:23:36 -060011#endif
Chris Cain40501a22022-03-14 17:33:27 -050012#include "powercap.hpp"
George Liuf3b75142021-06-10 11:22:50 +080013#include "utils.hpp"
Chris Cain78e86012021-03-04 16:15:31 -060014#ifdef POWER10
15#include "powermode.hpp"
16#endif
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053017
Gunnar Mills94df8c92018-09-14 14:50:03 -050018#include <sdbusplus/bus.hpp>
Chris Caina8857c52021-01-27 11:53:05 -060019#include <sdeventplus/event.hpp>
20#include <sdeventplus/utility/timer.hpp>
George Liub5ca1012021-09-10 12:53:11 +080021
22#include <cstring>
23#include <functional>
Gunnar Mills94df8c92018-09-14 14:50:03 -050024#include <vector>
25
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053026namespace sdbusRule = sdbusplus::bus::match::rules;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053027namespace open_power
28{
29namespace occ
30{
31
Chicago Duanbb895cb2021-06-18 19:37:16 +080032#ifdef READ_OCC_SENSORS
33enum occFruType
34{
35 processorCore = 0,
36 internalMemCtlr = 1,
37 dimm = 2,
38 memCtrlAndDimm = 3,
39 VRMVdd = 6,
40 PMIC = 7,
Matt Spinlerace67d82021-10-18 13:41:57 -050041 memCtlrExSensor = 8,
42 processorIoRing = 9
Chicago Duanbb895cb2021-06-18 19:37:16 +080043};
44#endif
45
Chris Caina8857c52021-01-27 11:53:05 -060046/** @brief Default time, in seconds, between OCC poll commands */
Matt Spinler37923462021-09-24 11:38:05 -050047#ifndef POWER10
Chicago Duanbb895cb2021-06-18 19:37:16 +080048constexpr unsigned int defaultPollingInterval = 1;
Matt Spinler37923462021-09-24 11:38:05 -050049#else
50constexpr unsigned int defaultPollingInterval = 5;
51#endif
Chris Caina8857c52021-01-27 11:53:05 -060052
Chris Cain17257672021-10-22 13:41:03 -050053constexpr auto AMBIENT_PATH =
54 "/xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp";
55constexpr auto AMBIENT_INTERFACE = "xyz.openbmc_project.Sensor.Value";
56constexpr auto AMBIENT_PROP = "Value";
57constexpr auto ALTITUDE_PATH = "/xyz/openbmc_project/sensors/altitude/Altitude";
58constexpr auto ALTITUDE_INTERFACE = "xyz.openbmc_project.Sensor.Value";
59constexpr auto ALTITUDE_PROP = "Value";
60
Sheldon Baileyd2b044f2025-02-12 11:50:24 -060061constexpr auto EXTN_LABEL_PWRM_MEMORY_POWER = "5057524d";
62constexpr auto EXTN_LABEL_PWRP_PROCESSOR_POWER = "50575250";
63
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053064/** @class Manager
65 * @brief Builds and manages OCC objects
66 */
67struct Manager
68{
Gunnar Mills94df8c92018-09-14 14:50:03 -050069 public:
70 Manager() = delete;
71 Manager(const Manager&) = delete;
72 Manager& operator=(const Manager&) = delete;
73 Manager(Manager&&) = delete;
74 Manager& operator=(Manager&&) = delete;
75 ~Manager() = default;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053076
Gunnar Mills94df8c92018-09-14 14:50:03 -050077 /** @brief Adds OCC pass-through and status objects on the bus
78 * when corresponding CPU inventory is created.
79 *
Gunnar Mills94df8c92018-09-14 14:50:03 -050080 * @param[in] event - Unique ptr reference to sd_event
81 */
George Liuf3a4a692021-12-28 13:59:51 +080082 explicit Manager(EventPtr& event) :
George Liuf3b75142021-06-10 11:22:50 +080083 event(event), pollInterval(defaultPollingInterval),
Chris Caina8857c52021-01-27 11:53:05 -060084 sdpEvent(sdeventplus::Event::get_default()),
85 _pollTimer(
86 std::make_unique<
87 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Cain17257672021-10-22 13:41:03 -050088 sdpEvent, std::bind(&Manager::pollerTimerExpired, this))),
89 ambientPropChanged(
90 utils::getBus(),
91 sdbusRule::member("PropertiesChanged") +
92 sdbusRule::path(AMBIENT_PATH) +
93 sdbusRule::argN(0, AMBIENT_INTERFACE) +
94 sdbusRule::interface("org.freedesktop.DBus.Properties"),
95 std::bind(&Manager::ambientCallback, this, std::placeholders::_1))
Matt Spinlerd267cec2021-09-01 14:49:19 -050096#ifdef POWER10
97 ,
98 discoverTimer(
99 std::make_unique<
100 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Caina7b74dc2021-11-10 17:03:43 -0600101 sdpEvent, std::bind(&Manager::findAndCreateObjects, this))),
102 waitForAllOccsTimer(
103 std::make_unique<
104 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
105 sdpEvent, std::bind(&Manager::occsNotAllRunning, this)))
Chris Cain755af102024-02-27 16:09:51 -0600106#ifdef PLDM
107 ,
Chris Cainc33171b2024-05-24 16:14:50 -0500108 throttlePldmTraceTimer(
Chris Cain755af102024-02-27 16:09:51 -0600109 std::make_unique<
110 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Cainc33171b2024-05-24 16:14:50 -0500111 sdpEvent, std::bind(&Manager::throttlePldmTraceExpired, this)))
Matt Spinlerd267cec2021-09-01 14:49:19 -0500112#endif
Chris Cain755af102024-02-27 16:09:51 -0600113#endif // POWER10
Gunnar Mills94df8c92018-09-14 14:50:03 -0500114 {
Lei YU0ab90ca2017-07-13 17:02:23 +0800115#ifdef I2C_OCC
Gunnar Mills94df8c92018-09-14 14:50:03 -0500116 // I2C OCC status objects are initialized directly
117 initStatusObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800118#else
Gunnar Mills94df8c92018-09-14 14:50:03 -0500119 findAndCreateObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800120#endif
Chris Cain17257672021-10-22 13:41:03 -0500121 readAltitude();
Gunnar Mills94df8c92018-09-14 14:50:03 -0500122 }
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530123
Chris Cain720a3842025-01-09 10:23:36 -0600124 void createPldmHandle();
125
Chris Caina8857c52021-01-27 11:53:05 -0600126 /** @brief Return the number of bound OCCs */
Gunnar Mills94df8c92018-09-14 14:50:03 -0500127 inline auto getNumOCCs() const
128 {
129 return activeCount;
130 }
Edward A. James636577f2017-10-06 10:53:55 -0500131
Eddie Jamescbad2192021-10-07 09:39:39 -0500132#ifdef PLDM
133 /** @brief Called by a Device to report that the SBE timed out
134 * and appropriate action should be taken
135 *
136 * @param[in] instance - the OCC instance id
137 */
138 void sbeTimeout(unsigned int instance);
139#endif
140
Chris Cain17257672021-10-22 13:41:03 -0500141 /** @brief Return the latest ambient and altitude readings
142 *
143 * @param[out] ambientValid - true if ambientTemp is valid
144 * @param[out] ambient - ambient temperature in degrees C
145 * @param[out] altitude - altitude in meters
146 */
147 void getAmbientData(bool& ambientValid, uint8_t& ambientTemp,
148 uint16_t& altitude) const;
149
Chris Cain40501a22022-03-14 17:33:27 -0500150 /** @brief Notify pcap object to update bounds */
151 void updatePcapBounds() const;
152
Sheldon Baileyc8dd4592022-05-12 10:15:14 -0500153 /**
154 * @brief Set all sensor values of this OCC to NaN.
155 * @param[in] id - Id of the OCC.
156 * */
157 void setSensorValueToNaN(uint32_t id) const;
158
Sheldon Bailey373af752022-02-21 15:14:00 -0600159 /** @brief Set all sensor values of this OCC to NaN and non functional.
160 *
161 * @param[in] id - Id of the OCC.
162 */
163 void setSensorValueToNonFunctional(uint32_t id) const;
164
Gunnar Mills94df8c92018-09-14 14:50:03 -0500165 private:
Matt Spinlerd267cec2021-09-01 14:49:19 -0500166 /** @brief Creates the OCC D-Bus objects.
Gunnar Mills94df8c92018-09-14 14:50:03 -0500167 */
168 void findAndCreateObjects();
Vishwanatha Subbannadfc7ec72017-09-07 18:18:01 +0530169
Gunnar Mills94df8c92018-09-14 14:50:03 -0500170 /** @brief Callback that responds to cpu creation in the inventory -
171 * by creating the needed objects.
172 *
173 * @param[in] msg - bus message
174 *
175 * @returns 0 to indicate success
176 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500177 int cpuCreated(sdbusplus::message_t& msg);
Deepak Kodihalli5f031f32017-07-26 08:25:59 -0500178
Gunnar Mills94df8c92018-09-14 14:50:03 -0500179 /** @brief Create child OCC objects.
180 *
181 * @param[in] occ - the occ name, such as occ0.
182 */
183 void createObjects(const std::string& occ);
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530184
Gunnar Mills94df8c92018-09-14 14:50:03 -0500185 /** @brief Callback handler invoked by Status object when the OccActive
186 * property is changed. This is needed to make sure that the
187 * error detection is started only after all the OCCs are bound.
188 * Similarly, when one of the OCC gets its OccActive property
189 * un-set, then the OCC error detection needs to be stopped on
190 * all the OCCs
191 *
192 * @param[in] status - OccActive status
193 */
Sheldon Bailey373af752022-02-21 15:14:00 -0600194 void statusCallBack(instanceID instance, bool status);
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530195
Chris Cainf0295f52024-09-12 15:41:14 -0500196 /** @brief Set flag that a PM Complex reset is needed (to be initiated
197 * later) */
198 void resetOccRequest(instanceID instance);
199
200 /** @brief Initiate the request to reset the PM Complex (PLDM -> HBRT) */
201 void initiateOccRequest(instanceID instance);
202
Gunnar Mills94df8c92018-09-14 14:50:03 -0500203 /** @brief Sends a Heartbeat command to host control command handler */
204 void sendHeartBeat();
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530205
Gunnar Mills94df8c92018-09-14 14:50:03 -0500206 /** @brief reference to sd_event wrapped in unique_ptr */
207 EventPtr& event;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530208
Gunnar Mills94df8c92018-09-14 14:50:03 -0500209 /** @brief OCC pass-through objects */
210 std::vector<std::unique_ptr<PassThrough>> passThroughObjects;
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530211
Gunnar Mills94df8c92018-09-14 14:50:03 -0500212 /** @brief OCC Status objects */
213 std::vector<std::unique_ptr<Status>> statusObjects;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530214
Chris Cain40501a22022-03-14 17:33:27 -0500215 /** @brief Power cap monitor and occ notification object */
216 std::unique_ptr<open_power::occ::powercap::PowerCap> pcap;
217
Chris Cain78e86012021-03-04 16:15:31 -0600218#ifdef POWER10
219 /** @brief Power mode monitor and notification object */
220 std::unique_ptr<open_power::occ::powermode::PowerMode> pmode;
221#endif
222
Gunnar Mills94df8c92018-09-14 14:50:03 -0500223 /** @brief sbdbusplus match objects */
224 std::vector<sdbusplus::bus::match_t> cpuMatches;
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530225
Gunnar Mills94df8c92018-09-14 14:50:03 -0500226 /** @brief Number of OCCs that are bound */
227 uint8_t activeCount = 0;
Lei YU0ab90ca2017-07-13 17:02:23 +0800228
Chris Caina8857c52021-01-27 11:53:05 -0600229 /** @brief Number of seconds between poll commands */
230 uint8_t pollInterval;
231
Chris Cain17257672021-10-22 13:41:03 -0500232 /** @brief Ambient temperature of the system in degrees C */
233 uint8_t ambient = 0xFF; // default: not available
234
235 /** @brief Altitude of the system in meters */
236 uint16_t altitude = 0xFFFF; // default: not available
237
Chris Caina8857c52021-01-27 11:53:05 -0600238 /** @brief Poll timer event */
239 sdeventplus::Event sdpEvent;
240
Chris Cainbae4d072022-02-28 09:46:50 -0600241 /** @brief Flags to indicate if waiting for all of the OCC active sensors to
242 * come online */
243 bool waitingForAllOccActiveSensors = false;
244
Chris Cainbd551de2022-04-26 13:41:16 -0500245 /** @brief Set containing intance numbers of any OCCs that became active
246 * while waiting for status objects to be created */
247 std::set<uint8_t> queuedActiveState;
248
Chris Caina8857c52021-01-27 11:53:05 -0600249 /**
250 * @brief The timer to be used once the OCC goes active. When it expires,
251 * a POLL command will be sent to the OCC and then timer restarted.
252 */
253 std::unique_ptr<
254 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
255 _pollTimer;
256
Chris Cain17257672021-10-22 13:41:03 -0500257 /** @brief Subscribe to ambient temperature changed events */
258 sdbusplus::bus::match_t ambientPropChanged;
259
Chris Cainf0295f52024-09-12 15:41:14 -0500260 /** @brief Flag to indicate that a PM complex reset needs to happen */
261 bool resetRequired = false;
262 /** @brief Instance number of the OCC/processor that triggered the reset */
263 uint8_t resetInstance = 255;
264 /** @brief Set when a PM complex reset has been issued (to prevent multiple
265 * requests) */
266 bool resetInProgress = false;
267
Lei YU0ab90ca2017-07-13 17:02:23 +0800268#ifdef I2C_OCC
Gunnar Mills94df8c92018-09-14 14:50:03 -0500269 /** @brief Init Status objects for I2C OCC devices
270 *
271 * It iterates in /sys/bus/i2c/devices, finds all occ hwmon devices
272 * and creates status objects.
273 */
274 void initStatusObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800275#endif
Tom Joseph815f9f52020-07-27 12:12:13 +0530276
277#ifdef PLDM
278 /** @brief Callback handler invoked by the PLDM event handler when state of
279 * the OCC is toggled by the host. The caller passes the instance
280 * of the OCC and state of the OCC.
281 *
282 * @param[in] instance - instance of the OCC
283 * @param[in] status - true when the OCC goes active and false when the OCC
284 * goes inactive
285 *
286 * @return true if setting the state of OCC is successful and false if it
287 * fails.
288 */
289 bool updateOCCActive(instanceID instance, bool status);
290
Sheldon Bailey31a2f132022-05-20 11:31:52 -0500291 /** @brief Callback handler invoked by the PLDM event handler when mode of
292 * the OCC SAFE MODE is inacted or cleared.
293 */
294 void updateOccSafeMode(bool safeState);
295
Eddie Jamescbad2192021-10-07 09:39:39 -0500296 /** @brief Callback handler invoked by PLDM sensor change when
297 * the HRESET succeeds or fails.
298 *
299 * @param[in] instance - the SBE instance id
300 * @param[in] success - true if the HRESET succeeded, otherwise false
301 */
302 void sbeHRESETResult(instanceID instance, bool success);
303
Chris Cain720a3842025-01-09 10:23:36 -0600304#ifdef PHAL_SUPPORT
Eddie Jamescbad2192021-10-07 09:39:39 -0500305 /** @brief Helper function to check whether an SBE dump should be collected
306 * now.
307 *
308 * @param[in] instance - the SBE instance id
309 *
310 * @return true if an SBE dump should be collected and false if not
311 */
312 bool sbeCanDump(unsigned int instance);
313
314 /** @brief Helper function to set the SBE state through PDBG/PHAL
315 *
316 * @param[in] instance - instance of the SBE
317 * @param[in] state - the state to which the SBE should be set
318 *
319 */
320 void setSBEState(unsigned int instance, enum sbe_state state);
321
322 /** @brief Helper function to get the SBE instance PDBG processor target
323 *
324 * @param[in] instance - the SBE instance id
325 *
326 * @return a pointer to the PDBG target
327 */
328 struct pdbg_target* getPdbgTarget(unsigned int instance);
329
330 /** @brief Whether pdbg_targets_init has been called */
331 bool pdbgInitialized = false;
Chris Cain720a3842025-01-09 10:23:36 -0600332#endif
Eddie Jamescbad2192021-10-07 09:39:39 -0500333
Tom Joseph815f9f52020-07-27 12:12:13 +0530334 std::unique_ptr<pldm::Interface> pldmHandle = nullptr;
335#endif
Chris Caina8857c52021-01-27 11:53:05 -0600336
Matt Spinlerd267cec2021-09-01 14:49:19 -0500337#ifdef POWER10
338 /**
339 * @brief Timer used when discovering OCCs in /dev.
340 */
341 std::unique_ptr<
342 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
343 discoverTimer;
344
345 /**
346 * @brief Used when discovering /dev/occ objects to know if
347 * any were added since the last check.
348 */
349 std::vector<int> prevOCCSearch;
Chris Caina7b74dc2021-11-10 17:03:43 -0600350
351 /**
352 * @brief Timer used when waiting for OCCs to go active.
353 */
354 std::unique_ptr<
355 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
356 waitForAllOccsTimer;
357
Chris Cain755af102024-02-27 16:09:51 -0600358#ifdef PLDM
359 /**
360 * @brief Timer used to throttle PLDM traces when there are problems
361 determining the OCC status via pldm. Used to prevent excessive
362 journal traces.
363 */
364 std::unique_ptr<
365 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
Chris Cainc33171b2024-05-24 16:14:50 -0500366 throttlePldmTraceTimer;
367 /**
368 * @brief onPldmTimeoutCreatePel flag will be used to indicate if
369 * a PEL should get created when the throttlePldmTraceTimer expires.
370 * The first time the throttlePldmTraceTimer expires, the traces
371 * will be throttled and then the timer gets restarted. The
372 * next time the timer expires, a PEL will get created.
373 */
374 bool onPldmTimeoutCreatePel = false;
Chris Cain755af102024-02-27 16:09:51 -0600375
376 /** @brief Check if all of the OCC Active sensors are available and if not
377 * restart the discoverTimer
378 */
Chris Cainc33171b2024-05-24 16:14:50 -0500379 void throttlePldmTraceExpired();
Chris Cain4b82f3e2024-04-22 14:44:29 -0500380
381 /** @brief Create a PEL when the code is not able to obtain the OCC PDRs
Chris Cainc33171b2024-05-24 16:14:50 -0500382 * via PLDM. This is called when the throttlePldmTraceTimer expires.
Chris Cain4b82f3e2024-04-22 14:44:29 -0500383 */
384 void createPldmSensorPEL();
Chris Cain755af102024-02-27 16:09:51 -0600385#endif
386
Chris Caina7b74dc2021-11-10 17:03:43 -0600387 /** @brief Called when code times out waiting for all OCCs to be running or
388 * after the app is restarted (Status does not callback into
389 * Manager).
390 */
391 void occsNotAllRunning();
Chris Cainbae4d072022-02-28 09:46:50 -0600392
393 /** @brief Check if all of the OCC Active sensors are available and if not
394 * restart the discoverTimer
395 */
396 void checkAllActiveSensors();
Chris Cain755af102024-02-27 16:09:51 -0600397#endif // POWER10
Matt Spinlerd267cec2021-09-01 14:49:19 -0500398
Chris Caina8857c52021-01-27 11:53:05 -0600399 /**
400 * @brief Called when poll timer expires and forces a POLL command to the
401 * OCC. The poll timer will then be restarted.
402 * */
403 void pollerTimerExpired();
Chicago Duanbb895cb2021-06-18 19:37:16 +0800404
Matt Spinlerd267cec2021-09-01 14:49:19 -0500405 /**
406 * @brief Finds the OCC devices in /dev
407 *
408 * @return The IDs of the OCCs - 0, 1, etc.
409 */
410 std::vector<int> findOCCsInDev();
411
Chicago Duanbb895cb2021-06-18 19:37:16 +0800412#ifdef READ_OCC_SENSORS
413 /**
414 * @brief Gets the occ sensor values.
Chris Cain5d66a0a2022-02-09 08:52:10 -0600415 * @param[in] occ - pointer to OCCs Status object
Chicago Duanbb895cb2021-06-18 19:37:16 +0800416 * */
Chris Cain5d66a0a2022-02-09 08:52:10 -0600417 void getSensorValues(std::unique_ptr<Status>& occ);
Chicago Duanbb895cb2021-06-18 19:37:16 +0800418
419 /**
420 * @brief Trigger OCC driver to read the temperature sensors.
421 * @param[in] path - path of the OCC sensors.
422 * @param[in] id - Id of the OCC.
423 * */
424 void readTempSensors(const fs::path& path, uint32_t id);
425
426 /**
Sheldon Baileyd2b044f2025-02-12 11:50:24 -0600427 * @brief Trigger OCC driver to read the extended sensors.
428 * @param[in] path - path of the OCC sensors.
429 * @param[in] id - Id of the OCC.
430 * */
431 void readExtnSensors(const fs::path& path, uint32_t id);
432
433 /**
Chicago Duanbb895cb2021-06-18 19:37:16 +0800434 * @brief Trigger OCC driver to read the power sensors.
435 * @param[in] path - path of the OCC sensors.
436 * @param[in] id - Id of the OCC.
437 * */
438 void readPowerSensors(const fs::path& path, uint32_t id);
439
Chicago Duanbb895cb2021-06-18 19:37:16 +0800440 /** @brief Store the existing OCC sensors on D-BUS */
441 std::map<std::string, uint32_t> existingSensors;
442
443 /** @brief Get FunctionID from the `powerX_label` file.
444 * @param[in] value - the value of the `powerX_label` file.
445 * @returns FunctionID of the power sensors.
446 */
Patrick Williams2d6ec902025-02-01 08:22:13 -0500447 std::optional<std::string> getPowerLabelFunctionID(
448 const std::string& value);
Chicago Duanbb895cb2021-06-18 19:37:16 +0800449
450 /** @brief The power sensor names map */
451 const std::map<std::string, std::string> powerSensorName = {
452 {"system", "total_power"}, {"1", "p0_mem_power"},
453 {"2", "p1_mem_power"}, {"3", "p2_mem_power"},
454 {"4", "p3_mem_power"}, {"5", "p0_power"},
455 {"6", "p1_power"}, {"7", "p2_power"},
456 {"8", "p3_power"}, {"9", "p0_cache_power"},
457 {"10", "p1_cache_power"}, {"11", "p2_cache_power"},
458 {"12", "p3_cache_power"}, {"13", "io_a_power"},
459 {"14", "io_b_power"}, {"15", "io_c_power"},
460 {"16", "fans_a_power"}, {"17", "fans_b_power"},
461 {"18", "storage_a_power"}, {"19", "storage_b_power"},
462 {"23", "mem_cache_power"}, {"25", "p0_mem_0_power"},
Sheldon Bailey11fd1312022-04-19 10:16:58 -0500463 {"26", "p0_mem_1_power"}, {"27", "p0_mem_2_power"},
464 {"35", "pcie_dcm0_power"}, {"36", "pcie_dcm1_power"},
465 {"37", "pcie_dcm2_power"}, {"38", "pcie_dcm3_power"},
466 {"39", "io_dcm0_power"}, {"40", "io_dcm1_power"},
467 {"41", "io_dcm2_power"}, {"42", "io_dcm3_power"},
468 {"43", "avdd_total_power"}};
Chicago Duanbb895cb2021-06-18 19:37:16 +0800469
Sheldon Bailey11fd1312022-04-19 10:16:58 -0500470 /** @brief The dimm temperature sensor names map */
Chicago Duanbb895cb2021-06-18 19:37:16 +0800471 const std::map<uint32_t, std::string> dimmTempSensorName = {
472 {internalMemCtlr, "_intmb_temp"},
473 {dimm, "_dram_temp"},
474 {memCtrlAndDimm, "_dram_extmb_temp"},
475 {PMIC, "_pmic_temp"},
476 {memCtlrExSensor, "_extmb_temp"}};
Matt Spinlerad8f4522023-10-25 11:14:46 -0500477
478 /** @brief The dimm DVFS temperature sensor names map */
479 const std::map<uint32_t, std::string> dimmDVFSSensorName = {
480 {internalMemCtlr, "dimm_intmb_dvfs_temp"},
481 {dimm, "dimm_dram_dvfs_temp"},
482 {memCtrlAndDimm, "dimm_dram_extmb_dvfs_temp"},
483 {PMIC, "dimm_pmic_dvfs_temp"},
484 {memCtlrExSensor, "dimm_extmb_dvfs_temp"}};
Chicago Duanbb895cb2021-06-18 19:37:16 +0800485#endif
Chris Cain17257672021-10-22 13:41:03 -0500486
487 /** @brief Read the altitude from DBus */
488 void readAltitude();
489
490 /** @brief Callback function when ambient temperature changes
491 *
492 * @param[in] msg - Data associated with subscribed signal
493 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500494 void ambientCallback(sdbusplus::message_t& msg);
Chris Caina7b74dc2021-11-10 17:03:43 -0600495
496 /** @brief Confirm that a single OCC master was found and start presence
497 * monitoring
498 */
499 void validateOccMaster();
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530500};
501
502} // namespace occ
503} // namespace open_power