blob: 7f02ad24ebec4f0ab710137caf8fdc880fed4b42 [file] [log] [blame]
Ricky CX Wu9f2ebc92024-07-30 13:22:21 +08001#!/bin/bash
Delphine CC Chiu177e9872023-09-22 10:30:23 +08002# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
3source /usr/libexec/yosemite4-common-functions
4
Tim Lee52b63362024-07-22 15:35:49 +08005is_nuvoton_board="$(check_nuvoton_board)"
Allen.Wang1fd57fe2024-04-03 18:03:11 +08006
7enable_all_fan_input()
8{
Ricky CX Wu9f2ebc92024-07-30 13:22:21 +08009 # There is no fan_enable for 2nd source Fan IC: NCT7363
10 if find /sys/bus/i2c/devices/*/hwmon/*/fan*_enable -print -quit 2>/dev/null | grep -q .; then
11 for file in /sys/bus/i2c/devices/*/hwmon/*/fan*_enable
12 do
13 echo 1 > "${file}"
14 done
15 fi
Allen.Wang1fd57fe2024-04-03 18:03:11 +080016}
17
Tim Lee68f27092024-07-19 11:20:47 +080018set_sd_bic_interface_to_i3c()
19{
20 for host_bus in $(seq 0 7);
21 do
22 GPIOCHIP=$(basename /sys/bus/i2c/devices/"$host_bus"-0023/*gpiochip*)
23 if [ "$GPIOCHIP" != "*gpiochip*" ]; then
24 gpioset "$GPIOCHIP" 24=1
25 fi
26 done
27}
28
Delphine CC Chiu177e9872023-09-22 10:30:23 +080029# set initial value for GPIO output pins
30set_gpio EN_P5V_USB_CPLD_R 1
31set_gpio EN_NIC0_POWER_BMC_R 1
32set_gpio EN_NIC1_POWER_BMC_R 1
33set_gpio EN_NIC2_POWER_BMC_R 1
34set_gpio EN_NIC3_POWER_BMC_R 1
35set_gpio FM_BMC_RTCRST_R 0
36set_gpio RST_USB_HUB_R_N 1
37set_gpio FM_BMC_READY_R2 1
38set_gpio SPI_LOCK_REQ_BMC_N 1
39set_gpio EN_P3V_BAT_SCALED_R 0
MarshallZhana365e4b2024-07-18 18:13:19 +080040set_gpio FM_BMC_SLED_CYCLE_R 0
Delphine CC Chiu177e9872023-09-22 10:30:23 +080041
Delphine CC Chiu177e9872023-09-22 10:30:23 +080042set_gpio NIC0_MAIN_PWR_EN 1
43set_gpio NIC1_MAIN_PWR_EN 1
44set_gpio NIC2_MAIN_PWR_EN 1
45set_gpio NIC3_MAIN_PWR_EN 1
46
Tim Lee52b63362024-07-22 15:35:49 +080047if [ -z "$is_nuvoton_board" ]
Tim Lee1b847b22024-07-18 14:29:03 +080048then
49 # short-term set gpio v0~v3 to input pin for slot5~8 reset button
Allen.Wang4682d542024-08-15 16:17:40 +080050 if [ ! -c "/dev/mem" ]; then
51 mknod -m 660 /dev/mem c 1 1
52 fi
Tim Lee1b847b22024-07-18 14:29:03 +080053 chown root:kmem /dev/mem
54 devmem 0x1e78008c 32 0x19000000
Marshall Zhan8a1dbe22024-09-24 16:45:00 +080055
56 # adjust the i2c clock duty cycle for bus 11
57 devmem 0x1E78A604 32 0x00487006
Tim Lee1b847b22024-07-18 14:29:03 +080058fi
Delphine CC Chiu05c30e12024-03-06 13:21:47 +080059
Allen.Wang1fd57fe2024-04-03 18:03:11 +080060# Enable all fan input as early as possible
61enable_all_fan_input
62
Tim Lee52b63362024-07-22 15:35:49 +080063if [ -n "$is_nuvoton_board" ]
Tim Lee68f27092024-07-19 11:20:47 +080064then
65 # Set interface to SD BIC to I3C for Nuvoton BMC
66 set_sd_bic_interface_to_i3c
67fi
68
Delphine CC Chiu177e9872023-09-22 10:30:23 +080069exit 0