blob: 45dd774c9f33e4e16ed570b2e4b76fe02d1c83a2 [file] [log] [blame]
Shawn McCarney71d7fe42024-05-02 16:06:10 -05001/**
2 * Copyright © 2024 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "pmbus_driver_device.hpp"
19#include "rail.hpp"
20#include "services.hpp"
21
22#include <cstdint>
23#include <map>
24#include <memory>
25#include <string>
26#include <utility>
27#include <vector>
28
29namespace phosphor::power::sequencer
30{
31
32/**
33 * @class UCD90xDevice
34 *
35 * PMBusDriverDevice sub-class for the UCD90X family of power sequencer devices.
36 *
37 * These devices share a common device driver.
38 */
39class UCD90xDevice : public PMBusDriverDevice
40{
41 public:
42 // Specify which compiler-generated methods we want
43 UCD90xDevice() = delete;
44 UCD90xDevice(const UCD90xDevice&) = delete;
45 UCD90xDevice(UCD90xDevice&&) = delete;
46 UCD90xDevice& operator=(const UCD90xDevice&) = delete;
47 UCD90xDevice& operator=(UCD90xDevice&&) = delete;
48 virtual ~UCD90xDevice() = default;
49
50 /**
51 * Constructor.
52 *
53 * @param name Device name
Shawn McCarney71d7fe42024-05-02 16:06:10 -050054 * @param bus I2C bus for the device
55 * @param address I2C address for the device
Shawn McCarney31234452025-10-28 12:32:05 -050056 * @param rails Voltage rails that are enabled and monitored by this device
57 * @param services System services like hardware presence and the journal
Shawn McCarney71d7fe42024-05-02 16:06:10 -050058 */
Shawn McCarney31234452025-10-28 12:32:05 -050059 explicit UCD90xDevice(const std::string& name, uint8_t bus,
60 uint16_t address,
Shawn McCarney71d7fe42024-05-02 16:06:10 -050061 std::vector<std::unique_ptr<Rail>> rails,
Shawn McCarney31234452025-10-28 12:32:05 -050062 Services& services) :
63 PMBusDriverDevice(name, bus, address, std::move(rails), services,
Shawn McCarney71d7fe42024-05-02 16:06:10 -050064 driverName)
65 {}
66
67 /**
68 * Returns the value of the PMBus MFR_STATUS command.
69 *
70 * This is a manufacturer-specific command that replaces the standard
71 * STATUS_MFR_SPECIFIC command on UCD90x devices.
72 *
73 * The returned value is in host-endian order.
74 *
75 * Note that the UCD90x documentation states that this is a paged command.
76 * This means that the PMBus PAGE should be set, and some of the bits in the
77 * command value are page-specific. However, the current device driver only
78 * provides a single file in sysfs, and the driver always sets the PAGE to
79 * 0. Thus, the bits that are page-specific in the returned value are
80 * always for PAGE 0.
81 *
82 * Throws an exception if the value could not be obtained.
83 *
84 * @return MFR_STATUS value
85 */
86 virtual uint64_t getMfrStatus();
87
88 constexpr static std::string driverName{"ucd9000"};
89
90 protected:
91 /** @copydoc PMBusDriverDevice::storePgoodFaultDebugData() */
92 virtual void storePgoodFaultDebugData(
93 Services& services, const std::vector<int>& gpioValues,
94 std::map<std::string, std::string>& additionalData) override;
95};
96
97} // namespace phosphor::power::sequencer