meta-bletchley: motor-ctrl: add host ac-on and ac-off service
1. add host-ac-on and host-ac-off service.
2. init host-ac-on during BMC boot.
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: Ie3954297e20f35c9d1f723d9d5e74cee91ec32ac
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
new file mode 100644
index 0000000..3962613
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Turn off AC at Sled%i
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/power-ctrl sled%i ac-off
+SyslogIdentifier=power-ctrl
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service
new file mode 100644
index 0000000..69d6042
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Turn on AC at Sled%i
+After=motor-init-calibration@%i.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/power-ctrl sled%i ac-on
+SyslogIdentifier=power-ctrl
+
+[Install]
+WantedBy=multi-user.target
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 2705eb8..fac0cd4 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
@@ -26,6 +26,8 @@
MOTOR_INIT_INSTFMT= "motor-init-calibration@{0}.service"
PWR_ON_INSTFMT="host-poweron@.service:host-poweron@{0}.service"
PWR_OFF_INSTFMT="host-poweroff@.service:host-poweroff@{0}.service"
+AC_ON_INSTFMT="host-ac-on@{0}.service"
+AC_OFF_INSTFMT="host-ac-off@.service:host-ac-off@{0}.service"
SYSTEMD_SERVICE:${PN} ="${@compose_list(d, 'MOTOR_INIT_INSTFMT', 'OBMC_HOST_INSTANCES')}"
FILES:${PN} += "${systemd_system_unitdir}/motor-init-calibration@.service"
@@ -35,3 +37,9 @@
SYSTEMD_SERVICE:${PN} +="host-poweroff@.service"
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"
+
+SYSTEMD_SERVICE:${PN} +="${@compose_list(d, 'AC_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}"
+FILES:${PN} += "${systemd_system_unitdir}/host-ac-#@.service"
+
+SYSTEMD_SERVICE:${PN} +="host-ac-off@.service"
+SYSTEMD_LINK:${PN} += "${@compose_list(d, 'AC_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"