feat(st): add a function to clear the FWU trial state counter

Add an API stm32_clear_fwu_trial_boot_cnt() function to clear the
trial state counter. This is called in the corner case scenario when
the active index is in an Invalid state, thus needing a reset of the
trial state counter.

Change-Id: I2980135da88d0d947c222655c7958b51eb572d69
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
This commit is contained in:
Sughosh Ganu 2024-02-20 14:17:57 +05:30
parent 26aab79560
commit 6e99fee43e
2 changed files with 10 additions and 0 deletions

View file

@ -142,6 +142,7 @@ void stm32_display_board_info(uint32_t board_id);
void stm32mp1_fwu_set_boot_idx(void); void stm32mp1_fwu_set_boot_idx(void);
uint32_t stm32_get_and_dec_fwu_trial_boot_cnt(void); uint32_t stm32_get_and_dec_fwu_trial_boot_cnt(void);
void stm32_set_max_fwu_trial_boot_cnt(void); void stm32_set_max_fwu_trial_boot_cnt(void);
void stm32_clear_fwu_trial_boot_cnt(void);
#endif /* PSA_FWU_SUPPORT */ #endif /* PSA_FWU_SUPPORT */
#endif /* STM32MP_COMMON_H */ #endif /* STM32MP_COMMON_H */

View file

@ -714,4 +714,13 @@ void stm32_set_max_fwu_trial_boot_cnt(void)
TAMP_BOOT_FWU_INFO_CNT_MSK); TAMP_BOOT_FWU_INFO_CNT_MSK);
clk_disable(RTCAPB); clk_disable(RTCAPB);
} }
void stm32_clear_fwu_trial_boot_cnt(void)
{
uintptr_t bkpr_fwu_cnt = tamp_bkpr(TAMP_BOOT_FWU_INFO_REG_ID);
clk_enable(RTCAPB);
mmio_clrbits_32(bkpr_fwu_cnt, TAMP_BOOT_FWU_INFO_CNT_MSK);
clk_disable(RTCAPB);
}
#endif /* PSA_FWU_SUPPORT */ #endif /* PSA_FWU_SUPPORT */