Add fb-powerctrl to Facebook Tiogapass
Added a new module fb-powerctrl to comtrol host power. It
includes power-util which controls power on and off of
given host server.
Tested: Build Facebook TiogaPass board and load on the
target hardware. Ensured that power on and off features
works as expected.
(From meta-facebook rev: 67abf96e04c1aab15c90480eca2b00bf9b5c51ab)
Change-Id: I21090bbe461111c15e404c544f303615fbf62c9b
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
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 0000000..59f91ec
--- /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;