meta-ufispace: Add meta-ufispace layer and meta-ncplite machine
Iniitial submission of meta-layer and meta-machine layer.
Tested: Build and run on our machine successfully.
Change-Id: I4920d8ce6aff119ba5cbc4772d84a6377784f85d
Signed-off-by: Jordan Chang <jordan.chang@ufispace.com>
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led.bb b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led.bb
new file mode 100644
index 0000000..82f421e
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led.bb
@@ -0,0 +1,27 @@
+SUMMARY = "OpenBMC NCPLite Front Panel LED Monitor"
+DESCRIPTION = "OpenBMC NCPLite Front Panel Monitor"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+inherit systemd
+
+DEPENDS += "systemd"
+RDEPENDS:${PN} += "bash"
+
+SRC_URI += " file://ncplite-led.sh \
+ file://ncplite-led.service \
+ "
+
+do_install() {
+ install -d ${D}${libexecdir}/{BPN}
+ install -m 0755 ${WORKDIR}/ncplite-led.sh ${D}${libexecdir}/{BPN}
+
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/ncplite-led.service ${D}${systemd_system_unitdir}
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "ncplite-led.service"
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.service b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.service
new file mode 100644
index 0000000..6e42fa2
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=NCPLite Front Panel LED Monitor
+After=xyz.openbmc_project.Inventory.Manager.service
+
+[Service]
+Restart=on-failure
+RestartSec=1s
+ExecStart=@LIBEXECDIR@/ncplite-led/ncplite-led.sh
+SyslogIdentifier=ncplite-led
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.sh b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.sh
new file mode 100644
index 0000000..35484d3
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/leds/ncplite-led/ncplite-led.sh
@@ -0,0 +1,93 @@
+#!/bin/bash -e
+
+HOST_SERVICE="xyz.openbmc_project.State.HostCondition.Gpio"
+HOST_OBJPATH="/xyz/openbmc_project/Gpios/host0"
+HOST_INTERFACE="xyz.openbmc_project.Condition.HostFirmware"
+HOST_PROPERTY="CurrentFirmwareCondition"
+
+FAN_SERVICE="xyz.openbmc_project.State.FanCtrl"
+FAN_OBJPATH="/xyz/openbmc_project/settings/fanctrl/zone1"
+FAN_INTERFACE="xyz.openbmc_project.Control.Mode"
+FAN_PROPERTY="FailSafe"
+
+PSU_SERVICE="xyz.openbmc_project.Inventory.Manager"
+PSU0_PRESENT_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_PRSNT_L"
+PSU1_PRESENT_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_PRSNT_L"
+PSU0_POWER_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_POWER_OK"
+PSU1_POWER_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_POWER_OK"
+PSU_INTERFACE="xyz.openbmc_project.Inventory.Item"
+PSU_PROPERTY="Present"
+
+CPLD_LED_offset1=0x80
+CPLD_LED_offset2=0x81
+CPLD_SYS_FAN_reg=0
+CPLD_PSU0_PSU1_reg=0
+
+while true; do
+ #System status LED
+ system_status=$(busctl get-property ${HOST_SERVICE} ${HOST_OBJPATH} ${HOST_INTERFACE} ${HOST_PROPERTY} | awk '{print $2}' | tr -d "\"" | awk -F . '{print $NF}')
+
+ if [ "${system_status}" == "Running" ]; then
+ #Solid Green
+ CPLD_SYS_reg=0x90
+ else
+ #Solid Yellow
+ CPLD_SYS_reg=0x80
+ fi
+
+ #Fan status LED
+ fan_status=$(busctl get-property ${FAN_SERVICE} ${FAN_OBJPATH} ${FAN_INTERFACE} ${FAN_PROPERTY} | awk '{print $2}')
+
+ if [ "${fan_status}" == "true" ]; then
+ #Blink Yellow
+ CPLD_FAN_reg=0xc
+ else
+ #Solid Green
+ CPLD_FAN_reg=0x9
+ fi
+
+ CPLD_SYS_FAN_reg=$((CPLD_SYS_reg | CPLD_FAN_reg))
+
+ #PSU0 status LED
+ psu0_prsnt_status=$(busctl get-property ${PSU_SERVICE} ${PSU0_PRESENT_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}')
+
+ psu0_power_status=$(busctl get-property ${PSU_SERVICE} ${PSU0_POWER_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}')
+
+ if [ "${psu0_prsnt_status}" == "true" ]; then
+ if [ "${psu0_power_status}" == "true" ]; then
+ #Solid Green
+ CPLD_PSU0_reg=0x9
+ else
+ #Blink Yellow
+ CPLD_PSU0_reg=0xc
+ fi
+ else
+ CPLD_PSU0_reg=0x0
+ fi
+
+ #PSU1 status LED
+ psu1_prsnt_status=$(busctl get-property ${PSU_SERVICE} ${PSU1_PRESENT_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}')
+
+ psu1_power_status=$(busctl get-property ${PSU_SERVICE} ${PSU1_POWER_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}')
+
+ if [ "${psu1_prsnt_status}" == "true" ]; then
+ if [ "${psu1_power_status}" == "true" ]; then
+ #Solid Green
+ CPLD_PSU1_reg=0x90
+ else
+ #Blink Yellow
+ CPLD_PSU1_reg=0xc0
+ fi
+ else
+ CPLD_PSU1_reg=0x0
+ fi
+
+ CPLD_PSU0_PSU1_reg=$((CPLD_PSU0_reg | CPLD_PSU1_reg))
+
+ i2cset -f -y 2 0x40 "${CPLD_LED_offset1}" "${CPLD_SYS_FAN_reg}" > /dev/null 2>&1
+ i2cset -f -y 2 0x40 "${CPLD_LED_offset2}" "${CPLD_PSU0_PSU1_reg}" > /dev/null 2>&1
+
+ sleep 2
+done
+
+exit 0
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service
new file mode 100644
index 0000000..f02821f
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Check GPIO State Manager
+After=phosphor-gpio-presence@.service
+Wants=phosphor-gpio-presence@.service
+
+[Service]
+ExecStart=@LIBEXECDIR@/ncplite-inventory-log/inventory-log.sh
+SyslogIdentifier=inventory-log
+Type=simple
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh
new file mode 100644
index 0000000..ee30b0e
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
+INVENTORY_OBJPATH=( \
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/ALL_PWR_GOOD_H"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/FAN_STATUS_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/THERMAL_ALERT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/CPU_CATERR_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/CPU_THERMTEIP_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_POWER_OK"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_POWER_OK"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_PRSNT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_PRSNT_L"
+)
+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, q : UINT16
+
+LOG_ERR="Configuration Error(Incorrect_interconnection)"
+LOG_EVENT_DATA="3 0x01 0xff 0xff"
+LOG_ASSERT_FLAG="true"
+LOG_DEASSERT_FLAG="false"
+LOG_GENID_FLAG="0x0020"
+
+initial_state=("false" "false" "false" "false" "false" "false" "false" "false" "false" "false" "false" "false")
+
+for i in "${!INVENTORY_OBJPATH[@]}"
+do
+ mapper wait "${INVENTORY_OBJPATH[$i]}"
+done
+
+while true; do
+ for i in "${!INVENTORY_OBJPATH[@]}"
+ do
+ current_status="$(busctl get-property $SERVICE_NAME "${INVENTORY_OBJPATH[$i]}" $INTERFACE_NAME Present | awk '{print $2}')"
+
+ if [ "$current_status" == "true" ] && [ "${initial_state[$i]}" == "false" ];then
+ initial_state[$i]="true"
+ busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${INVENTORY_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_ASSERT_FLAG $LOG_GENID_FLAG
+ elif [ "$current_status" == "false" ] && [ "${initial_state[$i]}" == "true" ]; then
+ initial_state[$i]="false"
+ busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${INVENTORY_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
+ fi
+ done
+ usleep 100000
+done
+
+exit 0
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb
new file mode 100644
index 0000000..43d2c05
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb
@@ -0,0 +1,25 @@
+SUMMARY = "OpenBMC NCPLite Check Inventory State Service"
+DESCRIPTION = "OpenBMC NCPLite Check Inventory State 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://inventory-log.sh \
+ file://inventory-log.service \
+ "
+
+do_install() {
+ install -d ${D}${libexecdir}/${BPN}
+ install -m 0755 ${WORKDIR}/inventory-log.sh ${D}${libexecdir}/${BPN}
+
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/inventory-log.service ${D}${systemd_system_unitdir}
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "inventory-log.service"