meta-bletchley: motor-ctrl: map host power action to obmc host target

Mapping AC relay on/off to chassis power on/off:
- host-ac-on@.service --> obmc-chassis-poweron@.target
- host-ac-off@.service --> obmc-chassis-poweroff@.target

Mapping host power button on/off to host starting/stopping
- host-poweron@.service --> obmc-host-starting@.target
- host-poweroff@.service --> obmc-host-stopping@.target

Test Results:

root@bletchley:~# obmcutil -i=6 poweron
root@bletchley:~# obmcutil -i=6 state
CurrentBMCState     : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState   : xyz.openbmc_project.State.Chassis.PowerState.On
CurrentHostState    : xyz.openbmc_project.State.Host.HostState.Running
BootProgress        : xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified
OperatingSystemState: xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive

root@bletchley:~# obmcutil -i=6 poweroff
root@bletchley:~# obmcutil -i=6 state
CurrentBMCState     : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState   : xyz.openbmc_project.State.Chassis.PowerState.Off
CurrentHostState    : xyz.openbmc_project.State.Host.HostState.Off
BootProgress        : xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified
OperatingSystemState: xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I1fa2ec6d9233be61117149ac7f7d46f0417a6930
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
index e65911f..6b42f8f 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
@@ -1,6 +1,7 @@
 [Unit]
 Description=Turn off AC at Sled%i
 Conflicts=host-ac-on@%i.service
+After=host-poweroff@%i.service
 
 [Service]
 Type=oneshot
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb
index feab224..1b9f75e 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb
@@ -29,12 +29,12 @@
 
 TGT = "${SYSTEMD_DEFAULT_TARGET}"
 MOTOR_INIT_INSTFMT="../motor-init-calibration@.service:${TGT}.wants/motor-init-calibration@{0}.service"
-PWR_ON_INSTFMT="../host-poweron@.service:obmc-host-startmin@{0}.target.wants/host-poweron@{0}.service"
-PWR_OFF_INSTFMT="../host-poweroff@.service:obmc-host-shutdown@{0}.target.wants/host-poweroff@{0}.service"
+PWR_ON_INSTFMT="../host-poweron@.service:obmc-host-starting@{0}.target.wants/host-poweron@{0}.service"
+PWR_OFF_INSTFMT="../host-poweroff@.service:obmc-host-stopping@{0}.target.wants/host-poweroff@{0}.service"
 PWR_RESET_INSTFMT="host-reset@.service:host-reset@{0}.service"
 PWR_CYCLE_INSTFMT="host-cycle@.service:host-cycle@{0}.service"
-AC_ON_INSTFMT="../host-ac-on@.service:${TGT}.wants/host-ac-on@{0}.service"
-AC_OFF_INSTFMT="host-ac-off@.service:host-ac-off@{0}.service"
+AC_ON_INSTFMT="../host-ac-on@.service:obmc-chassis-poweron@{0}.target.requires/host-ac-on@{0}.service"
+AC_OFF_INSTFMT="../host-ac-off@.service:obmc-chassis-poweroff@{0}.target.requires/host-ac-off@{0}.service"
 
 SYSTEMD_SERVICE:${PN} += "motor-init-calibration@.service"
 SYSTEMD_LINK:${PN} += "${@compose_list(d, 'MOTOR_INIT_INSTFMT', 'OBMC_HOST_INSTANCES')}"
@@ -85,4 +85,3 @@
 # Host off unit configurations
 HOST_OFF_OVERRIDE_CONF_FMT = "host-poweroff.conf:host-poweroff@{0}.service.d/host-poweroff.conf"
 SYSTEMD_OVERRIDE:${PN}:bletchley += "${@compose_list_zip(d, 'HOST_OFF_OVERRIDE_CONF_FMT', 'OBMC_HOST_INSTANCES')}"
-