xref: /openbmc/phosphor-bmc-code-mgmt/cpld/lattice/lattice_cpld_factory.hpp (revision b602aad5026847e2a4895598c6b5b7b08a377282)
1 #include "cpld/cpld_interface.hpp"
2 #include "cpld/lattice/lattice_base_cpld.hpp"
3 
4 namespace phosphor::software::cpld
5 {
6 
7 class LatticeCPLDFactory : public CPLDInterface
8 {
9   public:
LatticeCPLDFactory(sdbusplus::async::context & ctx,const std::string & chipName,latticeChip chipEnum,uint16_t bus,uint8_t address)10     LatticeCPLDFactory(sdbusplus::async::context& ctx,
11                        const std::string& chipName, latticeChip chipEnum,
12                        uint16_t bus, uint8_t address) :
13         CPLDInterface(ctx, chipName, bus, address), chipEnum(chipEnum)
14     {}
15 
16     sdbusplus::async::task<bool> updateFirmware(
17         bool force, const uint8_t* image, size_t imageSize,
18         std::function<bool(int)> progress) final;
19 
20     sdbusplus::async::task<bool> getVersion(std::string& version) final;
21 
22   private:
23     std::unique_ptr<LatticeBaseCPLD> getLatticeCPLD();
24     latticeChip chipEnum;
25 };
26 
27 } // namespace phosphor::software::cpld
28