Recipe for CFAM override procedure

This recipe will put the CFAM override procedure into the build.

Resolves openbmc/openbmc#1381

Change-Id: If805b6e947c6d9b09703cd6333df61f5fe61db54
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/op-host-control/cfam_override@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/op-host-control/cfam_override@.service
new file mode 100644
index 0000000..c6ee466
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/op-host-control/cfam_override@.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Applies user CFAM register overrides from file
+Wants=obmc-host-start-pre@%i.target
+Before=obmc-host-start-pre@%i.target
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Wants=fsi-scan@%i.service
+After=fsi-scan@%i.service
+Conflicts=obmc-power-chassis-off@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+ConditionFileExists=/var/lib/obmc/cfam_overrides
+
+[Service]
+ExecStart={sbindir}/openpower-proc-control CFAMOverride
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-power-chassis-on@%i.target
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/p9-cfam-override.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/p9-cfam-override.bb
new file mode 100644
index 0000000..b059ff4
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/p9-cfam-override.bb
@@ -0,0 +1,19 @@
+SUMMARY = "POWER9 CFAM override"
+DESCRIPTION = "Applies user CFAM register overrides from file"
+PR = "r1"
+
+inherit obmc-phosphor-systemd
+inherit obmc-phosphor-license
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/op-host-control:"
+RDEPENDS_${PN} += "op-proc-control"
+
+S = "${WORKDIR}"
+
+TMPL = "cfam_override@.service"
+INSTFMT = "cfam_override@{0}.service"
+TGTFMT = "obmc-power-chassis-on@{0}.target"
+FMT = "../${TMPL}:${TGTFMT}.requires/${INSTFMT}"
+
+SYSTEMD_SERVICE_${PN} += "${TMPL}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_CHASSIS_INSTANCES')}"
diff --git a/meta-openbmc-machines/meta-openpower/conf/machine/include/p9.inc b/meta-openbmc-machines/meta-openpower/conf/machine/include/p9.inc
index a589623..b0e0bb9 100644
--- a/meta-openbmc-machines/meta-openpower/conf/machine/include/p9.inc
+++ b/meta-openbmc-machines/meta-openpower/conf/machine/include/p9.inc
@@ -1,2 +1,2 @@
-OBMC_MACHINE_FEATURES += 'p9-vcs-workaround op-fsi'
+OBMC_MACHINE_FEATURES += 'p9-vcs-workaround op-fsi p9-cfam-override'
 PREFERRED_PROVIDER_virtual/obmc-host-ctl = "p9-host-start"