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) |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 13 | rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 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) |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 17 | rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5)) |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 18 | 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] | 19 | ;; |
| 20 | *) |
| 21 | ;; |
| 22 | esac |
| 23 | } |
Lancelot Kao | d3e767d | 2021-02-22 16:48:42 -0600 | [diff] [blame] | 24 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 25 | fw_rev cpldb |
| 26 | echo "BMC CPLD version : ${ver}" |
| 27 | echo "${ver}" > "${BMC_CPLD_VER_FILE}" |
| 28 | fw_rev cpldm |
| 29 | echo "MB CPLD version : ${ver}" |
Lancelot Kao | 1bdec86 | 2021-05-24 17:01:34 -0500 | [diff] [blame] | 30 | echo "${ver}" > "${MB_CPLD_VER_FILE}" |