Add ir35221 bind/unbind service to vrm control

Add service to bind and unbind ir35221 devices so that i2cset/get
won't run into problems with device conflicts during power on/off
script execution.

Resolves openbmc/openbmc#1702

Change-Id: I77020313f11700acaecf0c04f2c67b7ea7b4da6b
Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-bind@.service b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-bind@.service
new file mode 100644
index 0000000..aa5a079
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-bind@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Power off mode bind ir35221 device driver devs
+After=obmc-power-stop@%i.target
+Wants=obmc-power-stop@i.target
+After=vcs_off_poweroff@%i.service
+Conflicts=obmc-chassis-poweron@%i.target
+
+[Service]
+ExecStart=/usr/bin/ir35221-unbind-bind.sh bind
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-poweroff@%i.target
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-unbind@.service b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-unbind@.service
new file mode 100644
index 0000000..ef46134
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-off-unbind@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Power off mode unbind ir35221 device driver devs
+After=obmc-host-stop-pre@%i.target
+Before=vcs_off_poweroff@%i.service
+Conflicts=obmc-chassis-poweron@%i.target
+
+[Service]
+ExecStart=/usr/bin/ir35221-unbind-bind.sh unbind
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-poweroff@%i.target
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-bind@.service b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-bind@.service
new file mode 100644
index 0000000..49d1638
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-bind@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Power on bind ir35221 device driver devs
+After=vcs_on@%i.service
+Wants=obmc-host-start-pre@%i.target
+Before=obmc-host-start-pre@%i.target
+Conflicts=obmc-chassis-poweroff@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/ir35221-unbind-bind.sh bind
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-unbind@.service b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-unbind@.service
new file mode 100644
index 0000000..7638538
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-unbind@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=power on mode unbind ir35221 device driver devs
+Wants=obmc-power-start-pre@%i.target
+Before=obmc-power-start-pre@%i.target
+Conflicts=obmc-chassis-poweroff@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/ir35221-unbind-bind.sh unbind
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh
new file mode 100644
index 0000000..eea5070
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# #########################################################
+# Script to run on witherspoon BMC to unbind/bind the ir35221
+# driver's devices
+
+echo 4-0070 > /sys/bus/i2c/drivers/ir35221/$1
+echo 4-0071 > /sys/bus/i2c/drivers/ir35221/$1
+echo 5-0070 > /sys/bus/i2c/drivers/ir35221/$1
+echo 5-0071 > /sys/bus/i2c/drivers/ir35221/$1