meta-facebook: harma: modify PSM behavior

Server  On
xyz.openbmc_project.State.Host.Transition.On

Server  Off
xyz.openbmc_project.State.Host.Transition.Off

Server  Cycle
xyz.openbmc_project.State.Host.Transition.Reboot

Server  Reset xyz.openbmc_project.State.Host.Transition.GracefulWarmReboot              xyz.openbmc_project.State.Host.Transition.ForceWarmReboot

Chassis On    N/A
Chassis Off   N/A
Chassis Cycle
xyz.openbmc_project.State.Chassis.Transition.PowerCycle

Change-Id: Iaeca27aa3a8cf286deefc9c5f7d975d56d603a3c
Signed-off-by: Peter Yin <peter.yin@quantatw.com>
diff --git a/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update
index e29ca90..5877afe 100755
--- a/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update
+++ b/meta-facebook/meta-harma/recipes-phosphor/flash/phosphor-software-manager/bios-update
@@ -29,11 +29,13 @@
 
 echo "Bios upgrade started at $(date)"
 
-#Power off host server.
-echo "Power off host server by force off"
-obmcutil chassisoff
+# Power off the host server using a graceful shutdown.
+# If the server does not power off,
+# it will then perform a forced shutdown
+echo "Power off host server"
+obmcutil poweroff
 
-sleep 10
+sleep 25
 if [ "$(power_status)" != "off" ];
 then
     echo "Host server didn't power off"
diff --git a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff@.service b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff@.service
deleted file mode 100644
index 062d4f2..0000000
--- a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff@.service
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=power off host:%i
-After=obmc-host-stop-pre@%i.target
-Before=obmc-host-stopping@%i.target
-Conflicts=obmc-host-startmin@%i.target
-
-[Service]
-Restart=no
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/usr/libexec/phosphor-state-manager/host-force-poweroff %i
-
-[Install]
-RequiredBy=obmc-host-stop@%i.target
diff --git a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset
similarity index 90%
rename from meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff
rename to meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset
index 4a0d7e0..08b8722 100644
--- a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-force-poweroff
+++ b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset
@@ -3,4 +3,4 @@
 # shellcheck source=meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd
 source /usr/libexec/phosphor-state-manager/power-cmd
 
-force_power_off
+power_reset
diff --git a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset@.service b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset@.service
new file mode 100644
index 0000000..0fd059c
--- /dev/null
+++ b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/host-powerreset@.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Host Power Reset: %i
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/phosphor-state-manager/host-powerreset %i
+
+[Install]
+WantedBy=obmc-host-force-warm-reboot@%i.target
diff --git a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd
index 9587dce..253bf18 100644
--- a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd
+++ b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager/power-cmd
@@ -60,3 +60,12 @@
     fi
     return 0
 }
+
+# Host reset
+power_reset() {
+    set_gpio reset-control 0
+    sleep 1
+    set_gpio reset-control 1
+    sleep 1
+    return 0
+}
diff --git a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager_%.bbappend b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager_%.bbappend
index 72f7faa..9683b07 100644
--- a/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager_%.bbappend
+++ b/meta-facebook/meta-harma/recipes-phosphor/state/phosphor-state-manager_%.bbappend
@@ -30,42 +30,32 @@
     obmc-chassis-poweroff@{}.target.requires/obmc-powered-off@{}.service \
     "
 
-# Harma Chassis off is host force off
-CHASSIS_DEFAULT_TARGETS:append = " \
-    obmc-chassis-hard-poweroff@{}.target.requires/host-force-poweroff@{}.service \
-    "
-
 # Host Config
+# Host Reset
 HOST_DEFAULT_TARGETS:remove = " \
     obmc-host-warm-reboot@{}.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \
+    obmc-host-warm-reboot@{}.target.wants/pldmSoftPowerOff.service \
+    obmc-host-force-warm-reboot@{}.target.requires/obmc-host-stop@{}.target \
+    obmc-host-force-warm-reboot@{}.target.requires/phosphor-reboot-host@{}.service \
     "
 
-# TODO: Remove it when 69903 applied.
+# Host On/Off
 HOST_DEFAULT_TARGETS:append = " \
     obmc-host-startmin@{}.target.requires/host-poweron@{}.service \
     "
 
-# TODO: Remove it when 69903 applied.
 HOST_DEFAULT_TARGETS:append = " \
     obmc-host-shutdown@{}.target.requires/host-graceful-poweroff@{}.service \
-    obmc-host-warm-reboot@{}.target.requires/host-graceful-poweroff@{}.service \
     "
 
-# TODO: Remove it when 69903 applied.
-HOST_DEFAULT_TARGETS:append = " \
-    obmc-host-stop@{}.target.requires/host-force-poweroff@{}.service \
-    "
-
-# TODO: Remove it when 69903 applied.
 HOST_DEFAULT_TARGETS:remove = " \
     obmc-host-shutdown@{}.target.wants/host-poweroff@{}.service \
     obmc-host-start@{}.target.wants/host-poweron@{}.service \
-    obmc-host-reboot@{}.target.wants/host-powercycle@{}.service \
-    obmc-host-force-warm-reboot@{}.target.wants/host-powerreset@{}.service \
     "
 
-# TODO:  Remove when 69903 applied.
+# Host Cycle
 HOST_DEFAULT_TARGETS:remove = " \
+    obmc-host-reboot@{}.target.wants/host-powercycle@{}.service \
     obmc-host-reboot@{}.target.requires/obmc-host-shutdown@{}.service \
     "
 
@@ -87,12 +77,12 @@
     file://chassis-poweroff@.service \
     file://chassis-poweron \
     file://chassis-poweron@.service \
-    file://host-force-poweroff \
-    file://host-force-poweroff@.service \
     file://host-graceful-poweroff \
     file://host-graceful-poweroff@.service \
     file://host-poweron \
     file://host-poweron@.service \
+    file://host-powerreset \
+    file://host-powerreset@.service \
     file://power-cmd \
     file://phosphor-wait-power-off@.service \
     file://discover-sys-init.conf \
@@ -110,9 +100,9 @@
     install -m 0755 ${WORKDIR}/chassis-poweroff ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/chassis-poweron ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/chassis-powercycle ${D}${libexecdir}/${PN}/
-    install -m 0755 ${WORKDIR}/host-force-poweroff ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/host-graceful-poweroff ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/host-poweron ${D}${libexecdir}/${PN}/
+    install -m 0755 ${WORKDIR}/host-powerreset ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/power-cmd ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/phosphor-state-manager-init ${D}${libexecdir}/${PN}/
 }