xref: /openbmc/phosphor-power/phosphor-power-sequencer/src/ucd90160_device.hpp (revision fe5366751e86e156e478e53df79c6b6de040be5c)
1 /**
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 "rail.hpp"
19 #include "services.hpp"
20 #include "ucd90x_device.hpp"
21 
22 #include <cstdint>
23 #include <map>
24 #include <memory>
25 #include <string>
26 #include <utility>
27 #include <vector>
28 
29 namespace phosphor::power::sequencer
30 {
31 
32 /**
33  * @class UCD90160Device
34  *
35  * Class representing the UCD90160 power sequencer device.
36  */
37 class UCD90160Device : public UCD90xDevice
38 {
39   public:
40     // Specify which compiler-generated methods we want
41     UCD90160Device() = delete;
42     UCD90160Device(const UCD90160Device&) = delete;
43     UCD90160Device(UCD90160Device&&) = delete;
44     UCD90160Device& operator=(const UCD90160Device&) = delete;
45     UCD90160Device& operator=(UCD90160Device&&) = delete;
46     virtual ~UCD90160Device() = default;
47 
48     /**
49      * Constructor.
50      *
51      * @param bus I2C bus for the device
52      * @param address I2C address for the device
53      * @param powerControlGPIOName Name of the GPIO that turns this device on
54      *                             and off
55      * @param powerGoodGPIOName Name of the GPIO that reads the power good
56      *                          signal from this device
57      * @param rails Voltage rails that are enabled and monitored by this device
58      * @param services System services like hardware presence and the journal
59      */
UCD90160Device(uint8_t bus,uint16_t address,const std::string & powerControlGPIOName,const std::string & powerGoodGPIOName,std::vector<std::unique_ptr<Rail>> rails,Services & services)60     explicit UCD90160Device(
61         uint8_t bus, uint16_t address, const std::string& powerControlGPIOName,
62         const std::string& powerGoodGPIOName,
63         std::vector<std::unique_ptr<Rail>> rails, Services& services) :
64         UCD90xDevice(deviceName, bus, address, powerControlGPIOName,
65                      powerGoodGPIOName, std::move(rails), services)
66     {}
67 
68     constexpr static std::string deviceName{"UCD90160"};
69 
70   protected:
71     /** @copydoc UCD90xDevice::storeGPIOValues() */
72     virtual void storeGPIOValues(
73         Services& services, const std::vector<int>& values,
74         std::map<std::string, std::string>& additionalData) override;
75 };
76 
77 } // namespace phosphor::power::sequencer
78