convert sysfs gpio usage to libgpiod

Updated Chassis Intrusion Sensor monitoring
to use pin name and gpiod APIs. Number based sysfs
framework is deprecated and replaced by descriptor
based gpiod framework. With named gpio pin,
code is more portable provided the device tree
defines GPIO pin name consistently.

This requires device tree change (227661) and
configuration file change (entity-manager/+/28350)

Tested:
Build and run changes together and verified chassis intrusion sensor
value gets updated correctly through D-Bus object.

Signed-off-by: ZhikuiRen <zhikui.ren@intel.com>
Change-Id: I03c50e32059936902432d5a8bc498dabb812ea5e
diff --git a/include/ChassisIntrusionSensor.hpp b/include/ChassisIntrusionSensor.hpp
index 651e768..f65ef33 100644
--- a/include/ChassisIntrusionSensor.hpp
+++ b/include/ChassisIntrusionSensor.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <gpiod.hpp>
 #include <memory>
 #include <sdbusplus/asio/object_server.hpp>
 #include <string>
@@ -20,7 +21,7 @@
     ~ChassisIntrusionSensor();
 
     void start(IntrusionSensorType type, int busId, int slaveAddr,
-               int gpioIndex, bool gpioInverted);
+               bool gpioInverted);
 
   private:
     std::shared_ptr<sdbusplus::asio::dbus_interface> mIface;
@@ -38,10 +39,10 @@
     boost::asio::deadline_timer mPollTimer;
 
     // valid if it is via GPIO
-    int mGpioIndex;
     bool mGpioInverted;
-    boost::asio::ip::tcp::socket mInputDev;
-    int mFd;
+    std::string mPinName = "CHASSIS_INTRUSION";
+    gpiod::line mGpioLine;
+    boost::asio::posix::stream_descriptor mGpioFd;
 
     // common members
     bool mOverridenState = false;
@@ -54,6 +55,6 @@
     void pollSensorStatusByPch();
     void readGpio();
     void pollSensorStatusByGpio();
-    void initGpioDeviceFile(const int index);
+    void initGpioDeviceFile();
     int setSensorValue(const std::string& req, std::string& propertyValue);
 };