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