Commit Graph

538 Commits

Author SHA1 Message Date
Lidor T
0654fb49d8 counter: cmsdk_apb_timer: Use clock freq from DT clocks
Previously, the CMSDK APB timer driver hardcoded the
counter clock frequency to 24 MHz, which limits reuse
across SoCs and boards with different timer clock
sources.
This patch replaces the hardcoded frequency with a value
derived from the device tree's `clocks` phandle, using
the `clock-frequency` property of the referenced clock
controller node. If the property is missing, it falls
back to a default 24 MHz and issues a build-time
warning.

Signed-off-by: Lidor T <lidor@exibit-iot.com>
2025-07-08 13:36:58 -05:00
Gaetan Perrot
ad38ef7333 drivers: counter: Fix redundant identical condition
There was an unnecessary nested `if` in `ifx_cat1_counter_init` with the
same condition already checked in the outer block.

This results in dead and redundant code with no functional impact but
harms readability.

The inner `if (rslt != CY_RSLT_SUCCESS)` was removed to clean up the
function.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 15:48:58 -05:00
Gaetan Perrot
f1c27b6e4a drivers: counter: Fix possible null pointer dereference
The function counter_rz_gtm_set_alarm was accessing alarm_cfg->flags and
alarm_cfg->ticks before verifying that alarm_cfg is non-NULL.

This could lead to undefined behavior or crashes if a NULL pointer is
passed.

The pointer check has been moved before any dereference to fix this bug.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 15:48:49 -05:00
Etienne Carriere
c35ddccce4 drivers: counter: stm32: Fix RTC write access requests
Add missing backup domain access requests in STM32 RTC counter
driver that are needed to modify RTC registers.

Remove backup domain access requests in rtc_stm32_read() since this
function only reads RTC registers and backup domain access protection
protects RTC registers against write accesses only.

Fixes issue 92511.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
2025-07-04 13:06:36 -05:00
Pieter De Gendt
c57d76e1e5 drivers: counter: Place device APIs in linker sections
Use DEVICE_API macro to place driver API instances into a linker section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-27 10:09:32 -05:00
Saravanan Sekar
f672430b3b drivers: counter: Add vendor prefix ti to timer clock
Add vendor prefix ti to timer clock property prescale and divider.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2025-06-27 10:57:05 +02:00
Etienne Carriere
5a279d9309 drivers: counter: stm32: refcounter for Backup domain accesses
Use recently added SoCs functions to request access to SoC backup
domain resources These function use a reference counter to track these
request and ensure the resources are accessible as long as at least a
consumer requires access. When we're done accessing RTC registers and
other protected resource, release the access refcount.

By the way, simplify rtc_stm32_read() when COUNTER_NO_DATE is defined
that used a useless extra local variable.

By the way, correct stm32_hsem.h header file inclusion that requires
brackets (<>) delimiters, not double quotes, as per convention header
location.

Fixes issue 90942.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
2025-06-26 12:43:17 +02:00
Bjarki Arge Andreasen
0829c2bb8c drivers: nrfx: help select clock control when needed
CLOCK_CONTROL is required for fast instances of UART and COUNTER,
help select it when possible. The fast instances are UARTE120,
TIMER120 and TIMER121, and CLOCK_CONTROL is not supported for
CPUFLPR and CPUPPR even when the fast instances are used.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-23 15:47:01 +01:00
Benjamin Cabé
47108c3c86 drivers: counter: adopt SHELL_HELP
Adopt SHELL_HELP macro for counter_timer_shell

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 09:09:01 -04:00
Benjamin Cabé
77e5bec398 drivers; counter: run clang-format on counter_timer_shell.c
Run clang-format on this file

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 09:09:01 -04:00
Ruibin Chang
962d8dfd18 drivers/counter/it8xxx2: fix loss timer interrupt potential risk
1.correct timer register control flow
2.select timer interrupt rising edge trigger, instead of default
level trigger

Stress test: top timer fires interrupt every 300ms for 18 hours.
The result is that we don't lose any interrupts.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2025-06-16 08:31:17 +02:00
Bjarki Arge Andreasen
979a565289 drivers: clock_control: nrf2: align with hw binding names
Currently there is a mismatch between the naming of the hardware and
the drivers targetting the hardware. nrf2_ is used instead of
the actual bindings names, like nrf2_audiopll instead of
nrfs_audiopll. This makes it hard to map drivers to the hardware
they are targetting.

There is historical reason for some of this, namely the same binding
name was used for different hardware, which is why nrf2_ was used
on newer platforms. This is no longer the case though, so drivers
and configs can be named according to the hardware without conflict.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-13 11:12:43 +02:00
Saravanan Sekar
7a3f79ef86 drivers: counter: Add a support for TI MSPM0 Timer counter
TI MSPM0 SoC series has General Purpose Timer and Advanced control timers
with Counting module, Capture block (measure input signal period/time) and
Compare block (to generate time expiry, output waveform like PWM).

