meta-bletchley: move chassis and host power control service into phosphor-state-manager
Move chassis and host power control services as part of PSM package to
align with other platforms in meta-facebook.
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I6e6afc0ad62d3b872b330202a4696b704d245911
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-insertion@.target b/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-insertion@.target
index 6fef027..6b516a1 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-insertion@.target
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-insertion@.target
@@ -1,8 +1,8 @@
[Unit]
Description=Bletchlet SLED%i insertion target
-Requires=host-ac-on@%i.service
-After=host-ac-on@%i.service
+Requires=chassis-poweron@%i.service
+After=chassis-poweron@%i.service
Requires=motor-init-calibration@%i.service
After=motor-init-calibration@%i.service
Conflicts=bletchley-sled-removed@%i.target
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-removal@.target b/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-removal@.target
index 55fd5c3..4fd5918 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-removal@.target
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/detect-gpio-present/files/bletchley-sled-removal@.target
@@ -2,7 +2,7 @@
Description=Bletchlet SLED%i removal target
Conflicts=motor-init-calibration@%i.service
-Conflicts=host-ac-on@%i.service
+Conflicts=chassis-poweron@%i.service
Conflicts=bletchley-sled-insertion@%i.target
RefuseManualStop=yes
\ No newline at end of file
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 329c6f8..a0e85bd 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,31 +29,5 @@
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-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: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')}"
-
-SYSTEMD_SERVICE:${PN} += "host-poweron@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_SERVICE:${PN} += "host-poweroff@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_SERVICE:${PN} += "host-reset@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_RESET_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_SERVICE:${PN} += "host-cycle@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_CYCLE_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_SERVICE:${PN} += "host-ac-on@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'AC_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_SERVICE:${PN} += "host-ac-off@.service"
-SYSTEMD_LINK:${PN} += "${@compose_list(d, 'AC_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"
-
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc
index b32b28f..45f2428 100644
--- a/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc
@@ -14,4 +14,5 @@
board-type-checker \
obmc-phosphor-buttons-signals \
obmc-phosphor-buttons-handler \
+ phosphor-state-manager \
"
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle
new file mode 100644
index 0000000..c46e8ab
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ "$1" == "0" ]; then
+ echo "Enter chassis-cycle"
+ /usr/sbin/power-ctrl chassis-cycle
+else
+ echo "Enter sled$1 cycle"
+ /usr/sbin/power-ctrl "sled$1" cycle
+fi
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service
new file mode 100644
index 0000000..a8a110e
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Chassis Power Cycle: %i
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/phosphor-state-manager/chassis-powercycle %i
+
+[Install]
+WantedBy=obmc-chassis-powercycle@%i.target
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff@.service
similarity index 81%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff@.service
index 6b42f8f..7deff9a 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-off@.service
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff@.service
@@ -1,6 +1,6 @@
[Unit]
Description=Turn off AC at Sled%i
-Conflicts=host-ac-on@%i.service
+Conflicts=chassis-poweron@%i.service
After=host-poweroff@%i.service
[Service]
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
similarity index 89%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
index 657b2a8..2f5f67b 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-ac-on@.service
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
@@ -2,7 +2,7 @@
Description=Turn on AC at Sled%i
Requires=motor-init-calibration@%i.service
After=motor-init-calibration@%i.service
-Conflicts=host-ac-off@%i.service
+Conflicts=chassis-poweroff@%i.service
[Service]
Type=oneshot
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-cycle@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-powercycle@.service
similarity index 100%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-cycle@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-powercycle@.service
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-poweroff@.service
similarity index 100%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-poweroff@.service
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-poweron@.service
similarity index 80%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-poweron@.service
index fd0cbd9..5a57e97 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-poweron@.service
@@ -2,8 +2,8 @@
Description=Power on System in Sled%i by Step Motor
Requires=motor-init-calibration@%i.service
After=motor-init-calibration@%i.service
-Requires=host-ac-on@%i.service
-After=host-ac-on@%i.service
+Requires=chassis-poweron@%i.service
+After=chassis-poweron@%i.service
Conflicts=host-poweroff@%i.service
[Service]
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-reset@.service b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-powerreset@.service
similarity index 100%
rename from meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-reset@.service
rename to meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager/host-powerreset@.service
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager_%.bbappend
index f9783e5..2c0c2de 100644
--- a/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager_%.bbappend
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/state/phosphor-state-manager_%.bbappend
@@ -1,5 +1,27 @@
-FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"
-RDEPENDS:${PN}-discover:append = " bletchley-common-tool"
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append:bletchley = " \
+ file://chassis-powercycle \
+ file://chassis-powercycle@.service \
+ file://chassis-poweroff@.service \
+ file://chassis-poweron@.service \
+ file://host-poweroff@.service \
+ file://host-poweron@.service \
+ "
+
+RDEPENDS:${PN}-discover:append:bletchley = " bletchley-common-tool"
+RDEPENDS:${PN}:append:bletchley = " bash motor-ctrl"
+
+do_install:append:bletchley() {
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/*.service ${D}${systemd_system_unitdir}/
+
+ install -d ${D}${libexecdir}/${PN}
+ install -m 0777 ${WORKDIR}/chassis-powercycle ${D}${libexecdir}/${PN}/
+}
+
+FILES:${PN}:append:bletchley = " ${systemd_system_unitdir}"
+FILES:${PN}:append:bletchley = " ${libexecdir}/${PN}"
# Because Bletchley does not have IPMI between Bmc & Host, the Host init
# state will set to Off after Bmc booted. We require an extra service to
@@ -15,4 +37,11 @@
CHASSIS_DEFAULT_TARGETS:remove:bletchley = " \
obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-on@{}.service \
obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-running@{}.service \
+ obmc-chassis-poweroff@{}.target.requires/obmc-power-stop@{}.service \
+ obmc-chassis-poweron@{}.target.requires/obmc-power-start@{}.service \
"
+
+HOST_DEFAULT_TARGETS:append = " \
+ obmc-host-startmin@{}.target.wants/host-poweron@{}.service \
+ obmc-host-stop@{}.target.wants/host-poweroff@{}.service \
+"
\ No newline at end of file