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" |
Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame^] | 4 | #include "mps/mp2x6xx.hpp" |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 5 | #include "xdpe1x2xx/xdpe1x2xx.hpp" |
| 6 | |
| 7 | #include <map> |
| 8 | |
| 9 | namespace phosphor::software::VR |
| 10 | { |
| 11 | |
| 12 | std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx, |
| 13 | enum VRType vrType, uint16_t bus, |
| 14 | uint16_t address) |
| 15 | { |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 16 | switch (vrType) |
| 17 | { |
| 18 | case VRType::XDPE1X2XX: |
Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame^] | 19 | return std::make_unique<XDPE1X2XX>(ctx, bus, address); |
Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 20 | case VRType::ISL69269: |
Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame^] | 21 | return std::make_unique<ISL69269>(ctx, bus, address); |
| 22 | case VRType::MP2X6XX: |
| 23 | return std::make_unique<MP2X6XX>(ctx, bus, address); |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 24 | default: |
Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame^] | 25 | return nullptr; |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 26 | } |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | bool stringToEnum(std::string& vrStr, VRType& vrType) |
| 30 | { |
| 31 | std::map<std::string, enum VRType> VRTypeToString{ |
| 32 | {"XDPE1X2XXFirmware", VRType::XDPE1X2XX}, |
Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 33 | {"ISL69269Firmware", VRType::ISL69269}, |
Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame^] | 34 | {"MP2X6XXFirmware", VRType::MP2X6XX}}; |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 35 | |
| 36 | if (VRTypeToString.contains(vrStr)) |
| 37 | { |
| 38 | vrType = VRTypeToString[vrStr]; |
| 39 | return true; |
| 40 | } |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | } // namespace phosphor::software::VR |