blob: 533fa8e4ccf5092ed33c4608b417c5d3f319dea2 [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)
Charles Boyeraf721712022-02-09 09:17:35 -060013 rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 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)
Charles Boyeraf721712022-02-09 09:17:35 -060017 rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5))
Charles Boyer0dd80062022-03-17 14:57:50 -050018 ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
Lancelot Kao4357d532021-02-22 15:20:35 -060019 ;;
20 *)
21 ;;
22 esac
23}
Lancelot Kaod3e767d2021-02-22 16:48:42 -060024
Lancelot Kao4357d532021-02-22 15:20:35 -060025fw_rev cpldb
26echo "BMC CPLD version : ${ver}"
27echo "${ver}" > "${BMC_CPLD_VER_FILE}"
28fw_rev cpldm
29echo "MB CPLD version : ${ver}"
Lancelot Kao1bdec862021-05-24 17:01:34 -050030echo "${ver}" > "${MB_CPLD_VER_FILE}"