blob: 7280f917ee9b3da7b6b37150d788c494cefee9e8 [file] [log] [blame]
Christopher Meis7e446a42024-10-22 09:36:41 +02001#include "vr.hpp"
2
Christopher Meisf00ce802025-04-08 08:07:31 +02003#include "isl69269/isl69269.hpp"
Christopher Meis7e446a42024-10-22 09:36:41 +02004#include "xdpe1x2xx/xdpe1x2xx.hpp"
5
6#include <map>
7
8namespace phosphor::software::VR
9{
10
11std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx,
12 enum VRType vrType, uint16_t bus,
13 uint16_t address)
14{
15 std::unique_ptr<VoltageRegulator> ret;
16 switch (vrType)
17 {
18 case VRType::XDPE1X2XX:
19 ret = std::make_unique<XDPE1X2XX>(ctx, bus, address);
20 break;
Christopher Meisf00ce802025-04-08 08:07:31 +020021 case VRType::ISL69269:
22 ret = std::make_unique<ISL69269>(ctx, bus, address);
23 break;
Christopher Meis7e446a42024-10-22 09:36:41 +020024 default:
25 return NULL;
26 }
27 return ret;
28}
29
30bool stringToEnum(std::string& vrStr, VRType& vrType)
31{
32 std::map<std::string, enum VRType> VRTypeToString{
33 {"XDPE1X2XXFirmware", VRType::XDPE1X2XX},
Christopher Meisf00ce802025-04-08 08:07:31 +020034 {"ISL69269Firmware", VRType::ISL69269},
Christopher Meis7e446a42024-10-22 09:36:41 +020035 };
36
37 if (VRTypeToString.contains(vrStr))
38 {
39 vrType = VRTypeToString[vrStr];
40 return true;
41 }
42 return false;
43}
44
45} // namespace phosphor::software::VR