Commit graph

530 commits

Author SHA1 Message Date
Fabio Baltieri
2575bfc9b2 counter_timer_shell: add shell device filtering
Add shell device filtering using DEVICE_API_IS.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:47 +01:00
Andrew Featherstone
48e179e5c9 drivers: counter: rpi_pico_timer: Correct support for RP2350
Changes introduced in 293b9a16ca didn't
verify correct behaviour when running `TIMER1` with `TIMER0` is paused,
and was reporting the wrong tick counter being incremented. Correct this
and extend the testing to verify correct behaviour.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2025-01-23 23:19:36 +01:00
Henrik Brix Andersen
7fec3d7f12 soc: atmel: samx7x: refactor SoC support for the Atmel SAM E70/V71
Refactor and merge the SoC support files for the Atmel SAM E70 and SAM V71
product series. These SoCs are part of a larger product family (SAM
E70/S70/V70/V71) and share a common set of peripherals.

Support for the two remaining product series (SAM S70/V70) is not part of
this refactoring as these will require further additions to the Atmel HAL.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-01-16 22:39:25 +01:00
Mathieu Choplain
fc61e64a3a drivers: counter: stm32: add support for STM32WB0
This commit adds support for the STM32WB0 series to
the existing STM32 timer-based counters driver.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-01-14 20:49:30 +01:00
Gerson Fernando Budke
ea7922195b clocks: atmel: sam0: Fix gclk and mclk clock bindings
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.

Now the clocks properties is complemented by the atmel,assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.

All peripherals drivers were reworked with the newer solution.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2025-01-14 20:49:03 +01:00
Krzysztof Chruściński
573ed56be7 drivers: counter: nrfx_timer: Add request for global HFSLL
Add requesting for global HFSLL when fast instance TIMER (e.g.
TIMER120 in nrf54h20) is used.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-08 19:09:57 +01:00
Gerson Fernando Budke
bff3874eaf drivers: counter: sam: Allow empty pinctrl config
The Atmel counter driver requires a valid pinctrl list to initialize.
This relax this condition since the timer can be used as general purpose
timer, which may not require a pin associated with the timer unit.

Fixes #83509

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2025-01-03 11:37:21 +01:00
James Roy
364c555e21 drivers: counter: Fix unchecked return value in mcp7940
Fix unchecked return value scanned by Coverity.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-01-02 10:55:04 +01:00
Andrew Featherstone
293b9a16ca drivers: counter: rpi_pico_timer: Add support for RP2350
The RP2350 SoC series contain two timer peripherals. Extend the driver
to support using the second timer (`TIMER1`).

N.b. this requires a fix from the Pico SDK to be patched into
hal_rpi_pico. See https://github.com/raspberrypi/pico-sdk/pull/1949 .

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2024-12-23 23:57:57 +01:00
Manuel Argüelles
bf7837b8ac dts: bindings: rename nxp,kinetis-rtc compatible
Rename "nxp,kinetis-rtc" compatible to "nxp,rtc" to remove the
device family from its name.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-12-19 19:55:43 +01:00
Yishai Jaffe
1b4cef325b shell: use shell_device_get_binding
Use shell_device_get_binding() instead of device_get_binding() so that
we get the device based on its name and in addition by its label.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2024-12-18 15:32:10 +01:00
Raffael Rostagno
0d5c76a2b3 drivers: counter: esp32: Spinlocks cleanup
Remove unnecessary spinlock directives.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-12-17 15:23:38 +01:00
Raffael Rostagno
203c71d1f7 drivers: counter: esp32: Driver update
Cleanup and timer frequency management improvement to support
new devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-12-17 15:23:38 +01:00
Pieter De Gendt
401a8a29f4 drivers: counter: Place API into iterable section
Add wrapper DEVICE_API macro to all counter_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-29 21:46:15 +01:00
Marcio Ribeiro
65547044e6 drivers: touch/rtc/wdt: esp32: fix conflict among device drivers
allows use of touch_sensor, rtc_counter, and wdt simultaneously by enabling
ESP_INTR_FLAG_SHARED when calling esp_intr_alloc()

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2024-11-25 14:42:32 +01:00
Carles Cufi
e92323f0c4 manifest: hal_nordic: Update to nrfx 3.9.0
See https://github.com/zephyrproject-rtos/hal_nordic/pull/257.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2024-11-21 09:26:38 +01:00
Rafał Kuźnia
d6007690de manifest: update hal_nordic revision
The hal_nordic revision was updated to bring in NRFX v3.8.0.

Aligned the uses of single-instance API to use multi-instance instead.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2024-11-19 09:53:10 -05:00
Sadik Ozer
5e38168f0c drivers: counter: Add MAX32xxx counter RTC driver
Common RTC counter driver for MAX32xxx MCUs.
Time of day alarm is used to generate interrupt.
The resolution of time of day interrupt is 1Hz.
Subsecond alarm interrupt not works it does not meet
zephyr counter driver requirement, so that not used.

