blob: 8231e3de8ef132b5fd6669524d2cbd4d5336f92d [file] [log] [blame]
Lancelot Kao96a7ee32021-02-22 18:50:48 -06001#!/bin/bash
2
3source /usr/sbin/kudo-lib.sh
XP Chen164a9c92021-09-14 14:37:46 -05004
5function set_mux_default(){
6 # set all mux route to CPU before power on host
7 # BMC_CPU_RTC_I2C_SEL #120
8 set_gpio_ctrl 120 out 1
9 # BMC_CPU_DDR_I2C_SEL #84
10 set_gpio_ctrl 84 out 1
11 # BMC_CPU_EEPROM_I2C_SEL #85
12 set_gpio_ctrl 85 out 1
13 # BMC_CPU_PMBUS_SEL #86
14 set_gpio_ctrl 86 out 1
15 # LED control
16 # LED_BMC_LIVE #7
17 set_gpio_ctrl 7 out 1
18
19 # SPI control
20 # Send command to CPLD to switch the bios spi interface to host
21 i2cset -y -f -a 13 0x76 0x10 0x00
22
23}
24
25# 0 - 63 EVT
26# 64 + DVT/PVT
XP Chen0fb270a2021-08-26 17:30:19 -050027boardver=$(printf '%d' `cat /sys/bus/i2c/drivers/fiicpld/34-0076/CMD00 | awk '{print $6}'`)
XP Chen164a9c92021-09-14 14:37:46 -050028
XP Chen0fb270a2021-08-26 17:30:19 -050029# On EVT machines, the secondary SCP EEPROM is used.
30# Set BMC_I2C_BACKUP_SEL to secondary.
XP Chen164a9c92021-09-14 14:37:46 -050031if [[ $boardver -lt 64 ]]; then
XP Chen0fb270a2021-08-26 17:30:19 -050032 echo "EVT system. Choosing secondary SCP EEPROM."
33 set_gpio_ctrl 168 out 0
XP Chen164a9c92021-09-14 14:37:46 -050034 set_mux_default
35 # Power control
36 # S0_BMC_OK, GPIO 69
37 set_gpio_ctrl 69 out 1
Lancelot Kao96a7ee32021-02-22 18:50:48 -060038
XP Chen164a9c92021-09-14 14:37:46 -050039 # MON_BMC_ALIVE, GPIO 10(EVT), GPIO137(DVT)
40 set_gpio_ctrl 137 out 0 # setting unused GPIO
41 set_gpio_ctrl 10 out 1
42else
43 echo "DVT or PVT system"
44 # sleep so that FRU and all ipmitool Devices are ready before HOST OS
45 # gpio 143 for HPM_STBY_RST_N do to DC-SCM spec
46 set_gpio_ctrl 143 out 1 # on DVT this became HPM_STBY_RST_N (EVT1 came from CPLD)
47 sleep 5 # for the MUX to get ready
48 set_mux_default
49 # Power control
50 # S0_BMC_OK, GPIO 69
51 set_gpio_ctrl 69 out 1
Lancelot Kao96a7ee32021-02-22 18:50:48 -060052
XP Chen164a9c92021-09-14 14:37:46 -050053 # MON_BMC_ALIVE GPIO137(DVT)
54 set_gpio_ctrl 10 out 0 # setting unused GPIO
55 set_gpio_ctrl 137 out 1
56fi
Lancelot Kao19bfafb2021-05-25 15:04:57 -050057
58# Disable CPU 1 CLK when cpu not detected
Lancelot Kao19bfafb2021-05-25 15:04:57 -050059# echo init_once cpu $CPU1_STATUS > /dev/ttyS0
60# echo init_once board $boardver > /dev/ttyS0
61CPU1_STATUS_N=$(get_gpio_ctrl 136)
62if [[ $CPU1_STATUS_N == 1 ]]; then
63 #Execute this only on DVT systems
XP Chen164a9c92021-09-14 14:37:46 -050064 if [[ $boardver -lt 64 ]]; then
Lancelot Kao19bfafb2021-05-25 15:04:57 -050065 echo EVT system $boardver
66 else
67 echo DVT system $boardver
68 i2cset -y -a -f 37 0x68 0x05 0x03
69 fi
70 #These i2c deviecs are already installed on EVT systems
71 i2cset -y -a -f 16 0x6a 0 1 0xdf i
72 i2cset -y -a -f 16 0x6a 11 1 0x01 i
73 i2cset -y -a -f 17 0x67 1 2 0x3f 0x0c i
74fi