Add a support for counter driver with alarm and counter top functions.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2025-06-10 10:25:10 -04:00
Ruibin Chang
47d1e38043 drivers/counter: implement it51xxx counter driver
Implement counter driver for ITE it51xxx series chip.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2025-06-05 12:33:29 +02:00
Sylvio Alves
ad3df1d0f2 driver: counter: esp32: make sure callback is executed
User callback can be used to re-trigger the alarm.
In such case, copy current callback before it is overritten.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-06-02 22:10:51 +02:00
Joel Guittet
9d4530fb79 drivers: counter: introduce counter node in esp32 timers
Add counter device tree node to the esp32 timers.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2025-05-29 08:41:59 +02:00
The Nguyen
613ee72670 drivers: counter: migrate counter AGT to using HAL support
Migrate renesas,ra-agt-counter implementation to use hal_renesas.
Add additional AGT_CLOCK_SUBCLOCK count source.
Add constraint for counter resolution to 32 or 16 bit variant.

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-05-27 11:50:37 +02:00
Sylvio Alves
df5ade9c3e drivers: counter: esp32: add guard period support
Implements guard period support.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-05-26 13:16:53 +02:00
Sylvio Alves
65473e8bee drivers: counter: esp32: add top value handling
Implements top value callback and handling.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-05-26 13:16:53 +02:00
Sylvio Alves
dca598e311 drivers: counter: esp32: add reset counter function
Adds option to reset counter value.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-05-26 13:16:53 +02:00
Stoyan Bogdanov
cfe7a58a28 drivers: counter: Add support for cc23x0 LGPT
Add support for LGPT0, LGPT1, LGPT2 and LGPT3 to cc23x0 SoC.

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-05-23 11:03:24 +02:00
jhan bo chao
85dc257072 drivers: counter: rts5912: clear pending irq when setup
clear pending irq when setup.

Signed-off-by: jhan bo chao <jhan_bo_chao@realtek.com>
2025-05-22 20:57:15 +02:00
Stoyan Bogdanov
dddbfcce76 drivers: counter: Add support for cc23x0 RTC counter
Add support for cc23x0 RTC driver in counter.
RTC is always ON after device boot. Timer is restared only
on POR, and is active during STANDBY and ACTIVE power states.

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-05-21 17:34:16 +02:00
Anas Nashif
2aacbcaab5 style: add missing curly braces in if/while/for statements.
Add missing curly braces in if/while/for statements.

This is a style guideline we have that was not enforced in CI. All
issues fixed here were detected by sonarqube SCA.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-17 14:10:33 +02:00
Sean Kyer
3d55a9d410 drivers: counter: Place max32 API into iterable section
Add warpper DEVICE_API macro to counter_max32_wut instance.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-05-15 17:53:31 +02:00
Sean Kyer
ae681c48c7 drivers: counter: counter_max32_wut: Rename irq_config callback
Renamed irq_config callback function to follow
standard of other drivers.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-05-15 17:53:31 +02:00
Sean Kyer
b476fa78d2 drivers: counter: counter_max32_wut: Fixed PM resume routine
Seperated SW and HW initialization code so timer is not
wiped upon a PM resume event.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-05-15 17:53:31 +02:00
Sean Kyer
ee883a9f55 drivers: counter: counter_max32_wut: Add backup support
Added backup power mode support to max32 wut.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-05-15 17:53:31 +02:00
Tahsin Mutlugun
ab43ceb1eb drivers: counter: Add MAX32 Wake-Up Timer driver
MAX32 Wake-Up Timer is a 32-bit timer that can wakeup the device from
low-power modes.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-05-15 17:53:31 +02:00
Sai Santhosh Malae
a1913f9d9f drivers: counter: siwx91x: Enable siwx91x Counter driver
Enable sleeptimer counter driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2025-05-13 17:46:46 +02:00
Alberto Escolar Piedras
5c959c6136 drivers/counter/counter_native_sim: Merge if statements
To reduce the perceived code complexity

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-05-13 12:09:30 +02:00
Tsi-Chung Liew
e483b229de Counter_nxp_mrt: Adds PM low-power recovery support
Enables Sleep mode (PM3) in RW61x for MRT.

Signed-off-by: Tsi-Chung Liew <Tsi-Chung.Liew@nxp.com>
2025-05-12 19:19:40 +02:00
Tsi-Chung Liew
8ac0a675ee Counter_mcux_ctimer: Adds PM low-power recovery support
Enables Sleep mode (PM3) in RW61x for Ctimer.

