witherspoon:VDDR/VDN leakage and GPU PGOOD updates

This will disable GPU pgood from causing system faults
and workaround a leakage issue with memory.

This update came in one change set from the power team.

Resolves openbmc/openbmc#1958

Change-Id: I00c3d0f3cdd759d3b77e748ed9808e10dfde06db
Signed-off-by: Andrew Geissler <andrewg@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
index e529049..81cace3 100644
--- 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
@@ -19,18 +19,42 @@
   fi
 fi
 
-# Setup UCD module (in standby) to disable VCS rails from power-on:
+## program UCD to bypass VCS (DD1 issue)
+## move memory enables to align with VDN (VDN to VDDR leakage issue)
+## remove GPU PGOOD from system reset.
+#GPO_CONFIG_1 (GPIO15)
 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 0xF8 0x15 0x6E 0x80 0x08 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
+#GPO_CONFIG_2 (GPIO7)
 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 0xF8 0x15 0x16 0x80 0x08 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
+#SYSTEM_RESET_CONFIG
+i2cset -y 11 0x64 0xD2 0x09 0x3F 0xFF 0x27 0x0A 0x00 0x06 0x00 0x00 0x02 i
+#ON_OFF_CONFIG rail 15
 i2cset -y 11 0x64 0x00 0x0E i
 i2cset -y 11 0x64 0x02 0x1A i
+#ON_OFF_CONFIG rail 16
 i2cset -y 11 0x64 0x00 0x0F i
 i2cset -y 11 0x64 0x02 0x1A i
+# change VDN delays based on UCD MFR_REVISION setting
+REV=`i2cget -y 11 0x64 0x9B i 2|cut -f2 -d' '`
+if [ "$REV" == "0x01" -o "$REV" == "0x02" ] ; then
+  # use 20ms delay for VDN
+  #TON_DELAY rail 8
+  i2cset -y 11 0x64 0x00 0x07 i
+  i2cset -y 11 0x64 0x60 0x80 0xDA i
+  #TON_DELAY rail 9
+  i2cset -y 11 0x64 0x00 0x08 i
+  i2cset -y 11 0x64 0x60 0x80 0xDA i
+else
+  # use 70ms delay for VDN
+  #TON_DELAY rail 8
+  i2cset -y 11 0x64 0x00 0x07 i
+  i2cset -y 11 0x64 0x60 0x30 0xEA i
+  #TON_DELAY rail 9
+  i2cset -y 11 0x64 0x00 0x08 i
+  i2cset -y 11 0x64 0x60 0x30 0xEA i
+fi
 
 # re-bind ucd driver only if we unbound it (i.e. ucd has been set with a value)
 if [ -e $ucdpath -a -n "$ucd" ]; then
@@ -38,9 +62,9 @@
   until [ $j -ge $ucd_retries ] || [ -e $ucdpath/$ucd ]; do
     j=$((j+1))
     echo $ucd > $ucdpath/bind || ret=$?
-        if [ $j -gt 1 ]; then
-          echo "rebinding UCD driver. Retry number $j"
-          sleep 1
+    if [ $j -gt 1 ]; then
+      echo "rebinding UCD driver. Retry number $j"
+      sleep 1
     fi
   done
   if [ ! -e $ucdpath/$ucd ]; then exit $ret; fi
diff --git a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_on.sh b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_on.sh
index 4837575..3713662 100644
--- a/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_on.sh
+++ b/meta-witherspoon/recipes-phosphor/chassis/vcs-pre-post/vcs_on.sh
@@ -9,3 +9,37 @@
 i2cset -y 5 0x70 0x00 0x01 b
 i2cset -y 5 0x70 0x02 0x1A b #respond to OPERATION
 i2cset -y 5 0x70 0x00 0x00 b
+
+# unbind ucd driver to permit i2cset
+ucd_retries=5
+ucd=
+
+ucdpath="/sys/bus/i2c/drivers/ucd9000"
+if [ -e $ucdpath ]
+then
+  ucd=`ls -1 $ucdpath | grep 64`
+  if [ -n "$ucd" ]
+  then
+    echo $ucd > $ucdpath/unbind
+  fi
+fi
+
+
+# re-enable VCS in system PGOOD
+sleep 1
+#SYSTEM_RESET_CONFIG
+i2cset -y 11 0x64 0xD2 0x09 0xFF 0xFF 0x27 0x0A 0x00 0x06 0x00 0x00 0x02 i
+
+# re-bind ucd driver only if we unbound it (i.e. ucd has been set with a value)
+if [ -e $ucdpath -a -n "$ucd" ]; then
+  j=0
+  until [ $j -ge $ucd_retries ] || [ -e $ucdpath/$ucd ]; do
+    j=$((j+1))
+    echo $ucd > $ucdpath/bind || ret=$?
+    if [ $j -gt 1 ]; then
+      echo "rebinding UCD driver. Retry number $j"
+      sleep 1
+    fi
+  done
+  if [ ! -e $ucdpath/$ucd ]; then exit $ret; fi
+fi