Commit graph zephyr/drivers/counter
Author SHA1 Message Date
Raffael Rostagno
16632333a2 drivers: counter: rtc: esp32: Fix overflow case
Fix alarm setting when timer has overflown beyond 32-bit boundary.
Timer is 48-bit, so it requires high word to be programmed along
the 32-bit word managed by the driver.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-10-07 12:47:45 +02:00
Guillaume Gautier
1d2029a137 drivers: counter: stm32: kconfig: remove ll_tim selection
Usage of stm32xxxx_ll_tim.c has been removed so we can also remove the
selection of USE_STM32_LL_TIM from the Kconfig.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-10-02 21:58:55 +02:00
Guillaume Gautier
a02e1c70dd drivers: counter: stm32: rtc: remove init struct
Remove the calls to LL_RTC_Init, LL_RTC_DeInit and LL_RTC_ALMA_Init in
the RTC counter driver. This avoids calling functions from
stm32xxxx_ll_rtc.c.
They are replaced by a set of simpler functions from the header file.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-10-02 21:58:55 +02:00
Hieu Nguyen
424a12446f drivers: counter: Add Counter support for Renesas RZV2L, A3UL
Add Counter driver support for Renesas RZ/V2L, A3UL

Signed-off-by: Hieu Nguyen <hieu.nguyen.ym@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>

drivers: counter: Improve ISR Prototype for Renesas RZ
2025-10-02 09:31:28 +02:00
Andrew Featherstone
67f2e49ce3 drivers: counter: rpi_pico: Remove redundant CMSIS include
This header file isn't required, and prevents the driver building for
the RISC-V based Hazard3 cores.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2025-09-29 12:30:28 -04:00
Yurii Lozynskyi
c15920613d drivers: counter: add PSC3M5 counter driver
- Add a new counter driver implementation based on the PDL for
  Infineon CAT1B devices. This enables support for hardware
  counters on the PSC3M5 platform.
- Add IFX_TCPWM_Counter_DeInit and IFX_TCPWM_Counter_Init
  macros to include/zephyr/drivers/timer/ifx_tcpwm.h
  and sort all of the macros in that file

Signed-off-by: Yurii Lozynskyi <yurii.lozynskyi@infineon.com>
2025-09-22 17:50:00 -04: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
Guillaume Gautier
4457e6db95 drivers: counter: stm32: remove init struct
Remove the calls to LL_TIM_StructInit and LL_TIM_Init in the counter
driver. This avoids calling functions from stm32xxxx_ll_tim.c.
They are replaced by a set of simpler functions from the header file.

Also replaces some macros that used constants coming from the HAL. Use
an equivalent coming purely from the LL.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-09-19 12:46:46 -04:00
Hieu Nguyen
048d7ed22f drivers: counter: Add Counter support for Renesas RZ/T2M, N2L
Add Counter driver support for Renesas RZ/T2M, N2L

Signed-off-by: Hieu Nguyen <hieu.nguyen.ym@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
2025-09-17 14:53:20 +02:00
Felix Wang
5525941d83 drivers: Counter: Fix LPIT disable interrupt bug
The parameter for LPIT_DisableInterrupts should be
lpit_interrupt_enable_t, not channel id.

Besides, improve the code to use BIT macro for shift
operation.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2025-09-16 16:06:48 +02:00
Anisetti Avinash Krishna
2b1b3f0934 drivers: counter: Enables support for MFD in counter
Enabled support for MFD in CMOS counter.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
2025-09-15 14:44:08 +02:00
Holt Sun
7ac4180c58 drivers: counter: update nxp rtc counter drivers.
Don't clear match register when stop counter.
Fix some build warning.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2025-09-11 18:07:59 +01: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
Marek Matej
5761bf8b53 drivers: counter: FIx unused config
Remove unused config from the counter driver Kconfig.
Fix typo in dependant config.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2025-09-09 12:19:12 +01:00
Tomáš Juřena
87dbd2e2a4 drivers: counter: stm32: Disable BYPSHAD in init
Disable the shadow registers bypass in init function before RTC
deinitialisation to avoid infinite loop as the bit cases the RSF bit
to be kept in 0. The systick is not working in PRE_KERNEL_1 so it will
never timeout.

Signed-off-by: Tomáš Juřena <jurenatomas@gmail.com>
2025-09-08 09:48:12 +02:00
Felix Wang
193e9170bb drivers: Counter: FTM Support on Zephyr
1.Update dts bindings to move clock-source properties from
nxp,ftm-pwm.yaml to nxp,ftm.yaml.
2.Provide counter driver based on FTM driver from NXP mcux-sdk-ng

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2025-09-04 08:10:20 +02:00
Tomasz Bursztyka
8454ff70f2 drivers: counter: Fix mspm0 alarm cancellation
Cancelling the alarm needs to reset the callback to NULL, else setting
an alarm subsequently will never work.

chan_id parameter being unused, using ARG_UNUSED() relevantly then.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-09-02 09:59:58 +02:00
CHEN Xing
ed5b9cffd2 drivers: counter: sam_tc: Big fix for alarm 1
Issue: the alarm 1 do not generate interrupt
There are three compare registers in a SAM TC channel:
RA --> alarm 0
RB --> alarm 1
RC --> top_value
By default the RB/TOIB was configured as an input and no longer
generates interrupt.
Set the direction of TIOB to output for alarm 1 interrupt.

Fixes zephyrproject-rtos/zephyr#85018

