eeprom: update pt5161l getVersion()
Add a step to read fw_load_status before fetching the firmware
version. This ensures the service only proceeds when the device
reports a normal status.
Test on Harma:
```
<7> Host state xyz.openbmc_project.State.Host.HostState.Running matches to retrieve the version
<3> Status from file: /sys/kernel/debug/pt5161l/21-0024/fw_load_status is invalid: abnormal
<7> Host state xyz.openbmc_project.State.Host.HostState.Running matches to retrieve the version
<7> Device version is ready
<7> Harma_MB_Retimer_0_2251: set version 2.8.19
<7> Device version is ready
<7> Harma_MB_Retimer_1_8040: set version 2.8.19
```
Change-Id: I7b665652d8bee20956da3e3d15ff1d222560a656
Signed-off-by: Daniel Hsu <Daniel-Hsu@quantatw.com>
diff --git a/eeprom-device/pt5161l/pt5161l.cpp b/eeprom-device/pt5161l/pt5161l.cpp
index 2406862..1cc51df 100644
--- a/eeprom-device/pt5161l/pt5161l.cpp
+++ b/eeprom-device/pt5161l/pt5161l.cpp
@@ -39,6 +39,32 @@
return version;
}
+bool PT5161LDeviceVersion::isDeviceReady()
+{
+ std::string status;
+ std::ostringstream busOss;
+ std::ostringstream addrOss;
+
+ busOss << std::setw(2) << std::setfill('0') << static_cast<int>(bus);
+ addrOss << std::setw(4) << std::setfill('0') << std::hex << std::nouppercase
+ << static_cast<int>(address);
+
+ std::string fw_load_status = "/sys/kernel/debug/pt5161l/" + busOss.str() +
+ "-" + addrOss.str() + "/fw_load_status";
+
+ std::ifstream file(fw_load_status);
+
+ if (file && std::getline(file, status) && status == "normal")
+ {
+ return true;
+ }
+
+ error("Status from file: {PATH} is invalid: {STATUS}", "PATH",
+ fw_load_status, "STATUS", status);
+
+ return false;
+}
+
std::optional<HostPowerInf::HostState>
PT5161LDeviceVersion::getHostStateToQueryVersion()
{