blob: 2c502980a47fbaa3926fec6ac5d644b3534c9457 [file] [log] [blame]
Lancelot Kao4357d532021-02-22 15:20:35 -06001
2#!/bin/bash
3BMC_CPLD_VER_FILE="/run/cpld0.version"
4MB_CPLD_VER_FILE="/run/cpld1.version"
5ver=''
6
7function fw_rev() {
8 case $1 in
9 cpldb)
10 rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5))
11 ver=$(printf '%d.%d.%d.%d' ${rsp[6]} ${rsp[5]} ${rsp[4]} ${rsp[3]})
12 ;;
13 cpldm)
14 I2C_BUS_DEV=$(readlink "/sys/bus/i2c/devices/4-0077/channel-2" | cut -c 8-)
15 rsp=($(i2cget -y -f -a $I2C_BUS_DEV 0x76 0x00 i 5))
16 ver=$(printf '%d.%d.%d.%d' ${rsp[6]} ${rsp[5]} ${rsp[4]} ${rsp[3]})
17 ;;
18 *)
19 ;;
20 esac
21}
22fw_rev cpldb
23echo "BMC CPLD version : ${ver}"
24echo "${ver}" > "${BMC_CPLD_VER_FILE}"
25fw_rev cpldm
26echo "MB CPLD version : ${ver}"
27echo "${ver}" > "${MB_CPLD_VER_FILE}"