Watchdog: Enable Host Watchdog during early poweron

Enabling the Host Watchdog during early power on was
inadvertently removed and this change is bringing that back on.

Fixes openbmc/openbmc#1888

Change-Id: Ib2220e762379360742dee4a11c06f01a6060fbbe
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog.bb b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog.bb
index ca5022f..dd018fb 100644
--- a/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog.bb
+++ b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog.bb
@@ -34,8 +34,17 @@
 # This is really a DBUS service but the service name is
 # an argument, so making it this way.
 WATCHDOG_TMPL = "phosphor-watchdog@.service"
+ENABLE_WATCHDOG_TMPL = "obmc-enable-host-watchdog@.service"
 SYSTEMD_SERVICE_${PN} += "${WATCHDOG_TMPL}"
 
+# To Enable Host Watchdog early during poweron
+SYSTEMD_SERVICE_${PN} += "${ENABLE_WATCHDOG_TMPL}"
+
 WATCHDOG_TGTFMT = "phosphor-watchdog@{0}.service"
+ENABLE_WATCHDOG_TGTFMT = "obmc-enable-host-watchdog@{0}.service"
+
 WATCHDOG_FMT = "../${WATCHDOG_TMPL}:obmc-host-start@{1}.target.wants/${WATCHDOG_TGTFMT}"
+ENABLE_WATCHDOG_FMT = "../${ENABLE_WATCHDOG_TMPL}:obmc-host-start@{0}.target.wants/${ENABLE_WATCHDOG_TGTFMT}"
+
 SYSTEMD_LINK_${PN} += "${@compose_list(d, 'WATCHDOG_FMT', 'OBMC_HOST_WATCHDOG_INSTANCES', 'OBMC_HOST_INSTANCES')}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'ENABLE_WATCHDOG_FMT', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/obmc-enable-host-watchdog@.service b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/obmc-enable-host-watchdog@.service
new file mode 100644
index 0000000..1fc88f3
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/obmc-enable-host-watchdog@.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Start Watchdog%i
+Wants=obmc-host-started@%i.target
+After=obmc-host-started@%i.target
+Wants=mapper-wait@-xyz-openbmc_project-watchdog-host%i.service
+After=mapper-wait@-xyz-openbmc_project-watchdog-host%i.service
+Conflicts=obmc-host-stop@%i.target
+
+[Service]
+Type=oneshot
+ExecStart={sbindir}/mapper call /xyz/openbmc_project/watchdog/host%i org.freedesktop.DBus.Properties Set ssv xyz.openbmc_project.State.Watchdog Enabled b true
diff --git a/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/poweron.conf b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/poweron.conf
index 7399fa5..93e74e3 100644
--- a/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/poweron.conf
+++ b/meta-phosphor/common/recipes-phosphor/watchdog/phosphor-watchdog/poweron.conf
@@ -1,2 +1,3 @@
 [Unit]
 Conflicts=obmc-host-stop@0.target
+Conflicts=obmc-chassis-poweroff@0.target