Commit graph

991 commits

Author SHA1 Message Date
Aksel Skauge Mellbye
a13c810f3a drivers: timer: silabs_sleeptimer: Use chosen node
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>
2025-10-22 18:07:07 -04:00
Alberto Escolar Piedras
dd06e7ec72 drivers timer nrf_rtc: Fix dependency
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>
2025-10-22 15:56:04 +03:00
Felix Wang
c11cf177c7 drivers: timer: Use prescale_glitch_filter for prescale setting
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>
2025-10-22 09:04:33 +02:00
Aksel Skauge Mellbye
440755bd9e soc: silabs: Move Kconfig symbols for HAL selection to HAL
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>
2025-10-22 09:03:15 +02:00
Aksel Skauge Mellbye
4602300a27 soc: silabs: Move Kconfig symbol for sleeptimer to HAL
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>
2025-10-22 09:03:15 +02:00
Stoyan Bogdanov
6bb5378fbe drivers: timer: cc23x0: Add option to select between RTC and SYSTIM
Add choice menu where could be selected between RTC or SYSTIM for
system timer.

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-10-16 22:31:52 -04:00
Stoyan Bogdanov
ca6b18d808 drivers: timer: Add RTC timer driver for cc23x0
Add support for RTC as timer for cc23x0 SoC.

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-10-16 22:31:52 -04:00
Sylvio Alves
8d209b0926 timer: espressif: keep alarm disable support only for mcuboot
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>
2025-10-16 17:15:41 +03:00
Mathieu Choplain
0a5a607c77 drivers: timer: stm32_lptim: drop clock source configuration via Kconfig
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>
2025-10-16 17:10:11 +03:00
Michał Bainczyk
aa5b47634f drivers: timer: nrf_grtc_timer: use a function for cc enable check
Instead of checking register values directly, use a function from
nrfx that does this.

Signed-off-by: Michał Bainczyk <michal.bainczyk@nordicsemi.no>
2025-10-08 17:47:32 +03:00
Adam Kondraciuk
60af28e3f5 drivers: timer: nrf_grtc: Move GRTC initialization to early init
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>
2025-10-06 20:02:28 +03:00
Ali Hozhabri
85318a9e19 soc: st: stm32: Provide PM support for STM32WB0x
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>
2025-10-03 21:15:08 -04:00
Ali Hozhabri
bdb41c0ebd drivers: timer: Enable STM32WB0_RADIO_TIMER Kconfig parameter
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>
2025-10-03 21:15:08 -04:00
Ali Hozhabri
84f7098f8f drivers: timer: Provide radio timer driver for STM32WB0x SoCs
Provide radio timer driver for STM32WB0x SoCs.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2025-10-03 21:15:08 -04:00
Andrew Perepech
a75d6a40b6 drivers/timer: Fix build error when run by twister
Fix undefined reference to z_sys_timer_irq_for_test

Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
2025-09-30 19:36:47 +02:00
Andrew Perepech
fc8c17fd23 drivers/timer: Fix timer IRQ enable bit on MT818X and MT8195
MT818X and MT8195 use the same timer IRQ enable bit as MT8196

Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
2025-09-30 19:36:47 +02:00
Andrew Perepech
87a449762d drivers/timer: Fix timer clock source initialization for MT818X
Fix timer clock source initialization for MT8188, MT8186 platform.
Add 26Mhz define that is specific for MT818X.

Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
2025-09-30 19:36:47 +02:00
Benjamin Cabé
e29c173251 driver: timer: ti_dmtimer: TI DM Timer header should not be public
ti_dmtimer.h contains mask definitions only used internally by the
driver. Make it a private header.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-23 12:07:29 -04:00
Hoang Nguyen
9ceacc9317 drivers: timers: Add system timer support for RZ/V2L, RZ/A3UL
Add system timer driver support for RZ/V2L, RZ/A3UL

Signed-off-by: Hoang Nguyen <hoang.nguyen.jx@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>

