Converting absolute system ticks to RTC ticks is simple. It needs to be
multiplied by CYC_PER_TICK (which by default is 1). Complex algorithm
was used when driver was not tracking current 64 bit tick and function
was returning uint32_t.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The EC timer runs at 9.2 MHz, which leads to a non-integer number of
ticks per microsecond. This causes slight overestimation when delays
are computed using whole ticks (e.g., using 10 ticks for 1 µs).
To address this, the busy wait calculation is adjusted with a
compensation factor to minimize cumulative timing error over time.
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
Timer 7 is not used in timer driver, which means that timer
driver doesn't initialize timer 7, it's just declared in dtsi.
So I remove it, timer 7 will be used as alarm timer for counter driver.
Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
This driver currently only supports one instance of this timer and uses
it as the system clock. The instance is selected by being the first one
listed in DT in all places except sys_clock_driver_init() where it uses
the node label "systick_timer".
This driver should be fixed to correctly support multiple instances
of this timer, and the one used for the system timer should be selected
based on a flag or alias, not based on label.
For now simply use the 0th instance like everywhere else which removes
the need to have this node labeled a special way and makes no functional
changes to current users.
Signed-off-by: Andrew Davis <afd@ti.com>
This commit updates the riscv_machine_timer driver to resolve MTIME and
MTIMECMP register addresses by their `reg-names` instead of relying on
index order.
This improves clarity and robustness in DTS bindings, and is a prerequisite
for handling cases where not both MTIME and MTIMECMP registers are present
or accessible.
Signed-off-by: Chen Xingyu <hi@xingrz.me>
Update hal_wch.
As the hal upstream changed name, there is now a name conflict.
Rename ch32fun.h to hal_ch32fun.h to fix this conflict.
Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
Expand the current systick compatibility to include the CH32V00x
series. Change the HAL compatibility to include all of the CH32V
family.
Signed-off-by: Michael Hope <michaelh@juju.nz>
This commit add a system timer driver for Renesas RX using the
CMT peripheral. The driver supports both system ticks and
high-resolution cycle counting
- Configures CMT0 as the system tick timer
- Configures CMT1 as a free-running cycle timer for precise
time tracking
- Handles timer overflows to maintain a continuous cycle count.
- Implements sys_clock_cycle_get_32() and sys_clock_cycle_get_64()
for high-resolution timing
- Supports Zephyr tickless kernel mode by tracking elapsed cycles
- Enables interrupt-based tick announcement using CMT0
Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
Signed-off-by: Yuichi Nakada <yuichi.nakada.sx@renesas.com>
The CH32V003 CPU is a QingKe V2A while others in the CH32V00x series
use the QingKe V2C. Prepare for adding support for the CH32V006 moving
to the more specifc qingke-v2a, moving some cases of SOC_CH32V003
actually meaning SOC_FAMILY_QINGKE_V2A.
Signed-off-by: Michael Hope <michaelh@juju.nz>
This patch allows ti_dmtimer to provide the symbol z_sys_timer_irq_for_test
whenever tests are enabled. Not providing this results in failing some
kernel test cases which require this symbol.
Signed-off-by: Amneesh Singh <a-singh7@ti.com>
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>
Selection of the LF clock source for the GRTC should be performed
as early as possible, before starting GRTC.
Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
Converting absolute system ticks to GRTC ticks is simple and algorithm
can be simplified. Legacy algorithm was copied from nrf_rtc_timer which
back then was working on 32 bits only.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Convert z_clock_hw_cycles_per_sec to unsigned int to increase
supported frequency range.
Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
Add ULP Coprocessor board support for C6.
This requires a change in the board qualifier depending on the build
target.
Update esp32c6 overlay and configuration files to the proper name.
Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
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>
These socs were missing a config line to disable SYSTICK if the LPTMR is
configured for the system timer, similar to how other SOCs do this for
alternative system timers than systick.
This fixes build errors in the case where that lptmr kconfig is enabled.
Also, the LPTMR kconfig should be default no because it is a secondary
option for the system timer, being lower resolution than systick. This
also resolves build errors.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
In the case where more than a full tick was unannounced when
sys_clock_set_timeout() was called, the timer driver would
subtract it from the next timeout. However, this is already
done by the caller through the elapsed() function in timeout.c,
leading to the timer interrupt firing too early.
With this fix, SYS_CLOCK_TICKS_PER_SEC can be increased to the
full speed of the low frequency timer. The underlying sleeptimer
API must be called with a timeout of at least 1, and will if needed
increase the value to the minimum value required by the hardware.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Introduces the Z_IS_TIMEOUT_RELATIVE() macro to help ensure that
checking for relative/absolute timeouts is consistent. Using this
macro also helps ensure that we get the correct behavior when using
32-bit timeouts (CONFIG_TIMEOUT_64BIT=n).
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Do not start the LF clock unless CONFIG_CLOCK_CONTROL_NRF is enabled.
This is similar to how it's done in Nordic's GRTC driver.
Authored-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Correct the introduction comment, removing the native_posix mention,
and something which did not apply for several years.
Also remove an unnecessary include.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Including renaming the kconfig option
NATIVE_POSIX_TIMER into NATIVE_SIM_TIMER deprecating the first one.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Now that native_posix has been removed, this driver only needs to
support native_sim. Let's stop using the transitional headers which
supported both.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Modify the Cortex-M SysTick driver to work when the SoC resets SysTick
in low-power mode. This adds an invisible Kconfig symbol that must be
selected by SoCs with such behavior.
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Add support for a hook-based low-power mode timer to the Cortex-M SysTick
driver, in addition to the existing Counter API-based timer. This is useful
on platforms such as the STM32WB0 where the wake-up timer is too limited
for a Counter API driver to be implemented on top of it.
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
The Cortex-M SysTick supported collaboration with a so-called "IDLE timer"
to work even in low-power modes, when the SoC may disable its clock.
Rename "IDLE timer" to "low-power mode timer" to better reflect what this
timer is used for, and transform the single option into a Kconfig choice
to allow other behaviors to be implemented and chosen.
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Map the timer register space using DEVICE_MMIO_NAMED_MAP so if the MMU
is enabled, the register space is mapped correctly in the virtual
memory.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
1. The sys_clock_idle_exit function could be invoked multiple
times. Hence add code so that is counter is stopped and the
OS Timer is initialized once.
2. Reset the OS Timer when exiting low power modes where
the OS Timer loses its state
3. Improve the cycles conversion algorithm. Round to the nearest
microsecond when converting from ticks to microsecond rather
than always rounding up to the next highest value.
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>