blob: cd80674c21d7e2927873d38e6230c4ae1b0406cf [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
9 # BMC_CPU_RTC_I2C_SEL #120
10 set_gpio_ctrl 120 out 1
11 # BMC_CPU_DDR_I2C_SEL #84
12 set_gpio_ctrl 84 out 1
13 # BMC_CPU_EEPROM_I2C_SEL #85
14 set_gpio_ctrl 85 out 1
15 # BMC_CPU_PMBUS_SEL #86
16 set_gpio_ctrl 86 out 1
17 # LED control
18 # LED_BMC_LIVE #7
19 set_gpio_ctrl 7 out 1
20
21 # SPI control
22 # Send command to CPLD to switch the bios spi interface to host
23 i2cset -y -f -a 13 0x76 0x10 0x00
24
25}
26
27# 0 - 63 EVT
28# 64 + DVT/PVT
Charles Boyer0dd80062022-03-17 14:57:50 -050029boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/34-0076/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.
XP Chen164a9c92021-09-14 14:37:46 -050033if [[ $boardver -lt 64 ]]; then
XP Chen0fb270a2021-08-26 17:30:19 -050034 echo "EVT system. Choosing secondary SCP EEPROM."
35 set_gpio_ctrl 168 out 0
XP Chen164a9c92021-09-14 14:37:46 -050036 set_mux_default
37 # Power control
38 # S0_BMC_OK, GPIO 69
39 set_gpio_ctrl 69 out 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
43 # gpio 143 for HPM_STBY_RST_N do to DC-SCM spec
44 set_gpio_ctrl 143 out 1 # on DVT this became HPM_STBY_RST_N (EVT1 came from CPLD)
45 sleep 5 # for the MUX to get ready
46 set_mux_default
47 # Power control
48 # S0_BMC_OK, GPIO 69
49 set_gpio_ctrl 69 out 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
55CPU1_STATUS_N=$(get_gpio_ctrl 136)
56if [[ $CPU1_STATUS_N == 1 ]]; then
57 #Execute this only on DVT systems
XP Chen164a9c92021-09-14 14:37:46 -050058 if [[ $boardver -lt 64 ]]; 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"
Lancelot Kao19bfafb2021-05-25 15:04:57 -050062 i2cset -y -a -f 37 0x68 0x05 0x03
63 fi
64 #These i2c deviecs are already installed on EVT systems
65 i2cset -y -a -f 16 0x6a 0 1 0xdf i
66 i2cset -y -a -f 16 0x6a 11 1 0x01 i
67 i2cset -y -a -f 17 0x67 1 2 0x3f 0x0c i
68fi
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)&