blob: 814443c6003bbaffaf248d20faef170bd38f003c [file] [log] [blame]
Kevin Tung994a77f2024-12-23 17:48:56 +08001#pragma once
2
3#include "common/include/host_power.hpp"
4
5#include <cstdint>
6#include <memory>
7#include <optional>
8#include <string>
9
10namespace HostPowerInf = phosphor::software::host_power;
11
12class DeviceVersion
13{
14 public:
15 DeviceVersion(const std::string& chipModel, const uint16_t bus,
16 const uint8_t address) :
17 chipModel(chipModel), bus(bus), address(address)
18 {}
19
Daniel Hsu975fbbe2025-09-01 16:12:43 +080020 virtual bool isDeviceReady()
21 {
22 return true;
23 }
Kevin Tung994a77f2024-12-23 17:48:56 +080024 virtual std::string getVersion() = 0;
25 virtual std::optional<HostPowerInf::HostState>
26 getHostStateToQueryVersion() = 0;
27
28 virtual ~DeviceVersion() = default;
29 DeviceVersion(const DeviceVersion&) = delete;
30 DeviceVersion& operator=(const DeviceVersion&) = delete;
31 DeviceVersion(DeviceVersion&&) = delete;
32 DeviceVersion& operator=(DeviceVersion&&) = delete;
33
34 protected:
35 std::string chipModel;
36 uint16_t bus;
37 uint8_t address;
38};
39
40std::unique_ptr<DeviceVersion> getVersionProvider(
41 const std::string& chipModel, uint16_t bus, uint8_t address);