summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-common/recipes-ac01
diff options
context:
space:
mode:
authorThuBaNguyen <thu@os.amperecomputing.com>2021-07-08 10:20:43 +0300
committerThang Q. Nguyen <thang@os.amperecomputing.com>2021-08-04 11:03:33 +0300
commitfb214784edbc1da7ba155a1cddf7b3f6d0bbfb66 (patch)
tree6f5f53085fdf7b83d043926b2bbefc4a50ac33a3 /meta-ampere/meta-common/recipes-ac01
parent2f952142e9ed8b436a0e702a0f46ac88842dd51e (diff)
downloadopenbmc-fb214784edbc1da7ba155a1cddf7b3f6d0bbfb66.tar.xz
meta-ampere: power control: restructure source code
ampere-hostctrl package includes the generic codes and the platform specific codes. The generic sources are applied for all of the Ampere platforms, they are the service files and the scripts to setting the GPIO pins. The platform specific sources are the GPIO pin config file and the gpio monitor config files. This commit moves the platform specific files to the platform code. Tested: 1. Do the power control actions use ipmitool, BMC web and Redfish. 2. Make sure the server states are changed as expected. Signed-off-by: ThuBaNguyen <thu@os.amperecomputing.com> Change-Id: Ic0e261109f7a5dfaf38c883bff0afedab763a0b6
Diffstat (limited to 'meta-ampere/meta-common/recipes-ac01')
-rw-r--r--meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb26
-rw-r--r--meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service8
-rw-r--r--meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh144
-rw-r--r--meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack4
-rw-r--r--meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack4
5 files changed, 3 insertions, 183 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 4a44d1b2f..cfefa8d94 100644
--- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb
+++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb
@@ -7,41 +7,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca
inherit systemd
inherit obmc-phosphor-systemd
-# For now, monitoring shutdown_ack and reboot_ack are the only usecases
-OBMC_HOST_MONITOR_INSTANCES = "shutdown_ack reboot_ack"
-SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/shutdown_ack obmc/gpio/reboot_ack"
-
S = "${WORKDIR}"
SRC_URI = " \
- file://ampere_power_util.sh \
file://ampere-host-force-reset@.service \
- file://ampere-host-shutdown-ack@.service \
"
-DEPENDS = "systemd virtual/obmc-gpio-monitor"
-RDEPENDS_${PN} = "bash virtual/obmc-gpio-monitor"
-
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE_${PN} = " \
ampere-host-force-reset@.service \
- ampere-host-shutdown-ack@.service \
"
-# overwrite force reboot
+# append force reboot
HOST_WARM_REBOOT_FORCE_TGT = "ampere-host-force-reset@.service"
+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_TGT}"
+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')}"
-TMPL = "phosphor-gpio-monitor@.service"
-INSTFMT = "phosphor-gpio-monitor@{0}.service"
-TGT = "multi-user.target"
-FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}"
-SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_MONITOR_INSTANCES')}"
-
-do_install() {
- install -d ${D}/usr/sbin
- install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ampere_power_util.sh
-}
-
diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service
deleted file mode 100644
index 6588191aa..000000000
--- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Ampere Computing LLC host shutdown ACK
-Conflicts=obmc-chassis-poweron@0.target
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/env ampere_power_util.sh mb shutdown_ack
-SyslogIdentifier=ampere_host_shutdown_ack
diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh b/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh
deleted file mode 100644
index aa742104f..000000000
--- a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/bash
-# Usage of this utility
-function usage() {
- echo "usage: power-util mb [on|status|cycle|reset|graceful_reset|force_reset|soft_off]";
-}
-
-power_status() {
- st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6)
- if [ "$st" == "On\"" ]; then
- echo "on"
- else
- echo "off"
- fi
-}
-
-shutdown_ack() {
- if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
- echo "Receive shutdown ACK triggered after softportoff the host."
- touch /run/openbmc/host@0-softpoweroff-shutdown-ack
- else
- echo "Receive shutdown ACK triggered"
-<<<<<<< HEAD
- fi
-}
-
-graceful_shutdown() {
- if [ -f "/run/openbmc/host@0-request" ]; then
- echo "shutdown host immediately"
- power_off
- else
- echo "Triggering graceful shutdown"
- gpioset -l 0 49=1
- sleep 1
- gpioset -l 0 49=0
- sleep 30s
-=======
- sleep 3
- systemctl start obmc-chassis-poweroff@0.target
->>>>>>> 397e033ef... meta-ampere: power control: refactor host power control
- fi
-}
-
-soft_off() {
- # Trigger shutdown_req
- touch /run/openbmc/host@0-softpoweroff
- gpioset -l 0 49=1
- sleep 1s
- gpioset -l 0 49=0
-
- # Wait for shutdown_ack from the host in 30 seconds
- cnt=30
- while [ $cnt -gt 0 ];
- do
- # Wait for SHUTDOWN_ACK and create the host@0-softpoweroff-shutdown-ack
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- break
- fi
- sleep 1
- cnt=$((cnt - 1))
- done
- # Softpoweroff is successed
- sleep 2
- rm -rf /run/openbmc/host@0-softpoweroff
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- rm -rf /run/openbmc/host@0-softpoweroff-shutdown-ack
- fi
- echo 0
-}
-
-force_reset() {
- if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
- # In graceful host reset, after trigger os shutdown,
- # the phosphor-state-manager will call force-warm-reset
- # in this case the force_reset should wait for shutdown_ack from host
- cnt=30
- while [ $cnt -gt 0 ];
- do
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- break
- fi
- echo "Waiting for shutdown-ack count down $cnt"
- sleep 1
- cnt=$((cnt - 1))
- done
- # The host OS is failed to shutdown
- if [ $cnt == 0 ]; then
- echo "Shutdown-ack time out after 30s."
- exit 0
- fi
- fi
- echo "Triggering sysreset pin"
- gpioset -l 0 91=1
- sleep 1
- gpioset -l 0 91=0
-}
-
-if [ $# -lt 2 ]; then
- echo "Total number of parameter=$#"
- echo "Insufficient parameter"
- usage;
- exit 0;
-fi
-
-if [ $1 != "mb" ]; then
- echo "Invalid parameter1=$1"
- usage;
- exit 0;
-fi
-
-# check if power guard enabled
-dir="/run/systemd/system/"
-file="reboot-guard.conf"
-units=("reboot" "poweroff" "halt")
-for unit in "${units[@]}"; do
- if [ -f ${dir}${unit}.target.d/${file} ]; then
- echo "PowerGuard enabled, cannot do power control, exit!!!"
- exit -1
- fi
-done
-
-if [ ! -d "/run/openbmc/" ]; then
- mkdir -p "/run/openbmc/"
-fi
-
-if [ $2 == "shutdown_ack" ]; then
- shutdown_ack
-elif [ $2 == "status" ]; then
- power_status
-elif [ $2 == "force_reset" ]; then
- force_reset
-elif [ $2 == "soft_off" ]; then
- ret=$(soft_off)
- if [ $ret == 0 ]; then
- echo "The host is already softoff"
- else
- echo "Failed to softoff the host"
- fi
- exit $ret;
-else
- echo "Invalid parameter2=$2"
- usage;
-fi
-
-exit 0;
diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack b/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack
deleted file mode 100644
index a8ad98ee7..000000000
--- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack
+++ /dev/null
@@ -1,4 +0,0 @@
-DEVPATH=/dev/input/event0
-KEY=75
-POLARITY=1
-TARGET=obmc-host-force-warm-reboot@0.target
diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack b/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack
deleted file mode 100644
index 18cc87246..000000000
--- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack
+++ /dev/null
@@ -1,4 +0,0 @@
-DEVPATH=/dev/input/event0
-KEY=50
-POLARITY=1
-TARGET=ampere-host-shutdown-ack@0.service