Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 1 | #!/bin/bash |
Lancelot Kao | 1bdec86 | 2021-05-24 17:01:34 -0500 | [diff] [blame] | 2 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 3 | BMC_CPLD_VER_FILE="/run/cpld0.version" |
| 4 | MB_CPLD_VER_FILE="/run/cpld1.version" |
| 5 | ver='' |
| 6 | |
| 7 | function fw_rev() { |
| 8 | case $1 in |
| 9 | cpldb) |
| 10 | rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5)) |
Mohaimen Alsamarai | 12495de | 2021-06-29 14:15:33 -0500 | [diff] [blame] | 11 | ver=$(printf '%d.%d.%d.%d' ${rsp[5]} ${rsp[4]} ${rsp[3]} ${rsp[2]}) |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 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)) |
Mohaimen Alsamarai | 12495de | 2021-06-29 14:15:33 -0500 | [diff] [blame] | 16 | ver=$(printf '%d.%d.%d.%d' ${rsp[5]} ${rsp[4]} ${rsp[3]} ${rsp[2]}) |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 17 | ;; |
| 18 | *) |
| 19 | ;; |
| 20 | esac |
| 21 | } |
Lancelot Kao | d3e767d | 2021-02-22 16:48:42 -0600 | [diff] [blame] | 22 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 23 | fw_rev cpldb |
| 24 | echo "BMC CPLD version : ${ver}" |
| 25 | echo "${ver}" > "${BMC_CPLD_VER_FILE}" |
| 26 | fw_rev cpldm |
| 27 | echo "MB CPLD version : ${ver}" |
Lancelot Kao | 1bdec86 | 2021-05-24 17:01:34 -0500 | [diff] [blame] | 28 | echo "${ver}" > "${MB_CPLD_VER_FILE}" |