Support temp sensor on MCU which is available from I2C
Chassis MCU exposes register to report temperature for the peripheral board.
The MCU access is configurable as below:
{
"Bus": $bus,
"Address": "0xAA",
"Reg": "0xBB",
"Class": "MCUTemp",
"Name": "MCU Temp",
"Thresholds": [
xxx
]
"Type": "MCUTempSensor"
}
Tested:
The below interface was found under temperature sensor namespace:
└─/xyz/openbmc_project/sensors/temperature/MCU_Temp
Run ipmitool sensor and check below from list:
MCU Temp | 30.175 | degrees C | cr | na | 0.000 | 5.000 | 110.000 | 115.000 | na
Change-Id: I8d54455ccc39ea4f60a5b4aee5c68be092d39a72
Signed-off-by: Yuan Li <yuan.li@linux.intel.com>
diff --git a/include/MCUTempSensor.hpp b/include/MCUTempSensor.hpp
new file mode 100644
index 0000000..5dd3c03
--- /dev/null
+++ b/include/MCUTempSensor.hpp
@@ -0,0 +1,33 @@
+#pragma once
+#include "sensor.hpp"
+
+#include <boost/asio/deadline_timer.hpp>
+#include <boost/container/flat_map.hpp>
+#include <chrono>
+#include <limits>
+#include <vector>
+
+struct MCUTempSensor : public Sensor
+{
+ MCUTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
+ boost::asio::io_service& io, const std::string& name,
+ const std::string& sensorConfiguration,
+ sdbusplus::asio::object_server& objectServer,
+ std::vector<thresholds::Threshold>&& thresholds,
+ uint8_t busId, uint8_t mcuAddress, uint8_t tempReg);
+ ~MCUTempSensor();
+
+ void checkThresholds(void) override;
+ void read(void);
+ void init(void);
+
+ uint8_t busId;
+ uint8_t mcuAddress;
+ uint8_t tempReg;
+
+ private:
+ int getMCURegsInfoWord(uint8_t regs, int16_t* pu16data);
+ sdbusplus::asio::object_server& objectServer;
+ std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
+ boost::asio::deadline_timer waitTimer;
+};