blob: f7c7c0ff486547ffe51c5f08050601499e12dd64 [file] [log] [blame]
Christopher Meis7e446a42024-10-22 09:36:41 +02001#include "vr.hpp"
2
3#include "xdpe1x2xx/xdpe1x2xx.hpp"
4
5#include <map>
6
7namespace phosphor::software::VR
8{
9
10std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx,
11 enum VRType vrType, uint16_t bus,
12 uint16_t address)
13{
14 std::unique_ptr<VoltageRegulator> ret;
15 switch (vrType)
16 {
17 case VRType::XDPE1X2XX:
18 ret = std::make_unique<XDPE1X2XX>(ctx, bus, address);
19 break;
20 default:
21 return NULL;
22 }
23 return ret;
24}
25
26bool stringToEnum(std::string& vrStr, VRType& vrType)
27{
28 std::map<std::string, enum VRType> VRTypeToString{
29 {"XDPE1X2XXFirmware", VRType::XDPE1X2XX},
30 };
31
32 if (VRTypeToString.contains(vrStr))
33 {
34 vrType = VRTypeToString[vrStr];
35 return true;
36 }
37 return false;
38}
39
40} // namespace phosphor::software::VR