diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 9c51c0a8af8..eb183511626 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -7,13 +7,6 @@ menu "Timer Drivers" -config SYSTEM_CLOCK_DISABLE - bool "API to disable system clock" - help - This option enables the sys_clock_disable() API in the kernel. It is - needed by some subsystems (which will automatically select it), but is - rarely needed by applications. - config TIMER_HAS_64BIT_CYCLE_COUNTER bool help @@ -55,6 +48,12 @@ config TICKLESS_CAPABLE sys_clock_announce() (really, not to produce an interrupt at all) until the specified expiration. +config SYSTEM_TIMER_HAS_DISABLE_SUPPORT + bool + help + This option should be selected by drivers implementing support for + sys_clock_disable() API. + source "drivers/timer/Kconfig.altera_avalon" source "drivers/timer/Kconfig.apic" source "drivers/timer/Kconfig.arcv2" diff --git a/drivers/timer/Kconfig.cortex_m_systick b/drivers/timer/Kconfig.cortex_m_systick index 358109b244e..f95ca3b656b 100644 --- a/drivers/timer/Kconfig.cortex_m_systick +++ b/drivers/timer/Kconfig.cortex_m_systick @@ -16,6 +16,7 @@ config CORTEX_M_SYSTICK $(dt_compat_enabled,$(DT_COMPAT_ARM_V8M_SYSTICK)) || \ $(dt_compat_enabled,$(DT_COMPAT_ARM_V8_1M_SYSTICK)) select TICKLESS_CAPABLE + select SYSTEM_TIMER_HAS_DISABLE_SUPPORT help This module implements a kernel device driver for the Cortex-M processor SYSTICK timer and provides the standard "system clock driver" interfaces. diff --git a/drivers/timer/Kconfig.mchp_xec_rtos b/drivers/timer/Kconfig.mchp_xec_rtos index 4c348483d9b..fbf7fddc490 100644 --- a/drivers/timer/Kconfig.mchp_xec_rtos +++ b/drivers/timer/Kconfig.mchp_xec_rtos @@ -7,6 +7,7 @@ config MCHP_XEC_RTOS_TIMER bool "Microchip XEC series RTOS timer" depends on SOC_FAMILY_MEC select TICKLESS_CAPABLE + select SYSTEM_TIMER_HAS_DISABLE_SUPPORT help This module implements a kernel device driver for the Microchip XEC series RTOS timer and provides the standard "system clock diff --git a/drivers/timer/Kconfig.mcux_lptmr b/drivers/timer/Kconfig.mcux_lptmr index d72983dd36c..c7b03b3c6e0 100644 --- a/drivers/timer/Kconfig.mcux_lptmr +++ b/drivers/timer/Kconfig.mcux_lptmr @@ -6,6 +6,7 @@ config MCUX_LPTMR_TIMER bool "MCUX LPTMR timer" depends on HAS_MCUX_LPTMR && !COUNTER_MCUX_LPTMR + select SYSTEM_TIMER_HAS_DISABLE_SUPPORT help This module implements a kernel device driver for the NXP MCUX Low Power Timer (LPTMR) and provides the standard "system clock driver" diff --git a/drivers/timer/Kconfig.native_posix b/drivers/timer/Kconfig.native_posix index 72962d3f8b4..6fe1c3bde4d 100644 --- a/drivers/timer/Kconfig.native_posix +++ b/drivers/timer/Kconfig.native_posix @@ -9,6 +9,7 @@ config NATIVE_POSIX_TIMER depends on BOARD_NATIVE_POSIX select TICKLESS_CAPABLE select TIMER_HAS_64BIT_CYCLE_COUNTER + select SYSTEM_TIMER_HAS_DISABLE_SUPPORT help This module implements a kernel device driver for the native_posix HW timer model diff --git a/drivers/timer/native_posix_timer.c b/drivers/timer/native_posix_timer.c index 62b492ee053..246e000646e 100644 --- a/drivers/timer/native_posix_timer.c +++ b/drivers/timer/native_posix_timer.c @@ -107,8 +107,6 @@ uint32_t sys_clock_elapsed(void) return (hwm_get_time() - last_tick_time)/tick_period; } - -#if defined(CONFIG_SYSTEM_CLOCK_DISABLE) /** * * @brief Stop announcing sys ticks into the kernel @@ -122,7 +120,6 @@ void sys_clock_disable(void) irq_disable(TIMER_TICK_IRQ); hwtimer_set_silent_ticks(INT64_MAX); } -#endif /* CONFIG_SYSTEM_CLOCK_DISABLE */ /* * @brief Initialize system timer driver diff --git a/drivers/timer/sys_clock_init.c b/drivers/timer/sys_clock_init.c index f44dc7299f4..ea60adb67a2 100644 --- a/drivers/timer/sys_clock_init.c +++ b/drivers/timer/sys_clock_init.c @@ -30,7 +30,3 @@ void __weak sys_clock_set_timeout(int32_t ticks, bool idle) void __weak sys_clock_idle_exit(void) { } - -void __weak sys_clock_disable(void) -{ -} diff --git a/include/drivers/timer/system_timer.h b/include/drivers/timer/system_timer.h index e875e63892e..107bf901af2 100644 --- a/include/drivers/timer/system_timer.h +++ b/include/drivers/timer/system_timer.h @@ -108,6 +108,21 @@ extern void sys_clock_announce(int32_t ticks); * instantaneous answer. */ extern uint32_t sys_clock_elapsed(void); + +#if defined(CONFIG_SYS_CLOCK_EXISTS) && \ + defined(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT) || \ + defined(__DOXYGEN__) +/** + * @brief Disable system timer. + * + * This function is a no-op if the system timer does not have the capability + * of being disabled. + */ +extern void sys_clock_disable(void); +#else +static inline void sys_clock_disable(void) {} +#endif /* CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT */ + /** * @} */ diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 71253cfdf63..720758e3bc9 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -132,11 +132,10 @@ endif config REBOOT bool "Reboot functionality" - select SYSTEM_CLOCK_DISABLE help Enable the sys_reboot() API. Enabling this can drag in other subsystems - needed to perform a "safe" reboot (e.g. SYSTEM_CLOCK_DISABLE, to stop the - system clock before issuing a reset). + needed to perform a "safe" reboot (e.g. to stop the system clock before + issuing a reset). rsource "Kconfig.cbprintf" diff --git a/lib/os/reboot.c b/lib/os/reboot.c index c15c954a174..a93d765d742 100644 --- a/lib/os/reboot.c +++ b/lib/os/reboot.c @@ -4,19 +4,17 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include extern void sys_arch_reboot(int type); -extern void sys_clock_disable(void); FUNC_NORETURN void sys_reboot(int type) { (void)irq_lock(); -#ifdef CONFIG_SYS_CLOCK_EXISTS sys_clock_disable(); -#endif sys_arch_reboot(type);