meta-amd: Override watchdog recipe.
Override recipes-phosphor/watchdog files to provide AMD specific power
control services.
Change-Id: I11c1f1e9a4c263a8442e1085f7eb06a86af887d1
Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@amd.com>
diff --git a/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-cycle.service b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-cycle.service
new file mode 100644
index 0000000..3a22e56
--- /dev/null
+++ b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-cycle.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Power Cycle Host Server
+Requires=host-gpio.service
+After=host-gpio.service
+
+[Service]
+Type=oneshot
+ExecStart=busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off
+ExecStart=busctl set-property xyz.openbmc_project.Control.Host.RestartCause /xyz/openbmc_project/control/host0/restart_cause xyz.openbmc_project.Control.Host.RestartCause RequestedRestartCause s xyz.openbmc_project.State.Host.RestartCause.WatchdogTimer
+ExecStart=sleep 6
+ExecStart=busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.On
+SyslogIdentifier=phosphor-watchdog
diff --git a/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-poweroff.service b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-poweroff.service
new file mode 100644
index 0000000..ddcb9dc
--- /dev/null
+++ b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-poweroff.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Shutdown Host Server
+Requires=host-gpio.service
+After=host-gpio.service
+
+[Service]
+Type=oneshot
+ExecStart=busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off
+SyslogIdentifier=phosphor-watchdog
diff --git a/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-reset.service b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-reset.service
new file mode 100644
index 0000000..f0f03a1
--- /dev/null
+++ b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog-host-reset.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Reset Host Server
+Requires=host-gpio.service
+After=host-gpio.service
+
+[Service]
+Type=oneshot
+ExecStart=busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Reset
+ExecStart=busctl set-property xyz.openbmc_project.Control.Host.RestartCause /xyz/openbmc_project/control/host0/restart_cause xyz.openbmc_project.Control.Host.RestartCause RequestedRestartCause s xyz.openbmc_project.State.Host.RestartCause.WatchdogTimer
+SyslogIdentifier=phosphor-watchdog
diff --git a/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service
new file mode 100644
index 0000000..f7e93b8
--- /dev/null
+++ b/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Phosphor Watchdog
+
+[Service]
+ExecStart=/usr/bin/env phosphor-watchdog --continue --service=xyz.openbmc_project.Watchdog \
+ --path=/xyz/openbmc_project/watchdog/host0 \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.HardReset=phosphor-watchdog-host-reset.service \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.PowerOff=host-phosphor-watchdog-host-poweroff.service \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.PowerCycle=phosphor-watchdog-host-cycle.service \
+
+SyslogIdentifier=phosphor-watchdog
+BusName =xyz.openbmc_project.Watchdog
+Type=dbus
+
+[Install]
+WantedBy=basic.target
diff --git a/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend b/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
new file mode 100644
index 0000000..b0dcd09
--- /dev/null
+++ b/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
+
+# Remove the override to keep service running after DC cycle
+SYSTEMD_OVERRIDE_${PN}_remove = "poweron.conf:phosphor-watchdog@poweron.service.d/poweron.conf"
+SYSTEMD_SERVICE_${PN} = "phosphor-watchdog.service phosphor-watchdog-host-poweroff.service phosphor-watchdog-host-reset.service phosphor-watchdog-host-cycle.service"