1*f730973bSKevin Tung #pragma once 2*f730973bSKevin Tung 3*f730973bSKevin Tung #include "common/include/pmbus.hpp" 4*f730973bSKevin Tung #include "mps.hpp" 5*f730973bSKevin Tung 6*f730973bSKevin Tung namespace phosphor::software::VR 7*f730973bSKevin Tung { 8*f730973bSKevin Tung 9*f730973bSKevin Tung enum class MPX9XXCmd : uint8_t; 10*f730973bSKevin Tung 11*f730973bSKevin Tung /** 12*f730973bSKevin Tung * @class MPX9XX 13*f730973bSKevin Tung * @brief Base class for MPX9XX voltage regulators 14*f730973bSKevin Tung * 15*f730973bSKevin Tung * Provides common firmware update steps such as unlocking write protection, 16*f730973bSKevin Tung * programming registers, storing/restoring NVM data, and CRC checks. 17*f730973bSKevin Tung * Derived classes only need to provide the Config ID command. 18*f730973bSKevin Tung */ 19*f730973bSKevin Tung class MPX9XX : public MPSVoltageRegulator 20*f730973bSKevin Tung { 21*f730973bSKevin Tung public: MPX9XX(sdbusplus::async::context & ctx,uint16_t bus,uint16_t address)22*f730973bSKevin Tung MPX9XX(sdbusplus::async::context& ctx, uint16_t bus, uint16_t address) : 23*f730973bSKevin Tung MPSVoltageRegulator(ctx, bus, address) 24*f730973bSKevin Tung {} 25*f730973bSKevin Tung 26*f730973bSKevin Tung sdbusplus::async::task<bool> verifyImage(const uint8_t* image, 27*f730973bSKevin Tung size_t imageSize) final; 28*f730973bSKevin Tung sdbusplus::async::task<bool> updateFirmware(bool force) final; 29*f730973bSKevin Tung sdbusplus::async::task<bool> getCRC(uint32_t* checksum) final; 30*f730973bSKevin Tung sdbusplus::async::task<bool> parseDeviceConfiguration() final; 31*f730973bSKevin Tung bool forcedUpdateAllowed() final; 32*f730973bSKevin Tung 33*f730973bSKevin Tung private: 34*f730973bSKevin Tung sdbusplus::async::task<bool> checkId(MPX9XXCmd idCmd, uint32_t expected); 35*f730973bSKevin Tung sdbusplus::async::task<bool> unlockWriteProtect(); 36*f730973bSKevin Tung sdbusplus::async::task<bool> disableStoreFaultTriggering(); 37*f730973bSKevin Tung sdbusplus::async::task<bool> setMultiConfigAddress(uint8_t config); 38*f730973bSKevin Tung sdbusplus::async::task<bool> programConfigData( 39*f730973bSKevin Tung const std::vector<MPSData>& gdata); 40*f730973bSKevin Tung sdbusplus::async::task<bool> programAllRegisters(); 41*f730973bSKevin Tung sdbusplus::async::task<bool> storeDataIntoMTP(); 42*f730973bSKevin Tung sdbusplus::async::task<bool> restoreDataFromNVM(); 43*f730973bSKevin Tung sdbusplus::async::task<bool> checkMTPCRC(); 44*f730973bSKevin Tung 45*f730973bSKevin Tung protected: 46*f730973bSKevin Tung virtual MPX9XXCmd getConfigIdCmd() const = 0; 47*f730973bSKevin Tung }; 48*f730973bSKevin Tung 49*f730973bSKevin Tung class MP292X : public MPX9XX 50*f730973bSKevin Tung { 51*f730973bSKevin Tung public: 52*f730973bSKevin Tung using MPX9XX::MPX9XX; 53*f730973bSKevin Tung 54*f730973bSKevin Tung protected: 55*f730973bSKevin Tung MPX9XXCmd getConfigIdCmd() const final; 56*f730973bSKevin Tung }; 57*f730973bSKevin Tung 58*f730973bSKevin Tung class MP994X : public MPX9XX 59*f730973bSKevin Tung { 60*f730973bSKevin Tung public: 61*f730973bSKevin Tung using MPX9XX::MPX9XX; 62*f730973bSKevin Tung 63*f730973bSKevin Tung protected: 64*f730973bSKevin Tung MPX9XXCmd getConfigIdCmd() const final; 65*f730973bSKevin Tung }; 66*f730973bSKevin Tung 67*f730973bSKevin Tung } // namespace phosphor::software::VR 68