Read the idle timer counter value after getting interrupt status and
top value to ensure more accurate timing measurements when exiting
low-power mode.
Signed-off-by: Holt Sun <holt.sun@nxp.com>
Clear pending SysTick interrupt before entering low-power mode when
CONFIG_CORTEX_M_SYSTICK_RESET_BY_LPM is enabled. A pending interrupt
can inhibit LPM entry or cause immediate wakeup. This is safe since
cycle_count was already updated.
Also improve RESET_BY_LPM Kconfig help text.
Signed-off-by: Holt Sun <holt.sun@nxp.com>
- Fix incorrect data type that caused the timer to malfunction
after running for a period of time
Signed-off-by: Phuc Pham <phuc.pham.xr@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
Add support for configuring the SysTick clock source via devicetree
using a new `clock-source` property. This allows selecting between
the external reference clock (0) and the processor clock (1).
Previously, the driver always set the CLKSOURCE bit, forcing the use
of the processor clock. This change introduces a helper function
`systick_ctrl_clksource_flag_from_dt()` that reads the devicetree
property and returns the appropriate CTRL register flag.
The CTRL register is now programmed deterministically using direct
assignment instead of `|=` to ensure the CLKSOURCE bit is properly
cleared when switching to external clock, preventing potential
interrupt storms when CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC reflects
the external clock rate.
If the property is absent, the driver defaults to legacy behavior
(processor clock).
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Use API for registering synchronous interrupts. It reduced interrupt
latency due to NVM memory wake up.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Fixed the sys_clock_announce to be outside of spinlock context to
resolve the issues related to invalid spinlock when CONFIG_PM is
enabled
Signed-off-by: Merin George <merin.george@infineon.com>
Restore the clock source and exception bits in the CTRL register after
waking from low-power modes that reset SysTick. Also reconfigure the
interrupt priority.
Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
CONFIG_XLNX_PSTTC_TIMER_INDEX has been unused since commit 57784fb9d5
(v2.3 era), which switched to using the `DT_INST_` macro and defaulted to
the first instance via `DT_INST_REG_ADDR(0)`.
Remove the obsolete and broken CONFIG_XLNX_PSTTC_TIMER_INDEX.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Drop cat1 from the binding files to enable reuse by other
category devices as well.
Fixes#99174
Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
Most of Espressif drivers ISRs are already running in IRAM area, except
those in this PR. Move ISRs accordingly so we avoid any
interrupt miss when cache is disabled.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The GRTC timer, typically used as sys clock on newer nordic chips,
is currently tightly coupled to the CLOCK_CONTROL_NRF drivers though
not being dependent on it. The GRTC and its device driver is
independent from CLOCK_CONTROL, its clock requirements are managed
by hardware, based on its clock source selection.
This commit moves the clock source selection to the GRTC driver, and
removes the hard coupling to the CLOCK_CONTROL drivers. To preserve
backwards compatibility, if CLOCK_CONTROL_NRF_K32SRC_RC is selected,
GRTC will default to LFLPRC.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Add support for resetting the LPTIM peripheral to its default state
on initialization. This ensures that any previous configurations
do not interfere with the new settings.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Introduce CONFIG_MCUX_OS_TIMER_MIN_DELAY to allow the configuration
of the minimum delay cycles.
Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>
Improve the logic for detecting counter wrap-around events when exiting
low power mode.
Add idle_timer_alarm_ticks variable to track alarm configuration at LPM
entry. Implement comprehensive wrap detection that considers:
- Counter overflow (pre > post)
- Alarm pending with same pre/post values
- Alarm pending when pre + alarm_ticks would exceed counter top value
This ensures accurate time calculation across all counter wrap scenarios
during low power mode transitions.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
If the event timer or free-run timer is close to expiration when
system enters idle with I2C target DMA mode enabled, the memory
and CPU clocks may become unsynchronized after wakeup. This
causes CPU to fetch incorrect data and eventually trigger SoC
watchdog timeout.
Due to this hardware limitation, SoC should skip entering idle
mode if the remaining timer value is less than 150µs(safe margin).
Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
Preprocessor evaluates CYC_PER_TICK as zero in condition
`(COUNTER_MAX / CYC_PER_TICK) == 1` when
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME is defined.
This commit skips the check when
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME is defined.
Fixes: #100040
Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
New nrfx release contains major rework of nrfx drivers
instantiation making it easier to integrate with dts nodes.
Now, nrfx driver instances can no longer be `const`
because they contain driver runtime state.
Additionally, all nrfx drivers return `errno` error codes
instead of deprecated `nrfx_err_t`.
Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
This commit adds a prompt to the Kconfig file to make
CORTEX_M_SYSTICK_RESET_BY_LPM option more visible to users
configuring the driver.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
When low-power mode timer is enabled, a counter alarm is set on the
idle timer before entering low-power mode. The counter API requires
a non-NULL callback function for the alarm. This commit adds a stub
callback function to satisfy the API requirement.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
The CYC_TO_TICK macro converts hardware cycles to
system ticks. Smartbond timers can be driven by XTAL32,
RC32K, or RCX sources. At the application level,
tests use milliseconds, which introduces rounding when
converting to hardware cycles.
Previously, CYC_TO_TICK rounded up, causing sys_clock_elapsed()
to sometimes report one extra tick. This value, propagated
through z_add_timeout() via elapsed(), was then used by tests
to determine the current time and the next wake-up point.
As a result, sleep duration was shortened by one tick,
leading to an unnecessary extra wake-up detected by the test.
With this fix, sys_clock_elapsed() no longer reports ticks
that have not fully elapsed, ensuring accurate sleep timing.
Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg.xr@bp.renesas.com>
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.
Signed-off-by: Josuah Demangeon <me@josuah.net>
This driver was renamed in
078fef4ab5c5f8ff993a774778588a50794b886a
And with it the old kconfig option was deprecated for 4.2.
Let's remove this option now
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Update the custom vector table to have timer2_isr that
is used for kernel system timer.
While test passes test immediate crashes afterwards due to
missing handler for non-SysTick interrupt.
Now custom interrupt table has additional interrupt handler
to prevent crash.
timer2_isr is no longer static that should not result in
any conflict.
Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg.xr@bp.renesas.com>
Speed up execution of the interrupt handler and sys_clock_set_timeout().
Sys_clock_set_timeout() can be called in two scenarios: from previous
timeout expiration handler or freely. If the former case fast path
can be used since CC value in the GRTC register just expired and it
can be used as a reference for CCADD setting. This is only a single
register write so it's much faster. In the latter a longer procedure
is applied which also happens in two variants. If value which is
set in CC is further in the future (e.g. K_FOREVER was set before) then
CC can be safely overwritten with a new value without a risk of
triggering unexpected COMPARE event. If value in CC is earlier than
the new CC value (if earlier timeout was aborted) then there is a
risk of COMPARE event happening while it is being overwritten.
That case requires long and safer procedure of setting CC.
Update hal_nordic with changes in the nrfx_grtc driver which are
needed for nrf_grtc_timer changes.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
When system was configured to use smartbond_timer with
tick-based kernel, timer interrupt could fire only
once and then time would not advance.
Now when tick-based kernel is chosen timer2_isr()
schedules that it should be fired at next tick.
Timer comparator calculation code was extracted
from existing sys_clock_set_timeout() function
without change so it can be used for tick-less
and tick-based kernel.
Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg.xr@bp.renesas.com>
Remove redundant enabling of NRF_RTC_TIMER in SoC specific files
and replace it with default y in the NRF_RTC_TIMER definition.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Clarify that the AMD Xilinx PS Triple Timer Counter (TTC) is used in both
Zynq UltraScale+ MPSoC (ZynqMP) and Versal platforms. Update the device
tree binding description and Kconfig accordingly.
Also, rephrase the Kconfig help text to fix grammar issues and improve
clarity.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
The previous implementation had a logical error where the prescaler
could never be bypassed due to incorrect use of BIT() macro:
This patch fixes the issue by:
1. Remove BIT() wrapper from LPTMR_PRESCALER macro to use raw
devicetree property value
2. Update bypass logic to check for zero value explicitly
3. Map DTS values to hardware register values correctly:
- prescale_glitch_filter = 0 -> bypass prescaler
- prescale_glitch_filter = n -> divide by 2^n,
using register value (n-1)
The devicetree semantic is now:
- prescale_glitch_filter = <0>: No prescaling (bypass)
- prescale_glitch_filter = <1>: Divide by 2
- prescale_glitch_filter = <2>: Divide by 4
- prescale_glitch_filter = <3>: Divide by 8
- And so on...
Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
The LPTIM timer driver previously had hardcoded assumptions about
using LPTIM1 or LPTIM3, which prevented it from working with other
LPTIM instances like LPTIM2, LPTIM4, LPTIM5, and LPTIM6.
This change makes the driver work with any LPTIM instance by:
1. Adding lptim_enable_autonomous_mode() function that dynamically
detects which LPTIM instance is in use and enables autonomous
mode for instances that support it (LPTIM1, LPTIM3, LPTIM4).
LPTIM2, LPTIM5, LPTIM6 do not support autonomous mode.
2. Adding lptim_freeze_during_debug() function that handles debug
freeze configuration for all LPTIM instances across different
APB buses:
- LPTIM1: APB1_GRP1, APB3_GRP1, or APB7_GRP1
- LPTIM2: APB1_GRP1, APB1_GRP2, APB3_GRP1, or APB4_GRP1
- LPTIM3: APB1_GRP2, APB3_GRP1, or APB4_GRP1
- LPTIM4: APB3_GRP1 or APB4_GRP1
- LPTIM5: APB3_GRP1
- LPTIM6: APB3_GRP1
Both functions use DT_REG_ADDR() to compare the base address of the
configured LPTIM instance at compile time, ensuring zero runtime
overhead.
Tested on STM32U5A5 with all four LPTIM instances (LPTIM1-4).
Signed-off-by: Kamil Krzyżanowski <kamnxt@kamnxt.com>
Use the `silabs,sleeptimer` chosen node instead of a devicetree
compatible to select the devicetree node for the RTC.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
8498c39e13 seems to have introduce
an incorrect dependency which prevents the RTC timer from
been built if any of the RTC's are enabled.
It should only depend on the rtc1.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In eb785ef, "prescaler" has been deprecated and
"prescale_glitch_filter" is used for prescale setting.
This patch removes "prescaler" parameter and use
"prescale_glitch_filter" to simplify code and fix build
error caused by "precsaler" parameter.
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
The Kconfig symbols for selecting HAL content should be part
of the HAL module integration, not defined by the SoC. Split the
symbols between the Series 0/1 Gecko HAL and Series 2 SiSDK HAL
when moving them.
For now, the Series 0/1 HAL symbols retain their name, while new
names consistent with the symbols already defined in the module
integration layer are used for the Series 2 HAL.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Kconfig symbols for selecting HAL content should be part of the
HAL module integration, not defined in the SoC tree. Define the
sleeptimer symbol for WiSeConnect and SiSDK since both use it.
In the future, WiSeConnect should include the SiSDK configuration
and reuse it instead of redefining everything itself. This is a
larger scale refactor that this commit doesn't start tackling.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
There is no need to disable systimer in application level
as the restart procedure automatically handles it.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Remove the possibility to configure the LPTIM timer clock source
through Kconfig. The deprecation warning was added 3 years ago in
Zephyr 3.2 by commit bbac316be7; more
than enough time has elapsed for this option to be removed.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
GRTC is used by the logger, so it must be initialized
as early as possible. On the other hand, clock requests
are allowed once the clock control API has been initialized.
This PR introduces a two-stage GRTC initialization to meet
these requirements.
Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
Provide PM support, specifically suspend-to-ram, for STM32WB0x.
Enable STM32_RADIO_TIMER Kconfig parameter when PM is set.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Use radio timer as the system timer when Bluetooth is used.
Modify CMakeLists.txt to compile radio timer driver when
STM32WB0_RADIO_TIMER is enabled.
Remove the common parts from hci_stm32wb0.c that are present
in the radio timer driver.
Set and retrieve the appropriate value for SYS_CLOCK_TICKS_PER_SEC and
SYS_CLOCK_HW_CYCLES_PER_SEC respectively.
Define radio_timer node and its properties.
Enable radio_timer node in nucleo_wb0x boards.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>