warm-reboot: ensure cfam override is run

The cfam_override@.service is required in two situations:
- When chassis power is turned on (to ensure proper workarounds
  and overrides are in place)
- When the host is warm rebooted (i.e. no chassis power is turned
  off/on)

Install this service in both targets and ensure it only runs once per
boot.

Tested:
- Verified service was only run once during a cold boot
- Verified overrides were correctly applied on a warm reboot

(From meta-openpower rev: 59c6d368452c05a184549c0ee844eba63203250f)

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Idb667eb7c0b09d7c00e5893443abbcf58058a465
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-openpower/recipes-phosphor/host/op-host-control/cfam_override@.service b/meta-openpower/recipes-phosphor/host/op-host-control/cfam_override@.service
index e6bc938..8b773ec 100644
--- a/meta-openpower/recipes-phosphor/host/op-host-control/cfam_override@.service
+++ b/meta-openpower/recipes-phosphor/host/op-host-control/cfam_override@.service
@@ -7,6 +7,7 @@
 Wants=fsi-scan@%i.service
 After=fsi-scan@%i.service
 Conflicts=obmc-chassis-poweroff@%i.target
+Conflicts=obmc-host-stop@%i.target
 ConditionPathExists=!/run/openbmc/chassis@%i-on
 ConditionPathExists=/var/lib/obmc/cfam_overrides
 
@@ -18,3 +19,4 @@
 
 [Install]
 WantedBy=obmc-chassis-poweron@%i.target
+WantedBy=obmc-host-startmin@%i.target
diff --git a/meta-openpower/recipes-phosphor/host/op-proc-control-systemd-links.bb b/meta-openpower/recipes-phosphor/host/op-proc-control-systemd-links.bb
index cd4f63b..b8105fc 100644
--- a/meta-openpower/recipes-phosphor/host/op-proc-control-systemd-links.bb
+++ b/meta-openpower/recipes-phosphor/host/op-proc-control-systemd-links.bb
@@ -22,6 +22,14 @@
 	LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/op-cfam-reset.service"
 	TARGET="../op-cfam-reset.service"
 	ln -s $TARGET $LINK
+
+	# Only install cfam override if p9 system
+	if [ "${@bb.utils.contains("MACHINE_FEATURES", "p9-cfam-override", "True", "False", d)}" = True ]; then
+		mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.requires
+		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/cfam_override@0.service"
+		TARGET="../cfam_override@.service"
+		ln -s $TARGET $LINK
+	fi
 }
 
 pkg_prerm_${PN}() {
@@ -29,4 +37,9 @@
 	rm $LINK
 	LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/op-cfam-reset.service"
 	rm $LINK
+	# Only uninstall cfam override if p9 system
+	if [ "${@bb.utils.contains("MACHINE_FEATURES", "p9-cfam-override", "True", "False", d)}" = True ]; then
+		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/cfam_override@0.service"
+		rm $LINK
+	fi
 }