disable UCD VCS rails

Setup UCD module to disable VCS rails from power-on

Change-Id: Ib72595cf120cd082bb8baf3657307154b5abd117
Signed-off-by: Sergey Solomin <sergey.solomin@us.ibm.com>
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs.sh b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs.sh
new file mode 100644
index 0000000..d0bc63c
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# #############################################################
+# script to disable UCD VCS rails.
+# This REQUIRES unaltered/original UCD cfg file.
+# 10/28/16 PGR -
+# 11/10/16 PGR - unbind/bind UCD driver
+
+# unbind ucd driver to permit i2cset
+ucdpath="/sys/bus/i2c/drivers/ucd9000"
+if [ -e $ucdpath ]
+then
+  ucd=`ls $ucdpath | grep 64`
+  echo $ucd > $ucdpath/unbind
+fi
+
+# Setup UCD module (in standby) to disable VCS rails from power-on:
+i2cset -y 11 0x64 0xF7 0x00 i
+i2cset -y 11 0x64 0xF8 0x15 0x6E 0x80 0x0A 0x00 0x00 0x10 0x00 0x00 0x00 \
+	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
+i2cset -y 11 0x64 0xF7 0x01 i
+i2cset -y 11 0x64 0xF8 0x15 0x16 0x80 0x14 0x00 0x00 0x20 0x00 0x00 0x00 \
+	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
+i2cset -y 11 0x64 0xD2 0x09 0x3F 0xFF 0x2F 0x0A 0x00 0x06 0x00 0x00 0x02 i
+i2cset -y 11 0x64 0x00 0x0E i
+i2cset -y 11 0x64 0x02 0x1A i
+i2cset -y 11 0x64 0x00 0x0F i
+i2cset -y 11 0x64 0x02 0x1A i
+
+# re-bind ucd driver
+if [ -e $ucdpath ]
+then
+  echo $ucd > $ucdpath/bind
+fi
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs@.service b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs@.service
new file mode 100644
index 0000000..c218d05
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/ucd_disable_vcs@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Disable UCD VCS rails
+Wants=obmc-power-start-pre@%i.target
+Before=obmc-power-start-pre@%i.target
+Conflicts=obmc-chassis-stop@%i.target
+
+[Service]
+ExecStart={bindir}/ucd_disable_vcs.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-start@%i.target