Ricky CX Wu | 9f2ebc9 | 2024-07-30 13:22:21 +0800 | [diff] [blame] | 1 | #!/bin/bash |
Delphine CC Chiu | 177e987 | 2023-09-22 10:30:23 +0800 | [diff] [blame] | 2 | # shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions |
| 3 | source /usr/libexec/yosemite4-common-functions |
| 4 | |
Tim Lee | 52b6336 | 2024-07-22 15:35:49 +0800 | [diff] [blame] | 5 | is_nuvoton_board="$(check_nuvoton_board)" |
Allen.Wang | 1fd57fe | 2024-04-03 18:03:11 +0800 | [diff] [blame] | 6 | |
| 7 | enable_all_fan_input() |
| 8 | { |
Ricky CX Wu | 9f2ebc9 | 2024-07-30 13:22:21 +0800 | [diff] [blame] | 9 | # 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.Wang | 1fd57fe | 2024-04-03 18:03:11 +0800 | [diff] [blame] | 16 | } |
| 17 | |
Tim Lee | 68f2709 | 2024-07-19 11:20:47 +0800 | [diff] [blame] | 18 | set_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 Chiu | 177e987 | 2023-09-22 10:30:23 +0800 | [diff] [blame] | 29 | # set initial value for GPIO output pins |
| 30 | set_gpio EN_P5V_USB_CPLD_R 1 |
| 31 | set_gpio EN_NIC0_POWER_BMC_R 1 |
| 32 | set_gpio EN_NIC1_POWER_BMC_R 1 |
| 33 | set_gpio EN_NIC2_POWER_BMC_R 1 |
| 34 | set_gpio EN_NIC3_POWER_BMC_R 1 |
| 35 | set_gpio FM_BMC_RTCRST_R 0 |
| 36 | set_gpio RST_USB_HUB_R_N 1 |
| 37 | set_gpio FM_BMC_READY_R2 1 |
| 38 | set_gpio SPI_LOCK_REQ_BMC_N 1 |
| 39 | set_gpio EN_P3V_BAT_SCALED_R 0 |
MarshallZhan | a365e4b | 2024-07-18 18:13:19 +0800 | [diff] [blame] | 40 | set_gpio FM_BMC_SLED_CYCLE_R 0 |
Delphine CC Chiu | 177e987 | 2023-09-22 10:30:23 +0800 | [diff] [blame] | 41 | |
Delphine CC Chiu | 177e987 | 2023-09-22 10:30:23 +0800 | [diff] [blame] | 42 | set_gpio NIC0_MAIN_PWR_EN 1 |
| 43 | set_gpio NIC1_MAIN_PWR_EN 1 |
| 44 | set_gpio NIC2_MAIN_PWR_EN 1 |
| 45 | set_gpio NIC3_MAIN_PWR_EN 1 |
| 46 | |
Tim Lee | 52b6336 | 2024-07-22 15:35:49 +0800 | [diff] [blame] | 47 | if [ -z "$is_nuvoton_board" ] |
Tim Lee | 1b847b2 | 2024-07-18 14:29:03 +0800 | [diff] [blame] | 48 | then |
| 49 | # short-term set gpio v0~v3 to input pin for slot5~8 reset button |
Allen.Wang | 4682d54 | 2024-08-15 16:17:40 +0800 | [diff] [blame] | 50 | if [ ! -c "/dev/mem" ]; then |
| 51 | mknod -m 660 /dev/mem c 1 1 |
| 52 | fi |
Tim Lee | 1b847b2 | 2024-07-18 14:29:03 +0800 | [diff] [blame] | 53 | chown root:kmem /dev/mem |
| 54 | devmem 0x1e78008c 32 0x19000000 |
Marshall Zhan | 8a1dbe2 | 2024-09-24 16:45:00 +0800 | [diff] [blame] | 55 | |
| 56 | # adjust the i2c clock duty cycle for bus 11 |
| 57 | devmem 0x1E78A604 32 0x00487006 |
Tim Lee | 1b847b2 | 2024-07-18 14:29:03 +0800 | [diff] [blame] | 58 | fi |
Delphine CC Chiu | 05c30e1 | 2024-03-06 13:21:47 +0800 | [diff] [blame] | 59 | |
Allen.Wang | 1fd57fe | 2024-04-03 18:03:11 +0800 | [diff] [blame] | 60 | # Enable all fan input as early as possible |
| 61 | enable_all_fan_input |
| 62 | |
Tim Lee | 52b6336 | 2024-07-22 15:35:49 +0800 | [diff] [blame] | 63 | if [ -n "$is_nuvoton_board" ] |
Tim Lee | 68f2709 | 2024-07-19 11:20:47 +0800 | [diff] [blame] | 64 | then |
| 65 | # Set interface to SD BIC to I3C for Nuvoton BMC |
| 66 | set_sd_bic_interface_to_i3c |
| 67 | fi |
| 68 | |
Delphine CC Chiu | 177e987 | 2023-09-22 10:30:23 +0800 | [diff] [blame] | 69 | exit 0 |