drivers: timers: Improve ISR Prototype for Renesas RZ
2025-09-23 09:39:35 +01:00
Mahesh Mahadevan
efe34d04d2 drivers: nxp: Use a MACRO to enable Wakeup signals
Switch to using the new NXP_ENABLE_WAKEUP_SIGNAL and
NXP_DISABLE_WAKEUP_SIGNAL macros to avoid adding
platform specific calls in the Zephyr drivers.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-09-20 11:09:00 +02:00
Jamie McCrae
8498c39e13 drivers: Fix some Kconfig bleeds
Fixes instances of Kconfig options appearing for completely
irrelevant builds

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-09-18 13:50:33 -04:00
Mahesh Mahadevan
a053665817 drivers: timer: mcux_os_timer: Improve the overflow handling logic
Clear the remanining ticks value.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-09-17 08:44:31 +02:00
Rafal Dyla
3cf2627d85 arch: riscv: Support for Direct ISRs for RISCV targets
Added missing features and configuration to support Direct ISRs

Signed-off-by: Rafal Dyla <rafal.dyla@nordicsemi.no>
2025-09-15 14:44:24 +02:00
Kunihiko Hayashi
29956b0b24 drivers: arm_arch_timer: Move timer enablement after comparison value set
The timer is enabled before comparison value is set, which can lead to
unexpected behavior if the registers contain uninitialized values.

Should call arm_arch_timer_enable() after arm_arch_timer_set_compare().

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
2025-09-13 21:23:06 -04:00
Hao Luo
7d09c83fc6 drivers: timer: fix ambiq stimer MIN_DELAY incorrect define
Change to use HAL macro instead of magic number.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-09-11 09:54:12 +02:00
Khoa Nguyen
db981f65e9 drivers: Add assign event for current core for all Renesas drivers
Add assign event for current core for all Renesas drivers

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-09-11 09:53:13 +02:00
Benjamin Cabé
c820085376 drivers: timer: stm32: fix typo in kconfig help
Corrected the LSE frequency value from 32678 to 32768.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-02 15:54:48 +02:00
Quy Tran
eb61b44ee9 drivers: cmt: Update cmt driver for Renesas RX
- Update sys_clock_set_timeout function for Renesas RX using CMT
- Remove some unused definitions

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
2025-08-29 09:00:50 +02:00
Raffael Rostagno
36c528316d drivers: systimer: esp32h2: Add support
Add systimer support for ESP32-H2.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-08-26 22:07:36 +02:00
Mahesh Mahadevan
9cb38ecf58 drivers: mcux_os_timer: Fix build failure
z_nxp_os_timer_ignore_timer_wakeup() was only added
when Standby mode was enabled. Move this function
out of the conditional section.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-08-24 00:07:55 -04:00
Declan Snyder
40edefb4cf drivers: mcux_os_timer: Optimize counter timeout set
We can both optimize and clean up the code by using short circuit logic
and static variables instead of stack variables.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-22 06:52:42 +02:00
Declan Snyder
513b1645e0 drivers: mcux_os_timer: Refactor ISR
Refactor ISR by:
1) making a helper function to put the tickful calculation in, to reduce
   an indentation level and cognitively separate this case while reading
2) Rewrite the calculations to simplify them. More info on that below.

Math changes:
- In the ISR, there was a variable called "now" which represented the
current cycle count of the timer. last_count was updated using a
calculation based on the number of elapsed ticks
and the hardware cycles per second value. However, this is
redundant because mathematically, this is equivalent to "now". So the
variable can just be set to now.
Proof is that the previous calculation was (in programming language):
(1) last_count = last_count + elapsed_ticks * CYC_PER_TICK
So let's rewrite this as the following to be clear about the different
values we are talking about here (in math language):
(2) count[t] = count[t-1] + elapsed_ticks * CYC_PER_TICK
We calculated elapsed ticks in the function as:
(3) elapsed_ticks = (now - last_count) / CYC_PER_TICK
(4) elapsed_ticks = (now - count[t-1]) / CYC_PER_TICK
Rearranging (2), we see
(5) elapsed_ticks = ( count[t] - count[t-1] ) / CYC_PER_TICK
Substituting this into (4), we get:
(6) ( count[t] - count[t-1] ) / CYC_PER_TICK =
			(now - count[t-1]) / CYC_PER_TICK
