summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util
diff options
context:
space:
mode:
Diffstat (limited to 'meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util')
-rwxr-xr-xmeta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util49
1 files changed, 49 insertions, 0 deletions
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
new file mode 100755
index 000000000..59f91ece7
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Usage of this utility
+function usage() {
+ echo "usage: power-util mb 1 [on|off]";
+}
+
+GPIO_BASE=$(cat /sys/class/gpio/gpio*/base)
+PWR_GPIO=$(($GPIO_BASE + 32 + 3))
+BMC_RDY_GPIO=$(($GPIO_BASE + 144 +1))
+
+if [ $# -lt 3 ]; then
+ echo "Total number of parameter=$#"
+ echo "Insufficient parameter"
+ usage;
+ exit 0;
+fi
+
+if [ $1 != "mb" ]; then
+ echo "Invalid parameter1=$1"
+ usage;
+ exit 0;
+fi
+
+if [ $2 -ne 1 ]; then
+ echo "Invalid parameter2=$2, Server $2 not supported"
+ 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
+else
+ echo "Invalid parameter3=$3"
+ usage;
+fi
+
+exit 0;
OpenPOWER on IntegriCloud