blob: a5ec8e7608ab3e754bbe1be726d1cfe887541dcd [file] [log] [blame]
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +00001#!/bin/bash
2
Thang Q. Nguyend9c89652023-10-05 09:02:31 +07003# shellcheck disable=SC2046
Patrick Williams0731ef82023-04-16 16:41:45 -05004# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/mtmitchell_platform_gpios_init.sh
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +00005source /usr/sbin/platform_gpios_init.sh
6
7#pre platform init function. implemented in platform_gpios_init.sh
8pre-platform-init
9
10# =======================================================
11# Setting default value for device sel and mux
12bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
13if [ "$bootstatus" == '32' ]; then
14 echo "CONFIGURE: gpio pins to output high after AC power"
15 for gpioName in "${output_high_gpios_in_ac[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070016 gpioset $(gpiofind "$gpioName")=1
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000017 done
18 echo "CONFIGURE: gpio pins to output low after AC power"
19 for gpioName in "${output_low_gpios_in_ac[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070020 gpioset $(gpiofind "$gpioName")=0
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000021 done
22 echo "CONFIGURE: gpio pins to input after AC power"
23 for gpioName in "${input_gpios_in_ac[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070024 gpioget $(gpiofind "$gpioName")
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000025 done
26fi
27
28# =======================================================
29# Setting default value for others gpio pins
30echo "CONFIGURE: gpio pins to output high"
31for gpioName in "${output_high_gpios_in_bmc_reboot[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070032 gpioset $(gpiofind "$gpioName")=1
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000033done
34echo "CONFIGURE: gpio pins to output low"
35for gpioName in "${output_low_gpios_in_bmc_reboot[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070036 gpioset $(gpiofind "$gpioName")=0
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000037done
38echo "CONFIGURE: gpio pins to input"
39for gpioName in "${input_gpios_in_bmc_reboot[@]}"; do
Thang Q. Nguyend9c89652023-10-05 09:02:31 +070040 gpioget $(gpiofind "$gpioName")
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000041done
42
Chanh Nguyen2fc68eb2022-04-28 09:11:28 +000043#post platform init function. implemented in platform_gpios_init.sh
44post-platform-init
45
46exit 0