meta-quanta: gbs: expose more GPIO signals as IPMI SDR

1. monitor more GPIO signals

gpio_net_name / gpio_number:
['SATA0_PRSNT_N']=5
['HSBP_CABLE_PRSNT_BUF_N']=57
['FAN_BRD_CABLE_PRSNT_BUF']=58
['HSBP_P12V_STBY_CABLE_PRSNT']=69
['PE_SLOT0_PRSNT_N']=120
['PE_SLOT1_PRSNT_N']=121

2. add these GPIO signals to the sensor YAML config

Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: Ic4cc39789217b37e3bd792725dd98ead3187823c
diff --git a/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service b/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service
deleted file mode 100644
index 6575f4f..0000000
--- a/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Detect SAS Cable Manager
-Wants=phosphor-gpio-presence@.service
-After=phosphor-gpio-presence@.service
-
-[Service]
-ExecStart=/usr/bin/detect-sas-cable.sh
-StandardOutput=syslog
-Type=simple
-
-[Install]
-WantedBy=multi-user.target
diff --git a/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh b/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh
deleted file mode 100644
index ed02c90..0000000
--- a/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-
-SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
-SAS_CABLE_OBJPATH=("/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab0_prsnt"
-"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab1_prsnt"
-"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab2_prsnt"
-"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab3_prsnt")
-INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
-
-IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
-IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
-IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
-IPMI_LOG_FUNCT="IpmiSelAdd"
-IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16
-LOG_ERR="Cable_error(Incorrect_interconnection)"
-LOG_EVENT_DATA="3 0x01 0xff 0xfe"
-LOG_ASSERT_FLAG="true"
-LOG_DEASSERT_FLAG="false"
-LOG_GENID_FLAG="0x0020"
-cable_state=("true" "true" "true" "true")
-
-mapper wait ${SAS_CABLE_OBJPATH[0]}
-mapper wait ${SAS_CABLE_OBJPATH[1]}
-mapper wait ${SAS_CABLE_OBJPATH[2]}
-mapper wait ${SAS_CABLE_OBJPATH[3]}
-
-while true; do
-    for i in {0..3};
-    do
-        boot_status="$(busctl get-property $SERVICE_NAME ${SAS_CABLE_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')"
-
-        if [ $boot_status == "false" ] && [ ${cable_state[$i]} == "true" ];then
-            echo "Update cable $(($i+1)) state."
-            cable_state[$i]="false"
-            busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG
-        elif [ $boot_status == "true" ] && [ ${cable_state[$i]} != "true" ];then
-            echo "Update cable $(($i+1)) state."
-            cable_state[$i]="true"
-            busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
-        fi
-    done
-    sleep 1
-done
-
-exit 0
diff --git a/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb b/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb
deleted file mode 100644
index 74785ef..0000000
--- a/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb
+++ /dev/null
@@ -1,25 +0,0 @@
-SUMMARY = "OpenBMC Quanta Detect SAS Cable Service"
-DESCRIPTION = "OpenBMC Quanta Detect SAS Cable Daemon."
-PR = "r1"
-LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
-
-inherit systemd
-
-DEPENDS += "systemd"
-RDEPENDS_${PN} += "bash"
-
-SRC_URI =  " file://detect-sas-cable.sh \
-             file://detect-sas-cable.service \
-            "
-
-do_install() {
-    install -d ${D}${bindir}
-    install -m 0755 ${WORKDIR}/detect-sas-cable.sh ${D}${bindir}/
-
-    install -d ${D}${systemd_system_unitdir}
-    install -m 0644 ${WORKDIR}/detect-sas-cable.service ${D}${systemd_system_unitdir}
-}
-
-SYSTEMD_PACKAGES = "${PN}"
-SYSTEMD_SERVICE_${PN} = "detect-sas-cable.service"
diff --git a/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.service b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.service
new file mode 100644
index 0000000..9731ee3
--- /dev/null
+++ b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Detect GPIO Present Manager
+After=phosphor-gpio-presence@.service
+Requires=phosphor-gpio-presence@.service
+
+[Service]
+ExecStart=/usr/bin/detect-gpio-present.sh
+StandardOutput=syslog
+Type=simple
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh
new file mode 100644
index 0000000..66f52f0
--- /dev/null
+++ b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
+PRESENT_OBJPATH=("/xyz/openbmc_project/inventory/system/chassis/gpios/ss_cab0_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/ss_cab1_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/ss_cab2_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/ss_cab3_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/hsbp_cab_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/fanbd_cab_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/bp12v_cab_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/sata0_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/pe_slot0_prsnt"
+"/xyz/openbmc_project/inventory/system/chassis/gpios/pe_slot1_prsnt")
+INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
+
+IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
+IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
+IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
+IPMI_LOG_FUNCT="IpmiSelAdd"
+IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16
+LOG_ERR="Configuration Error(Incorrect_interconnection)"
+LOG_EVENT_DATA="3 0x01 0xff 0xfe"
+LOG_ASSERT_FLAG="true"
+LOG_DEASSERT_FLAG="false"
+LOG_GENID_FLAG="0x0020"
+present_state=("true" "true" "true" "true" "true" "true" "true" "true" "true" "true")
+
+while true; do
+    for i in ${!PRESENT_OBJPATH[@]}
+    do
+        mapper wait ${PRESENT_OBJPATH[$i]}
+        boot_status="$(busctl get-property $SERVICE_NAME ${PRESENT_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')"
+
+        if [ $boot_status == "false" ] && [ ${present_state[$i]} == "true" ];then
+            echo "Update cable $(($i+1)) state."
+            present_state[$i]="false"
+            busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG
+        elif [ $boot_status == "true" ] && [ ${present_state[$i]} == "false" ];then
+            echo "Update cable $(($i+1)) state."
+            present_state[$i]="true"
+            busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
+        fi
+    done
+    sleep 1
+done
+
+exit 0
diff --git a/meta-gbs/recipes-gbs/gbs-detect-gpio-present/gbs-detect-gpio-present.bb b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/gbs-detect-gpio-present.bb
new file mode 100644
index 0000000..3e1a6d8
--- /dev/null
+++ b/meta-gbs/recipes-gbs/gbs-detect-gpio-present/gbs-detect-gpio-present.bb
@@ -0,0 +1,25 @@
+SUMMARY = "OpenBMC Quanta Detect Present Service"
+DESCRIPTION = "OpenBMC Quanta Detect Present Daemon."
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit systemd
+
+DEPENDS += "systemd"
+RDEPENDS_${PN} += "bash"
+
+SRC_URI = " file://detect-gpio-present.sh \
+            file://detect-gpio-present.service \
+          "
+
+do_install() {
+    install -d ${D}${bindir}
+    install -m 0755 ${WORKDIR}/detect-gpio-present.sh ${D}${bindir}/
+
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/detect-gpio-present.service ${D}${systemd_system_unitdir}
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "detect-gpio-present.service"