Signed-off-by: Tsi-Chung Liew <Tsi-Chung.Liew@nxp.com>
2025-05-12 19:19:40 +02:00
Alberto Escolar Piedras
fe70e480f4 drivers/counter native_sim: Avoid reusing tag name
Don't use the same name for the structure instance and type.
As that is a violation of MISRA-C 2012 rule 5.7.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-05-12 09:47:59 +02:00
Joel Guittet
54b826336b drivers: counter: counter_reset api support to stm32 timer
Add support to reset counter value.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2025-05-08 19:53:12 +02:00
Henrik Brix Andersen
2e8a08a165 drivers: counter: add NEORV32 GPTMR driver
Add counter driver for the NEORV32 General Purpose Timer (GPTMR).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-05-05 12:20:50 +02:00
Marcin Lyda
f7280fac32 drivers: counter: Add MCP7940N property to enable VBAT backup
This PR adds a new devicetree property
that allows enabling external battery
backup functionality.

Signed-off-by: Marcin Lyda <elektromarcin@gmail.com>
2025-05-05 10:57:28 +02:00
Titan Chen
2bca8d4e59 drivers: counter: rts5912: add support timer32 counter driver
Port rts5912 timer32 counter driver on Zephyr

Signed-off-by: Titan Chen <titan.chen@realtek.com>
2025-04-22 14:02:27 +02:00
Hao Luo
6f4b92d64d soc: ambiq: Optimize the inclusion relationship of header files
Optimized the inclusion relationship of header files

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-04-17 09:06:18 +02:00
Marco Widmer
491e297418 drivers: counter: nrfx_timer: Use shutdown task if available
Add a workaround for NRF52 anomaly 78: "High current consumption when
using timer STOP task only". Use the SHUTDOWN task instead.

For consistency, CLEAR the timer timer after STOPPING on devices that
lack the SHUTDOWN task. This also aligns the behavior with
nrfx_timer_disable().

For devices with the SHUTDOWN task, this restores the behavior previous
to e92323f.

Fixes #87224

Signed-off-by: Marco Widmer <marco.widmer@bytesatwork.ch>
2025-04-09 11:43:01 +02:00
Yunshao Chiang
c6fe84caf2 drivers: counter: add ite it8xxx2 timer driver
The IT8xxx2 timer driver uses timer 7 and timer 8 to implement the alarm
timer and the top timer, respectively.

Signed-off-by: Yunshao Chiang <Yunshao.Chiang@ite.com.tw>
2025-04-08 16:12:11 +02:00
Titan Chen
5a94a1ca66 drivers: counter: rts5912: add support slow timer counter driver
Port rts5912 slow timer counter driver on Zephyr

Signed-off-by: Titan Chen <titan.chen@realtek.com>
2025-04-07 21:13:10 +02:00
Raffael Rostagno
4b8dc5f3ff drivers: esp32: Update for shared intc
Drivers update to use shared interrupt allocator for Xtensa
and RISCV devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-04-02 19:02:27 +02:00
James Roy
bcbf69ed9f drivers: counter: nrf: Add nrfx-timer implementation
Implement the '.reset' interface in the nrfx-timer driver
to allow the upper layers to use the counter_reset
function.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-03-26 08:54:58 +01:00
James Roy
d019aea47b drivers: counter: Add native-posix implementation example
Implement the '.reset' interface in the native-posix driver
to allow the upper layers to use the counter_reset
function.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-03-26 08:54:58 +01:00
Declan Snyder
b990f96feb dts: counter: Remove old kinetis lptmr binding
Remove deprecated nxp,kinetis-lptmr compatible string
which is superseded by nxp,lptmr compatible due to
removing family specific name.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-03-20 17:14:28 +01:00
Khaoula Bidani
4d3cce4872 drivers : counter: clean up usage of "USE_STM32_LL"
clean up usage of select USE_STM32_LL_RCC, USE_STM32_LL_EXTI
and USE_STM32_LL_PWR from Kconfig.stm32
this modifications due to the include unconditionally of
stm32xxxx_ll_rcc.h, stm32xxxx_ll_exti.h and
stm32xxxx_ll_pwr.h in the HAL.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-03-20 09:32:56 +01:00
Mathieu Choplain
eec7bb5514 drivers: counter: stm32_rtc: disallow enabling on STM32WB0 series
Don't allow enabling the driver on STM32WB0 series due to hardware erratum.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-03-19 01:32:43 +01:00
Alberto Escolar Piedras
ab7a6de5bb drivers/counter/counter_native_sim: Rename from counter_native_posix
Including renaming the DTS binding and kconfig options
deprecating the old one.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-10 06:52:37 +01:00
Krzysztof Chruściński
074215a30f drivers: clock_control: nrf: Move NRF_PERIPH_GET_FREQUENCY
Move macro from nrf_clock_control.h to soc_nrf_common.h. Clock control
header fetches many dependencies (e.g. onoff.h) so move macro to more
low level header.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-07 19:52:10 +01:00