To use as wakeup source wakeup-source parameter shall be
defined as below

&rtc_counter {
    status = "okay";
    wakeup-source;
};

Co-authored-by: Okan Sahin <okan.sahin@analog.com>
Signed-off-by: Sadik Ozer <sadik.ozer@analog.com>
2024-11-16 15:08:43 -05:00
Ioannis Karachalios
a66c070598 drivers: counter: Fix unbalanced policy state lock
This commit should deal with fixing unbalanced policy state locks.
When PM and PM_DEVICE are declared, default state, policy locks
should be given only when  active.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2024-11-12 15:48:20 -06:00
Gerson Fernando Budke
0cc8f93e8a soc: atmel: Drop PINCTRL from Kconfig.defconfig
This Kconfig has wrongly been added to defconfig files. It is not the
right place for it. It has never been the right place for it. Drivers
that need it should select the symbol in their Kconfig entries. Drop
PINCTL from Kconfig.defconfig and add proper select at Kconfig.sam*.

Fixes #78619

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2024-11-04 13:43:26 -06:00
Khoa Nguyen
b56d6e670e drivers: counter: fix AGT renesas prefix properties
- Modify the macro in source code AGT to get the right data from
device tree
- Modify name of agt node

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2024-10-29 07:11:04 -05:00
Raffael Rostagno
d33b8f6314 drivers: counter: rtc: esp32: Limit minimum time for set_alarm
Include value of 30 us as not valid to set alarm for RTC counter.
Change included to allow RTC timer to be properly set to use
RC_FAST_D256 as clock source.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-10-26 03:57:23 +01:00
Raffael Rostagno
03dc880aa6 drivers: counter: esp32: Clang run
Clang run on driver for formatting

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-10-25 00:04:25 +01:00
Raffael Rostagno
4be1897519 drivers: counter: systimer: esp32c2: Fix clock parameters
Fix clock source frequency for systimer and GP timer.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-10-25 00:04:25 +01:00
Aksel Skauge Mellbye
da6ddc92cd drivers: timer: silabs: Add sleeptimer timer driver
Add OS timer implementation making use of the Sleeptimer HAL.
Sleeptimer integrates tightly with the Silabs Power Manager HAL,
and must be used as the OS timer to achieve optimal power consumption
when using the radio.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-10-24 17:51:01 +02:00
Thao Luong
a61484f7ad drivers: counter: Add AGT counter driver support for Renesas RA8
- boards: renesas: Add support for agt.
- drivers: counter: Add support for counter driver use agt
- dts: arm: Add support for agt.
- dts: bindings: Add support for agt counter driver.
- soc: renesas: Add support for agt counter driver.
- samples: drivers: counter: alarm: Add support for RA8

This is initial support with only basic functionality for counter
operation on Zephyr using AGT hardware, current support for
count source is limited to LOCO and PCLKB, other count source
like underflow signal external pin or AGTIO from another AGT
channel will be added in later support

Signed-off-by: Ha Nguyen <ha.nguyen.fz@bp.renesas.com>
Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
Signed-off-by: Duy Phuong Hoang. Nguyen <duy.nguyen.xa@renesas.com>
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2024-10-21 12:41:00 +02:00
Sylvio Alves
7668a4d27e drivers: counter: esp32: force capture to read value
Force capture call so that timer counter value is updated
accordingly.

This also adds get_value_64 counter API function.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-10-16 09:58:47 +02:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Sylvio Alves
5fc3f56125 drivers: counter: esp32: disable timer before int clear
Make sure to stop timer counter before interrupt is cleared,
otherwise it might re-trigger it due to default interrupt level mode.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-09-25 04:04:26 -04:00
TOKITA Hiroshi
cbec7c8569 drivers: counter: Specify _POSIX_C_SOURCE when native_sim
When building with native_sim, We need to specify

```
 #define _POSIX_C_SOURCE 200809L
```

to make `gmtime_r` available.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-09-19 15:13:57 +02:00
Yong Cong Sin
7ebd3decd8 drivers: counter: shell: device name autocompletion
Add timer device name autocompletion to the commands.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-09-18 15:30:35 +02:00
Yong Cong Sin
a3d9ede341 drivers: counter: shell: change callback functions to static
These callback functions are not used outside of the file, make
them `static`

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-09-18 15:30:35 +02:00
Sadik Ozer
bfb21ced8d drivers: counter: Add MAX32xxx counter driver
Common counter driver based on timer for MAX32xxx MCUs
To use as wakeup source wakeup-source parameter shall be
defined as below

&lptimer0 {
	status = "okay";
	clock-source = <ADI_MAX32_PRPH_CLK_SRC_ERTCO>;
	wakeup-source;
	counter {
		status = "okay";
	};
};

