Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "pmbus.hpp" |
| 4 | #include "power_sequencer_monitor.hpp" |
| 5 | |
| 6 | #include <sdbusplus/bus.hpp> |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 7 | #include <sdbusplus/bus/match.hpp> |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 8 | |
Jim Wright | d8a8617 | 2021-12-08 11:38:26 -0600 | [diff] [blame^] | 9 | #include <filesystem> |
| 10 | #include <vector> |
| 11 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 12 | namespace phosphor::power::sequencer |
| 13 | { |
| 14 | |
Jim Wright | d8a8617 | 2021-12-08 11:38:26 -0600 | [diff] [blame^] | 15 | struct Pin |
| 16 | { |
| 17 | std::string name; |
| 18 | int line; |
| 19 | }; |
| 20 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 21 | /** |
| 22 | * @class UCD90320Monitor |
| 23 | * This class implements fault analysis for the UCD90320 |
| 24 | * power sequencer device. |
| 25 | */ |
| 26 | class 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 Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 45 | /** |
| 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 Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 51 | private: |
| 52 | /** |
| 53 | * The D-Bus bus object |
| 54 | */ |
| 55 | sdbusplus::bus::bus& bus; |
| 56 | |
| 57 | /** |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 58 | * The match to Entity Manager interfaces added. |
| 59 | */ |
| 60 | sdbusplus::bus::match_t match; |
| 61 | |
| 62 | /** |
Jim Wright | d8a8617 | 2021-12-08 11:38:26 -0600 | [diff] [blame^] | 63 | * List of pins |
| 64 | */ |
| 65 | std::vector<Pin> pins; |
| 66 | |
| 67 | /** |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 68 | * The read/write interface to this hardware |
| 69 | */ |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 70 | pmbus::PMBus pmbusInterface; |
| 71 | |
| 72 | /** |
Jim Wright | d8a8617 | 2021-12-08 11:38:26 -0600 | [diff] [blame^] | 73 | * List of rail names |
| 74 | */ |
| 75 | std::vector<std::string> rails; |
| 76 | |
| 77 | /** |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 78 | * 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 Wright | d8a8617 | 2021-12-08 11:38:26 -0600 | [diff] [blame^] | 83 | |
| 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 Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | } // namespace phosphor::power::sequencer |