drivers: timer: move initialization setup to drivers
The weak symbol sys_clock_driver_init has been removed, therefore moving the init responsability to the drivers themselves. As a result, the init function has now been made static on all drivers and moved to the bottom, following the convention used in other areas. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
7b1349cfe6
commit
b1ced75386
29 changed files with 724 additions and 648 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#define DT_DRV_COMPAT nxp_os_timer
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/timer/system_timer.h>
|
||||
#include <sys_clock.h>
|
||||
#include <spinlock.h>
|
||||
|
@ -50,30 +51,6 @@ void mcux_lpc_ostick_isr(void *arg)
|
|||
sys_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1);
|
||||
}
|
||||
|
||||
int sys_clock_driver_init(const struct device *device)
|
||||
{
|
||||
ARG_UNUSED(device);
|
||||
|
||||
/* Configure event timer's ISR */
|
||||
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
|
||||
mcux_lpc_ostick_isr, NULL, 0);
|
||||
|
||||
base = (OSTIMER_Type *)DT_INST_REG_ADDR(0);
|
||||
|
||||
EnableDeepSleepIRQ(DT_INST_IRQN(0));
|
||||
|
||||
/* Initialize the OS timer, setting clock configuration. */
|
||||
OSTIMER_Init(base);
|
||||
|
||||
last_count = OSTIMER_GetCurrentTimerValue(base);
|
||||
OSTIMER_SetMatchValue(base, last_count + CYC_PER_TICK, NULL);
|
||||
|
||||
/* Enable event timer interrupt */
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sys_clock_set_timeout(int32_t ticks, bool idle)
|
||||
{
|
||||
ARG_UNUSED(idle);
|
||||
|
@ -132,3 +109,30 @@ uint64_t sys_clock_cycle_get_64(void)
|
|||
{
|
||||
return OSTIMER_GetCurrentTimerValue(base);
|
||||
}
|
||||
|
||||
static int sys_clock_driver_init(const struct device *device)
|
||||
{
|
||||
ARG_UNUSED(device);
|
||||
|
||||
/* Configure event timer's ISR */
|
||||
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
|
||||
mcux_lpc_ostick_isr, NULL, 0);
|
||||
|
||||
base = (OSTIMER_Type *)DT_INST_REG_ADDR(0);
|
||||
|
||||
EnableDeepSleepIRQ(DT_INST_IRQN(0));
|
||||
|
||||
/* Initialize the OS timer, setting clock configuration. */
|
||||
OSTIMER_Init(base);
|
||||
|
||||
last_count = OSTIMER_GetCurrentTimerValue(base);
|
||||
OSTIMER_SetMatchValue(base, last_count + CYC_PER_TICK, NULL);
|
||||
|
||||
/* Enable event timer interrupt */
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(sys_clock_driver_init, PRE_KERNEL_2,
|
||||
CONFIG_SYSTEM_CLOCK_INIT_PRIORITY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue