meta-fii: meta-mori: Add phosphor-state-manager configurations

Summary of Changes:
 - Add custom Chassis and Host services
 - Enable Host Condition GPIO using host0-ready

Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I74330028d4ce20d8abf4d6a5169c1bc6c491c7d4
diff --git a/meta-fii/meta-mori/recipes-phosphor/image/obmc-phosphor-image.bbappend b/meta-fii/meta-mori/recipes-phosphor/image/obmc-phosphor-image.bbappend
index 48e0d6d..fe66784 100644
--- a/meta-fii/meta-mori/recipes-phosphor/image/obmc-phosphor-image.bbappend
+++ b/meta-fii/meta-mori/recipes-phosphor/image/obmc-phosphor-image.bbappend
@@ -28,6 +28,7 @@
 # Required from packagegroup-mori-apps
 OBMC_IMAGE_EXTRA_INSTALL:append:mori = " obmc-phosphor-buttons-signals"
 OBMC_IMAGE_EXTRA_INSTALL:append:mori = " obmc-phosphor-buttons-handler"
+OBMC_IMAGE_EXTRA_INSTALL:append:mori = " obmc-op-control-power"
 OBMC_IMAGE_EXTRA_INSTALL:append:mori = " ncsid"
 OBMC_IMAGE_EXTRA_INSTALL:append:mori = " gbmc-mac-config"
 OBMC_IMAGE_EXTRA_INSTALL:append:mori = " entity-manager"
diff --git a/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Chassis@.service b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Chassis@.service
new file mode 100644
index 0000000..7868113
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Chassis@.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Phosphor Chassis%i State Manager
+Before=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+Wants=obmc-mapper.target
+After=obmc-mapper.target
+After=org.openbmc.control.Power@%i.service
+Wants=xyz.openbmc_project.Logging.service
+After=xyz.openbmc_project.Logging.service
+After=host-powerctrl.service
+
+[Service]
+ExecStartPre=/bin/sleep 5
+ExecStart=/usr/bin/phosphor-chassis-state-manager --chassis %i
+Restart=always
+Type=dbus
+BusName=xyz.openbmc_project.State.Chassis%i
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Host@.service b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Host@.service
new file mode 100644
index 0000000..c1a2330
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager/xyz.openbmc_project.State.Host@.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Phosphor Host%i State Manager
+Wants=mapper-wait@-xyz-openbmc_project-control-host%i-auto_reboot.service
+After=mapper-wait@-xyz-openbmc_project-control-host%i-auto_reboot.service
+Wants=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+After=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+Wants=obmc-mapper.target
+After=obmc-mapper.target
+After=phosphor-ipmi-host.service
+Before=obmc-host-reset@%i.target
+
+[Service]
+ExecStart=/usr/bin/phosphor-host-state-manager --host %i
+Restart=always
+Type=dbus
+BusName=xyz.openbmc_project.State.Host%i
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager_%.bbappend b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager_%.bbappend
new file mode 100644
index 0000000..03510cf
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/state/phosphor-state-manager_%.bbappend
@@ -0,0 +1,31 @@
+FILESEXTRAPATHS:prepend:mori := "${THISDIR}/${PN}:"
+
+DEPENDS:append:mori = " gpioplus"
+EXTRA_OEMESON:append = " -Dhost-gpios=enabled"
+
+FILES:${PN}:append:mori = " ${systemd_system_unitdir}/*"
+FILES:${PN}-host:append:mori = " ${bindir}/phosphor-host-condition-gpio"
+SYSTEMD_SERVICE:${PN}-host:append:mori = " phosphor-host-condition-gpio@.service"
+
+pkg_postinst:${PN}-obmc-targets:prepend:mori() {
+    mkdir -p $D$systemd_system_unitdir/multi-user.target.requires
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-host-condition-gpio@0.service"
+    TARGET="../phosphor-host-condition-gpio@.service"
+    ln -s $TARGET $LINK
+}
+
+pkg_prerm:${PN}-obmc-targets:prepend:mori() {
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-host-condition-gpio@0.service"
+    rm $LINK
+}
+
+SRC_URI:append:mori = " \
+    file://xyz.openbmc_project.State.Chassis@.service \
+    file://xyz.openbmc_project.State.Host@.service \
+    "
+
+do_install:append:mori() {
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/xyz.openbmc_project.State.Chassis@.service ${D}${systemd_system_unitdir}/xyz.openbmc_project.State.Chassis@.service
+    install -m 0644 ${WORKDIR}/xyz.openbmc_project.State.Host@.service ${D}${systemd_system_unitdir}/xyz.openbmc_project.State.Host@.service
+}