Thang Q. Nguyen | 7d0f84a | 2021-09-23 06:47:52 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 3 | # shellcheck disable=SC2046 |
| 4 | # shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh |
| 5 | source /usr/sbin/platform_gpios_init.sh |
Chau Ly | 0a0f348 | 2023-04-13 05:06:28 +0000 | [diff] [blame] | 6 | source /usr/sbin/ampere_uart_console_setup.sh |
Thang Q. Nguyen | 7d0f84a | 2021-09-23 06:47:52 +0000 | [diff] [blame] | 7 | |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 8 | #pre platform init function. implemented in platform_gpios_init.sh |
| 9 | pre-platform-init |
Thang Q. Nguyen | 7d0f84a | 2021-09-23 06:47:52 +0000 | [diff] [blame] | 10 | |
| 11 | # ======================================================= |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 12 | # Setting default value for device sel and mux |
Thang Q. Nguyen | ed81813 | 2022-02-22 10:48:32 +0000 | [diff] [blame] | 13 | bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus) |
| 14 | if [ "$bootstatus" == '32' ]; then |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 15 | echo "CONFIGURE: gpio pins to output high after AC power" |
| 16 | for gpioName in "${output_high_gpios_in_ac[@]}"; do |
| 17 | gpioset $(gpiofind "$gpioName")=1 |
| 18 | done |
| 19 | echo "CONFIGURE: gpio pins to output low after AC power" |
| 20 | for gpioName in "${output_low_gpios_in_ac[@]}"; do |
| 21 | gpioset $(gpiofind "$gpioName")=0 |
| 22 | done |
| 23 | echo "CONFIGURE: gpio pins to input after AC power" |
| 24 | for gpioName in "${input_gpios_in_ac[@]}"; do |
| 25 | gpioget $(gpiofind "$gpioName") |
| 26 | done |
Thang Q. Nguyen | 7d0f84a | 2021-09-23 06:47:52 +0000 | [diff] [blame] | 27 | fi |
Thang Q. Nguyen | bddca60 | 2022-07-29 14:45:33 +0700 | [diff] [blame] | 28 | |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 29 | # ======================================================= |
| 30 | # Setting default value for others gpio pins |
| 31 | echo "CONFIGURE: gpio pins to output high" |
| 32 | for gpioName in "${output_high_gpios_in_bmc_reboot[@]}"; do |
| 33 | gpioset $(gpiofind "$gpioName")=1 |
| 34 | done |
| 35 | echo "CONFIGURE: gpio pins to output low" |
| 36 | for gpioName in "${output_low_gpios_in_bmc_reboot[@]}"; do |
| 37 | gpioset $(gpiofind "$gpioName")=0 |
| 38 | done |
| 39 | echo "CONFIGURE: gpio pins to input" |
| 40 | for gpioName in "${input_gpios_in_bmc_reboot[@]}"; do |
| 41 | gpioget $(gpiofind "$gpioName") |
| 42 | done |
| 43 | |
Chau Ly | 0a0f348 | 2023-04-13 05:06:28 +0000 | [diff] [blame] | 44 | # ======================================================= |
| 45 | # Setting uart muxes to BMC as default |
| 46 | uart_console_setup |
Thu Nguyen | e50b26f | 2023-07-12 11:59:14 +0700 | [diff] [blame] | 47 | |
| 48 | #post platform init function. implemented in platform_gpios_init.sh |
| 49 | post-platform-init |
| 50 | |
| 51 | exit 0 |