#pragma once #include "common/include/pmbus.hpp" #include "mps.hpp" namespace phosphor::software::VR { enum class MPX9XXCmd : uint8_t; /** * @class MPX9XX * @brief Base class for MPX9XX voltage regulators * * Provides common firmware update steps such as unlocking write protection, * programming registers, storing/restoring NVM data, and CRC checks. * Derived classes only need to provide the Config ID command. */ class MPX9XX : public MPSVoltageRegulator { public: MPX9XX(sdbusplus::async::context& ctx, uint16_t bus, uint16_t address) : MPSVoltageRegulator(ctx, bus, address) {} sdbusplus::async::task verifyImage(const uint8_t* image, size_t imageSize) final; sdbusplus::async::task updateFirmware(bool force) final; sdbusplus::async::task getCRC(uint32_t* checksum) final; sdbusplus::async::task parseDeviceConfiguration() final; bool forcedUpdateAllowed() final; private: sdbusplus::async::task checkId(MPX9XXCmd idCmd, uint32_t expected); sdbusplus::async::task unlockWriteProtect(); sdbusplus::async::task disableStoreFaultTriggering(); sdbusplus::async::task setMultiConfigAddress(uint8_t config); sdbusplus::async::task programConfigData( const std::vector& gdata); sdbusplus::async::task programAllRegisters(); sdbusplus::async::task storeDataIntoMTP(); sdbusplus::async::task restoreDataFromNVM(); sdbusplus::async::task checkMTPCRC(); protected: virtual MPX9XXCmd getConfigIdCmd() const = 0; }; class MP292X : public MPX9XX { public: using MPX9XX::MPX9XX; protected: MPX9XXCmd getConfigIdCmd() const final; }; class MP994X : public MPX9XX { public: using MPX9XX::MPX9XX; protected: MPX9XXCmd getConfigIdCmd() const final; }; } // namespace phosphor::software::VR