|
43 | 43 | #define CS42L43_MCU_UPDATE_TIMEOUT_US 500000
|
44 | 44 | #define CS42L43_MCU_UPDATE_RETRIES 5
|
45 | 45 |
|
| 46 | +#define CS42L43_MCU_ROM_REV 0x2001 |
| 47 | +#define CS42L43_MCU_ROM_BIOS_REV 0x0000 |
| 48 | + |
46 | 49 | #define CS42L43_MCU_SUPPORTED_REV 0x2105
|
47 | 50 | #define CS42L43_MCU_SHADOW_REGS_REQUIRED_REV 0x2200
|
48 | 51 | #define CS42L43_MCU_SUPPORTED_BIOS_REV 0x0001
|
@@ -709,6 +712,23 @@ static void cs42l43_mcu_load_firmware(const struct firmware *firmware, void *con
|
709 | 712 | complete(&cs42l43->firmware_download);
|
710 | 713 | }
|
711 | 714 |
|
| 715 | +static int cs42l43_mcu_is_hw_compatible(struct cs42l43 *cs42l43, |
| 716 | + unsigned int mcu_rev, |
| 717 | + unsigned int bios_rev) |
| 718 | +{ |
| 719 | + /* |
| 720 | + * The firmware has two revision numbers bringing either of them up to a |
| 721 | + * supported version will provide the disable the driver requires. |
| 722 | + */ |
| 723 | + if (mcu_rev < CS42L43_MCU_SUPPORTED_REV && |
| 724 | + bios_rev < CS42L43_MCU_SUPPORTED_BIOS_REV) { |
| 725 | + dev_err(cs42l43->dev, "Firmware too old to support disable\n"); |
| 726 | + return -EINVAL; |
| 727 | + } |
| 728 | + |
| 729 | + return 0; |
| 730 | +} |
| 731 | + |
712 | 732 | /*
|
713 | 733 | * The process of updating the firmware is split into a series of steps, at the
|
714 | 734 | * end of each step a soft reset of the device might be required which will
|
@@ -745,11 +765,10 @@ static int cs42l43_mcu_update_step(struct cs42l43 *cs42l43)
|
745 | 765 | ((mcu_rev & CS42L43_FW_SUBMINOR_REV_MASK) >> 8);
|
746 | 766 |
|
747 | 767 | /*
|
748 |
| - * The firmware has two revision numbers bringing either of them up to a |
749 |
| - * supported version will provide the features the driver requires. |
| 768 | + * The firmware has two revision numbers both of them being at the ROM |
| 769 | + * revision indicates no patch has been applied. |
750 | 770 | */
|
751 |
| - patched = mcu_rev >= CS42L43_MCU_SUPPORTED_REV || |
752 |
| - bios_rev >= CS42L43_MCU_SUPPORTED_BIOS_REV; |
| 771 | + patched = mcu_rev != CS42L43_MCU_ROM_REV || bios_rev != CS42L43_MCU_ROM_BIOS_REV; |
753 | 772 | /*
|
754 | 773 | * Later versions of the firmwware require the driver to access some
|
755 | 774 | * features through a set of shadow registers.
|
@@ -794,10 +813,15 @@ static int cs42l43_mcu_update_step(struct cs42l43 *cs42l43)
|
794 | 813 | return cs42l43_mcu_stage_2_3(cs42l43, shadow);
|
795 | 814 | }
|
796 | 815 | case CS42L43_MCU_BOOT_STAGE3:
|
797 |
| - if (patched) |
| 816 | + if (patched) { |
| 817 | + ret = cs42l43_mcu_is_hw_compatible(cs42l43, mcu_rev, bios_rev); |
| 818 | + if (ret) |
| 819 | + return ret; |
| 820 | + |
798 | 821 | return cs42l43_mcu_disable(cs42l43);
|
799 |
| - else |
| 822 | + } else { |
800 | 823 | return cs42l43_mcu_stage_3_2(cs42l43);
|
| 824 | + } |
801 | 825 | case CS42L43_MCU_BOOT_STAGE4:
|
802 | 826 | return 0;
|
803 | 827 | default:
|
|
0 commit comments