blob: 0ee8a8dc7e3d7bdfec544ec328c55d9184078224 [file] [log] [blame]
Delphine CC Chiu177e9872023-09-22 10:30:23 +08001#!/bin/bash -e
2# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
3source /usr/libexec/yosemite4-common-functions
4
Tim Lee1b847b22024-07-18 14:29:03 +08005check_nuvoton_board
6is_nuvoton_board=$?
Allen.Wang1fd57fe2024-04-03 18:03:11 +08007
8enable_all_fan_input()
9{
10 for file in /sys/bus/i2c/devices/*/hwmon/*/fan*_enable
11 do
12 echo 1 > "${file}"
13 done
14}
15
Tim Lee68f27092024-07-19 11:20:47 +080016set_sd_bic_interface_to_i3c()
17{
18 for host_bus in $(seq 0 7);
19 do
20 GPIOCHIP=$(basename /sys/bus/i2c/devices/"$host_bus"-0023/*gpiochip*)
21 if [ "$GPIOCHIP" != "*gpiochip*" ]; then
22 gpioset "$GPIOCHIP" 24=1
23 fi
24 done
25}
26
Erica29bca52023-12-05 10:27:41 +080027# probe devices behind mux for management board cpld
28
29rev_id_gpiochip=$(basename "/sys/bus/i2c/devices/13-0020/"*gpiochip*)
30rev_id_bit0=$(gpioget "$rev_id_gpiochip" 0)
31rev_id_bit1=$(gpioget "$rev_id_gpiochip" 1)
32rev_id_bit2=$(gpioget "$rev_id_gpiochip" 2)
33rev_id_bit3=$(gpioget "$rev_id_gpiochip" 3)
34
35# Default devicetree was set for EVT and later, only POC will do following manual devices' probing
36if [ "$rev_id_bit0" -eq 0 ] && [ "$rev_id_bit1" -eq 0 ] && [ "$rev_id_bit2" -eq 0 ] && [ "$rev_id_bit3" -eq 0 ]
37then
38 echo 24c128 "0x50" > /sys/bus/i2c/devices/i2c-12/new_device
39 echo 24c64 "0x54" > /sys/bus/i2c/devices/i2c-12/new_device
40 echo tmp75 "0x48" > /sys/bus/i2c/devices/i2c-12/new_device
41 echo nct3018y "0x6f" > /sys/bus/i2c/devices/i2c-12/new_device
42fi
43
Delphine CC Chiu177e9872023-09-22 10:30:23 +080044# set initial value for GPIO output pins
45set_gpio EN_P5V_USB_CPLD_R 1
46set_gpio EN_NIC0_POWER_BMC_R 1
47set_gpio EN_NIC1_POWER_BMC_R 1
48set_gpio EN_NIC2_POWER_BMC_R 1
49set_gpio EN_NIC3_POWER_BMC_R 1
50set_gpio FM_BMC_RTCRST_R 0
51set_gpio RST_USB_HUB_R_N 1
52set_gpio FM_BMC_READY_R2 1
53set_gpio SPI_LOCK_REQ_BMC_N 1
54set_gpio EN_P3V_BAT_SCALED_R 0
55
Delphine CC Chiu177e9872023-09-22 10:30:23 +080056set_gpio NIC0_MAIN_PWR_EN 1
57set_gpio NIC1_MAIN_PWR_EN 1
58set_gpio NIC2_MAIN_PWR_EN 1
59set_gpio NIC3_MAIN_PWR_EN 1
60
Tim Lee1b847b22024-07-18 14:29:03 +080061if [ "$is_nuvoton_board" -ne "1" ]
62then
63 # short-term set gpio v0~v3 to input pin for slot5~8 reset button
64 mknod -m 660 /dev/mem c 1 1
65 chown root:kmem /dev/mem
66 devmem 0x1e78008c 32 0x19000000
67fi
Delphine CC Chiu05c30e12024-03-06 13:21:47 +080068
Allen.Wang1fd57fe2024-04-03 18:03:11 +080069# Enable all fan input as early as possible
70enable_all_fan_input
71
Tim Lee68f27092024-07-19 11:20:47 +080072if [ "$is_nuvoton_board" -eq "1" ]
73then
74 # Set interface to SD BIC to I3C for Nuvoton BMC
75 set_sd_bic_interface_to_i3c
76fi
77
Delphine CC Chiu177e9872023-09-22 10:30:23 +080078exit 0