summaryrefslogtreecommitdiffstats
path: root/meta-facebook
diff options
context:
space:
mode:
authorVijay Khemka <vijaykhemka@fb.com>2018-12-13 11:07:06 -0800
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-12-19 12:34:50 +0000
commit45269ba94fe8f694fb42e61ba6c8886b5354bce5 (patch)
treef4a63e483c2a4cb21a269ef956d7971a5dfa7b47 /meta-facebook
parentfaff686d093ae242479776fd960c8a355b91805f (diff)
downloadtalos-openbmc-45269ba94fe8f694fb42e61ba6c8886b5354bce5.tar.gz
talos-openbmc-45269ba94fe8f694fb42e61ba6c8886b5354bce5.zip
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>
Diffstat (limited to 'meta-facebook')
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/fb-powerctrl.bb23
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-gpio.service9
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service9
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service12
-rwxr-xr-xmeta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/power-util49
-rwxr-xr-xmeta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh28
-rw-r--r--meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb1
7 files changed, 131 insertions, 0 deletions
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/fb-powerctrl.bb b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/fb-powerctrl.bb
new file mode 100644
index 000000000..37fa83588
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/fb-powerctrl.bb
@@ -0,0 +1,23 @@
+FILESEXTRAPATHS_append := "${THISDIR}/files:"
+
+inherit systemd
+
+S = "${WORKDIR}/"
+
+SRC_URI = "file://setup_gpio.sh \
+ file://power-util \
+ file://host-gpio.service \
+ file://host-poweroff.service \
+ file://host-poweron.service"
+
+DEPENDS = "systemd"
+RDEPENDS_${PN} = "bash"
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "host-gpio.service host-poweron.service host-poweroff.service"
+
+do_install() {
+ install -d ${D}/usr/sbin
+ install -m 0755 ${S}setup_gpio.sh ${D}/${sbindir}/
+ install -m 0755 ${S}power-util ${D}/${sbindir}/
+}
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-gpio.service b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-gpio.service
new file mode 100644
index 000000000..00c116b78
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-gpio.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Configure GPIOs for Host Power Control
+
+[Service]
+Restart=no
+RemainAfterExit=true
+Type=oneshot
+ExecStart=/usr/sbin/setup_gpio.sh
+SyslogIdentifier=setup_gpio.sh
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
new file mode 100644
index 000000000..95c770837
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweroff.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Shutdown Host Server
+Requires=host-gpio.service
+After=host-gpio.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/power-util mb 1 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
new file mode 100644
index 000000000..b070edac2
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/host-poweron.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Poweron Host Server
+Requires=host-gpio.service
+After=host-gpio.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/power-util mb 1 on
+SyslogIdentifier=power-util
+
+[Install]
+WantedBy=basic.target
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;
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
new file mode 100755
index 000000000..4e13109cb
--- /dev/null
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/fb-powerctrl/files/setup_gpio.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Set all output GPIOs as such and drive them with reasonable values.
+function set_gpio_active_low() {
+ if [ $# -ne 2 ]; then
+ echo "set_gpio_active_low: need both GPIO# and initial level";
+ return;
+ fi
+
+ echo $1 > /sys/class/gpio/export
+ echo $2 > /sys/class/gpio/gpio$1/direction
+}
+
+GPIO_BASE=$(cat /sys/class/gpio/gpio*/base)
+
+# FM_BMC_READY_N, GPIO S1, active low
+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
+
+# 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
+
+exit 0;
diff --git a/meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb b/meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb
index bce17dead..09cb8b246 100644
--- a/meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb
+++ b/meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb
@@ -16,4 +16,5 @@ SUMMARY_${PN}-system = "Facebook System"
RDEPENDS_${PN}-system = " \
entity-manager \
dbus-sensors \
+ fb-powerctrl \
"
OpenPOWER on IntegriCloud