Turn P9 VCS back off on a power off.

After the system is powered off (PGOOD is a 0),
we will make sure VCS is off. Even though the power on
sequence also turns it off, we're being safe by
also doing it here especially if some other code
does the power on.

Change-Id: I0834650083005bd41fbffc500cb2bc88b61d5c81
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post.bb b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post.bb
index 676df3d..2fdd52e 100644
--- a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post.bb
+++ b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post.bb
@@ -24,15 +24,19 @@
 }
 
 TMPL_OFF = "vcs_off@.service"
+TMPL_OFF_PO = "vcs_off_poweroff@.service"
 TMPL_ON = "vcs_on@.service"
 TMPL_UCD = "ucd_disable_vcs@.service"
 INSTFMT_OFF = "vcs_off@{0}.service"
+INSTFMT_OFF_PO = "vcs_off_poweroff@{0}.service"
 INSTFMT_ON = "vcs_on@{0}.service"
 INSTFMT_UCD = "ucd_disable_vcs@{0}.service"
 TGTFMT = "obmc-chassis-start@{0}.target"
+TGTFMT_STOP= "obmc-chassis-stop@{0}.target"
 FMT_OFF = "../${TMPL_OFF}:${TGTFMT}.wants/${INSTFMT_OFF}"
 FMT_ON = "../${TMPL_ON}:${TGTFMT}.wants/${INSTFMT_ON}"
 FMT_UCD = "../${TMPL_UCD}:${TGTFMT}.wants/${INSTFMT_UCD}"
+FMT_OFF_PO = "../${TMPL_OFF_PO}:${TGTFMT_STOP}.wants/${INSTFMT_OFF_PO}"
 
 SYSTEMD_SERVICE_${PN} += "${TMPL_OFF}"
 SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_OFF', 'OBMC_CHASSIS_INSTANCES')}"
@@ -40,4 +44,6 @@
 SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_ON', 'OBMC_CHASSIS_INSTANCES')}"
 SYSTEMD_SERVICE_${PN} += "${TMPL_UCD}"
 SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_UCD', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_SERVICE_${PN} += "${TMPL_OFF_PO}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_OFF_PO', 'OBMC_CHASSIS_INSTANCES')}"
 
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_off_poweroff@.service b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_off_poweroff@.service
new file mode 100644
index 0000000..d8d4b2c
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_off_poweroff@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Disable VCS on a power off
+Wants=op-wait-power-off@%i.service
+After=op-wait-power-off@%i.service
+Conflicts=obmc-chassis-start@%i.target
+
+[Service]
+ExecStart={bindir}/vcs_off.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-stop@%i.target