summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
blob: 7e33776947e00c9317e7f75f839bec6a640f19b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

# shellcheck disable=SC2046
# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh
source /usr/sbin/platform_gpios_init.sh
source /usr/sbin/ampere_uart_console_setup.sh

#pre platform init function. implemented in platform_gpios_init.sh
pre-platform-init

# =======================================================
# Setting default value for device sel and mux
bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
if [ "$bootstatus" == '32' ]; then
    echo "CONFIGURE: gpio pins to output high after AC power"
    for gpioName in "${output_high_gpios_in_ac[@]}"; do
        gpioset $(gpiofind "$gpioName")=1
    done
    echo "CONFIGURE: gpio pins to output low after AC power"
    for gpioName in "${output_low_gpios_in_ac[@]}"; do
        gpioset $(gpiofind "$gpioName")=0
    done
    echo "CONFIGURE: gpio pins to input after AC power"
    for gpioName in "${input_gpios_in_ac[@]}"; do
        gpioget $(gpiofind "$gpioName")
    done
fi

# =======================================================
# Setting default value for others gpio pins
echo "CONFIGURE: gpio pins to output high"
for gpioName in "${output_high_gpios_in_bmc_reboot[@]}"; do
    gpioset $(gpiofind "$gpioName")=1
done
echo "CONFIGURE: gpio pins to output low"
for gpioName in "${output_low_gpios_in_bmc_reboot[@]}"; do
    gpioset $(gpiofind "$gpioName")=0
done
echo "CONFIGURE: gpio pins to input"
for gpioName in "${input_gpios_in_bmc_reboot[@]}"; do
    gpioget $(gpiofind "$gpioName")
done

# =======================================================
# Setting uart muxes to BMC as default
uart_console_setup

#post platform init function. implemented in platform_gpios_init.sh
post-platform-init

exit 0