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