diff options
5 files changed, 100 insertions, 0 deletions
diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb index cfefa8d94..5c4b6a012 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb @@ -11,6 +11,7 @@ S = "${WORKDIR}" SRC_URI = " \ file://ampere-host-force-reset@.service \ + file://ampere-host-on-host-check@.service \ " SYSTEMD_PACKAGES = "${PN}" @@ -24,4 +25,11 @@ HOST_WARM_REBOOT_FORCE_INSTMPL = "ampere-host-force-reset@{0}.service" HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target" HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_INSTMPL}" SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${HOST_WARM_REBOOT_FORCE_TGT}" +HOST_ON_RESET_HOSTTMPL = "ampere-host-on-host-check@.service" +HOST_ON_RESET_HOSTINSTMPL = "ampere-host-on-host-check@{0}.service" +HOST_ON_RESET_HOSTTGTFMT = "obmc-host-startmin@{0}.target" +HOST_ON_RESET_HOSTFMT = "../${HOST_ON_RESET_HOSTTMPL}:${HOST_ON_RESET_HOSTTGTFMT}.requires/${HOST_ON_RESET_HOSTINSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_ON_RESET_HOSTFMT', 'OBMC_HOST_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${HOST_ON_RESET_HOSTTMPL}" diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service new file mode 100644 index 000000000..36e5a642c --- /dev/null +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Check Host%i status before obmc-host-startmin +Wants=obmc-host-started@%i.target +After=obmc-host-started@%i.target +Conflicts=obmc-host-stop@%i.target +Conflicts=phosphor-reset-host-check@%i.service +OnFailure=obmc-host-quiesce@%i.target +OnFailureJobMode=flush +ConditionPathExists=!/run/openbmc/host@%i-on + +[Service] +Type=oneshot +ExecStart=/usr/sbin/ampere_host_check.sh 1 0 diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb index 184d643f6..159ccdd64 100644 --- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb @@ -6,13 +6,17 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca SRC_URI = " \ file://gpio-defs.sh \ + file://gpio-lib.sh \ file://ampere_power_util.sh \ + file://ampere_host_check.sh \ " RDEPENDS_${PN} = "bash" do_install() { install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/gpio-lib.sh ${D}/${sbindir}/ install -m 0755 ${WORKDIR}/gpio-defs.sh ${D}/${sbindir}/ install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_host_check.sh ${D}/${sbindir}/ }
\ No newline at end of file diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh new file mode 100644 index 000000000..9eeeeca5a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +source /usr/sbin/gpio-defs.sh +source /usr/sbin/gpio-lib.sh + +host_status() { + st=$(busctl get-property xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host CurrentHostState | cut -d"." -f6) + if [ "$st" == "Running\"" ]; then + echo "on" + else + echo "off" + fi +} + +createFile=$1 +setState=$2 + +if [ $(host_status) == "on" ]; then + exit 0 +fi + +# Time out to check S0_FW_BOOT_OK is 60 seconds +cnt=60 +val=0 +while [ $cnt -gt 0 ]; +do + val=$(gpio_get_val $S0_CPU_FW_BOOT_OK) + cnt=$((cnt - 1)) + echo "$cnt S0_CPU_FW_BOOT_OK = $val" + if [ $val == 1 ]; then + # Sleep 5 second before the host is ready + sleep 5 + if [ $createFile == 1 ]; then + if [ ! -d "/run/openbmc" ]; then + mkdir -p /run/openbmc + fi + echo "Creating /run/openbmc/host@0-on" + touch /run/openbmc/host@0-on + fi + exit 0 + fi + sleep 1 +done + +exit 1 diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh new file mode 100644 index 000000000..fcc2d5411 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function gpio_number() { + GPIO_BASE=$(cat /sys/class/gpio/gpio*/base) + echo $((${GPIO_BASE} + $1)) +} + +# Configure GPIO as output and set its value +function gpio_configure_output() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo out > /sys/class/gpio/gpio${gpioId}/direction + echo $2 > /sys/class/gpio/gpio${gpioId}/value + echo $gpioId > /sys/class/gpio/unexport +} + +function gpio_get_val() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo $(cat /sys/class/gpio/gpio$gpioId/value) + echo $gpioId > /sys/class/gpio/unexport +} + +# Configure GPIO as input +function gpio_configure_input() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo "in" > /sys/class/gpio/gpio${gpioId}/direction + echo $gpioId > /sys/class/gpio/unexport +} |