intrusionsensor: Add hwmon reading method
This commit adds a new reading method for intrusionsensor, which reads
the chassis intrusion status from hwmon.
Example:
{
"Class": "Aspeed2600_Hwmon",
"Name": "Chassis_Intrusion_Status",
"Type": "ChassisIntrusionSensor"
}
intrusionsensor will search for the sysfs hwmon name string in the
compatibleHwmonNames map using the Class string (e.g intrusion0_alarm
for Aspeed2600_Hwmon class) and read the chassis intrusion status from
it. This currently just supports Aspeed2600_Hwmon class which is based
on the aspeed-chassis driver from Aspeed SDK. The driver reads the
Intrusion Status bit in the CHAI10 register from AST2600. This bit
needs to be cleared every read in order to get the current state (which
means to write 0 to the hwmon file). In the condition of being cleared
every read, it will show 0 in hwmon for the normal state, and 1 for the
intrusion state.
Tested:
$ busctl get-property xyz.openbmc_project.IntrusionSensor \
/xyz/openbmc_project/Chassis/Intrusion \
xyz.openbmc_project.Chassis.Intrusion Status
If the chassis cover is closed: "Normal"
If the chassis cover is open: "HardwareIntrusion"
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I6f6a42592c8acae7be4f10e65a8b52ee30a4bd4f
diff --git a/src/ChassisIntrusionSensor.hpp b/src/ChassisIntrusionSensor.hpp
index e690bd2..b8ac953 100644
--- a/src/ChassisIntrusionSensor.hpp
+++ b/src/ChassisIntrusionSensor.hpp
@@ -74,3 +74,22 @@
int readSensor() override;
void pollSensorStatus() override;
};
+
+class ChassisIntrusionHwmonSensor :
+ public ChassisIntrusionSensor,
+ public std::enable_shared_from_this<ChassisIntrusionHwmonSensor>
+{
+ public:
+ ChassisIntrusionHwmonSensor(boost::asio::io_context& io,
+ sdbusplus::asio::object_server& objServer,
+ std::string hwmonName);
+
+ ~ChassisIntrusionHwmonSensor() override;
+
+ private:
+ std::string mHwmonName;
+ std::string mHwmonPath;
+ boost::asio::steady_timer mPollTimer;
+ int readSensor() override;
+ void pollSensorStatus() override;
+};