1 #include "vr.hpp" 2 3 #include "isl69269/isl69269.hpp" 4 #include "mps/mp297x.hpp" 5 #include "mps/mp2x6xx.hpp" 6 #include "xdpe1x2xx/xdpe1x2xx.hpp" 7 8 #include <map> 9 10 namespace phosphor::software::VR 11 { 12 13 std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx, 14 enum VRType vrType, uint16_t bus, 15 uint16_t address) 16 { 17 switch (vrType) 18 { 19 case VRType::XDPE1X2XX: 20 return std::make_unique<XDPE1X2XX>(ctx, bus, address); 21 case VRType::ISL69269: 22 return std::make_unique<ISL69269>(ctx, bus, address); 23 case VRType::MP2X6XX: 24 return std::make_unique<MP2X6XX>(ctx, bus, address); 25 case VRType::MP297X: 26 return std::make_unique<MP297X>(ctx, bus, address); 27 case VRType::RAA22XGen2: 28 return std::make_unique<ISL69269>(ctx, bus, address, 29 ISL69269::Gen::Gen2); 30 default: 31 return nullptr; 32 } 33 } 34 35 bool stringToEnum(std::string& vrStr, VRType& vrType) 36 { 37 std::map<std::string, enum VRType> VRTypeToString{ 38 {"XDPE1X2XXFirmware", VRType::XDPE1X2XX}, 39 {"ISL69269Firmware", VRType::ISL69269}, 40 {"MP2X6XXFirmware", VRType::MP2X6XX}, 41 {"MP297XFirmware", VRType::MP297X}, 42 {"RAA22XGen2Firmware", VRType::RAA22XGen2}}; 43 if (VRTypeToString.contains(vrStr)) 44 { 45 vrType = VRTypeToString[vrStr]; 46 return true; 47 } 48 return false; 49 } 50 51 } // namespace phosphor::software::VR 52