meta-fii/meta-kudo: Add ampere-host-reset.service

1. ampere-host-power-cycle.service will force off host followed
   by force on.
2. ampere-host-reset.service will pulse the sysreset pin

Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I4736c82f8f462a21650d5abba55c036a05da8e25
diff --git a/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl.bb b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl.bb
index f8f85b3..5e41d6b 100644
--- a/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl.bb
+++ b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl.bb
@@ -16,6 +16,7 @@
           file://ampere-chassis-powercycle.service \
           file://ampere-host-shutdown-ack.service \
           file://ampere-host-power-cycle.service \
+          file://ampere-host-reset.service \
           "
 
 DEPENDS = "systemd"
@@ -29,6 +30,7 @@
         ampere-chassis-powercycle.service \
         ampere-host-shutdown-ack.service \
         ampere-host-power-cycle.service \
+        ampere-host-reset.service \
         "
 # host power control
 # overwrite the host shutdown to graceful shutdown
diff --git a/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-power-cycle.service b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-power-cycle.service
index 3e03e07..b020aa3 100644
--- a/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-power-cycle.service
+++ b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-power-cycle.service
@@ -8,6 +8,6 @@
 [Service]
 RemainAfterExit=no
 Type=oneshot
-ExecStart=/usr/bin/env ampere_power_util.sh mb force_reset
+ExecStart=/usr/bin/env ampere_power_util.sh mb host_cycle
 SyslogIdentifier=ampere_power_util.sh
 
diff --git a/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-reset.service b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-reset.service
new file mode 100644
index 0000000..830fb44
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/host/ampere-hostctrl/ampere-host-reset.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Ampere Computing LLC power cycle service
+Conflicts=obmc-host-start@0.target
+OnFailure=obmc-chassis-powerreset@0.target
+Wants=kudo-bios-verify.service
+After=kudo-bios-verify.service
+
+[Service]
+RemainAfterExit=no
+Type=oneshot
+ExecStart=/usr/bin/env ampere_power_util.sh mb host_reset
+SyslogIdentifier=ampere_power_util.sh
\ No newline at end of file
diff --git a/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh b/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
index 19ccc0e..d9bcb0c 100644
--- a/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
@@ -4,7 +4,7 @@
 
 # Usage of this utility
 function usage() {
-  echo "usage: power-util mb [on|off|graceful_shutdown|force_reset|shutdown_ack|hotswap|power_button]";
+  echo "usage: power-util mb [on|off|graceful_shutdown|host_reset|host_cycle|shutdown_ack|hotswap|power_button]";
 }
 
 hotswap() {
@@ -70,7 +70,7 @@
   fi
 }
 
-force_reset() {
+host_reset() {
   if [ $(host_status) == "on" ]; then
     echo "Triggering sysreset pin"
     busctl set-property xyz.openbmc_project.Watchdog /xyz/openbmc_project/watchdog/host0 xyz.openbmc_project.State.Watchdog ExpireAction s xyz.openbmc_project.State.Watchdog.Action.None
@@ -82,6 +82,13 @@
   fi
 }
 
+host_cycle() {
+  echo "DC cycling host"
+  force_off
+  sleep 2
+  power_on
+}
+
 shutdown_ack() {
   echo "Receive shutdown ACK triggered"
   power_off
@@ -141,8 +148,10 @@
   hotswap
 elif [[ $2 == "graceful_shutdown" ]]; then
   graceful_shutdown
-elif [ $2 == "force_reset" ]; then
-  force_reset
+elif [ $2 == "host_reset" ]; then
+  host_reset
+elif [ $2 == "host_cycle" ]; then
+  host_cycle
 elif [ $2 == "shutdown_ack" ]; then
   shutdown_ack
 elif [ $2 == "power_button" ]; then