Doing simple algebra, you can see we result with:
(7) count[t] = now
So therefore, we can simplify the programming expression to
(8) last_count = now

- The other change is regarding the calculation of the next tick match
  value for tickful kernel mode. The previous calculation was doing:
(1) next = now + CYC_PER_TICK
We know that last_count is equivalent to now, at this point in the code
with the first change:
(2) next = last_count + CYC_PER_TICK
And then, for some reason, we are adding yet another CYC_PER_TICK to
next if (next - now) < MIN_DELAY. The reason for that I do not
understand, but let's write that down:
(3) next - now < MIN_DELAY
Now rewrite (2) as (4) and (3) as (5):
(4) count[t+1] = count[t] + CYC_PER_TICK
(5) count[t+1] - count[t] < MIN_DELAY
And now we substitute (4) into (5):
(6) count[t] + CYC_PER_TICK - count[t] < MIN_DELAY
And simplify:
(7) CYC_PER_TICK < MIN_DELAY
So actually no runtime calculations are needed here, this is a
hardcoding. The reason for this calculation I don't know, but we can
simplify the code.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-22 06:52:42 +02:00
Declan Snyder
992f6fb774 mcux_os_timer: Refactor elapsed ticks calculation
There are a couple places where effectively the exact same calculation
is done. Refactor to share code to do this calculation to make it easier
to read, and explode the code to multiple statements to be even easier
to follow the calculation. Compiler will likely optimize the same way
when opt enabled. Rename dticks variable to be more explicit what that
means (elapsed ticks).

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-22 06:52:42 +02:00
Declan Snyder
d26f3b41b3 drivers: timer: mcux_os_timer: General refactor
Refactor to remove nesting and consolidate lines of code.

I also ran clang format but that actually did not change very much in
addition to what I had already changed manually.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-22 06:52:42 +02:00
Mahesh Mahadevan
4da30d01b8 drivers: mcux_os_timer: Handle counter overflow in Power Mode 3
The counter that is used in Power Mode 3 to track System time could
overflow for large timeouts.
Add an API that the power system could use to ignore wakeup events
from the timer.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-08-19 23:35:32 +02:00
Krzysztof Chruściński
0a51a1714d drivers: timer: nrf_rtc: Fix custom wrapping
Use channel 0 for RTC wrapping. Skip that channel when processing
channels.
Fix algorithm that prevents setting CC=0 when custom wrapping is used.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-08-12 21:31:55 +02:00
Michał Stasiak
41d56fd4d9 drivers: timer: nrf_rtc_timer: Allow use of custom bit width
Allowed use of counter bit width lower than hardware 24.
In that case, PPI connection is established to trigger
clear task once maximum value is reached.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-08-05 11:54:06 +01:00
Swift Tian
814ed6803f tests: fix arm_irq_vector_table fail on Ambiq platforms
Fixed build fail since 4c93fcd35b.
Fixed test run fail on Ambiq platforms.
Added Ambiq section in the test.

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2025-07-30 07:27:19 -04:00
Hake Huang
8add9219a7 drivers: timer : cortex_m_systick MAX_TICKS protection
when CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC set to 960M
and CONFIG_SYS_CLOCK_TICKS_PER_SEC set to 100
the MAX_TICKS will be zero or even negative value, which is not
expected.
so need add a protection here downgrading the accuracy to
its as high as possible

also add build message to show that tickless has no effect

fixes: #36766

there used to be a workaround, not a fix,
either change the CONFIG_SYS_CLOCK_TICKS_PER_SEC=200
or
CONFIG_PM to set the CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
to 32678

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2025-07-22 08:19:55 -04:00
Scott Worley
ef4ec43e63 drivers: timer: microchip: xec: Microchip MEC one kernel timer driver
We want to simplify the maintenance burden and confusion of having
more than one driver for the same kernel timer peripheral used on
all Microchip MEC parts. The XEC version of the driver was converted
register definitions in the driver. Register access is performed using
Zephyr sys_read/write architecture specific inline routines. Driver DT
YAML was updated to use phandle for the 32-bit basic timer used for
ARCH_HAS_CUSTOM_BUSY_WAIT support, basic timer max value property,
and GIRQ interrtup aggregator hardware information.
SoC part Kconfigs, chip level/board level DTSI updated to use the
unified driver.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2025-07-19 15:39:40 -04:00
Declan Snyder
efdd8580ca soc: nxp: Flatten MCX SOCs
Turn MCX series into families.