Signed-off-by: Sadik Ozer <sadik.ozer@analog.com>
2024-09-11 20:18:33 -04:00
Pisit Sawangvonganan
847a4eaad2 style: drivers: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-09-11 07:40:35 -04:00
Krzysztof Chruściński
d8c3ae0286 drivers: counter: nrfx_timer: Add barrier when reading CC
Add barrier between triggering Capture task and reading CC as otherwise
it is possible that CC read will occur before task is triggered when
bus is busy.

Add barrier between reading previous CC value and writing the new one.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-09-03 14:40:10 +01:00
Krystof Sadlik
16cdd5b852 Drivers: Counter: Added flag for counting up
Tmr and dtmr drivers were missing a flag which tells the
counter_is_conting_up function that the counter is counting up. So I've
added the flag

Signed-off-by: Krystof Sadlik <krystof.sadlik@nxp.com>
2024-09-02 09:07:57 +02:00
Emilio Benavente
cdfa11ee94 drivers: counter: mcux_lptmr: Updated lptmr to support multi instance.
Updated the counter_mcux_lptmr driver to support multiple
instances of the lptmr peripheral. Also added a new
binding property to identify if the user is using
counter-mode or pulse mode. since we were previously using the
prescaler value to check this which could be wrong
if used as a division value for getting the freq.
Added a property that allows the user to decide
what the counter value in lptmr should be divided by.
Cleaned up INIT macro for lptmr.

Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
2024-08-27 12:46:11 +02:00
Raffael Rostagno
90c6106926 drivers: esp32: Interrupts flags configuration
Allows configuring interrupts flags in the device tree for
ESP32 devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-22 14:25:25 -04:00
Raffael Rostagno
bb746cdcc5 drivers: esp32: esp_intr_alloc return condition
Add checks to return value of esp_intr_alloc to avoid drivers init
returning 0 when interrupt allocation fails.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-22 14:25:25 -04:00
Raffael Rostagno
0b3a34cdca drivers: esp32: Interrupts priority configuration
Allows configuring interrupts priority in the device tree for
ESP32 devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-22 14:25:25 -04:00
Pisit Sawangvonganan
1bcae0ea9f style: drivers: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-20 10:33:51 +02:00
Raffael Rostagno
c1f8948e76 drivers: counter: esp32c2: Add support
Add counter support to ESP32C2 and ESP8684

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-16 14:08:22 -04:00
Francois Ramu
48b84d2c65 drivers: counter: stm32 counter timer exclude stm32 devices without APB2
The STM32 devices like stm32F0/G0/C0 which have a f0-rcc compatible
does not have APB2 prescaler : do not try to set it.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-08-13 14:56:22 +02:00
Anke Xiao
7c7760f4cd drivers: counter: update counter_mcux_rtc.c
Set LPO 1KHZ clock for RTC if clock source 'LPO' is selected.
The frdm_ke17z512 has no 32KHZ OSC, the RTC clock comes from SOSC,
RTC_CLKIN, LPO 1KHZ. But usually the SOSC is connected with 8MHZ
oscilator, so only 1kHZ LPO is usable.
Update the nxp,kinetis-rtc.yaml to select RTC clock source.

Signed-off-by: Anke Xiao <anke.xiao@nxp.com>
2024-08-13 09:50:13 +01:00
Manuel Argüelles
c27a8e158a drivers: counter: nxp_sys_timer: support late and short alarms
Support short relative and late alarms for NXP System Timer Module
counter driver. The late alarm detection algorithm applied, is based on
existing counter drivers.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-08-12 15:14:34 +02:00
Manuel Argüelles
896d8d6896 drivers: counter: nxp: convert STM to native driver
Convert NXP System Timer Module driver to a native driver.

Timer prescaler in tests is updated because short relative alarms
sometimes give false positives.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-08-05 07:35:57 -05:00
Ioannis Damigos
0a0bccabd8 drivers/smartbond: Fix PM device runtime support
Removed PM device runtime support from drivers in PD_SYS domain.

Update the rest device drivers to call pm_device_runtime_get/put()
functions when CONFIG_PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Yong Cong Sin
88c96f7986 drivers: counter: stm32: remove deprecated clock source Kconfigs
These clock selection Kconfigs should have been deprecated for
more than 2 releases, remove them:

- `CONFIG_COUNTER_RTC_STM32_CLOCK_SRC`
- `CONFIG_COUNTER_RTC_STM32_CLOCK_LSI`
- `CONFIG_COUNTER_RTC_STM32_CLOCK_LSE`

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-18 14:33:58 -04:00
Adam Berlinger
19b39406eb soc: st: Add support for STOP3 on STM32U5
LPTIM is not available in STOP3 mode, so RTC needs to be used instead.
This code usese similar approach as STM32WBAx for suspend to ram.
The STOP3 is disabled by default in device tree.

Signed-off-by: Adam Berlinger <adam.berlinger@st.com>
2024-06-15 04:44:26 -04:00
Dawid Niedzwiecki
3b85e8b8ea drivers: counter: add missing include
Add missing include for get_value_64 in the counter_handlers.c file.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-06-14 21:14:43 -04:00