Initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
SUMMARY = "Zaius AVSBus control"
|
||||
DESCRIPTION = "Voltage regulator module (VRM) AVSBus control for Zaius"
|
||||
PR = "r0"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
TMPL_OFF = "avsbus-disable@.service"
|
||||
TMPL_ON = "avsbus-enable@.service"
|
||||
INSTFMT_OFF = "avsbus-disable@{0}.service"
|
||||
INSTFMT_ON = "avsbus-enable@{0}.service"
|
||||
TGTFMT_OFF = "obmc-host-stop@{0}.target"
|
||||
TGTFMT_ON = "obmc-chassis-poweron@{0}.target"
|
||||
FMT_OFF = "../${TMPL_OFF}:${TGTFMT_OFF}.wants/${INSTFMT_OFF}"
|
||||
FMT_ON = "../${TMPL_ON}:${TGTFMT_ON}.requires/${INSTFMT_ON}"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} += "${TMPL_OFF}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_OFF', 'OBMC_CHASSIS_INSTANCES')}"
|
||||
SYSTEMD_SERVICE:${PN} += "${TMPL_ON}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_ON', 'OBMC_CHASSIS_INSTANCES')}"
|
||||
|
||||
SRC_URI += "file://zaius_avsbus.sh"
|
||||
RDEPENDS:${PN} += "i2c-tools"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/zaius_avsbus.sh ${D}${bindir}/zaius_avsbus.sh
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Disable AVSBus on VRMs
|
||||
Wants=obmc-power-stop-pre@%i.target
|
||||
Before=obmc-power-stop-pre@%i.target
|
||||
Conflicts=obmc-host-startmin@%i.target
|
||||
ConditionPathExists=!/run/openbmc/chassis@%i-on
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env zaius_avsbus.sh disable
|
||||
SyslogIdentifier=zaius_avsbus.sh
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=obmc-host-stop@%i.target
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Enable AVSBus on VRMs
|
||||
Wants=obmc-host-start-pre@%i.target
|
||||
Before=obmc-host-start-pre@%i.target
|
||||
Conflicts=obmc-host-stop@%i.target
|
||||
ConditionPathExists=!/run/openbmc/chassis@%i-on
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env zaius_avsbus.sh enable
|
||||
SyslogIdentifier=zaius_avsbus.sh
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
RequiredBy=obmc-chassis-poweron@%i.target
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh -e
|
||||
# AVSBus control for PMBUS voltage regulator modules (VRMs)
|
||||
# Switches output voltage target between
|
||||
# - VOUT_COMMAND register (AVSBus disabled, default on Zaius)
|
||||
# - AVSBus target output (AVSBus enabled, voltage set by host)
|
||||
|
||||
cpu0_i2c_bus="7"
|
||||
cpu1_i2c_bus="8"
|
||||
buses="$cpu0_i2c_bus $cpu1_i2c_bus"
|
||||
vdd_i2c_addr_page="0x60:0x01"
|
||||
vdn_i2c_addr_page="0x64:0x01"
|
||||
vcs_i2c_addr_page="0x64:0x00"
|
||||
addrs_pages="$vdd_i2c_addr_page $vdn_i2c_addr_page $vcs_i2c_addr_page"
|
||||
|
||||
i2c_path="/sys/bus/i2c/devices/"
|
||||
|
||||
# Usage: vrm_avs_enable <bus> <i2c_address> <page>
|
||||
# Initializes the AVSBus VOUT setpoint to the value in PMBus VOUT_COMMAND
|
||||
vrm_avs_enable()
|
||||
{
|
||||
echo "Enabling AVSBus on bus $1 VRM @$2 rail $3..."
|
||||
echo 1 > "${i2c_path}/$1-$(printf "%04x" "$2")/hwmon/hwmon*/avs$(printf "%d" "$3")_enable"
|
||||
}
|
||||
|
||||
# Usage: vrm_avs_disable <bus> <i2c_address> <page>
|
||||
# Sets OPERATION PMBUS register to
|
||||
# - Enable/Disable: On
|
||||
# - VOUT Source: VOUT_COMMAND
|
||||
# - AVSBus Copy: VOUT_COMMAND remains unchanged
|
||||
vrm_avs_disable()
|
||||
{
|
||||
echo "Disabling AVSBus on bus $1 VRM @$2 rail $3..."
|
||||
echo 0 > "${i2c_path}/$1-$(printf "%04x" "$2")/hwmon/hwmon*/avs$(printf "%d" "$3")_enable"
|
||||
}
|
||||
|
||||
# Usage: for_each_rail <command>
|
||||
# <command> will be invoked with <bus> <i2c_address> <page>
|
||||
for_each_rail()
|
||||
{
|
||||
for bus in $buses
|
||||
do
|
||||
for addr_page in $addrs_pages
|
||||
do
|
||||
$1 "$bus" "$(echo "$addr_page" | tr : " ")"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "enable" ]
|
||||
then
|
||||
for_each_rail vrm_avs_enable
|
||||
elif [ "$1" = "disable" ]
|
||||
then
|
||||
for_each_rail vrm_avs_disable
|
||||
else
|
||||
echo "\"$0 <enable|disable>\" to control whether VRMs use AVSBus"
|
||||
echo "\"$0 <vdn_max>\" to set VDN rails VOUT_MAX to 1.1V"
|
||||
fi
|
||||
@@ -0,0 +1,29 @@
|
||||
SUMMARY = "Zaius VCS rail control"
|
||||
DESCRIPTION = "VCS voltage rail control implementation for Zaius"
|
||||
PR = "r0"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
TMPL_OFF = "vcs-off@.service"
|
||||
TMPL_ON = "vcs-on@.service"
|
||||
INSTFMT_OFF = "vcs-off@{0}.service"
|
||||
INSTFMT_ON = "vcs-on@{0}.service"
|
||||
TGTFMT_OFF = "obmc-host-stop@{0}.target"
|
||||
TGTFMT_ON = "obmc-chassis-poweron@{0}.target"
|
||||
FMT_OFF = "../${TMPL_OFF}:${TGTFMT_OFF}.wants/${INSTFMT_OFF}"
|
||||
FMT_ON = "../${TMPL_ON}:${TGTFMT_ON}.requires/${INSTFMT_ON}"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} += "${TMPL_OFF}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_OFF', 'OBMC_CHASSIS_INSTANCES')}"
|
||||
SYSTEMD_SERVICE:${PN} += "${TMPL_ON}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_ON', 'OBMC_CHASSIS_INSTANCES')}"
|
||||
|
||||
SRC_URI += "file://zaius_vcs.sh"
|
||||
RDEPENDS:${PN} += "bash i2c-tools"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/zaius_vcs.sh ${D}${bindir}/zaius_vcs.sh
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Turn VCS rails off
|
||||
Wants=obmc-power-stop-pre@%i.target
|
||||
Before=obmc-power-stop-pre@%i.target
|
||||
Conflicts=obmc-host-startmin@%i.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env zaius_vcs.sh off
|
||||
SyslogIdentifier=zaius_vcs.sh
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=obmc-host-stop@%i.target
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Turn VCS rails on
|
||||
Wants=vcs_workaround@%i.service
|
||||
After=vcs_workaround@%i.service
|
||||
Wants=obmc-host-start-pre@%i.target
|
||||
Before=obmc-host-start-pre@%i.target
|
||||
Conflicts=obmc-host-stop@%i.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env zaius_vcs.sh on
|
||||
SyslogIdentifier=zaius_vcs.sh
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
RequiredBy=obmc-chassis-poweron@%i.target
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash -e
|
||||
# Read and control VCS rails by sending the UCD power sequencer I2C commands.
|
||||
# This script assumes that the UCD is controlling VCS rails as GPIOs 5 and 6.
|
||||
# Also assumes that those GPIOs are already enabled.
|
||||
|
||||
ucd_bus="0"
|
||||
ucd_addr="0x64"
|
||||
ucd_retries="5"
|
||||
|
||||
retry()
|
||||
{
|
||||
local i=0
|
||||
until [ $i -ge $ucd_retries ]; do
|
||||
i=$((i+1))
|
||||
retry_output=$("$@") && break
|
||||
done
|
||||
local ret=$?
|
||||
if [ $i -eq $ucd_retries ]; then exit $ret; fi
|
||||
}
|
||||
|
||||
# Usage: ucd_get address
|
||||
# Result stored in $ucd_reg
|
||||
ucd_get()
|
||||
{
|
||||
retry i2cget -f -y $ucd_bus $ucd_addr "$1" b
|
||||
ucd_reg=$retry_output
|
||||
}
|
||||
|
||||
# Usage: ucd_get address value
|
||||
ucd_set()
|
||||
{
|
||||
retry i2cset -f -y $ucd_bus $ucd_addr "$1" "$2" b
|
||||
}
|
||||
|
||||
vcs_set_gpios()
|
||||
{
|
||||
echo -e "\tSetting UCD GPIO 5 to $1"
|
||||
ucd_set 0xFA 5
|
||||
ucd_set 0xFB "$1"
|
||||
ucd_set 0xFB "$1"
|
||||
echo -e "\tSetting UCD GPIO 6 to $1"
|
||||
ucd_set 0xFA 6
|
||||
ucd_set 0xFB "$1"
|
||||
ucd_set 0xFB "$1"
|
||||
}
|
||||
|
||||
vcs_get()
|
||||
{
|
||||
echo Reading VCS settings
|
||||
ucd_set 0xFA 5
|
||||
ucd_get 0xFB
|
||||
local val=
|
||||
val=$(echo "$ucd_reg" | grep -i -c 0x0f)
|
||||
echo -e "\tUCD GPIO 5 state=$val"
|
||||
ucd_set 0xFA 6
|
||||
ucd_get 0xFB
|
||||
val=$(echo "$ucd_reg" | grep -i -c 0x0f)
|
||||
echo -e "\tUCD GPIO 6 state=$val"
|
||||
}
|
||||
|
||||
|
||||
if [ "$1" == "on" ]; then
|
||||
echo Turning on VCS
|
||||
vcs_set_gpios 0x7
|
||||
elif [ "$1" == "off" ]; then
|
||||
echo Turning off VCS
|
||||
vcs_set_gpios 0x3
|
||||
else
|
||||
vcs_get
|
||||
echo "$0 <on|off>" to set state
|
||||
fi
|
||||
Reference in New Issue
Block a user