blob: 629bb48486845d84763e8354a6d824fccc254199 [file] [log] [blame]
Supreeth Venkateshd1b931c2020-05-27 15:16:15 -05001#!/bin/bash
2
3# Set all output GPIOs as such and drive them with reasonable values.
4function set_gpio_active_low() {
5 if [ $# -ne 3 ]; then
6 echo "set_gpio_active_low: need GPIO#, active_low and initial value";
7 return;
8 fi
9
10 echo $1 > /sys/class/gpio/export
11 echo $2 > /sys/class/gpio/gpio$1/active_low
12 echo $3 > /sys/class/gpio/gpio$1/direction
13}
14
15GPIO_BASE=$(cat /sys/devices/platform/ahb/ahb:apb/1e780000.gpio/gpio/*/base)
16# MGMT_ASSERT_BMC_READY - Hold low until BMC has completed initialization, then drive high, GPIO M7, (Default = Low)
17GPIO_BMC_READY=$((${GPIO_BASE} + 96 + 7))
18
19#MGMT_ASSERT_PWR_BTN - Asserts the system power button, GPIO M0, Active High, (Default = Low)
20set_gpio_active_low $((${GPIO_BASE} + 96 + 0)) 0 low
21
22#MGMT_ASSERT_RST_BTN - Assert the system cold reset button, GPIO M1, Active High, (Default = Low)
23set_gpio_active_low $((${GPIO_BASE} + 96 + 1)) 0 low
24
25#MGMT_ASSERT_NMI_BTN - Asserts the system NMI button, GPIO M2 Active High, (Default = Low)
26set_gpio_active_low $((${GPIO_BASE} + 96 + 2)) 0 low
27
28#MGMT_ASSERT_P0_PROCHOT - Asserts the P0 PROCHOT_L signal, GPIO M4, Active High, (Default = Low)
29set_gpio_active_low $((${GPIO_BASE} + 96 + 4)) 0 low
30
31#MGMT_ASSERT_P1_PROCHOT - Asserts the P1 PROCHOT_L signal, GPIO M6, Active High, (Default = Low)
32set_gpio_active_low $((${GPIO_BASE} + 96 + 5)) 0 low
33
34#MGMT_ASSERT_CLR_CMOS - Clears processor CMOS, assert high for 1s To clear CMOS, (Default = Low)
35set_gpio_active_low $((${GPIO_BASE} + 96 + 6)) 0 low
36
37# MGMT_ASSERT_BMC_READY - Hold low until BMC has completed initialization, then drive high, GPIO M7, (Default = Low)
38set_gpio_active_low $((${GPIO_BASE} + 96 + 7)) 0 low
39
40# DRIVE BMC_READY HIGH
41echo 1 > /sys/class/gpio/gpio${GPIO_BMC_READY}/value
42POWER_STATUS=on
43# Write to temp. file named "power_status"
44rm -f /tmp/power_status
45printf %s "$POWER_STATUS" > /tmp/power_status
46exit 0;