1 #pragma once 2 3 #include <sdbusplus/async.hpp> 4 5 #include <cstdint> 6 #include <memory> 7 #include <string> 8 9 namespace phosphor::software::VR 10 { 11 12 enum class VRType 13 { 14 XDPE1X2XX, 15 ISL69269, 16 MP2X6XX, 17 MP297X, 18 MP5998, 19 RAA22XGen2, 20 RAA22XGen3p5, 21 }; 22 23 class VoltageRegulator 24 { 25 public: 26 explicit VoltageRegulator(sdbusplus::async::context& ctx) : ctx(ctx) {} 27 virtual ~VoltageRegulator() = default; 28 29 VoltageRegulator(VoltageRegulator& vr) = delete; 30 VoltageRegulator& operator=(VoltageRegulator other) = delete; 31 VoltageRegulator(VoltageRegulator&& other) = delete; 32 VoltageRegulator& operator=(VoltageRegulator&& other) = delete; 33 34 // @brief Parses the firmware image into the configuration structure 35 // and verifies its correctness. 36 // @return sdbusplus::async::task<bool> true indicates success. 37 virtual sdbusplus::async::task<bool> verifyImage(const uint8_t* image, 38 size_t imageSize) = 0; 39 40 // @brief Applies update to the voltage regulator 41 // @return sdbusplus::async::task<bool> true indicates success. 42 virtual sdbusplus::async::task<bool> updateFirmware(bool force) = 0; 43 44 // @brief Requests the CRC value of the voltage regulator over I2C. 45 // @param pointer to write the result to. 46 // @returns < 0 on error 47 virtual sdbusplus::async::task<bool> getCRC(uint32_t* checksum) = 0; 48 49 // @brief This function returns true if the voltage regulator supports 50 // force of updates. 51 virtual bool forcedUpdateAllowed() = 0; 52 53 protected: 54 sdbusplus::async::context& ctx; 55 }; 56 57 std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx, 58 enum VRType vrType, uint16_t bus, 59 uint16_t address); 60 61 bool stringToEnum(std::string& vrStr, VRType& vrType); 62 63 } // namespace phosphor::software::VR 64