Reasoning:
 1. The MCX SOCs are quite different from each other and having them all
    under one family in the HWMv2 hierarchy is fruitless because there
    are so many differences that it is confusing to try to introduce
    family-level code and configs since they would each only apply to a
    subset of the series. There is almost nothing that can be shared
    between all of them. Which is why there are comments in the MCX
    family files saying not to put anything in them. This is a technical
    waste.
 2. Therefore, turning all of them into families is almost 0 effort and
    makes sense. It will allow these different types of MCX to be
    further subdivided into series in the future as the MCX portfolio
    expands and such division will be necessary as new SOCs within each
    letter family are released.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-07-19 13:25:29 -04:00
Erwan Gouriou
a884e3b537 drivers: timer: stm32 lptim: Fix the st,timeout runtime check
Existing check failed on correct settings.
Add an assert to fasten the debug.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-07-19 13:22:44 -04:00
Erwan Gouriou
e99db0ddd2 drivers: timer: stm32_lptim: Fix behavior of st,timeout
To be consistent with the definition of label stm32_lp_tick_source,
be sure "st,timeout" is taken from the LPTIM defined as lp_tick_source.

Then, fix the computation of lptim_time_base.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-07-19 13:22:44 -04:00
Peter Mitsis
ec80ab5bb6 drivers: timer: Clean up Cortex-M systick Kconfig
Makes the choice CORTEX_M_SYSTICK_LPM dependent upon the
CORTEX_M_SYSTICK to prevent its default from showing up in
the .config of projects that do not use the CORTEX_M_SYSTICK
timer driver.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-07-04 16:40:31 -10:00
Adam Kondraciuk
e77f942cff drivers: timer: nrf_grtc_timer: add last_count initialization
The GRTC counter is not cleared at startup, therefore the
`last_count` variable needs to be initialized accordingly.
This change:
- Prevents overflow of the `sys_clock_announce()` int32_t parameter
- Ensures the correct uptime value, which should be reset during
  initialization

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2025-06-30 15:23:44 -05:00
Mahesh Mahadevan
14b1ba15ac drivers: timer: Fix the logic to compensate the clock when turned off
The original logic relied on the tick passed in. This method
is inaccurate as the tick value passed in was the exit latency.
Update the code to calculate the remaining time left and set
a counter using this value.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-06-27 18:21:25 -05:00
Peter Wang
f8b14155f0 boards: frdm_mcxa166, frdm_mcxa276: add ostimer support
1. add the ostimer
2. by default, the systick is used.
3. The ostimer could be tested with below configure in xxx.overlay:
&systick {
    status = "disabled";
};

&ostimer0 {
    status = "okay";
};
And below configure in xxx.conf:
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1000000

Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
2025-06-27 08:54:06 -10:00
Mickael Bosch
888bde94be drivers: timer: handle the stm32u0 target
Configure the lptim to wake-up from sleep.

Signed-off-by: Mickael Bosch <mickael.bosch@linux.com>
2025-06-25 15:33:47 -10:00
Tomas Groth Christensen
089c4613ba driver: timer: enable 64 bit cycle counter for MCUX_OS_TIMER
Selects TIMER_HAS_64BIT_CYCLE_COUNTER as an dependency for MCUX_OS_TIMER
This already is supported in the timer implementation in
drivers/timer/mcux_os_timer.c

Signed-off-by: Tomas Groth Christensen <tgc@foss.dk>
2025-06-24 20:03:01 -10:00
Alessandro Manganaro
6244e9307e drivers: timer: Fix interrupt management in stm32 lptim timer
Fix interrupt management issue in stm32 lptim timer

Signed-off-by: Alessandro Manganaro <alessandro.manganaro@st.com>
2025-06-23 13:44:15 +02:00