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 |
Charles Boyer | 498262c | 2022-07-26 08:45:26 -0500 | [diff] [blame] | 5 | # Provide source directive to shellcheck. |
| 6 | # shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh |
| 7 | source /usr/libexec/kudo-fw/kudo-lib.sh |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 8 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 9 | BMC_CPLD_VER_FILE="/run/cpld0.version" |
| 10 | MB_CPLD_VER_FILE="/run/cpld1.version" |
| 11 | ver='' |
| 12 | |
| 13 | function fw_rev() { |
| 14 | case $1 in |
| 15 | cpldb) |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 16 | rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x00 i 5)) |
Grant Williams | 62fd630 | 2022-04-19 16:24:00 -0500 | [diff] [blame] | 17 | ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}") |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 18 | ;; |
| 19 | cpldm) |
Charles Boyer | af72171 | 2022-02-09 09:17:35 -0600 | [diff] [blame] | 20 | rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5)) |
Grant Williams | 62fd630 | 2022-04-19 16:24:00 -0500 | [diff] [blame] | 21 | ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}") |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 22 | ;; |
| 23 | *) |
| 24 | ;; |
| 25 | esac |
| 26 | } |
Lancelot Kao | d3e767d | 2021-02-22 16:48:42 -0600 | [diff] [blame] | 27 | |
Lancelot Kao | 4357d53 | 2021-02-22 15:20:35 -0600 | [diff] [blame] | 28 | fw_rev cpldb |
| 29 | echo "BMC CPLD version : ${ver}" |
| 30 | echo "${ver}" > "${BMC_CPLD_VER_FILE}" |
| 31 | fw_rev cpldm |
| 32 | echo "MB CPLD version : ${ver}" |
Lancelot Kao | 1bdec86 | 2021-05-24 17:01:34 -0500 | [diff] [blame] | 33 | echo "${ver}" > "${MB_CPLD_VER_FILE}" |