Lancelot Kao | 96a7ee3 | 2021-02-22 18:50:48 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 3 | # Provide source directive to shellcheck. |
| 4 | # shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh |
Charles Boyer | 2adad36 | 2021-11-24 15:58:03 -0600 | [diff] [blame] | 5 | source /usr/libexec/kudo-fw/kudo-lib.sh |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 6 | |
| 7 | function set_mux_default(){ |
| 8 | # set all mux route to CPU before power on host |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 9 | # 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 Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 17 | # LED control |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 18 | # LED_BMC_LIVE |
| 19 | set_gpio_ctrl LED_BMC_ALIVE 1 |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 20 | |
| 21 | # SPI control |
| 22 | # Send command to CPLD to switch the bios spi interface to host |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 23 | i2cset -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x10 0x00 |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 24 | |
| 25 | } |
| 26 | |
| 27 | # 0 - 63 EVT |
| 28 | # 64 + DVT/PVT |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 29 | boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/"${I2C_MB_CPLD[0]}"-00"${I2C_MB_CPLD[1]}"/CMD00)") |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 30 | |
XP Chen | 0fb270a | 2021-08-26 17:30:19 -0500 | [diff] [blame] | 31 | # On EVT machines, the secondary SCP EEPROM is used. |
| 32 | # Set BMC_I2C_BACKUP_SEL to secondary. |
Charles Boyer | 5db75b8 | 2022-02-09 09:30:36 -0600 | [diff] [blame^] | 33 | if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then |
XP Chen | 0fb270a | 2021-08-26 17:30:19 -0500 | [diff] [blame] | 34 | echo "EVT system. Choosing secondary SCP EEPROM." |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 35 | set_gpio_ctrl BACKUP_SCP_SEL 0 |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 36 | set_mux_default |
| 37 | # Power control |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 38 | # S0_BMC_OK |
| 39 | set_gpio_ctrl S0_BMC_OK 1 |
XP Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 40 | else |
| 41 | echo "DVT or PVT system" |
| 42 | # sleep so that FRU and all ipmitool Devices are ready before HOST OS |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 43 | # 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 Chen | 164a9c9 | 2021-09-14 14:37:46 -0500 | [diff] [blame] | 45 | sleep 5 # for the MUX to get ready |
| 46 | set_mux_default |
| 47 | # Power control |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 48 | # S0_BMC_OK |
| 49 | set_gpio_ctrl S0_BMC_OK 1 |
Charles Boyer | 9508b34 | 2021-11-04 10:37:14 -0500 | [diff] [blame] | 50 | fi |
Lancelot Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 51 | |
| 52 | # Disable CPU 1 CLK when cpu not detected |
Lancelot Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 53 | # echo init_once cpu $CPU1_STATUS > /dev/ttyS0 |
| 54 | # echo init_once board $boardver > /dev/ttyS0 |
Charles Boyer | d7d3423 | 2022-02-09 08:32:22 -0600 | [diff] [blame] | 55 | CPU1_STATUS_N=$(get_gpio_ctrl S1_STATUS_N) |
Lancelot Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 56 | if [[ $CPU1_STATUS_N == 1 ]]; then |
| 57 | #Execute this only on DVT systems |
Charles Boyer | 5db75b8 | 2022-02-09 09:30:36 -0600 | [diff] [blame^] | 58 | if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 59 | echo EVT system "$boardver" |
Lancelot Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 60 | else |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 61 | echo DVT system "$boardver" |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 62 | i2cset -y -a -f "${I2C_S1_CLKGEN[0]}" 0x"${I2C_S1_CLKGEN[1]}" 0x05 0x03 |
Lancelot Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 63 | fi |
| 64 | #These i2c deviecs are already installed on EVT systems |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 65 | 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 Kao | 19bfafb | 2021-05-25 15:04:57 -0500 | [diff] [blame] | 68 | fi |
Charles Boyer | a3dc550 | 2021-10-29 16:39:16 -0500 | [diff] [blame] | 69 | |
| 70 | # Create /run/openbmc for system power files |
| 71 | mkdir "/run/openbmc" |
Ashwin Murali | 33dc239 | 2021-11-29 15:04:38 -0600 | [diff] [blame] | 72 | |
| 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)& |