Supreeth Venkatesh | d1b931c | 2020-05-27 15:16:15 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Set all output GPIOs as such and drive them with reasonable values. |
| 4 | function 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 | |
| 15 | GPIO_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) |
| 17 | GPIO_BMC_READY=$((${GPIO_BASE} + 96 + 7)) |
| 18 | |
| 19 | #MGMT_ASSERT_PWR_BTN - Asserts the system power button, GPIO M0, Active High, (Default = Low) |
| 20 | set_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) |
| 23 | set_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) |
| 26 | set_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) |
| 29 | set_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) |
| 32 | set_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) |
| 35 | set_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) |
| 38 | set_gpio_active_low $((${GPIO_BASE} + 96 + 7)) 0 low |
| 39 | |
| 40 | # DRIVE BMC_READY HIGH |
| 41 | echo 1 > /sys/class/gpio/gpio${GPIO_BMC_READY}/value |
| 42 | POWER_STATUS=on |
| 43 | # Write to temp. file named "power_status" |
| 44 | rm -f /tmp/power_status |
| 45 | printf %s "$POWER_STATUS" > /tmp/power_status |
| 46 | exit 0; |