Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 1 | #include "vr.hpp" |
| 2 | |
Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 3 | #include "isl69269/isl69269.hpp" |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 4 | #include "xdpe1x2xx/xdpe1x2xx.hpp" |
| 5 | |
| 6 | #include <map> |
| 7 | |
| 8 | namespace phosphor::software::VR |
| 9 | { |
| 10 | |
| 11 | std::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 Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 21 | case VRType::ISL69269: |
| 22 | ret = std::make_unique<ISL69269>(ctx, bus, address); |
| 23 | break; |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 24 | default: |
| 25 | return NULL; |
| 26 | } |
| 27 | return ret; |
| 28 | } |
| 29 | |
| 30 | bool stringToEnum(std::string& vrStr, VRType& vrType) |
| 31 | { |
| 32 | std::map<std::string, enum VRType> VRTypeToString{ |
| 33 | {"XDPE1X2XXFirmware", VRType::XDPE1X2XX}, |
Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 34 | {"ISL69269Firmware", VRType::ISL69269}, |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 35 | }; |
| 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 |