Signed-off-by: CHEN Xing <xing.chen@microchip.com>
2025-08-22 09:45:41 +02:00
Guillaume Gautier
2ab5452b32 drivers: counter: stm32: use kernel clock instead of dedicated function
Now that the timer kernel clocks are defined in device tree, use the
clock get API to fetch the clock frequency instead of calculating the
value in the driver.
Removes the now unused function counter_stm32_get_tim_clk.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-08-21 13:06:58 +02:00
Jake Greaves
e247cc3d9c drivers: counter: stm32: config rtc prescaler from DT
Handle RTC prescaler options inside RTC counter driver

Signed-off-by: Jake Greaves <jake.greaves@analog.com>
2025-08-20 18:46:47 +02:00
Pieter De Gendt
be216ba9e6 drivers: counter: mcux_snvs: Convert Kconfig symbol to dts property
The SNVS RTC can act as a wakeup source, re-use pm.yaml properties and
remove the Kconfig symbol.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-08-13 11:10:03 +01:00
Felix Wang
a717fac593 drivers: Counter: LPIT Support on Zephyr
1.Add dts bindings nxp,lpit-channel.yaml and nxp,lpit.yaml
2.Provide counter driver based on lpit driver from NXP mcux-sdk-ng

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2025-08-08 10:44:24 -05:00
Tahsin Mutlugun
a5ea4c2dc0 drivers: counter: max32_wut: Add missing include
Include adi_max32_clock.h to resolve undeclared ADI_MAX32_PRPH_CLK_SRC_*
errors.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-08-06 12:03:12 -04:00
Bjarki Arge Andreasen
c326bf6bc7 drivers: counter: counter_nrfx_timer: fix fast instance clock ctrl
Update handling of fast instances to take into account whether
CONFIG_CLOCK_CONTROL is enabled or not.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-08-06 17:13:11 +03:00
Johann Fischer
9d06111346 Revert "drivers: counter: sam_tc: Big fix for alarm 1"
This reverts commit 8f5daca5e5.
The CI is failing on sam4l_wm400_cape after this commit.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-08-06 17:09:26 +03:00
Mathieu Choplain
2881186244 drivers: counter: stm32_timer: use "cc" interrupt if it exists
Currently, the STM32 TIM counter driver will always register itself as ISR
for interrupts[0] of the timer node. This works fine for timers which have
a single "global" interrupt but not for others (e.g., Advanced Timer) which
have separate IRQ lines for various events.

Borrow the pattern from PWM driver: use the "cc" interrupt if it exists on
timer node, otherwise use the "global" interrupt. If neither of those are
found, a build error is raised to ensure silent failures cannot occur.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-08-05 10:24:56 +01:00
CHEN Xing
8f5daca5e5 drivers: counter: sam_tc: Big fix for alarm 1
Issue: the alarm 1 do not generate interrupt
There are three compare registers in a SAM TC channel:
RA --> alarm 0
RB --> alarm 1
RC --> top_value
By default the RB/TOIB was configured as an input and no longer
generates interrupt.
Set the direction of TIOB to output for alarm 1 interrupt.

Fixes zephyrproject-rtos/zephyr#85018

Signed-off-by: CHEN Xing <xing.chen@microchip.com>
2025-07-30 06:45:07 -04:00
Bjarki Arge Andreasen
2b0d1ae4d0 soc: nordic: nrf54h: transition from gpd to zephyr pinctrl and pds
Transition nrf54h away from the soc specific gpd
(global power domain) driver which mixed power domains, pinctrl
and gpio pin retention into a non scalable solution, forcing soc
specific logic to bleed into nrf drivers.

The new solution uses zephyrs PM_DEVICE based power domains to
properly model the hardware layout of device and pin power domains,
and moves pin retention logic out of drivers into pinctrl and
gpio, which are the components which manage pins (pads).

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-07-29 09:03:37 -04:00
Raffael Rostagno
166bf18d30 drivers: counter: esp32: Fix alarm stops working
Fix condition in which alarm stops working after a certain amount
of time. Hardware timer is 54-bit, yet it is treated as 32-bit by
the counter driver. To allow alarm event by hardware comparators,
counter high word must be loaded into the register along with
the lower word managed by the driver.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-07-25 23:29:40 +02:00
Tahsin Mutlugun
cb0f951f3d drivers: counter: max32_rtc: Add clock source selection support
Add clock source selection support by applying changes introduced in
41a0ba7.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-07-23 17:29:34 +01:00
Lidor T
b68058787e counter: cmsdk_apb_dualtimer: Use clock freq from DT clocks
Previously, the CMSDK APB dual 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.

Signed-off-by: Lidor T <lidor@exibit-iot.com>
2025-07-19 15:50:31 -04:00
Hao Luo
4b3565d958 drivers: pwm: Add support for Apollo510 pwm
This commit adds support for Apollo510 pwm driver

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-07-19 15:31:08 -04:00
Richard Wheatley
902005e0ef drivers: add assert to check for max children in timer
check for max number of children in timer.

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2025-07-19 15:31:08 -04:00
Richard Wheatley
7cd378d9c9 dts: bindings: move clk-source to parent
Move clk-source from pwm to timer
change associated files to match

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2025-07-19 15:31:08 -04:00
Richard Wheatley
e81a241678 driver: pwm: create ambiq pwm driver
Restructured counter and timer.
CTimer/Timer is now parent to pwm and counter.
Created PWM driver and tied to pwm and pwm-led

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2025-07-19 15:31:08 -04:00
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