psu-ng: Add code to set ON_OFF_CONFIG
Add code that sends the appropriate ON_OFF_CONFIG mask for the power
supply power on operation.
Tested:
Ran gtest using x86sdk
Used simulator to change ON_OFF_CONFIG value, restarted service,
verified ON_OFF_CONFIG changed.
Used i2cget on hardware to change ON_OFF_CONFIG, restarted service,
verified ON_OFF_CONFIG changed.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Ifd9d63fcd2e86a62b7358e08958b5e2dbd21db9f
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 37e5666..8c80ef3 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -93,6 +93,30 @@
}
}
+void PowerSupply::onOffConfig(uint8_t data)
+{
+ using namespace phosphor::pmbus;
+
+ if (present)
+ {
+ log<level::INFO>("ON_OFF_CONFIG write", entry("DATA=0x%02X", data));
+ try
+ {
+ std::vector<uint8_t> configData{data};
+ pmbusIntf->writeBinary(ON_OFF_CONFIG, configData,
+ Type::HwmonDeviceDebug);
+ }
+ catch (...)
+ {
+ // The underlying code in writeBinary will log a message to the
+ // journal if the write fails. If the ON_OFF_CONFIG is not setup as
+ // desired, later fault detection and analysis code should catch any
+ // of the fall out. We should not need to terminate the application
+ // if this write fails.
+ }
+ }
+}
+
void PowerSupply::clearFaults()
{
faultFound = false;
@@ -133,6 +157,7 @@
if (std::get<bool>(valPropMap->second))
{
present = true;
+ onOffConfig(phosphor::pmbus::ON_OFF_CONFIG_CONTROL_PIN_ONLY);
clearFaults();
}
else