diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-23 04:40:54 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 19:39:42 +0300 |
commit | 194ff4f1f5d44b12e9cb06ddafa6adb20174a13c (patch) | |
tree | 823835cd29daf8901a31ac14c7e6534abf199be3 /meta-ibm/meta-witherspoon/recipes-phosphor/chassis | |
parent | 4feb727cd6b77a68bdaca63e121b378d814f5eaf (diff) | |
download | openbmc-194ff4f1f5d44b12e9cb06ddafa6adb20174a13c.tar.xz |
[Subtree] Bring openbmc machines to top level
The new subtree model brings the subtrees up from the openbmc-machines
layer.
Change-Id: I58a03ae1be374bc79ae1438e65e888375d12d0c0
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-ibm/meta-witherspoon/recipes-phosphor/chassis')
20 files changed, 616 insertions, 0 deletions
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control.bb b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control.bb new file mode 100644 index 0000000000..a09cdc750e --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control.bb @@ -0,0 +1,40 @@ +SUMMARY = "Witherspoon AVSBus control" +PR = "r1" + +inherit obmc-phosphor-systemd +inherit obmc-phosphor-license + +RDEPENDS_${PN} += "i2c-tools" + +S = "${WORKDIR}" +SRC_URI += "file://power-workarounds.sh \ + file://avsbus-enable.sh \ + file://avsbus-disable.sh" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/power-workarounds.sh \ + ${D}${bindir}/power-workarounds.sh + install -m 0755 ${WORKDIR}/avsbus-disable.sh \ + ${D}${bindir}/avsbus-disable.sh + install -m 0755 ${WORKDIR}/avsbus-enable.sh \ + ${D}${bindir}/avsbus-enable.sh +} + +TMPL_EN= "avsbus-enable@.service" +TMPL_DIS= "avsbus-disable@.service" +TMPL_WA= "power-workarounds@.service" +INSTFMT_EN= "avsbus-enable@{0}.service" +INSTFMT_DIS= "avsbus-disable@{0}.service" +INSTFMT_WA= "power-workarounds@{0}.service" +TGTFMT = "obmc-chassis-poweron@{0}.target" +FMT_EN = "../${TMPL_EN}:${TGTFMT}.requires/${INSTFMT_EN}" +FMT_DIS = "../${TMPL_DIS}:${TGTFMT}.requires/${INSTFMT_DIS}" +FMT_WA = "../${TMPL_WA}:${TGTFMT}.requires/${INSTFMT_WA}" + +SYSTEMD_SERVICE_${PN} += "${TMPL_EN}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_EN', 'OBMC_CHASSIS_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${TMPL_DIS}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_DIS', 'OBMC_CHASSIS_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${TMPL_WA}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_WA', 'OBMC_CHASSIS_INSTANCES')}" 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 0000000000..a158f159ef --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +i2cset -y 4 0x70 0x00 0x00 b # VDD 0 - PAGE set +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 0x00 0x00 b # VDN 0 - PAGE set +i2cset -y 4 0x71 0x01 0x80 b # VDN 0 +i2cset -y 5 0x70 0x00 0x00 b # VDD 1 - PAGE set +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 0x00 0x00 b # VDN 1 - PAGE set +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 0000000000..859f428836 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Disable the AVS bus on the VRMs +Wants=power-workarounds@%i.service +After=power-workarounds@%i.service +Before=vrm-control@%i.service +Conflicts=obmc-chassis-poweroff@%i.target +ConditionPathExists=!/run/openbmc/chassis@%i-on + +[Service] +ExecStart=/usr/bin/env avsbus-disable.sh +SyslogIdentifier=avsbus-disable.sh +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=obmc-chassis-poweron@%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 0000000000..6306c58b07 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +i2cset -y 4 0x70 0x00 0x00 b # VDD 0 - PAGE set +i2cset -y 4 0x70 0x21 0x00 0x01 i # VDD 0 - Set default HW boot voltage +i2cset -y 4 0x70 0x01 0xB0 b # VDD 0 +i2cset -y 4 0x70 0x00 0x01 b # VCS 0 - PAGE set +i2cset -y 4 0x70 0x21 0x08 0x01 i # VCS 0 - Set default HW boot voltage +i2cset -y 4 0x70 0x01 0xB0 b # VCS 0 +i2cset -y 4 0x70 0x00 0x00 b # VCS 0 - PAGE reset +i2cset -y 4 0x71 0x00 0x00 b # VDN 0 - PAGE set +i2cset -y 4 0x71 0x21 0x00 0x01 i # VDN 0 - Set default HW boot voltage +i2cset -y 4 0x71 0x01 0xB0 b # VDN 0 +i2cset -y 5 0x70 0x00 0x00 b # VDD 1 - PAGE set +i2cset -y 5 0x70 0x21 0x00 0x01 i # VDD 1 - Set default HW boot voltage +i2cset -y 5 0x70 0x01 0xB0 b # VDD 1 +i2cset -y 5 0x70 0x00 0x01 b # VCS 1 - PAGE set +i2cset -y 5 0x70 0x21 0x08 0x01 i # VCS 1 - Set default HW boot voltage +i2cset -y 5 0x70 0x01 0xB0 b # VCS 1 +i2cset -y 5 0x70 0x00 0x00 b # VCS 1 - PAGE reset +i2cset -y 5 0x71 0x00 0x00 b # VDN 1 - PAGE set +i2cset -y 5 0x71 0x21 0x00 0x01 i # VDN 1 - Set default HW boot voltage +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 0000000000..b7fb41e245 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service @@ -0,0 +1,15 @@ +[Unit] +Description=Enable the AVS bus on VRMs +Wants=vrm-control@%i.service +After=vrm-control@%i.service +Conflicts=obmc-chassis-poweroff@%i.target +ConditionPathExists=!/run/openbmc/chassis@%i-on + +[Service] +ExecStart=/usr/bin/env avsbus-enable.sh +SyslogIdentifier=avsbus-enable.sh +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=obmc-chassis-poweron@%i.target diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds.sh new file mode 100644 index 0000000000..d405797311 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds.sh @@ -0,0 +1,134 @@ +#!/bin/sh + +# ensure VCS ON_OFF_CONFIG set correctly from prior FW drivers +# A side +i2cset -y 4 0x70 0x00 0x01 b +i2cset -y 4 0x70 0x02 0x16 b #respond to ENABLE pin +i2cset -y 4 0x70 0x00 0x00 b +# B side +i2cset -y 5 0x70 0x00 0x01 b +i2cset -y 5 0x70 0x02 0x16 b #respond to ENABLE pin +i2cset -y 5 0x70 0x00 0x00 b + +# vddio = 1.0V, mdat/sdat PU enabled +i2cset -y 4 0x12 0xFF 0x00 b # VDD/VCS 0 +i2cset -y 4 0x12 0x2E 0x03 b # VDD/VCS 0 +i2cset -y 4 0x13 0xFF 0x00 b # VDN 0 +i2cset -y 4 0x13 0x2E 0x03 b # VDN 0 +i2cset -y 5 0x12 0xFF 0x00 b # VDD/VCS 1 +i2cset -y 5 0x12 0x2E 0x03 b # VDD/VCS 1 +i2cset -y 5 0x13 0xFF 0x00 b # VDN 1 +i2cset -y 5 0x13 0x2E 0x03 b # VDN 1 + +# A side VDDR - set to 1.23V +i2cset -y 4 0x71 0x00 0x01 +i2cset -y 4 0x71 0x21 0x3B 0x01 i +i2cset -y 4 0x71 0x00 0x00 + +# B side VDDR - set to 1.23V +i2cset -y 5 0x71 0x00 0x01 +i2cset -y 5 0x71 0x21 0x3B 0x01 i +i2cset -y 5 0x71 0x00 0x00 + +# VDN A - PGOOD_ON threshold +i2cset -y 4 0x71 0x00 0x00 b # PAGE +i2cset -y 4 0x71 0x5E 0xCD 0x00 i # set to 0.8V + +# VDN B - PGOOD_ON threshold +i2cset -y 5 0x71 0x00 0x00 b # PAGE +i2cset -y 5 0x71 0x5E 0xCD 0x00 i # set to 0.8V + +# 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 + +# make sure VCS ON_OFF_CONFIG set correctly from old FW releases +i2cset -y 11 0x64 0x00 0x0E i +i2cset -y 11 0x64 0x02 0x16 i +i2cset -y 11 0x64 0x00 0x0F i +i2cset -y 11 0x64 0x02 0x16 i + +## move memory enables to align with VDN (VDN to VDDR leakage issue) +#GPO_CONFIG_1 (GPIO15) : mem 0 reg enables +i2cset -y 11 0x64 0xF7 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) : mem 1 reg enables +i2cset -y 11 0x64 0xF7 0x01 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 + +# 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 + +# Raise AVDD +100mV +i2cset -y 11 0x64 0x00 0x09 i # set PAGE +i2cset -y 11 0x64 0xF5 0x81 i # set margin_config +i2cset -y 11 0x64 0x21 0x85 0x33 i # set VOUT_COMMAND + +# Increase over-current settings +#VDD A phase current +i2cset -y 4 0x12 0xFF 0x04 b # set window register high byte to 4 +i2cset -y 4 0x12 0x3C 0x80 b # Set to 64A +#VDD B phase current +i2cset -y 5 0x12 0xFF 0x04 b # set window register high byte to 4 +i2cset -y 5 0x12 0x3C 0x80 b # Set to 64A +#VDD A master OC fault to 445A +i2cset -y 4 0x70 0x00 0x00 b # PAGE +i2cset -y 4 0x70 0x46 0x08DE w +# VDD A master OC warn to 326A +i2cset -y 4 0x70 0x4A 0x08A3 w # A308 +#VDD B master OC fault to 445A +i2cset -y 5 0x70 0x00 0x00 b # PAGE +i2cset -y 5 0x70 0x46 0x08DE w +# VDD B master OC warn to 326A +i2cset -y 5 0x70 0x4A 0x08A3 w +#VCS phase current to 30A C/C +i2cset -y 4 0x12 0xFF 0x08 b # set window register to 8 +i2cset -y 4 0x12 0x3C 0x3C b # 30A +i2cset -y 5 0x12 0xFF 0x08 b # set window register to 8 +i2cset -y 5 0x12 0x3C 0x3C b # 30A +#VCS master OC to 43A +i2cset -y 4 0x70 0x00 0x01 # PAGE 1 +i2cset -y 4 0x70 0x46 0x0816 w # OC to 43A +i2cset -y 5 0x70 0x00 0x01 # PAGE 1 +i2cset -y 5 0x70 0x46 0x0816 w # OC to 43A + +# 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 diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds@.service new file mode 100644 index 0000000000..74d8e4bfcf --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/avsbus-control/power-workarounds@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Perform power workarounds on VRMs +Wants=ir35221-on-unbind@%i.service +After=ir35221-on-unbind@%i.service +Before=avsbus-disable@%i.service +Conflicts=obmc-chassis-poweroff@%i.target +ConditionPathExists=!/run/openbmc/chassis@%i-on + +[Service] +ExecStart=/usr/bin/env power-workarounds.sh +SyslogIdentifier=power-workarounds.sh +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=obmc-chassis-poweron@%i.target diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%.bbappend b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%.bbappend new file mode 100644 index 0000000000..c1d50e6ffc --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%.bbappend @@ -0,0 +1,24 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +INSTANCES = "motherboard/uuid motherboard/bmc/ethernet" +ITEMS_FMT = "system/chassis/{0}" + +ITEMS = "${@compose_list(d, 'ITEMS_FMT', 'INSTANCES')}" + +ENV_FILES = "obmc/sync_inventory_item/{0}" +SYSTEMD_ENVIRONMENT_FILE_${PN} += "${@compose_list(d, 'ENV_FILES', 'ITEMS')}" + +TMPL = "obmc-sync-inventory-item@.service" +TGT = "${SYSTEMD_DEFAULT_TARGET}" + +ETH_SVC = "system-chassis-motherboard-bmc-ethernet.service" +UUID_SVC = "system-chassis-motherboard-uuid.service" + +ETH_DROPIN_DIR = "obmc-sync-inventory-item@${ETH_SVC}.d" +UUID_DROPIN_DIR = "obmc-sync-inventory-item@${UUID_SVC}.d" + +SYSTEMD_OVERRIDE_${PN} += "mac_sync_inventory.conf:${ETH_DROPIN_DIR}/mac_sync_inventory.conf" +SYSTEMD_OVERRIDE_${PN} += "uuid_sync_inventory.conf:${UUID_DROPIN_DIR}/uuid_sync_inventory.conf" + +SYSTEMD_LINK_${PN} += "../${TMPL}:${TGT}.wants/obmc-sync-inventory-item@${ETH_SVC}" +SYSTEMD_LINK_${PN} += "../${TMPL}:${TGT}.wants/obmc-sync-inventory-item@${UUID_SVC}" diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/mac_sync_inventory.conf b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/mac_sync_inventory.conf new file mode 100644 index 0000000000..f04b6dd37e --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/mac_sync_inventory.conf @@ -0,0 +1,6 @@ +[Unit] +Wants=mapper-wait@-xyz-openbmc_project-network-config.service +After=mapper-wait@-xyz-openbmc_project-network-config.service + +Wants=op-vpd-parser.service +After=op-vpd-parser.service diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/bmc/ethernet b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/bmc/ethernet new file mode 100644 index 0000000000..722e0e6418 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/bmc/ethernet @@ -0,0 +1,2 @@ +PROPERTY="MACAddress" +SYNC_TYPE=mac diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/uuid b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/uuid new file mode 100644 index 0000000000..95abbc885b --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/obmc/sync_inventory_item/system/chassis/motherboard/uuid @@ -0,0 +1,2 @@ +PROPERTY="UUID" +SYNC_TYPE=uuid diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/uuid_sync_inventory.conf b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/uuid_sync_inventory.conf new file mode 100644 index 0000000000..5874762449 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-mgr-inventory%/uuid_sync_inventory.conf @@ -0,0 +1,3 @@ +[Unit] +Wants=op-vpd-parser.service +After=op-vpd-parser.service diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power.bbappend b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power.bbappend new file mode 100644 index 0000000000..72d991c7e5 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power.bbappend @@ -0,0 +1 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power/obmc/power_control b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power/obmc/power_control new file mode 100644 index 0000000000..a93bdd758d --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/obmc-op-control-power/obmc/power_control @@ -0,0 +1,2 @@ +POLL_INTERVAL="500" +PGOOD_TIMEOUT="10" diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control.bb b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control.bb new file mode 100644 index 0000000000..d05e67fb9c --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control.bb @@ -0,0 +1,36 @@ +SUMMARY = "Witherspoon VRM Overrides" +DESCRIPTION = "Sets Witherspoon VRMs to custom voltages" +PR = "r1" + +inherit obmc-phosphor-systemd +inherit obmc-phosphor-license + +RDEPENDS_${PN} += "i2c-tools bash" + +S = "${WORKDIR}" +SRC_URI += "file://vrm-control.sh \ + file://ir35221-unbind-bind.sh" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/vrm-control.sh ${D}${bindir}/vrm-control.sh + install -m 0755 ${WORKDIR}/ir35221-unbind-bind.sh ${D}${bindir}/ir35221-unbind-bind.sh +} + +TMPL = "vrm-control@.service" +INSTFMT = "vrm-control@{0}.service" +TGTFMT_ON = "obmc-chassis-poweron@{0}.target" +FMT_ON = "../${TMPL}:${TGTFMT_ON}.requires/${INSTFMT}" + +TMPL_ON_IRBIND = "ir35221-on-bind@.service" +INSTFMT_ON_IRBIND = "ir35221-on-bind@{0}.service" +FMT_ON_IRBIND = "../${TMPL_ON_IRBIND}:${TGTFMT_ON}.wants/${INSTFMT_ON_IRBIND}" + +TMPL_ON_IRUNBIND = "ir35221-on-unbind@.service" +INSTFMT_ON_IRUNBIND = "ir35221-on-unbind@{0}.service" +FMT_ON_IRUNBIND = "../${TMPL_ON_IRUNBIND}:${TGTFMT_ON}.requires/${INSTFMT_ON_IRUNBIND}" + +SYSTEMD_SERVICE_${PN} += "${TMPL} ${TMPL_ON_IRUNBIND} ${TMPL_ON_IRBIND}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_ON', 'OBMC_CHASSIS_INSTANCES')}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_ON_IRBIND', 'OBMC_CHASSIS_INSTANCES')}" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_ON_IRUNBIND', 'OBMC_CHASSIS_INSTANCES')}" diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-bind@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-bind@.service new file mode 100644 index 0000000000..e6adc05f3a --- /dev/null +++ b/meta-ibm/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=avsbus-enable@%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-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-unbind@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-on-unbind@.service new file mode 100644 index 0000000000..7638538d14 --- /dev/null +++ b/meta-ibm/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-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh new file mode 100644 index 0000000000..160cc5d27b --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# ######################################################### +# Script to run on witherspoon BMC to unbind/bind the ir35221 +# driver's devices + +status=0 +max_retries=3 +driver_path="/sys/bus/i2c/drivers/ir35221/" +platform_path="/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/" + +unbind_driver () { + echo $1 > $driver_path/unbind +} + +bind_driver () { + device=$1 + tries=0 + + until [ $tries -ge $max_retries ]; do + tries=$((tries+1)) + ret=0 + echo $device > $driver_path/bind || ret=$? + if [ $ret -ne 0 ]; then + echo "VRM $1 bind failed. Try $tries" + sleep 1 + else + tries=$((max_retries+1)) + fi + done + + #Script will return a nonzero value if any binds fail. + if [ $ret -ne 0 ]; then + status=$ret + fi +} + +if [ "$1" = "unbind" ] +then + if [ -e $driver_path/4-0070 ] + then + unbind_driver "4-0070" + fi + + if [ -e $driver_path/4-0071 ] + then + unbind_driver "4-0071" + fi + + if [ -e $driver_path/5-0070 ] + then + unbind_driver "5-0070" + fi + + if [ -e $driver_path/5-0071 ] + then + unbind_driver "5-0071" + fi +elif [ "$1" = "bind" ] +then + if [ -e $platform_path/1e78a140.i2c-bus/i2c-4/4-0070 ] + then + bind_driver "4-0070" + fi + + if [ -e $platform_path/1e78a140.i2c-bus/i2c-4/4-0071 ] + then + bind_driver "4-0071" + fi + + if [ -e $platform_path/1e78a180.i2c-bus/i2c-5/5-0070 ] + then + bind_driver "5-0070" + fi + + if [ -e $platform_path/1e78a180.i2c-bus/i2c-5/5-0071 ] + then + bind_driver "5-0071" + fi +fi + +exit $status diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control.sh new file mode 100644 index 0000000000..c67e244a73 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control.sh @@ -0,0 +1,155 @@ +#!/bin/bash +# ######################################################### +# Script to run on witherspoon BMC to read/set vrm voltages + + +# ######################################################### +d2v () { +# usage: d2v <decimal volts> + +echo $1 | awk '{print $1 * 256 + .5}' | cut -d '.' -f 1 +} + + +# ######################################################### +v2d () { +# usage: v2d <hex val> + +printf " %0.3fV" `echo $1 | awk '{print $1 / 256}'` +} + + +# ######################################################### +i2d () { +# usage: i2d <hex val> <current divisor> + +# parse current mantisa and exponent +# format: SEEE ESMM MMMM MMMM +let e=$1/0x800 +let esign=e/0x10 +let m=$1\&0x07FF +let msign=m/0x0400 + +if [ $msign -eq 1 ] +then + # calc ones compliment + let m=($m^0x07FF)+1 + m="-$m" +fi +if [ $esign -eq 1 ] +then + # calc ones compliment + let e=(e^0x1F)+1 + e="-$e" +fi +printf " %0.3fA\n" `echo $m $e $2 | awk '{print ($1 * 2^$2)}'` +} + + +# ######################################################### +rw_vc () { +# usage: rw_vc <bus> <addr> <current divisor> <channel> <value> + +# select channel +if [ $4 != "x" ] +then + i2cset -y $1 $2 0 $4 b +fi + +# write new voltage set point +if [ ! -e $5 ] +then + i2cset -y $1 $2 0x21 `d2v $5` w +fi + +# print voltage set point +v2d `i2cget -y $1 $2 0x21 w` + +# print voltage +v2d `i2cget -y $1 $2 0x8B w` + +# print current +i2d `i2cget -y $1 $2 0x8C w` $3 + +# default back to channel 0 +if [ $4 != "x" ] +then + i2cset -y $1 $2 0 0 b +fi +} + + +# ######################################################### +# Main + +if [ -e $1 ] +then + $0 vdda vcsa vdna vioa vddra vppa vddb vcsb vdnb viob vddrb vppb + exit +fi + +if [ $1 == "-h" ] +then + echo " Usage: vrm [<rail>=[value] [<rail>=[value]] ...]" + echo " rail: vdda vcsa vdna vioa vddra vppa vddb vcsb vdnb viob vddrb vppb vdnd viod" + echo " value: volts" + echo + echo " e.g., vrm vioa=1.0 viob=1.0" + echo + exit +fi + +echo "rail set read current" +echo "------- ------- ------- -------" +for param in ${@:1} +do + rail=`echo $param | cut -d'=' -f 1` + val=`echo ${param}= | cut -d'=' -f 2` + echo -n "$rail" + case "$rail" in + vdda) + rw_vc 4 0x70 2 0 $val + ;; + vddb) + rw_vc 5 0x70 2 0 $val + ;; + vcsa) + rw_vc 4 0x70 4 1 $val + ;; + vcsb) + rw_vc 5 0x70 4 1 $val + ;; + vdna) + rw_vc 4 0x71 2 0 $val + ;; + vdnb) + rw_vc 5 0x71 2 0 $val + ;; + vioa) + rw_vc 4 0x40 2 x $val + ;; + viob) + rw_vc 5 0x40 2 x $val + ;; + vddra) + rw_vc 4 0x71 2 1 $val + ;; + vddrb) + rw_vc 5 0x71 2 1 $val + ;; + vppa) + rw_vc 12 0x41 2 x $val + ;; + vppb) + rw_vc 13 0x41 2 x $val + ;; + vdnd) + rw_vc 2 0x70 2 0 $val + ;; + viod) + rw_vc 2 0x70 2 1 $val + ;; + *) + echo " non-existant" + esac +done diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control@.service b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control@.service new file mode 100644 index 0000000000..731ce55c34 --- /dev/null +++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/vrm-control@.service @@ -0,0 +1,16 @@ +[Unit] +Description=Apply voltage overrides to VRMs +Wants=avsbus-disable@%i.service +After=avsbus-disable@%i.service +Before=avsbus-enable@%i.service +Conflicts=obmc-chassis-poweroff@%i.target +ConditionPathExists=!/run/openbmc/chassis@%i-on + +[Service] +ExecStart=/usr/bin/env vrm-control.sh vdna=0.9 vdnb=0.9 +SyslogIdentifier=vrm-control.sh +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=obmc-chassis-poweron@%i.target |