Automatically check for chassis power on BMC reboot
Run the obmc-chassis-reset@.target:
- Check if pgood is on
- If it is, create the file in /run/openbmc/chassis@%i-on and
- Run the systemctl command to start the chassis power on target
Resolves openbmc/openbmc#1094
Change-Id: I93f94fc1b75e35fd353387d0bed5569e07615171
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
index 7c4fb2b..6217e14 100644
--- a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
+++ b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
@@ -19,6 +19,7 @@
op-wait-power-off@.service \
op-reset-pgood-check@.service \
op-reset-set-power-on@.service \
+ op-reset-chassis-on@.service \
"
SYSTEMD_ENVIRONMENT_FILE_${PN} += "obmc/power_control"
@@ -50,6 +51,10 @@
RESET_ON_INSTFMT = "op-reset-set-power-on@{0}.service"
RESET_ON_FMT = "../${RESET_ON_TMPL}:${RESET_TGTFMT}.requires/${RESET_ON_INSTFMT}"
+RESET_ON_CHASSIS_TMPL = "op-reset-chassis-on@.service"
+RESET_ON_CHASSIS_INSTFMT = "op-reset-chassis-on@{0}.service"
+RESET_ON_CHASSIS_FMT = "../${RESET_ON_CHASSIS_TMPL}:${RESET_TGTFMT}.requires/${RESET_ON_CHASSIS_INSTFMT}"
+
# Build up requires relationship for START_TGTFMT and STOP_TGTFMT
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'START_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'STOP_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
@@ -57,6 +62,7 @@
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'OFF_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'RESET_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'RESET_ON_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'RESET_ON_CHASSIS_FMT', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
# Now show that the main control target requires these power targets
START_TMPL_CTRL = "obmc-power-chassis-on@.target"
@@ -69,4 +75,11 @@
STOP_TGTFMT_CTRL = "obmc-chassis-stop@{1}.target"
STOP_INSTFMT_CTRL = "obmc-power-chassis-off@{0}.target"
STOP_FMT_CTRL = "../${STOP_TMPL_CTRL}:${STOP_TGTFMT_CTRL}.requires/${STOP_INSTFMT_CTRL}"
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
\ No newline at end of file
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
+
+# Force the standby target to run the chassis reset check target
+RESET_TMPL_CTRL = "obmc-chassis-reset@.target"
+SYSD_TGT = "${SYSTEMD_DEFAULT_TARGET}"
+RESET_INSTFMT_CTRL = "obmc-chassis-reset@{0}.target"
+RESET_FMT_CTRL = "../${RESET_TMPL_CTRL}:${SYSD_TGT}.wants/${RESET_INSTFMT_CTRL}"
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'RESET_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service
new file mode 100644
index 0000000..e41950d
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Start chassis%i on after BMC reset
+Requires=op-reset-set-power-on@%i.service
+After=op-reset-set-power-on@%i.service
+After=obmc-power-reset-on@%i.target
+Requires=obmc-power-reset-on@%i.target
+
+[Service]
+RemainAfterExit=no
+ExecStart=/bin/systemctl start obmc-power-chassis-on@%i.target
+
+
+[Install]
+WantedBy=obmc-chassis-reset@%i.target
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
index 8c4d3d3..46e413e 100644
--- a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
+++ b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
@@ -11,6 +11,7 @@
Type=oneshot
RemainAfterExit=yes
ExecStart={sbindir}/pgood_wait /org/openbmc/control/power%i off
+ExecStart=/bin/rm -f /run/openbmc/chassis@%i-on
[Install]
WantedBy=obmc-chassis-stop@%i.target