blob: ea13b17e0011219872f6a1ae720581b68908a902 [file] [log] [blame]
Lancelot Kao96a7ee32021-02-22 18:50:48 -06001#!/bin/bash
2
Charles Boyer2adad362021-11-24 15:58:03 -06003source /usr/libexec/kudo-fw/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
XP Chen164a9c92021-09-14 14:37:46 -050038else
39 echo "DVT or PVT system"
40 # sleep so that FRU and all ipmitool Devices are ready before HOST OS
41 # gpio 143 for HPM_STBY_RST_N do to DC-SCM spec
42 set_gpio_ctrl 143 out 1 # on DVT this became HPM_STBY_RST_N (EVT1 came from CPLD)
43 sleep 5 # for the MUX to get ready
44 set_mux_default
45 # Power control
46 # S0_BMC_OK, GPIO 69
47 set_gpio_ctrl 69 out 1
Charles Boyer9508b342021-11-04 10:37:14 -050048fi
Lancelot Kao19bfafb2021-05-25 15:04:57 -050049
50# Disable CPU 1 CLK when cpu not detected
Lancelot Kao19bfafb2021-05-25 15:04:57 -050051# echo init_once cpu $CPU1_STATUS > /dev/ttyS0
52# echo init_once board $boardver > /dev/ttyS0
53CPU1_STATUS_N=$(get_gpio_ctrl 136)
54if [[ $CPU1_STATUS_N == 1 ]]; then
55 #Execute this only on DVT systems
XP Chen164a9c92021-09-14 14:37:46 -050056 if [[ $boardver -lt 64 ]]; then
Lancelot Kao19bfafb2021-05-25 15:04:57 -050057 echo EVT system $boardver
58 else
59 echo DVT system $boardver
60 i2cset -y -a -f 37 0x68 0x05 0x03
61 fi
62 #These i2c deviecs are already installed on EVT systems
63 i2cset -y -a -f 16 0x6a 0 1 0xdf i
64 i2cset -y -a -f 16 0x6a 11 1 0x01 i
65 i2cset -y -a -f 17 0x67 1 2 0x3f 0x0c i
66fi
Charles Boyera3dc5502021-10-29 16:39:16 -050067
68# Create /run/openbmc for system power files
69mkdir "/run/openbmc"
Ashwin Murali33dc2392021-11-29 15:04:38 -060070
71# Restart psusensor service to enusre that the VBAT sensor doesn't say "no reading" until
72# it's second query after a hotswap
73(sleep 45; systemctl restart xyz.openbmc_project.psusensor.service)&