14af83db5SShawn McCarney /** 24af83db5SShawn McCarney * Copyright © 2024 IBM Corporation 34af83db5SShawn McCarney * 44af83db5SShawn McCarney * Licensed under the Apache License, Version 2.0 (the "License"); 54af83db5SShawn McCarney * you may not use this file except in compliance with the License. 64af83db5SShawn McCarney * You may obtain a copy of the License at 74af83db5SShawn McCarney * 84af83db5SShawn McCarney * http://www.apache.org/licenses/LICENSE-2.0 94af83db5SShawn McCarney * 104af83db5SShawn McCarney * Unless required by applicable law or agreed to in writing, software 114af83db5SShawn McCarney * distributed under the License is distributed on an "AS IS" BASIS, 124af83db5SShawn McCarney * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134af83db5SShawn McCarney * See the License for the specific language governing permissions and 144af83db5SShawn McCarney * limitations under the License. 154af83db5SShawn McCarney */ 164af83db5SShawn McCarney #pragma once 174af83db5SShawn McCarney 18f47a7a72SShawn McCarney #include "rail.hpp" 194af83db5SShawn McCarney #include "services.hpp" 204af83db5SShawn McCarney 214af83db5SShawn McCarney #include <cstdint> 224af83db5SShawn McCarney #include <map> 234af83db5SShawn McCarney #include <string> 244af83db5SShawn McCarney #include <vector> 254af83db5SShawn McCarney 264af83db5SShawn McCarney namespace phosphor::power::sequencer 274af83db5SShawn McCarney { 284af83db5SShawn McCarney 294af83db5SShawn McCarney /** 304af83db5SShawn McCarney * @class PowerSequencerDevice 314af83db5SShawn McCarney * 324af83db5SShawn McCarney * Abstract base class for a hardware device that performs the following tasks: 334af83db5SShawn McCarney * - Enables (turns on) the voltage rails in the proper sequence 344af83db5SShawn McCarney * - Checks the pgood (power good) status of each voltage rail 354af83db5SShawn McCarney */ 364af83db5SShawn McCarney class PowerSequencerDevice 374af83db5SShawn McCarney { 384af83db5SShawn McCarney public: 394af83db5SShawn McCarney // Specify which compiler-generated methods we want 404af83db5SShawn McCarney PowerSequencerDevice() = default; 414af83db5SShawn McCarney PowerSequencerDevice(const PowerSequencerDevice&) = delete; 424af83db5SShawn McCarney PowerSequencerDevice(PowerSequencerDevice&&) = delete; 434af83db5SShawn McCarney PowerSequencerDevice& operator=(const PowerSequencerDevice&) = delete; 444af83db5SShawn McCarney PowerSequencerDevice& operator=(PowerSequencerDevice&&) = delete; 454af83db5SShawn McCarney virtual ~PowerSequencerDevice() = default; 464af83db5SShawn McCarney 474af83db5SShawn McCarney /** 484af83db5SShawn McCarney * Returns the device name. 494af83db5SShawn McCarney * 504af83db5SShawn McCarney * @return device name 514af83db5SShawn McCarney */ 524af83db5SShawn McCarney virtual const std::string& getName() const = 0; 534af83db5SShawn McCarney 544af83db5SShawn McCarney /** 55f47a7a72SShawn McCarney * Returns the voltage rails that are enabled and monitored by this device. 56f47a7a72SShawn McCarney * 57f47a7a72SShawn McCarney * @return voltage rails 58f47a7a72SShawn McCarney */ 59f47a7a72SShawn McCarney virtual const std::vector<std::unique_ptr<Rail>>& getRails() const = 0; 60f47a7a72SShawn McCarney 61f47a7a72SShawn McCarney /** 624af83db5SShawn McCarney * Returns the GPIO values that can be read from the device. 634af83db5SShawn McCarney * 644af83db5SShawn McCarney * The vector indices correspond to the libgpiod line offsets. For example, 654af83db5SShawn McCarney * the element at vector index 0 is the GPIO value at libgpiod line offset 664af83db5SShawn McCarney * 0. These offsets may correspond to logical pin IDs, but they are usually 674af83db5SShawn McCarney * different from the physical pin numbers on the device. Consult the 684af83db5SShawn McCarney * device documentation for more information. 694af83db5SShawn McCarney * 704af83db5SShawn McCarney * Throws an exception if the values could not be read or the device does 714af83db5SShawn McCarney * not support GPIO values. 724af83db5SShawn McCarney * 73fc3f31fbSShawn McCarney * @param services System services like hardware presence and the journal 744af83db5SShawn McCarney * @return GPIO values 754af83db5SShawn McCarney */ 76fc3f31fbSShawn McCarney virtual std::vector<int> getGPIOValues(Services& services) = 0; 774af83db5SShawn McCarney 784af83db5SShawn McCarney /** 794af83db5SShawn McCarney * Returns the value of the PMBus STATUS_WORD command for the specified 804af83db5SShawn McCarney * PMBus page. 814af83db5SShawn McCarney * 824af83db5SShawn McCarney * The returned value is in host-endian order. 834af83db5SShawn McCarney * 844af83db5SShawn McCarney * Throws an exception if the value could not be obtained or the device does 854af83db5SShawn McCarney * not support the STATUS_WORD command. 864af83db5SShawn McCarney * 874af83db5SShawn McCarney * @param page PMBus page 884af83db5SShawn McCarney * @return STATUS_WORD value 894af83db5SShawn McCarney */ 904af83db5SShawn McCarney virtual uint16_t getStatusWord(uint8_t page) = 0; 914af83db5SShawn McCarney 924af83db5SShawn McCarney /** 934af83db5SShawn McCarney * Returns the value of the PMBus STATUS_VOUT command for the specified 944af83db5SShawn McCarney * PMBus page. 954af83db5SShawn McCarney * 964af83db5SShawn McCarney * Throws an exception if the value could not be obtained or the device does 974af83db5SShawn McCarney * not support the STATUS_VOUT command. 984af83db5SShawn McCarney * 994af83db5SShawn McCarney * @param page PMBus page 1004af83db5SShawn McCarney * @return STATUS_VOUT value 1014af83db5SShawn McCarney */ 1024af83db5SShawn McCarney virtual uint8_t getStatusVout(uint8_t page) = 0; 1034af83db5SShawn McCarney 1044af83db5SShawn McCarney /** 1054af83db5SShawn McCarney * Returns the value of the PMBus READ_VOUT command for the specified 1064af83db5SShawn McCarney * PMBus page. 1074af83db5SShawn McCarney * 1084af83db5SShawn McCarney * The returned value is in Volts. 1094af83db5SShawn McCarney * 1104af83db5SShawn McCarney * Throws an exception if the value could not be obtained or the device does 1114af83db5SShawn McCarney * not support the READ_VOUT command. 1124af83db5SShawn McCarney * 1134af83db5SShawn McCarney * @param page PMBus page 1144af83db5SShawn McCarney * @return READ_VOUT value in volts 1154af83db5SShawn McCarney */ 1164af83db5SShawn McCarney virtual double getReadVout(uint8_t page) = 0; 1174af83db5SShawn McCarney 1184af83db5SShawn McCarney /** 1194af83db5SShawn McCarney * Returns the value of the PMBus VOUT_UV_FAULT_LIMIT command for the 1204af83db5SShawn McCarney * specified PMBus page. 1214af83db5SShawn McCarney * 1224af83db5SShawn McCarney * The returned value is in Volts. 1234af83db5SShawn McCarney * 1244af83db5SShawn McCarney * Throws an exception if the value could not be obtained or the device does 1254af83db5SShawn McCarney * not support the VOUT_UV_FAULT_LIMIT command. 1264af83db5SShawn McCarney * 1274af83db5SShawn McCarney * @param page PMBus page 1284af83db5SShawn McCarney * @return VOUT_UV_FAULT_LIMIT value in volts 1294af83db5SShawn McCarney */ 1304af83db5SShawn McCarney virtual double getVoutUVFaultLimit(uint8_t page) = 0; 1314af83db5SShawn McCarney 1324af83db5SShawn McCarney /** 133472101c5SShawn McCarney * Checks whether a pgood fault has occurred on one of the rails being 1344af83db5SShawn McCarney * monitored by this device. 1354af83db5SShawn McCarney * 136472101c5SShawn McCarney * If a pgood fault was found, this method returns a string containing the 137472101c5SShawn McCarney * error that should be logged. If no fault was found, an empty string is 138472101c5SShawn McCarney * returned. 139472101c5SShawn McCarney * 1404af83db5SShawn McCarney * Throws an exception if an error occurs while trying to obtain the status 1414af83db5SShawn McCarney * of the rails. 1424af83db5SShawn McCarney * 143f47a7a72SShawn McCarney * @param services System services like hardware presence and the journal 1444af83db5SShawn McCarney * @param powerSupplyError Power supply error that occurred before the pgood 1454af83db5SShawn McCarney * fault. Set to the empty string if no power 1464af83db5SShawn McCarney * supply error occurred. This error may be the 1474af83db5SShawn McCarney * root cause if a pgood fault occurred on a power 1484af83db5SShawn McCarney * supply rail monitored by this device. 1494af83db5SShawn McCarney * @param additionalData Additional data to include in the error log if 150472101c5SShawn McCarney * a pgood fault was found 151472101c5SShawn McCarney * @return error that should be logged if a pgood fault was found, or an 152472101c5SShawn McCarney * empty string if no pgood fault was found 1534af83db5SShawn McCarney */ 154*92261f88SPatrick Williams virtual std::string findPgoodFault( 155*92261f88SPatrick Williams Services& services, const std::string& powerSupplyError, 1564af83db5SShawn McCarney std::map<std::string, std::string>& additionalData) = 0; 1574af83db5SShawn McCarney }; 1584af83db5SShawn McCarney 1594af83db5SShawn McCarney } // namespace phosphor::power::sequencer 160