blob: 43489d2dfdcf6cf8808c1591fb43e88ea5ce9693 [file] [log] [blame]
Brandon Wyman24e422f2017-07-25 19:40:14 -05001#pragma once
Brandon Wyman1db9a9e2017-07-26 18:50:22 -05002#include "device.hpp"
Brandon Wyman442035f2017-08-08 15:58:45 -05003#include "pmbus.hpp"
Brandon Wyman24e422f2017-07-25 19:40:14 -05004
Brandon Wyman1db9a9e2017-07-26 18:50:22 -05005namespace witherspoon
Brandon Wyman24e422f2017-07-25 19:40:14 -05006{
7namespace power
8{
9namespace psu
10{
11
12/**
13 * @class PowerSupply
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050014 * Represents a PMBus power supply device.
Brandon Wyman24e422f2017-07-25 19:40:14 -050015 */
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050016class PowerSupply : public Device
Brandon Wyman24e422f2017-07-25 19:40:14 -050017{
18 public:
19 PowerSupply() = delete;
20 PowerSupply(const PowerSupply&) = delete;
Brandon Wyman24e422f2017-07-25 19:40:14 -050021 PowerSupply(PowerSupply&&) = default;
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050022 PowerSupply& operator=(const PowerSupply&) = default;
Brandon Wyman24e422f2017-07-25 19:40:14 -050023 PowerSupply& operator=(PowerSupply&&) = default;
24 ~PowerSupply() = default;
25
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050026 /**
27 * Constructor
28 *
29 * @param[in] name - the device name
30 * @param[in] inst - the device instance
31 * @param[in] objpath - the path to monitor
32 * @param[in] invpath - the inventory path to use
Brandon Wyman442035f2017-08-08 15:58:45 -050033 * @param[in] bus - D-Bus bus object
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050034 */
35 PowerSupply(const std::string& name, size_t inst,
Brandon Wyman442035f2017-08-08 15:58:45 -050036 const std::string& objpath,
37 const std::string& invpath,
38 sdbusplus::bus::bus& bus)
39 : Device(name, inst), monitorPath(objpath), inventoryPath(invpath),
40 bus(bus), pmbusIntf(objpath)
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050041 {
42 }
43
44 /**
45 * Power supply specific function to analyze for faults/errors.
46 *
47 * Various PMBus status bits will be checked for fault conditions.
48 * If a certain fault bits are on, the appropriate error will be
49 * committed.
50 */
51 void analyze() override;
52
53 /**
54 * Write PMBus CLEAR_FAULTS
55 *
56 * This function will be called in various situations in order to clear
57 * any fault status bits that may have been set, in order to start over
58 * with a clean state. Presence changes and power state changes will
59 * want to clear any faults logged.
60 */
61 void clearFaults() override;
62
63 private:
64 /**
65 * The path to use for reading various PMBus bits/words.
66 */
67 std::string monitorPath;
68
69 /**
70 * The D-Bus path to use for this power supply's inventory status.
71 */
72 std::string inventoryPath;
Brandon Wyman442035f2017-08-08 15:58:45 -050073
74 /** @brief Connection for sdbusplus bus */
75 sdbusplus::bus::bus& bus;
76
77 /**
78 * @brief Pointer to the PMBus interface
79 *
80 * Used to read out of or write to the /sysfs tree(s) containing files
81 * that a device driver monitors the PMBus interface to the power
82 * supplies.
83 */
84 witherspoon::pmbus::PMBus pmbusIntf;
85
86 /**
87 * @brief Has a PMBus read failure already been logged?
88 */
89 bool readFailLogged = false;
90
91 /**
92 * @brief Set to true when a VIN UV fault has been detected
93 *
94 * This is the VIN_UV_FAULT bit in the low byte from the STATUS_WORD
95 * command response.
96 */
97 bool vinUVFault = false;
98
99 /**
100 * @brief Set to true when an input fault or warning is detected
101 *
102 * This is the "INPUT FAULT OR WARNING" bit in the high byte from the
103 * STATUS_WORD command response.
104 */
105 bool inputFault = false;
Brandon Wyman24e422f2017-07-25 19:40:14 -0500106};
107
108}
109}
110}