IpmbSensor:Fix SMBus configuration for VR Temp.
The SMBus index configuration for VR Temp sensor is different
for some platforms.
Hence, SMBus index in which these sensors are connected
is made as D-Bus property, read from xx_baseboard.json file.
Also, sensor read request commands modified to use this value.
Tested :
1.Dediprog and redfish flash the different platforms,
with[SMBus index read from json file] and
without[default SMBus index =3] this configuration change.
- System up and running.
- VR Temp sensor and other sensor readings shows
correctly in 'ipmitool sensor list' output.
Signed-off-by: Anoop S <anoopx.s@intel.com>
Change-Id: Ia106f1c699f5f1515c90585309a65ede37906f18
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index dccdffb..29fd7f4 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -49,6 +49,7 @@
static constexpr uint8_t meAddress = 1;
static constexpr uint8_t lun = 0;
+static constexpr uint8_t hostSMbusIndexDefault = 0x03;
static constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
@@ -65,12 +66,14 @@
const std::string& sensorConfiguration,
sdbusplus::asio::object_server& objectServer,
std::vector<thresholds::Threshold>&& thresholdData,
- uint8_t deviceAddress, std::string& sensorTypeName) :
+ uint8_t deviceAddress, uint8_t hostSMbusIndex,
+ std::string& sensorTypeName) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", ipmbMaxReading,
ipmbMinReading, conn, PowerState::on),
- deviceAddress(deviceAddress), objectServer(objectServer), waitTimer(io)
+ deviceAddress(deviceAddress), hostSMbusIndex(hostSMbusIndex),
+ objectServer(objectServer), waitTimer(io)
{
std::string dbusPath = sensorPathPrefix + sensorTypeName + "/" + name;
@@ -149,11 +152,13 @@
command = ipmi::me_bridge::sendRawPmbus;
initCommand = ipmi::me_bridge::sendRawPmbus;
// pmbus read temp
- commandData = {0x57, 0x01, 0x00, 0x16, 0x3, deviceAddress, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x8d};
+ commandData = {0x57, 0x01, 0x00, 0x16, hostSMbusIndex,
+ deviceAddress, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x8d};
// goto page 0
- initData = {0x57, 0x01, 0x00, 0x14, 0x03, deviceAddress, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00};
+ initData = {0x57, 0x01, 0x00, 0x14, hostSMbusIndex,
+ deviceAddress, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00};
readingFormat = ReadingFormat::elevenBit;
}
else if (type == IpmbType::IR38363VR)
@@ -162,8 +167,9 @@
netfn = ipmi::me_bridge::netFn;
command = ipmi::me_bridge::sendRawPmbus;
// pmbus read temp
- commandData = {0x57, 0x01, 0x00, 0x16, 0x03, deviceAddress, 00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x8D};
+ commandData = {0x57, 0x01, 0x00, 0x16, hostSMbusIndex,
+ deviceAddress, 00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x8D};
readingFormat = ReadingFormat::elevenBitShift;
}
else if (type == IpmbType::ADM1278HSC)
@@ -202,11 +208,13 @@
command = ipmi::me_bridge::sendRawPmbus;
initCommand = ipmi::me_bridge::sendRawPmbus;
// pmbus read temp
- commandData = {0x57, 0x01, 0x00, 0x16, 0x3, deviceAddress, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x8d};
+ commandData = {0x57, 0x01, 0x00, 0x16, hostSMbusIndex,
+ deviceAddress, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x8d};
// goto page 0
- initData = {0x57, 0x01, 0x00, 0x14, 0x03, deviceAddress, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00};
+ initData = {0x57, 0x01, 0x00, 0x14, hostSMbusIndex,
+ deviceAddress, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00};
readingFormat = ReadingFormat::byte3;
}
else
@@ -410,6 +418,13 @@
std::string sensorClass =
loadVariant<std::string>(entry.second, "Class");
+ uint8_t hostSMbusIndex = hostSMbusIndexDefault;
+ auto findSmType = entry.second.find("HostSMbusIndex");
+ if (findSmType != entry.second.end())
+ {
+ hostSMbusIndex = std::visit(
+ VariantToUnsignedIntVisitor(), findSmType->second);
+ }
/* Default sensor type is "temperature" */
std::string sensorTypeName = "temperature";
@@ -424,7 +439,7 @@
sensor = std::make_unique<IpmbSensor>(
dbusConnection, io, name, pathPair.first, objectServer,
std::move(sensorThresholds), deviceAddress,
- sensorTypeName);
+ hostSMbusIndex, sensorTypeName);
/* Initialize scale and offset value */
sensor->scaleVal = 1;