From d6d41d248453aa0925ecbee9d896712be4780553 Mon Sep 17 00:00:00 2001 From: George Hung Date: Thu, 4 Jun 2020 19:54:41 +0800 Subject: meta-quanta: gbs: detect SlimSAS cable presence Add gpio configuration for SlimSAS cable0~3 and detect cables connected or not (From meta-quanta rev: 09b8cd98a953ef96fabd7bc1c8d090bd02c53d88) Signed-off-by: George Hung Change-Id: Ifee5ebf1a1055943ade8defce6be63b690bea8d2 Signed-off-by: Andrew Geissler --- .../files/detect-sas-cable.service | 12 ++++++ .../detect-sas-cable/files/detect-sas-cable.sh | 45 ++++++++++++++++++++++ .../detect-sas-cable/gbs-detect-sas-cable.bb | 25 ++++++++++++ .../obmc/gpio/slimsas-cable-0.conf | 6 +++ .../obmc/gpio/slimsas-cable-1.conf | 6 +++ .../obmc/gpio/slimsas-cable-2.conf | 6 +++ .../obmc/gpio/slimsas-cable-3.conf | 6 +++ .../phosphor-gpio-presence@.service.replace | 14 +++++++ .../gpio/phosphor-gpio-monitor_%.bbappend | 26 +++++++++++++ 9 files changed, 146 insertions(+) create mode 100644 meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service create mode 100644 meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh create mode 100644 meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-0.conf create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-1.conf create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-2.conf create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-3.conf create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-gpio-presence@.service.replace create mode 100644 meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend (limited to 'meta-quanta') diff --git a/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service new file mode 100644 index 000000000..6575f4fb7 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.service @@ -0,0 +1,12 @@ +[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-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh new file mode 100644 index 000000000..ed02c9023 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/files/detect-sas-cable.sh @@ -0,0 +1,45 @@ +#!/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-quanta/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb new file mode 100644 index 000000000..74785ef63 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-gbs/detect-sas-cable/gbs-detect-sas-cable.bb @@ -0,0 +1,25 @@ +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-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-0.conf b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-0.conf new file mode 100644 index 000000000..e26c8f50e --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-0.conf @@ -0,0 +1,6 @@ +#The gpio 70 is a real gpio, which is used to +#store the sas cable 0 present signal +INVENTORY=/system/chassis/cable/ss_cab0_prsnt +DEVPATH=/dev/input/event0 +KEY=70 +NAME=ss_cab0_prsnt diff --git a/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-1.conf b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-1.conf new file mode 100644 index 000000000..e6a18ee6c --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-1.conf @@ -0,0 +1,6 @@ +#The gpio 71 is a real gpio, which is used to +#store the sas cable 1 present signal +INVENTORY=/system/chassis/cable/ss_cab1_prsnt +DEVPATH=/dev/input/event0 +KEY=71 +NAME=ss_cab1_prsnt diff --git a/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-2.conf b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-2.conf new file mode 100644 index 000000000..490f97f49 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-2.conf @@ -0,0 +1,6 @@ +#The gpio 72 is a real gpio, which is used to +#store the sas cable 2 present signal +INVENTORY=/system/chassis/cable/ss_cab2_prsnt +DEVPATH=/dev/input/event0 +KEY=72 +NAME=ss_cab2_prsnt diff --git a/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-3.conf b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-3.conf new file mode 100644 index 000000000..f3579ab97 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/slimsas-cable-3.conf @@ -0,0 +1,6 @@ +#The gpio 73 is a real gpio, which is used to +#store the sas cable 3 present signal +INVENTORY=/system/chassis/cable/ss_cab3_prsnt +DEVPATH=/dev/input/event0 +KEY=73 +NAME=ss_cab3_prsnt diff --git a/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-gpio-presence@.service.replace b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-gpio-presence@.service.replace new file mode 100644 index 000000000..3ab99702f --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-gpio-presence@.service.replace @@ -0,0 +1,14 @@ +[Unit] +Description=Phosphor GPIO %I Presence +Wants=mapper-wait@-xyz-openbmc_project-inventory.service +After=mapper-wait@-xyz-openbmc_project-inventory.service +ConditionPathExists=/etc/default/obmc/gpio/slimsas-cable-%i.conf +StartLimitBurst=10 + +[Service] +Restart=on-failure +EnvironmentFile=/etc/default/obmc/gpio/slimsas-cable-%i.conf +ExecStart=/usr/bin/phosphor-gpio-presence --path=${DEVPATH} --inventory=${INVENTORY} --key=${KEY} --name=${NAME} --drivers=${DRIVERS} --extra-ifaces=${EXTRA_IFACES} + +[Install] +RequiredBy=multi-user.target diff --git a/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend new file mode 100644 index 000000000..50974f7ee --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend @@ -0,0 +1,26 @@ +inherit obmc-phosphor-systemd + +FILESEXTRAPATHS_prepend_gbs := "${THISDIR}/${PN}:" + +SRC_URI_append_gbs = " file://phosphor-gpio-presence@.service.replace" + +TMPL_SLIMSASCABLE = "phosphor-gpio-presence@.service" +INSTFMT_SLIMSASCABLE = "phosphor-gpio-presence@{0}.service" +SLIMSASCABLE_TGT = "multi-user.target" +FMT_SLIMSASCABLE = "../${TMPL_SLIMSASCABLE}:${SLIMSASCABLE_TGT}.requires/${INSTFMT_SLIMSASCABLE}" +SYSTEMD_ENVIRONMENT_FILE_${PN}_append_gbs +="obmc/gpio/slimsas-cable-0.conf" +SYSTEMD_ENVIRONMENT_FILE_${PN}_append_gbs +="obmc/gpio/slimsas-cable-1.conf" +SYSTEMD_ENVIRONMENT_FILE_${PN}_append_gbs +="obmc/gpio/slimsas-cable-2.conf" +SYSTEMD_ENVIRONMENT_FILE_${PN}_append_gbs +="obmc/gpio/slimsas-cable-3.conf" +GBS_OBMC_SLIMSAS_CABLE_INSTANCES = "0 1 2 3" + +SYSTEMD_LINK_${PN}-presence_append_gbs = " ${@compose_list(d, 'FMT_SLIMSASCABLE', 'GBS_OBMC_SLIMSAS_CABLE_INSTANCES')}" + +GBS_SLIMSASCABLE_ENV_FMT = "obmc/gpio/slimsas-cable-{0}.conf" + +SYSTEMD_ENVIRONMENT_FILE_${PN}-presence_gbs = " ${@compose_list(d, 'GBS_SLIMSASCABLE_ENV_FMT', 'GBS_OBMC_SLIMSAS_CABLE_INSTANCES')}" + +do_install_append_gbs() { + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/phosphor-gpio-presence@.service.replace ${D}${systemd_system_unitdir}/phosphor-gpio-presence@.service +} -- cgit v1.2.3