blob: d8f681b1ab5fbd3ae9aa3d9507f8372817452acd [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
Charles Boyer498262c2022-07-26 08:45:26 -05005# Provide source directive to shellcheck.
6# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
7source /usr/libexec/kudo-fw/kudo-lib.sh
Charles Boyer0dd80062022-03-17 14:57:50 -05008
Lancelot Kao4357d532021-02-22 15:20:35 -06009BMC_CPLD_VER_FILE="/run/cpld0.version"
10MB_CPLD_VER_FILE="/run/cpld1.version"
11ver=''
12
13function fw_rev() {
14 case $1 in
15 cpldb)
Charles Boyeraf721712022-02-09 09:17:35 -060016 rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x00 i 5))
Grant Williams62fd6302022-04-19 16:24:00 -050017 ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
Lancelot Kao4357d532021-02-22 15:20:35 -060018 ;;
19 cpldm)
Charles Boyeraf721712022-02-09 09:17:35 -060020 rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5))
Grant Williams62fd6302022-04-19 16:24:00 -050021 ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
Lancelot Kao4357d532021-02-22 15:20:35 -060022 ;;
23 *)
24 ;;
25 esac
26}
Lancelot Kaod3e767d2021-02-22 16:48:42 -060027
Lancelot Kao4357d532021-02-22 15:20:35 -060028fw_rev cpldb
29echo "BMC CPLD version : ${ver}"
30echo "${ver}" > "${BMC_CPLD_VER_FILE}"
31fw_rev cpldm
32echo "MB CPLD version : ${ver}"
Lancelot Kao1bdec862021-05-24 17:01:34 -050033echo "${ver}" > "${MB_CPLD_VER_FILE}"