Witherspoon AVS Bus Control
Perform an AVS bus workaround on the VRMs attached
to the processor. The AVS bus is how the processor
talks to the VRMs.
After the workaround, this also provides services to
disable the AVS bus so a VRM override can be run, and
then enable it again afterwards.
Change-Id: I68c48ffaafe5d7125556aa9d36cf11bf55ca93ac
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable.sh
new file mode 100644
index 0000000..1d7977c
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+i2cset -y 4 0x70 0x01 0x80 b # VDD 0
+i2cset -y 4 0x70 0x00 0x01 b # VCS 0 - PAGE set
+i2cset -y 4 0x70 0x01 0x80 b # VCS 0
+i2cset -y 4 0x70 0x00 0x00 b # VCS 0 - PAGE reset
+i2cset -y 4 0x71 0x01 0x80 b # VDN 0
+i2cset -y 5 0x70 0x01 0x80 b # VDD 1
+i2cset -y 5 0x70 0x00 0x01 b # VCS 1 - PAGE set
+i2cset -y 5 0x70 0x01 0x80 b # VCS 1
+i2cset -y 5 0x70 0x00 0x00 b # VCS 1 - PAGE reset
+i2cset -y 5 0x71 0x01 0x80 b # VDN 1
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service
new file mode 100644
index 0000000..1970f00
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Disable the AVS bus on the VRMs
+Wants=avsbus-workaround@%i.service
+After=avsbus-workaround@%i.service
+Before=vrm-control@%i.service
+Conflicts=obmc-chassis-stop@%i.target
+
+[Service]
+ExecStart={bindir}/avsbus-disable.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-start@%i.target
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable.sh
new file mode 100644
index 0000000..8e857cf
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+i2cset -y 4 0x70 0x01 0xB0 b # VDD 0
+i2cset -y 4 0x70 0x00 0x01 b # VCS 0 - PAGE set
+i2cset -y 4 0x70 0x01 0xB0 b # VCS 0
+i2cset -y 4 0x70 0x00 0x00 b # VCS 0 - PAGE reset
+i2cset -y 4 0x71 0x01 0xB0 b # VDN 0
+i2cset -y 5 0x70 0x01 0xB0 b # VDD 1
+i2cset -y 5 0x70 0x00 0x01 b # VCS 1 - PAGE set
+i2cset -y 5 0x70 0x01 0xB0 b # VCS 1
+i2cset -y 5 0x70 0x00 0x00 b # VCS 1 - PAGE reset
+i2cset -y 5 0x71 0x01 0xB0 b # VDN 1
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service
new file mode 100644
index 0000000..9032f68
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Enable the AVS bus on VRMs
+Wants=vrm-control@%i.service
+After=vrm-control@%i.service
+Before=vcs_off@%i.service
+Conflicts=obmc-chassis-stop@%i.target
+
+[Service]
+ExecStart={bindir}/avsbus-enable.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-start@%i.target
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround.sh
new file mode 100644
index 0000000..775c45d
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+i2cset -y 4 0x12 0x2E 0x23 b # VDD/VCS 0
+i2cset -y 4 0x13 0x2E 0x23 b # VDN 0
+i2cset -y 5 0x12 0x2E 0x23 b # VDD/VCS 1
+i2cset -y 5 0x13 0x2E 0x23 b # VDN 1
+
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround@.service
new file mode 100644
index 0000000..5662371
--- /dev/null
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-workaround@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Perform AVS bus workaround on VRMs
+Wants=ucd_disable_vcs@%i.service
+After=ucd_disable_vcs@%i.service
+Before=avsbus-disable@%i.service
+Conflicts=obmc-chassis-stop@%i.target
+
+[Service]
+ExecStart={bindir}/avsbus-workaround.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-start@%i.target