summaryrefslogtreecommitdiffstats
path: root/meta-facebook
diff options
context:
space:
mode:
authorAmithash Prasad <amithash@fb.com>2019-03-08 14:24:26 -0800
committerAndrew Geissler <geissonator@yahoo.com>2019-03-10 16:20:42 -0500
commit645ef2988be6765b043c15641ea47f49cb90f930 (patch)
tree509a07c18fa39a218eaf72e05d383404784e04e2 /meta-facebook
parentc13b82eebd60cd38cc174994520076d8857b62fa (diff)
downloadtalos-openbmc-645ef2988be6765b043c15641ea47f49cb90f930.tar.gz
talos-openbmc-645ef2988be6765b043c15641ea47f49cb90f930.zip
Add support for reset, cycle and sled-cycle.
Remove the requirement of the fru-id 1 from the command line. Add support to reset and cycle the server Add support to cycle the entire sled (Through the hotswap controller) Basic checks during power on/off to ensure valid initial steps. (From meta-facebook rev: af4ff94581bafa922e84b75b8eeff8b7e821328d) Change-Id: I8044e2afd52e58b095dd4ffad89e4397121a971a Signed-off-by: Amithash Prasad <amithash@fb.com> Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-facebook')
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service2
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service2
-rwxr-xr-xmeta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util94
-rwxr-xr-xmeta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh14
4 files changed, 85 insertions, 27 deletions
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service
index 95c770837..d23ef909c 100644
--- a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service
@@ -5,5 +5,5 @@ After=host-gpio.service
[Service]
Type=oneshot
-ExecStart=/usr/sbin/power-util mb 1 off
+ExecStart=/usr/sbin/power-util mb off
SyslogIdentifier=power-util
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service
index b070edac2..446df3850 100644
--- a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service
@@ -5,7 +5,7 @@ After=host-gpio.service
[Service]
Type=oneshot
-ExecStart=/usr/sbin/power-util mb 1 on
+ExecStart=/usr/sbin/power-util mb on
SyslogIdentifier=power-util
[Install]
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util
index 59f91ece7..a2261fb81 100755
--- a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util
@@ -1,48 +1,96 @@
#!/bin/bash
# Usage of this utility
function usage() {
- echo "usage: power-util mb 1 [on|off]";
+ echo "usage: power-util mb [on|off|status|cycle|reset]";
+ echo " power-util sled-cycle"
}
GPIO_BASE=$(cat /sys/class/gpio/gpio*/base)
PWR_GPIO=$(($GPIO_BASE + 32 + 3))
BMC_RDY_GPIO=$(($GPIO_BASE + 144 +1))
+PWR_GOOD=$(($GPIO_BASE + 8 + 6))
+PWR_RESET=$(($GPIO_BASE + 33))
-if [ $# -lt 3 ]; then
+power_off() {
+ echo "Shutting down Server $2"
+ echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
+ sleep 1
+ echo 0 > /sys/class/gpio/gpio${PWR_GPIO}/value
+ sleep 6
+ echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
+}
+
+power_on() {
+ echo "Powering on Server $2"
+ echo 0 > /sys/class/gpio/gpio${BMC_RDY_GPIO}/value
+ echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
+ echo 0 > /sys/class/gpio/gpio${PWR_GPIO}/value
+ sleep 1
+ echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
+}
+
+power_status() {
+ st=$(cat /sys/class/gpio/gpio${PWR_GOOD}/value)
+ if [ "$st" == "0" ]; then
+ echo "off"
+ else
+ echo "on"
+ fi
+}
+
+power_reset() {
+ echo "Reset on server $2"
+ echo 0 > /sys/class/gpio/gpio${PWR_RESET}/value
+ sleep 0.1
+ echo 1 > /sys/class/gpio/gpio${PWR_RESET}/value
+}
+
+sled_cycle() {
+ i2cset -y 7 0x45 0xd9 c
+}
+
+if [ $# -lt 2 ]; then
echo "Total number of parameter=$#"
echo "Insufficient parameter"
usage;
exit 0;
fi
-if [ $1 != "mb" ]; then
- echo "Invalid parameter1=$1"
- usage;
- exit 0;
+if [ $1 == "sled-cycle" ]; then
+ sled_cycle
fi
-if [ $2 -ne 1 ]; then
- echo "Invalid parameter2=$2, Server $2 not supported"
+if [ $1 != "mb" ]; then
+ echo "Invalid parameter1=$1"
usage;
exit 0;
fi
-if [ $3 = "on" ]; then
- echo "Powering on Server $2"
- echo 0 > /sys/class/gpio/gpio${BMC_RDY_GPIO}/value
- echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
- echo 0 > /sys/class/gpio/gpio${PWR_GPIO}/value
- sleep 1
- echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
-elif [ $3 = "off" ]; then
- echo "Shutting down Server $2"
- echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
- sleep 1
- echo 0 > /sys/class/gpio/gpio${PWR_GPIO}/value
- sleep 6
- echo 1 > /sys/class/gpio/gpio${PWR_GPIO}/value
+if [ $2 = "on" ]; then
+ if [ $(power_status) == "off" ]; then
+ power_on
+ fi
+elif [ $2 = "off" ]; then
+ if [ $(power_status) == "on" ]; then
+ power_off
+ fi
+elif [ $2 == "cycle" ]; then
+ if [ $(power_status) == "on" ]; then
+ power_off
+ else
+ echo "WARNING: Powering on server"
+ fi
+ power_on
+elif [ $2 == "reset" ]; then
+ if [ $(power_status) == "on" ]; then
+ power_reset
+ else
+ echo "ERROR: Server not powered on"
+ fi
+elif [ $2 == "status" ]; then
+ power_status
else
- echo "Invalid parameter3=$3"
+ echo "Invalid parameter2=$2"
usage;
fi
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh
index 4e13109cb..1b1b2e3f0 100755
--- a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh
@@ -17,12 +17,22 @@ GPIO_BASE=$(cat /sys/class/gpio/gpio*/base)
set_gpio_active_low $((${GPIO_BASE} + 144 +1)) high
# FM_BMC_SSB_SMI_LPC_N, GPIO Q6, active low
-set_gpio_active_low $((${GPIO_BASE} + 128 + 6)) high
+#set_gpio_active_low $((${GPIO_BASE} + 128 + 6)) high
# FP_PWR_BTN_PASS_R_N, GPIO E3, active low
set_gpio_active_low $((${GPIO_BASE} + 32 + 3)) high
# FP_PWR_GOOD, GPIO B6, active low
-set_gpio_active_low $((${GPIO_BASE} + 8 + 6)) high
+set_gpio_active_low $((${GPIO_BASE} + 8 + 6)) in
+
+# SYSRST_BTN_OUT_N, GPIO E1, active low
+set_gpio_active_low $((${GPIO_BASE} + 32 + 1)) high
+
+# FP_PECI_MUX, active low
+set_gpio_active_low $((${GPIO_BASE} + 212)) high
+
+# Set PECI Mux to high to select Peci interface
+echo 1 > /sys/class/gpio/gpio$((${GPIO_BASE} + 212))/value
+
exit 0;
OpenPOWER on IntegriCloud