blob: a6bf18bf1cde283e4869cbbcddc0170125f4f887 [file] [log] [blame]
Daniel Hsuf6470b52025-02-26 15:03:47 +08001#pragma once
2
3#include "common/include/device.hpp"
4#include "common/include/software_manager.hpp"
5#include "cpld_interface.hpp"
6
7#include <phosphor-logging/lg2.hpp>
8#include <sdbusplus/async/context.hpp>
9
10PHOSPHOR_LOG2_USING;
11
12namespace ManagerInf = phosphor::software::manager;
13
14namespace phosphor::software::cpld
15{
16
17class CPLDDevice : public Device
18{
19 public:
20 CPLDDevice(sdbusplus::async::context& ctx, const std::string& chiptype,
21 const std::string& chipname, const uint16_t& bus,
22 const uint8_t& address, SoftwareConfig& config,
23 ManagerInf::SoftwareManager* parent) :
24 Device(ctx, config, parent,
25 {RequestedApplyTimes::Immediate, RequestedApplyTimes::OnReset}),
26 cpldInterface(CPLDFactory::instance().create(chiptype, ctx, chipname,
27 bus, address))
28 {}
29
30 using Device::softwareCurrent;
31 sdbusplus::async::task<bool> updateDevice(const uint8_t* image,
32 size_t image_size) final;
33 sdbusplus::async::task<bool> getVersion(std::string& version);
34
35 private:
36 std::unique_ptr<CPLDInterface> cpldInterface;
37};
38
39} // namespace phosphor::software::cpld