blob: d7b66ad5ea841c0cfb3e65db3b03c83dd4ade88d [file] [log] [blame]
Jim Wright7945dd22021-04-06 16:55:15 -05001#pragma once
2
3#include "pmbus.hpp"
4#include "power_sequencer_monitor.hpp"
5
6#include <sdbusplus/bus.hpp>
Jim Wright56ae78e2021-12-01 14:46:15 -06007#include <sdbusplus/bus/match.hpp>
Jim Wright7945dd22021-04-06 16:55:15 -05008
Jim Wrightd8a86172021-12-08 11:38:26 -06009#include <filesystem>
10#include <vector>
11
Jim Wright7945dd22021-04-06 16:55:15 -050012namespace phosphor::power::sequencer
13{
14
Jim Wrightd8a86172021-12-08 11:38:26 -060015struct Pin
16{
17 std::string name;
18 int line;
19};
20
Jim Wright7945dd22021-04-06 16:55:15 -050021/**
22 * @class UCD90320Monitor
23 * This class implements fault analysis for the UCD90320
24 * power sequencer device.
25 */
26class UCD90320Monitor : public PowerSequencerMonitor
27{
28 public:
29 UCD90320Monitor() = delete;
30 UCD90320Monitor(const UCD90320Monitor&) = delete;
31 UCD90320Monitor& operator=(const UCD90320Monitor&) = delete;
32 UCD90320Monitor(UCD90320Monitor&&) = delete;
33 UCD90320Monitor& operator=(UCD90320Monitor&&) = delete;
34 virtual ~UCD90320Monitor() = default;
35
36 /**
37 * Create a device object for UCD90320 monitoring.
38 * @param[in] bus D-Bus bus object
39 * @param[in] i2cBus The bus number of the power sequencer device
40 * @param[in] i2cAddress The I2C address of the power sequencer device
41 */
42 UCD90320Monitor(sdbusplus::bus::bus& bus, std::uint8_t i2cBus,
43 const std::uint16_t i2cAddress);
44
Jim Wright56ae78e2021-12-01 14:46:15 -060045 /**
46 * Callback function to handle interfacesAdded D-Bus signals
47 * @param msg Expanded sdbusplus message data
48 */
49 void interfacesAddedHandler(sdbusplus::message::message& msg);
50
Jim Wright7945dd22021-04-06 16:55:15 -050051 private:
52 /**
53 * The D-Bus bus object
54 */
55 sdbusplus::bus::bus& bus;
56
57 /**
Jim Wright56ae78e2021-12-01 14:46:15 -060058 * The match to Entity Manager interfaces added.
59 */
60 sdbusplus::bus::match_t match;
61
62 /**
Jim Wrightd8a86172021-12-08 11:38:26 -060063 * List of pins
64 */
65 std::vector<Pin> pins;
66
67 /**
Jim Wright7945dd22021-04-06 16:55:15 -050068 * The read/write interface to this hardware
69 */
Jim Wright56ae78e2021-12-01 14:46:15 -060070 pmbus::PMBus pmbusInterface;
71
72 /**
Jim Wrightd8a86172021-12-08 11:38:26 -060073 * List of rail names
74 */
75 std::vector<std::string> rails;
76
77 /**
Jim Wright56ae78e2021-12-01 14:46:15 -060078 * Finds the list of compatible system types using D-Bus methods.
79 * This list is used to find the correct JSON configuration file for the
80 * current system.
81 */
82 void findCompatibleSystemTypes();
Jim Wrightd8a86172021-12-08 11:38:26 -060083
84 /**
85 * Finds the JSON configuration file.
86 * Looks for a configuration file based on the list of compatible system
87 * types.
88 * Throws an exception if an operating system error occurs while checking
89 * for the existance of a file.
90 * @param[in] compatibleSystemTypes List of compatible system types
91 */
92 void findConfigFile(const std::vector<std::string>& compatibleSystemTypes);
93
94 /**
95 * Parse the JSON configuration file.
96 * @param[in] pathName the path name
97 */
98 void parseConfigFile(const std::filesystem::path& pathName);
Jim Wright7945dd22021-04-06 16:55:15 -050099};
100
101} // namespace phosphor::power::sequencer