blob: 1e25ab572fe25242953961097cff1e3ec0ffcc32 [file] [log] [blame]
Christopher Meis7e446a42024-10-22 09:36:41 +02001#include "vr.hpp"
2
Christopher Meisf00ce802025-04-08 08:07:31 +02003#include "isl69269/isl69269.hpp"
Kevin Tung3f2f3e62025-08-15 15:41:07 +08004#include "mps/mp297x.hpp"
Kevin Tungdcf4b602025-07-04 13:14:49 +08005#include "mps/mp2x6xx.hpp"
FreddieJheng782d6ee2025-08-19 18:53:15 +08006#include "mps/mp5998.hpp"
Kevin Tungf7309732025-11-12 15:27:53 +08007#include "mps/mpx9xx.hpp"
Leo Yangc1b36622025-10-28 10:39:55 +08008#include "tda38640a/tda38640a.hpp"
Christopher Meis7e446a42024-10-22 09:36:41 +02009#include "xdpe1x2xx/xdpe1x2xx.hpp"
10
11#include <map>
12
13namespace phosphor::software::VR
14{
15
16std::unique_ptr<VoltageRegulator> create(sdbusplus::async::context& ctx,
17 enum VRType vrType, uint16_t bus,
18 uint16_t address)
19{
Christopher Meis7e446a42024-10-22 09:36:41 +020020 switch (vrType)
21 {
22 case VRType::XDPE1X2XX:
Kevin Tungdcf4b602025-07-04 13:14:49 +080023 return std::make_unique<XDPE1X2XX>(ctx, bus, address);
Christopher Meisf00ce802025-04-08 08:07:31 +020024 case VRType::ISL69269:
Kevin Tungdcf4b602025-07-04 13:14:49 +080025 return std::make_unique<ISL69269>(ctx, bus, address);
26 case VRType::MP2X6XX:
27 return std::make_unique<MP2X6XX>(ctx, bus, address);
Kevin Tungf7309732025-11-12 15:27:53 +080028 case VRType::MP292X:
29 return std::make_unique<MP292X>(ctx, bus, address);
Kevin Tung3f2f3e62025-08-15 15:41:07 +080030 case VRType::MP297X:
31 return std::make_unique<MP297X>(ctx, bus, address);
FreddieJheng782d6ee2025-08-19 18:53:15 +080032 case VRType::MP5998:
33 return std::make_unique<MP5998>(ctx, bus, address);
Kevin Tung3638c242025-10-07 13:48:13 +080034 case VRType::MP994X:
35 return std::make_unique<MP994X>(ctx, bus, address);
cchoux86a2fd02025-08-20 16:22:12 +080036 case VRType::RAA22XGen2:
37 return std::make_unique<ISL69269>(ctx, bus, address,
38 ISL69269::Gen::Gen2);
Leo Yangb5938702025-09-30 15:51:54 +080039 case VRType::RAA22XGen3p5:
40 return std::make_unique<ISL69269>(ctx, bus, address,
41 ISL69269::Gen::Gen3p5);
Leo Yangc1b36622025-10-28 10:39:55 +080042 case VRType::TDA38640A:
43 return std::make_unique<TDA38640A>(ctx, bus, address);
Christopher Meis7e446a42024-10-22 09:36:41 +020044 default:
Kevin Tungdcf4b602025-07-04 13:14:49 +080045 return nullptr;
Christopher Meis7e446a42024-10-22 09:36:41 +020046 }
Christopher Meis7e446a42024-10-22 09:36:41 +020047}
48
49bool stringToEnum(std::string& vrStr, VRType& vrType)
50{
51 std::map<std::string, enum VRType> VRTypeToString{
52 {"XDPE1X2XXFirmware", VRType::XDPE1X2XX},
Christopher Meisf00ce802025-04-08 08:07:31 +020053 {"ISL69269Firmware", VRType::ISL69269},
Kevin Tung3f2f3e62025-08-15 15:41:07 +080054 {"MP2X6XXFirmware", VRType::MP2X6XX},
Kevin Tungf7309732025-11-12 15:27:53 +080055 {"MP292XFirmware", VRType::MP292X},
cchoux86a2fd02025-08-20 16:22:12 +080056 {"MP297XFirmware", VRType::MP297X},
FreddieJheng782d6ee2025-08-19 18:53:15 +080057 {"MP5998Firmware", VRType::MP5998},
Kevin Tung3638c242025-10-07 13:48:13 +080058 {"MP994XFirmware", VRType::MP994X},
Leo Yangb5938702025-09-30 15:51:54 +080059 {"RAA22XGen2Firmware", VRType::RAA22XGen2},
Leo Yangc1b36622025-10-28 10:39:55 +080060 {"RAA22XGen3p5Firmware", VRType::RAA22XGen3p5},
61 {"TDA38640AFirmware", VRType::TDA38640A}};
FreddieJheng782d6ee2025-08-19 18:53:15 +080062
Christopher Meis7e446a42024-10-22 09:36:41 +020063 if (VRTypeToString.contains(vrStr))
64 {
65 vrType = VRTypeToString[vrStr];
66 return true;
67 }
68 return false;
69}
70
71} // namespace phosphor::software::VR