drivers: rtc: stm32: Fixes RTC issues related to device runtime pm
When device runtime pm is enabled, Backup Domain protection is active most of the time. RTC driver need this protection to be disabled in order to set the time or calibration. This fix disable the protection in set time and set calibration functions. Fixes: 62843 Signed-off-by: Petr Hlineny <development@hlineny.cz>
This commit is contained in:
parent
21e37498e3
commit
4a4543569e
1 changed files with 24 additions and 0 deletions
|
@ -181,6 +181,10 @@ static int rtc_stm32_init(const struct device *dev)
|
|||
|
||||
err = rtc_stm32_configure(dev);
|
||||
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_DisableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -208,10 +212,18 @@ static int rtc_stm32_set_time(const struct device *dev, const struct rtc_time *t
|
|||
}
|
||||
|
||||
LOG_INF("Setting clock");
|
||||
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
LL_RTC_DisableWriteProtection(RTC);
|
||||
|
||||
err = rtc_stm32_enter_initialization_mode(true);
|
||||
if (err) {
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_DisableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
k_mutex_unlock(&data->lock);
|
||||
return err;
|
||||
}
|
||||
|
@ -237,6 +249,10 @@ static int rtc_stm32_set_time(const struct device *dev, const struct rtc_time *t
|
|||
|
||||
LL_RTC_EnableWriteProtection(RTC);
|
||||
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_DisableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
k_mutex_unlock(&data->lock);
|
||||
|
||||
return err;
|
||||
|
@ -359,12 +375,20 @@ static int rtc_stm32_set_calibration(const struct device *dev, int32_t calibrati
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
LL_RTC_DisableWriteProtection(RTC);
|
||||
|
||||
MODIFY_REG(RTC->CALR, RTC_CALR_CALP | RTC_CALR_CALM, calp | calm);
|
||||
|
||||
LL_RTC_EnableWriteProtection(RTC);
|
||||
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_DisableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue