blob: 23a65c1bd0f92083b87fd4a8310ac63d29e8722f [file] [log] [blame]
Lancelot Kao4357d532021-02-22 15:20:35 -06001#!/bin/bash
Lancelot Kao1bdec862021-05-24 17:01:34 -05002
Charles Boyer0dd80062022-03-17 14:57:50 -05003# Disable check for splitting
4# shellcheck disable=SC2207
5
Lancelot Kao4357d532021-02-22 15:20:35 -06006BMC_CPLD_VER_FILE="/run/cpld0.version"
7MB_CPLD_VER_FILE="/run/cpld1.version"
8ver=''
9
10function fw_rev() {
11 case $1 in
12 cpldb)
13 rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5))
Charles Boyer0dd80062022-03-17 14:57:50 -050014 ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
Lancelot Kao4357d532021-02-22 15:20:35 -060015 ;;
16 cpldm)
17 I2C_BUS_DEV=$(readlink "/sys/bus/i2c/devices/4-0077/channel-2" | cut -c 8-)
Charles Boyer0dd80062022-03-17 14:57:50 -050018 rsp=($(i2cget -y -f -a "$I2C_BUS_DEV" 0x76 0x00 i 5))
19 ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
Lancelot Kao4357d532021-02-22 15:20:35 -060020 ;;
21 *)
22 ;;
23 esac
24}
Lancelot Kaod3e767d2021-02-22 16:48:42 -060025
Lancelot Kao4357d532021-02-22 15:20:35 -060026fw_rev cpldb
27echo "BMC CPLD version : ${ver}"
28echo "${ver}" > "${BMC_CPLD_VER_FILE}"
29fw_rev cpldm
30echo "MB CPLD version : ${ver}"
Lancelot Kao1bdec862021-05-24 17:01:34 -050031echo "${ver}" > "${MB_CPLD_VER_FILE}"