drivers: timer: improve sys_timer_disable usage
- Remove the weak symbol definition - Notify about the capability of disabling via a selected Kconfig option (CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT) - Provide a dummy inline function when the functionality is not available Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
24a169e329
commit
78dc8ce338
10 changed files with 28 additions and 20 deletions
|
@ -7,13 +7,6 @@
|
||||||
|
|
||||||
menu "Timer Drivers"
|
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
|
config TIMER_HAS_64BIT_CYCLE_COUNTER
|
||||||
bool
|
bool
|
||||||
help
|
help
|
||||||
|
@ -55,6 +48,12 @@ config TICKLESS_CAPABLE
|
||||||
sys_clock_announce() (really, not to produce an interrupt at
|
sys_clock_announce() (really, not to produce an interrupt at
|
||||||
all) until the specified expiration.
|
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.altera_avalon"
|
||||||
source "drivers/timer/Kconfig.apic"
|
source "drivers/timer/Kconfig.apic"
|
||||||
source "drivers/timer/Kconfig.arcv2"
|
source "drivers/timer/Kconfig.arcv2"
|
||||||
|
|
|
@ -16,6 +16,7 @@ config CORTEX_M_SYSTICK
|
||||||
$(dt_compat_enabled,$(DT_COMPAT_ARM_V8M_SYSTICK)) || \
|
$(dt_compat_enabled,$(DT_COMPAT_ARM_V8M_SYSTICK)) || \
|
||||||
$(dt_compat_enabled,$(DT_COMPAT_ARM_V8_1M_SYSTICK))
|
$(dt_compat_enabled,$(DT_COMPAT_ARM_V8_1M_SYSTICK))
|
||||||
select TICKLESS_CAPABLE
|
select TICKLESS_CAPABLE
|
||||||
|
select SYSTEM_TIMER_HAS_DISABLE_SUPPORT
|
||||||
help
|
help
|
||||||
This module implements a kernel device driver for the Cortex-M processor
|
This module implements a kernel device driver for the Cortex-M processor
|
||||||
SYSTICK timer and provides the standard "system clock driver" interfaces.
|
SYSTICK timer and provides the standard "system clock driver" interfaces.
|
||||||
|
|
|
@ -7,6 +7,7 @@ config MCHP_XEC_RTOS_TIMER
|
||||||
bool "Microchip XEC series RTOS timer"
|
bool "Microchip XEC series RTOS timer"
|
||||||
depends on SOC_FAMILY_MEC
|
depends on SOC_FAMILY_MEC
|
||||||
select TICKLESS_CAPABLE
|
select TICKLESS_CAPABLE
|
||||||
|
select SYSTEM_TIMER_HAS_DISABLE_SUPPORT
|
||||||
help
|
help
|
||||||
This module implements a kernel device driver for the Microchip
|
This module implements a kernel device driver for the Microchip
|
||||||
XEC series RTOS timer and provides the standard "system clock
|
XEC series RTOS timer and provides the standard "system clock
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
config MCUX_LPTMR_TIMER
|
config MCUX_LPTMR_TIMER
|
||||||
bool "MCUX LPTMR timer"
|
bool "MCUX LPTMR timer"
|
||||||
depends on HAS_MCUX_LPTMR && !COUNTER_MCUX_LPTMR
|
depends on HAS_MCUX_LPTMR && !COUNTER_MCUX_LPTMR
|
||||||
|
select SYSTEM_TIMER_HAS_DISABLE_SUPPORT
|
||||||
help
|
help
|
||||||
This module implements a kernel device driver for the NXP MCUX Low
|
This module implements a kernel device driver for the NXP MCUX Low
|
||||||
Power Timer (LPTMR) and provides the standard "system clock driver"
|
Power Timer (LPTMR) and provides the standard "system clock driver"
|
||||||
|
|
|
@ -9,6 +9,7 @@ config NATIVE_POSIX_TIMER
|
||||||
depends on BOARD_NATIVE_POSIX
|
depends on BOARD_NATIVE_POSIX
|
||||||
select TICKLESS_CAPABLE
|
select TICKLESS_CAPABLE
|
||||||
select TIMER_HAS_64BIT_CYCLE_COUNTER
|
select TIMER_HAS_64BIT_CYCLE_COUNTER
|
||||||
|
select SYSTEM_TIMER_HAS_DISABLE_SUPPORT
|
||||||
help
|
help
|
||||||
This module implements a kernel device driver for the native_posix HW timer
|
This module implements a kernel device driver for the native_posix HW timer
|
||||||
model
|
model
|
||||||
|
|
|
@ -107,8 +107,6 @@ uint32_t sys_clock_elapsed(void)
|
||||||
return (hwm_get_time() - last_tick_time)/tick_period;
|
return (hwm_get_time() - last_tick_time)/tick_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSTEM_CLOCK_DISABLE)
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Stop announcing sys ticks into the kernel
|
* @brief Stop announcing sys ticks into the kernel
|
||||||
|
@ -122,7 +120,6 @@ void sys_clock_disable(void)
|
||||||
irq_disable(TIMER_TICK_IRQ);
|
irq_disable(TIMER_TICK_IRQ);
|
||||||
hwtimer_set_silent_ticks(INT64_MAX);
|
hwtimer_set_silent_ticks(INT64_MAX);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SYSTEM_CLOCK_DISABLE */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Initialize system timer driver
|
* @brief Initialize system timer driver
|
||||||
|
|
|
@ -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_idle_exit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void __weak sys_clock_disable(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -108,6 +108,21 @@ extern void sys_clock_announce(int32_t ticks);
|
||||||
* instantaneous answer.
|
* instantaneous answer.
|
||||||
*/
|
*/
|
||||||
extern uint32_t sys_clock_elapsed(void);
|
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 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -132,11 +132,10 @@ endif
|
||||||
|
|
||||||
config REBOOT
|
config REBOOT
|
||||||
bool "Reboot functionality"
|
bool "Reboot functionality"
|
||||||
select SYSTEM_CLOCK_DISABLE
|
|
||||||
help
|
help
|
||||||
Enable the sys_reboot() API. Enabling this can drag in other subsystems
|
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
|
needed to perform a "safe" reboot (e.g. to stop the system clock before
|
||||||
system clock before issuing a reset).
|
issuing a reset).
|
||||||
|
|
||||||
rsource "Kconfig.cbprintf"
|
rsource "Kconfig.cbprintf"
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,17 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <drivers/timer/system_timer.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <sys/printk.h>
|
#include <sys/printk.h>
|
||||||
|
|
||||||
extern void sys_arch_reboot(int type);
|
extern void sys_arch_reboot(int type);
|
||||||
extern void sys_clock_disable(void);
|
|
||||||
|
|
||||||
FUNC_NORETURN void sys_reboot(int type)
|
FUNC_NORETURN void sys_reboot(int type)
|
||||||
{
|
{
|
||||||
(void)irq_lock();
|
(void)irq_lock();
|
||||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
|
||||||
sys_clock_disable();
|
sys_clock_disable();
|
||||||
#endif
|
|
||||||
|
|
||||||
sys_arch_reboot(type);
|
sys_arch_reboot(type);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue