| 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" |
| FreddieJheng | 782d6ee | 2025-08-19 18:53:15 +0800 | [diff] [blame] | 6 | #include "mps/mp5998.hpp" |
| Kevin Tung | f730973 | 2025-11-12 15:27:53 +0800 | [diff] [blame^] | 7 | #include "mps/mpx9xx.hpp" |
| Leo Yang | c1b3662 | 2025-10-28 10:39:55 +0800 | [diff] [blame] | 8 | #include "tda38640a/tda38640a.hpp" |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 9 | #include "xdpe1x2xx/xdpe1x2xx.hpp" |
| 10 | |
| 11 | #include <map> |
| 12 | |
| 13 | namespace phosphor::software::VR |
| 14 | { |
| 15 | |
| 16 | std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx, |
| 17 | enum VRType vrType, uint16_t bus, |
| 18 | uint16_t address) |
| 19 | { |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 20 | switch (vrType) |
| 21 | { |
| 22 | case VRType::XDPE1X2XX: |
| Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame] | 23 | return std::make_unique<XDPE1X2XX>(ctx, bus, address); |
| Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 24 | case VRType::ISL69269: |
| Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame] | 25 | return std::make_unique<ISL69269>(ctx, bus, address); |
| 26 | case VRType::MP2X6XX: |
| 27 | return std::make_unique<MP2X6XX>(ctx, bus, address); |
| Kevin Tung | f730973 | 2025-11-12 15:27:53 +0800 | [diff] [blame^] | 28 | case VRType::MP292X: |
| 29 | return std::make_unique<MP292X>(ctx, bus, address); |
| Kevin Tung | 3f2f3e6 | 2025-08-15 15:41:07 +0800 | [diff] [blame] | 30 | case VRType::MP297X: |
| 31 | return std::make_unique<MP297X>(ctx, bus, address); |
| FreddieJheng | 782d6ee | 2025-08-19 18:53:15 +0800 | [diff] [blame] | 32 | case VRType::MP5998: |
| 33 | return std::make_unique<MP5998>(ctx, bus, address); |
| Kevin Tung | 3638c24 | 2025-10-07 13:48:13 +0800 | [diff] [blame] | 34 | case VRType::MP994X: |
| 35 | return std::make_unique<MP994X>(ctx, bus, address); |
| cchoux | 86a2fd0 | 2025-08-20 16:22:12 +0800 | [diff] [blame] | 36 | case VRType::RAA22XGen2: |
| 37 | return std::make_unique<ISL69269>(ctx, bus, address, |
| 38 | ISL69269::Gen::Gen2); |
| Leo Yang | b593870 | 2025-09-30 15:51:54 +0800 | [diff] [blame] | 39 | case VRType::RAA22XGen3p5: |
| 40 | return std::make_unique<ISL69269>(ctx, bus, address, |
| 41 | ISL69269::Gen::Gen3p5); |
| Leo Yang | c1b3662 | 2025-10-28 10:39:55 +0800 | [diff] [blame] | 42 | case VRType::TDA38640A: |
| 43 | return std::make_unique<TDA38640A>(ctx, bus, address); |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 44 | default: |
| Kevin Tung | dcf4b60 | 2025-07-04 13:14:49 +0800 | [diff] [blame] | 45 | return nullptr; |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 46 | } |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | bool stringToEnum(std::string& vrStr, VRType& vrType) |
| 50 | { |
| 51 | std::map<std::string, enum VRType> VRTypeToString{ |
| 52 | {"XDPE1X2XXFirmware", VRType::XDPE1X2XX}, |
| Christopher Meis | f00ce80 | 2025-04-08 08:07:31 +0200 | [diff] [blame] | 53 | {"ISL69269Firmware", VRType::ISL69269}, |
| Kevin Tung | 3f2f3e6 | 2025-08-15 15:41:07 +0800 | [diff] [blame] | 54 | {"MP2X6XXFirmware", VRType::MP2X6XX}, |
| Kevin Tung | f730973 | 2025-11-12 15:27:53 +0800 | [diff] [blame^] | 55 | {"MP292XFirmware", VRType::MP292X}, |
| cchoux | 86a2fd0 | 2025-08-20 16:22:12 +0800 | [diff] [blame] | 56 | {"MP297XFirmware", VRType::MP297X}, |
| FreddieJheng | 782d6ee | 2025-08-19 18:53:15 +0800 | [diff] [blame] | 57 | {"MP5998Firmware", VRType::MP5998}, |
| Kevin Tung | 3638c24 | 2025-10-07 13:48:13 +0800 | [diff] [blame] | 58 | {"MP994XFirmware", VRType::MP994X}, |
| Leo Yang | b593870 | 2025-09-30 15:51:54 +0800 | [diff] [blame] | 59 | {"RAA22XGen2Firmware", VRType::RAA22XGen2}, |
| Leo Yang | c1b3662 | 2025-10-28 10:39:55 +0800 | [diff] [blame] | 60 | {"RAA22XGen3p5Firmware", VRType::RAA22XGen3p5}, |
| 61 | {"TDA38640AFirmware", VRType::TDA38640A}}; |
| FreddieJheng | 782d6ee | 2025-08-19 18:53:15 +0800 | [diff] [blame] | 62 | |
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 63 | if (VRTypeToString.contains(vrStr)) |
| 64 | { |
| 65 | vrType = VRTypeToString[vrStr]; |
| 66 | return true; |
| 67 | } |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | } // namespace phosphor::software::VR |