xref: /openbmc/phosphor-bmc-code-mgmt/i2c-vr/i2cvr_device.hpp (revision ee55117464c86f0fe4483cd86f82da0501e896e1)
1 #pragma once
2 
3 #include "common/include/device.hpp"
4 #include "common/include/software_config.hpp"
5 #include "common/include/software_manager.hpp"
6 #include "vr.hpp"
7 
8 namespace SoftwareInf = phosphor::software;
9 namespace ManagerInf = SoftwareInf::manager;
10 namespace DeviceInf = SoftwareInf::device;
11 namespace ConfigInf = SoftwareInf::config;
12 
13 namespace VRInf = SoftwareInf::VR;
14 
15 namespace SDBusPlusSoftware = sdbusplus::common::xyz::openbmc_project::software;
16 
17 namespace phosphor::software::i2c_vr::device
18 {
19 
20 class I2CVRDevice : public DeviceInf::Device
21 {
22   public:
23     using DeviceInf::Device::softwareCurrent;
I2CVRDevice(sdbusplus::async::context & ctx,enum VRInf::VRType vrType,const uint16_t & bus,const uint8_t & address,ConfigInf::SoftwareConfig & config,ManagerInf::SoftwareManager * parent)24     I2CVRDevice(sdbusplus::async::context& ctx, enum VRInf::VRType vrType,
25                 const uint16_t& bus, const uint8_t& address,
26                 ConfigInf::SoftwareConfig& config,
27                 ManagerInf::SoftwareManager* parent) :
28         DeviceInf::Device(
29             ctx, config, parent,
30             {SDBusPlusSoftware::ApplyTime::RequestedApplyTimes::OnReset}),
31         vrInterface(VRInf::create(ctx, vrType, bus, address))
32     {}
33 
34     std::unique_ptr<VRInf::VoltageRegulator> vrInterface;
35 
36     sdbusplus::async::task<bool> updateDevice(const uint8_t* image,
37                                               size_t image_size) final;
38 
39     sdbusplus::async::task<bool> getVersion(uint32_t* sum) const;
40 };
41 
42 } // namespace phosphor::software::i2c_vr::device
43