| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 1 | #pragma once | 
 | 2 |  | 
 | 3 | #include "common/include/i2c/i2c.hpp" | 
 | 4 | #include "i2c-vr/vr.hpp" | 
 | 5 |  | 
 | 6 | #include <sdbusplus/async.hpp> | 
 | 7 |  | 
 | 8 | #include <cstdint> | 
 | 9 |  | 
 | 10 | namespace phosphor::software::VR | 
 | 11 | { | 
 | 12 |  | 
 | 13 | class XDPE1X2XX : public VoltageRegulator | 
 | 14 | { | 
 | 15 |   public: | 
 | 16 |     XDPE1X2XX(sdbusplus::async::context& ctx, uint16_t bus, uint16_t address); | 
 | 17 |  | 
 | 18 |     sdbusplus::async::task<bool> verifyImage(const uint8_t* image, | 
 | 19 |                                              size_t imageSize) final; | 
 | 20 |  | 
 | 21 |     sdbusplus::async::task<bool> updateFirmware(bool force) final; | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 22 |  | 
 | 23 |     sdbusplus::async::task<bool> getCRC(uint32_t* checksum) final; | 
 | 24 |     bool forcedUpdateAllowed() final; | 
 | 25 |  | 
 | 26 |   private: | 
 | 27 |     static const int MaxSectCnt = 16; | 
 | 28 |     static const int MaxSectDataCnt = 200; | 
 | 29 |  | 
| Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 30 |     struct deviceInfo | 
 | 31 |     { | 
 | 32 |         uint8_t deviceId; | 
 | 33 |         uint8_t deviceRev; | 
 | 34 |         uint8_t remainingWrites; | 
 | 35 |         uint32_t scratchPadAddress; | 
 | 36 |         uint32_t actualCRC; | 
 | 37 |         uint32_t configSize; | 
 | 38 |     }; | 
 | 39 |  | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 40 |     struct configSect | 
 | 41 |     { | 
 | 42 |         uint8_t type; | 
 | 43 |         uint16_t dataCnt; | 
 | 44 |         uint32_t data[MaxSectDataCnt]; | 
 | 45 |     }; | 
 | 46 |  | 
 | 47 |     struct xdpe1x2xxConfig | 
 | 48 |     { | 
 | 49 |         uint8_t addr; | 
 | 50 |         uint16_t totalCnt; | 
 | 51 |         uint32_t sumExp; | 
 | 52 |         uint8_t sectCnt; | 
 | 53 |         struct configSect section[MaxSectCnt]; | 
 | 54 |     }; | 
 | 55 |  | 
 | 56 |     sdbusplus::async::task<bool> getDeviceId(uint8_t* deviceId); | 
| Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 57 |     sdbusplus::async::task<bool> mfrFWcmd(uint8_t cmd, uint16_t processTime, | 
 | 58 |                                           uint8_t* data, uint8_t* resp); | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 59 |     sdbusplus::async::task<bool> getRemainingWrites(uint8_t* remain); | 
 | 60 |     sdbusplus::async::task<bool> program(bool force); | 
| Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 61 |     sdbusplus::async::task<bool> getScratchPadAddress(); | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 62 |  | 
| Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 63 |     bool parseImage(const uint8_t* image, size_t imageSize); | 
 | 64 |     bool checkImage(); | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 65 |  | 
 | 66 |     static uint32_t calcCRC32(const uint32_t* data, int len); | 
 | 67 |     static int getConfigSize(uint8_t deviceId, uint8_t revision); | 
 | 68 |     static int lineSplit(char** dst, char* src, char* delim); | 
 | 69 |  | 
 | 70 |     phosphor::i2c::I2C i2cInterface; | 
 | 71 |  | 
| Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 72 |     struct deviceInfo info; | 
| Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 73 |     struct xdpe1x2xxConfig configuration; | 
 | 74 | }; | 
 | 75 |  | 
 | 76 | } // namespace phosphor::software::VR |