Replace old gpio-monitor with new one

Change-Id: I8f96987ab61d7657c3ccd3d665fa34ed6cb508ec
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
index 07d024e..d5d8d7f 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
@@ -15,15 +15,11 @@
 # via GPIO assertion
 SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/checkstop"
 
-SYSTEMD_SERVICE_${PN} += "openpower-host-checkstop-monitor@.target"
+STATES = "start stop"
+CHECKSTOP_SERVICE_FMT = "openpower-host-checkstop-monitor-{0}@.target"
+SYSTEMD_SERVICE_${PN} += "${@compose_list(d, 'CHECKSTOP_SERVICE_FMT', 'STATES')}"
 
-CHECKSTOP_TMPL = "openpower-host-checkstop-monitor@.target"
-CHECKSTOP_TGTFMT = "openpower-host-checkstop-monitor@{0}.target"
-CHECKSTOP_MONITOR_FMT = "${CHECKSTOP_TMPL}:${CHECKSTOP_TGTFMT}"
-SYSTEMD_LINK_${PN} += "${@compose_list(d, 'CHECKSTOP_MONITOR_FMT', 'OBMC_HOST_MONITOR_INSTANCES')}"
-
-GPIO_TMPL = "phosphor-gpio-monitor@.service"
-MONITOR_TGTFMT = "openpower-host-checkstop-monitor@{0}.target"
-GPIO_INSTFMT = "phosphor-gpio-monitor@{0}.service"
-MONITOR_GPIO_FMT = "../${GPIO_TMPL}:${MONITOR_TGTFMT}.wants/${GPIO_INSTFMT}"
-SYSTEMD_LINK_${PN} += "${@compose_list(d, 'MONITOR_GPIO_FMT', 'OBMC_HOST_MONITOR_INSTANCES')}"
+CHECKSTOP_TMPL = "openpower-host-checkstop-monitor-{0}@.target"
+CHECKSTOP_TGTFMT = "openpower-host-checkstop-monitor-{0}@{1}.target"
+CHECKSTOP_MONITOR_FMT = "../${CHECKSTOP_TMPL}:obmc-host-{0}@{2}.target.wants/${CHECKSTOP_TGTFMT}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'CHECKSTOP_MONITOR_FMT', 'STATES', 'OBMC_HOST_MONITOR_INSTANCES', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target
new file mode 100644
index 0000000..6b07a6c
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=Start Host %I monitor
+Requires=phosphor-gpio-monitor@%i.service
+RefuseManualStop=yes
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target
new file mode 100644
index 0000000..242683a
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=Stop Host %I monitor
+Conflicts=phosphor-gpio-monitor@%i.service
+RefuseManualStop=yes
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor@.target b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor@.target
deleted file mode 100644
index 8c2168b..0000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor@.target
+++ /dev/null
@@ -1,4 +0,0 @@
-[Unit]
-Description=Host instance %i checkstop monitor
-Requires=phosphor-gpio-monitor@%i.service
-RefuseManualStop=yes
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/packagegroups/packagegroup-op-apps.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
index 8e69012..69884ab 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
@@ -27,7 +27,6 @@
         obmc-button-power \
         obmc-button-reset \
         obmc-control-chassis \
-        obmc-hostcheckstop \
         obmc-op-control-power \
         obmc-pcie-detect \
         obmc-watchdog \
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop.bb b/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop.bb
deleted file mode 100644
index c4b3616..0000000
--- a/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop.bb
+++ /dev/null
@@ -1,12 +0,0 @@
-SUMMARY = "OpenBMC checkstop monitor."
-DESCRIPTION = "The checkstop monitor watches a GPIO for a checkstop signal \
-and reboots a server."
-PR = "r1"
-
-inherit skeleton-gdbus
-inherit obmc-phosphor-dbus-service
-
-SKELETON_DIR = "hostcheckstop"
-
-FMT = "org.openbmc.control.Checkstop@{0}.service"
-DBUS_SERVICE_${PN} += "${@compose_list(d, 'FMT', 'OBMC_CHECKSTOP_INSTANCES')}"
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop/org.openbmc.control.Checkstop@.service b/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop/org.openbmc.control.Checkstop@.service
deleted file mode 100644
index d5fea67..0000000
--- a/meta-phosphor/common/recipes-phosphor/chassis/obmc-hostcheckstop/org.openbmc.control.Checkstop@.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Phosphor Host%i Checkstop Monitor
-Wants=mapper-wait@-org-openbmc-managers-System.service
-After=mapper-wait@-org-openbmc-managers-System.service
-
-[Service]
-Restart=always
-ExecStart={sbindir}/host_checkstop.exe
-Type=dbus
-BusName={BUSNAME}
-
-[Install]
-WantedBy={SYSTEMD_DEFAULT_TARGET}