blob: 6e931524d6ee029a6dcb5d5a4e902a9216011f74 [file] [log] [blame]
Lancelot Kao96a7ee32021-02-22 18:50:48 -06001#!/bin/bash
2
Charles Boyer0dd80062022-03-17 14:57:50 -05003# Provide source directive to shellcheck.
4# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
Charles Boyer2adad362021-11-24 15:58:03 -06005source /usr/libexec/kudo-fw/kudo-lib.sh
XP Chen164a9c92021-09-14 14:37:46 -05006
7function set_mux_default(){
8 # set all mux route to CPU before power on host
Charles Boyerd7d34232022-02-09 08:32:22 -06009 # BMC_CPU_RTC_I2C_SEL
10 set_gpio_ctrl CPU_RTC_SEL 1
11 # BMC_CPU_DDR_I2C_SEL
12 set_gpio_ctrl CPU_DDR_SEL 1
13 # BMC_CPU_EEPROM_I2C_SEL
14 set_gpio_ctrl CPU_EEPROM_SEL 1
15 # BMC_CPU_PMBUS_SEL
16 set_gpio_ctrl CPU_VRD_SEL 1
XP Chen164a9c92021-09-14 14:37:46 -050017 # LED control
Charles Boyerd7d34232022-02-09 08:32:22 -060018 # LED_BMC_LIVE
19 set_gpio_ctrl LED_BMC_ALIVE 1
XP Chen164a9c92021-09-14 14:37:46 -050020
21 # SPI control
22 # Send command to CPLD to switch the bios spi interface to host
Charles Boyeraf721712022-02-09 09:17:35 -060023 i2cset -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x10 0x00
XP Chen164a9c92021-09-14 14:37:46 -050024
25}
26
27# 0 - 63 EVT
28# 64 + DVT/PVT
Charles Boyeraf721712022-02-09 09:17:35 -060029boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/"${I2C_MB_CPLD[0]}"-00"${I2C_MB_CPLD[1]}"/CMD00)")
XP Chen164a9c92021-09-14 14:37:46 -050030
XP Chen0fb270a2021-08-26 17:30:19 -050031# On EVT machines, the secondary SCP EEPROM is used.
32# Set BMC_I2C_BACKUP_SEL to secondary.
Charles Boyer5db75b82022-02-09 09:30:36 -060033if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then
XP Chen0fb270a2021-08-26 17:30:19 -050034 echo "EVT system. Choosing secondary SCP EEPROM."
Charles Boyerd7d34232022-02-09 08:32:22 -060035 set_gpio_ctrl BACKUP_SCP_SEL 0
XP Chen164a9c92021-09-14 14:37:46 -050036 set_mux_default
37 # Power control
Charles Boyerd7d34232022-02-09 08:32:22 -060038 # S0_BMC_OK
39 set_gpio_ctrl S0_BMC_OK 1
XP Chen164a9c92021-09-14 14:37:46 -050040else
41 echo "DVT or PVT system"
42 # sleep so that FRU and all ipmitool Devices are ready before HOST OS
Charles Boyerd7d34232022-02-09 08:32:22 -060043 # HPM_STBY_RST_N to DC-SCM spec
44 set_gpio_ctrl HPM_STBY_RST_N 1 # on DVT this became HPM_STBY_RST_N (EVT1 came from CPLD)
XP Chen164a9c92021-09-14 14:37:46 -050045 sleep 5 # for the MUX to get ready
46 set_mux_default
47 # Power control
Charles Boyerd7d34232022-02-09 08:32:22 -060048 # S0_BMC_OK
49 set_gpio_ctrl S0_BMC_OK 1
Charles Boyer9508b342021-11-04 10:37:14 -050050fi
Lancelot Kao19bfafb2021-05-25 15:04:57 -050051
52# Disable CPU 1 CLK when cpu not detected
Lancelot Kao19bfafb2021-05-25 15:04:57 -050053# echo init_once cpu $CPU1_STATUS > /dev/ttyS0
54# echo init_once board $boardver > /dev/ttyS0
Charles Boyerd7d34232022-02-09 08:32:22 -060055CPU1_STATUS_N=$(get_gpio_ctrl S1_STATUS_N)
Lancelot Kao19bfafb2021-05-25 15:04:57 -050056if [[ $CPU1_STATUS_N == 1 ]]; then
57 #Execute this only on DVT systems
Charles Boyer5db75b82022-02-09 09:30:36 -060058 if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then
Charles Boyer0dd80062022-03-17 14:57:50 -050059 echo EVT system "$boardver"
Lancelot Kao19bfafb2021-05-25 15:04:57 -050060 else
Charles Boyer0dd80062022-03-17 14:57:50 -050061 echo DVT system "$boardver"
Charles Boyeraf721712022-02-09 09:17:35 -060062 i2cset -y -a -f "${I2C_S1_CLKGEN[0]}" 0x"${I2C_S1_CLKGEN[1]}" 0x05 0x03
Lancelot Kao19bfafb2021-05-25 15:04:57 -050063 fi
64 #These i2c deviecs are already installed on EVT systems
Charles Boyeraf721712022-02-09 09:17:35 -060065 i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 0 1 0xdf i
66 i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 11 1 0x01 i
67 i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN2[0]}" 0x"${I2C_S1_PCIE_CLKGEN2[1]}" 1 2 0x3f 0x0c i
Lancelot Kao19bfafb2021-05-25 15:04:57 -050068fi
Charles Boyera3dc5502021-10-29 16:39:16 -050069
70# Create /run/openbmc for system power files
71mkdir "/run/openbmc"
Ashwin Murali33dc2392021-11-29 15:04:38 -060072
73# Restart psusensor service to enusre that the VBAT sensor doesn't say "no reading" until
74# it's second query after a hotswap
75(sleep 45; systemctl restart xyz.openbmc_project.psusensor.service)&