summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files
diff options
context:
space:
mode:
Diffstat (limited to 'meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files')
-rw-r--r--meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-gpio.service9
-rw-r--r--meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweroff.service14
-rw-r--r--meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweron.service14
-rwxr-xr-xmeta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh32
-rwxr-xr-xmeta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh10
-rwxr-xr-xmeta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh10
6 files changed, 89 insertions, 0 deletions
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-gpio.service b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-gpio.service
new file mode 100644
index 000000000..159b3cca6
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-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/bin/env init_once.sh
+SyslogIdentifier=init_once.sh
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweroff.service b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweroff.service
new file mode 100644
index 000000000..9b96ce7ca
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweroff.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Stop Host
+Requires=host-gpio.service
+After=host-gpio.service
+Conflicts=obmc-chassis-power-on@0.target
+
+[Service]
+RemainAfterExit=yes
+Type=oneshot
+ExecStart=/usr/bin/env poweroff.sh
+SyslogIdentifier=poweroff.sh
+
+[Install]
+WantedBy=obmc-chassis-power-off@0.target
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweron.service b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweron.service
new file mode 100644
index 000000000..69720c9aa
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/host-poweron.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Start Host
+Requires=host-gpio.service
+After=host-gpio.service
+Conflicts=obmc-chassis-poweroff@0.target
+
+[Service]
+RemainAfterExit=yes
+Type=oneshot
+ExecStart=/usr/bin/env poweron.sh
+SyslogIdentifier=poweron.sh
+
+[Install]
+WantedBy=obmc-chassis-poweron@0.target
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh
new file mode 100755
index 000000000..205ecaff0
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/init_once.sh
@@ -0,0 +1,32 @@
+#!/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 1 > /sys/class/gpio/gpio$1/active_low
+ echo $2 > /sys/class/gpio/gpio$1/direction
+}
+
+GPIO_BASE=$(cat /sys/devices/platform/ahb/ahb:apb/1e780000.gpio/gpio/*/base)
+
+# FM_BMC_READY_N, GPIO Q4, active low
+set_gpio_active_low $((${GPIO_BASE} + 128 + 4)) high
+
+# FM_BMC_SSB_SMI_LPC_N, GPIO Q6, active low
+set_gpio_active_low $((${GPIO_BASE} + 128 + 6)) high
+
+# FM_BMC_SYS_THROTTLE_N, GPIO A3, active low
+set_gpio_active_low $((${GPIO_BASE} + 0 + 3)) high
+
+# FM_BMC_SSB_SCI_LPC_N, GPIO E4, active low
+set_gpio_active_low $((${GPIO_BASE} + 32 + 4)) high
+
+# FP_PWR_BTN_PASS_R_N, GPIO D3, active low
+set_gpio_active_low $((${GPIO_BASE} + 24 + 3)) high
+
+exit 0;
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh
new file mode 100755
index 000000000..8e0dae38c
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweroff.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+GPIO_BASE=$(cat /sys/devices/platform/ahb/ahb:apb/1e780000.gpio/gpio/*/base)
+GPIO_NUM=$(($GPIO_BASE + 24 + 3))
+
+echo 1 > /sys/class/gpio/gpio${GPIO_NUM}/value
+sleep 5
+echo 0 > /sys/class/gpio/gpio${GPIO_NUM}/value
+
+exit 0;
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh
new file mode 100755
index 000000000..f925a33a8
--- /dev/null
+++ b/meta-quanta/meta-q71l/recipes-phosphor/quanta-powerctrl/files/poweron.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+GPIO_BASE=$(cat /sys/devices/platform/ahb/ahb:apb/1e780000.gpio/gpio/*/base)
+GPIO_NUM=$(($GPIO_BASE + 24 + 3))
+
+echo 1 > /sys/class/gpio/gpio${GPIO_NUM}/value
+sleep 1
+echo 0 > /sys/class/gpio/gpio${GPIO_NUM}/value
+
+exit 0;