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 | |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 3 | # Disable check for splitting |
| 4 | # shellcheck disable=SC2207 |
| 5 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 6 | BMC_CPLD_VER_FILE="/run/cpld0.version" |
| 7 | MB_CPLD_VER_FILE="/run/cpld1.version" |
| 8 | ver='' |
| 9 | |
| 10 | function fw_rev() { |
| 11 | case $1 in |
| 12 | cpldb) |
| 13 | rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5)) |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 14 | 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] | 15 | ;; |
| 16 | cpldm) |
| 17 | I2C_BUS_DEV=$(readlink "/sys/bus/i2c/devices/4-0077/channel-2" | cut -c 8-) |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 18 | 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 Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 20 | ;; |
| 21 | *) |
| 22 | ;; |
| 23 | esac |
| 24 | } |
Lancelot Kao | d3e767d | 2021-02-22 16:48:42 -0600 | [diff] [blame] | 25 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 26 | fw_rev cpldb |
| 27 | echo "BMC CPLD version : ${ver}" |
| 28 | echo "${ver}" > "${BMC_CPLD_VER_FILE}" |
| 29 | fw_rev cpldm |
| 30 | echo "MB CPLD version : ${ver}" |
Lancelot Kao | 1bdec86 | 2021-05-24 17:01:34 -0500 | [diff] [blame] | 31 | echo "${ver}" > "${MB_CPLD_VER_FILE}" |