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 "tda38640a/tda38640a.hpp"
8 #include "xdpe1x2xx/xdpe1x2xx.hpp"
9
10 #include <map>
11
12 namespace phosphor::software::VR
13 {
14
create(sdbusplus::async::context & ctx,enum VRType vrType,uint16_t bus,uint16_t address)15 std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx,
16 enum VRType vrType, uint16_t bus,
17 uint16_t address)
18 {
19 switch (vrType)
20 {
21 case VRType::XDPE1X2XX:
22 return std::make_unique<XDPE1X2XX>(ctx, bus, address);
23 case VRType::ISL69269:
24 return std::make_unique<ISL69269>(ctx, bus, address);
25 case VRType::MP2X6XX:
26 return std::make_unique<MP2X6XX>(ctx, bus, address);
27 case VRType::MP297X:
28 return std::make_unique<MP297X>(ctx, bus, address);
29 case VRType::MP5998:
30 return std::make_unique<MP5998>(ctx, bus, address);
31 case VRType::RAA22XGen2:
32 return std::make_unique<ISL69269>(ctx, bus, address,
33 ISL69269::Gen::Gen2);
34 case VRType::RAA22XGen3p5:
35 return std::make_unique<ISL69269>(ctx, bus, address,
36 ISL69269::Gen::Gen3p5);
37 case VRType::TDA38640A:
38 return std::make_unique<TDA38640A>(ctx, bus, address);
39 default:
40 return nullptr;
41 }
42 }
43
stringToEnum(std::string & vrStr,VRType & vrType)44 bool stringToEnum(std::string& vrStr, VRType& vrType)
45 {
46 std::map<std::string, enum VRType> VRTypeToString{
47 {"XDPE1X2XXFirmware", VRType::XDPE1X2XX},
48 {"ISL69269Firmware", VRType::ISL69269},
49 {"MP2X6XXFirmware", VRType::MP2X6XX},
50 {"MP297XFirmware", VRType::MP297X},
51 {"MP5998Firmware", VRType::MP5998},
52 {"RAA22XGen2Firmware", VRType::RAA22XGen2},
53 {"RAA22XGen3p5Firmware", VRType::RAA22XGen3p5},
54 {"TDA38640AFirmware", VRType::TDA38640A}};
55
56 if (VRTypeToString.contains(vrStr))
57 {
58 vrType = VRTypeToString[vrStr];
59 return true;
60 }
61 return false;
62 }
63
64 } // namespace phosphor::software::VR
65