Use LL_RTC_EnterInitMode and LL_RTC_DisableInitMode instead
of rtc_stm32_enter_initialization_mode and
rtc_stm32_leave_initialization_mode.
Signed-off-by: Petr Hlineny <development@hlineny.cz>
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 change marks each instance of the 'rtc_driver_api' as 'static const'.
The rationale is that 'rtc_driver_api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
rtc_get_time() on STM32 does not implement the -ENODATA return code.
This prevents testing the initialisation status of the RTC.
Fixed by reading INITS flag and adding a error path in
rtc_stm32_get_time().
Signed-off-by: Adrien Bruant <adrien.bruant@aalberts-hfc.com>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The Cat.1 STM32L1 MCUs do not provide the subsecond feature. This disable
subsecond related code for these MCUs.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
STM32 BBRAM depends on RTC to work. This changes STM32 RTC init stage to
PRE_KERNEL_1 to allow RTC driver to initialize before BBRAM driver.
Some adjustments are made so that kernel API is not used during the init
procedure.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
This driver only supports a single instance. This commit cleans up the
device definition and indicates this.
Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
Assert the source clock is defined in the device tree to ensure the
reference is valid.
Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
The DT_INST_CLOCKS_CELL macro takes as the first argument the device
instance and not the cell index. This change correctly gets the second
index of the first device as intended.
Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
STM32F2 and STM32L1 Cat. 1 only provide the coarse calibration feature
which is not supported by the code yet.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
This replaces the verbose LL_RTC_CONVERT_BCD2BIN and LL_RTC_CONVERT_BIN2BCD
by the bcd2bin and bin2bcd Zephyr provided equivalent
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
This adds mutex a lock in rtc_stm32_set_time and rtc_stm32_get_time to
ensure consistent data reading. Also performs register reading in a single
operation in rtc_stm32_get_calibration for the same reason.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
LL_RTC_Init() internally uses LL_RTC_EnterInitMode() wich uses a blocking
while loop. This rewrite uses the less CPU time wasteful local
rtc_stm32_enter_initialization_mode() instead. As a side effect
LL_RTC_InitTypeDef in rtc_stm32_config is not needed anymore.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
Calling LL_RTC_Init causes the RTC to stop while being configured thus
inducing time drift. This commit avoids doing it at each reset if the RTC
is already properly configured.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
As shadow registers bypass is enabled, an erroneous reading may occur at
each day or second increment. This commit fixes this issue.
Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
For now clock can be read and written.
Clock can be set in full iso8601 time format, like 2023-12-24T12:45:56
or by just providing either data or time
Alarms not accessible
Signed-off-by: Kim Bøndergaard <kim.bondergaard@prevas.dk>
This commit adds input clock selection to the RTC driver. This
is required to allow for the real hardware to operate. The
QEMU emulated hardware ignores the input clock settings.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
The MC146818 driver was not properly initialized
by the driver, interrupts where not handled correctly,
and the alarm feature was not implemented properly.
This commit fixes these issues, while removing some
code which became redundant as the MC146818 driver
was patched.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
STM32F1 series RTC is not compatible with other STM32F1 series,
and it uses a different LL API.
Current implementation of the driver doesn't take this into account,
so we need to explicitly exclude STM32F1 series support until
some changes are made.
Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
STM32 RTC driver for the new RTC API.
Can't coexist with old COUNTER based RTC
Though supported by HW, RTC_ALARM still to be supported by driver
Signed-off-by: Kim Bøndergaard <kim.bondergaard@prevas.dk>
That's correct. We are still fixing the Y2K bug in 2023 \o/
* write century to RAM register 0x32
* ensure year register is in [0,99] (inclusive)
Aside from that, there were a few other errors in the driver.
* translate epoch-centric RTC API year to begin at 1900
* fix off-by-one error with month limit
* fix off-by-one error with wday
* fix off-by-one-hundred error with year limit
* adjust timeptr values in rtc_mc146818_validate_time()
* adjust timeptr values in rtc_mc146818_validate_alarm()
With the above, the testsuite passes!
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Added RTC driver that supports Motorola MC146818B
Enabled RTC set/get time and alarm, alarm callback
and update callback.
Counter and RTC uses same hardware in case of
Motorola MC146818, so they can't be used at a time.
Updated stand-alone mc146818 counter dts instances
to support rtc and counter with same compatible
string of "motorola,mc146818" on ia32, atom,
apollo_lake, elhart_lake and raptor_lake platforms.
Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>