Create recipe files for phosphor-cooling-type

Adding service file for this application. Environment file for Witherspoon.
This is currently the only system known to really need this check for water
cooling property to be set/updated.

Resolves openbmc/openbmc#370

Change-Id: I978de38d09111c38d77e1ca4b287724243acf0a9
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%.bbappend b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%.bbappend
new file mode 100644
index 0000000..48bad3d
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%.bbappend
@@ -0,0 +1,23 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+PACKAGECONFIG += "cooling-type"
+
+# Package configuration
+FAN_PACKAGES += " \
+        phosphor-cooling-type \
+"
+RDEPENDS_phosphor-cooling-type += "libevdev"
+
+COOLING_TMPL = "phosphor-cooling-type@.service"
+COOLING_INSTFMT = "phosphor-cooling-type@{0}.service"
+COOLING_TGT = "${SYSTEMD_DEFAULT_TARGET}"
+COOLING_FMT = "../${COOLING_TMPL}:${COOLING_TGT}.requires/${COOLING_INSTFMT}"
+
+FILES_phosphor-cooling-type = "${sbindir}/phosphor-cooling-type"
+SYSTEMD_SERVICE_phosphor-cooling-type += "${COOLING_TMPL}"
+SYSTEMD_LINK_phosphor-cooling-type += "${@compose_list(d, 'COOLING_FMT', 'OBMC_CHASSIS_INSTANCES')}"
+
+COOLING_ENV_FMT = "obmc/phosphor-fan/phosphor-cooling-type-{0}.conf"
+
+SYSTEMD_ENVIRONMENT_FILE_phosphor-chassis-cooling-type += "${@compose_list(d, 'COOLING_ENV_FMT', 'OBMC_CHASSIS_INSTANCES')}"
+
diff --git a/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/obmc/phosphor-fan/phosphor-cooling-type-0.conf b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/obmc/phosphor-fan/phosphor-cooling-type-0.conf
new file mode 100644
index 0000000..334ded0
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/obmc/phosphor-fan/phosphor-cooling-type-0.conf
@@ -0,0 +1,6 @@
+OBJPATH="--path=/system/chassis"
+AIR="--air"
+WATER=""
+DEVICE="--dev=/dev/input/event0"
+CODE="--event=13"
+
diff --git a/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/phosphor-cooling-type@.service b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/phosphor-cooling-type@.service
new file mode 100644
index 0000000..62fd438
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/fans/phosphor-fan%/phosphor-cooling-type@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Phosphor Cooling Type
+Wants=mapper-wait@-xyz-openbmc_project-inventory.service
+After=mapper-wait@-xyz-openbmc_project-inventory.service
+ConditionPathExists={envfiledir}/phosphor-cooling-type-%i.conf
+
+[Service]
+EnvironmentFile={envfiledir}/phosphor-cooling-type-%i.conf
+ExecStart={sbindir}/phosphor-cooling-type ${{OBJPATH}} ${{AIR}} ${{WATER}} ${{DEVICE}} ${{CODE}}
+
+[Install]
+RequiredBy={SYSTEMD_DEFAULT_TARGET}
diff --git a/meta-witherspoon/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-witherspoon/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
index 672fe0b..af3933b 100644
--- a/meta-witherspoon/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
+++ b/meta-witherspoon/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
@@ -1 +1 @@
-RDEPENDS_${PN}-inventory += "openpower-fru-vpd openpower-occ-control"
+RDEPENDS_${PN}-inventory += "openpower-fru-vpd openpower-occ-control phosphor-cooling-type"