Update _sys_clock_driver_init() interface

Prepares the _sys_clock_driver_init() routine to interface with the new driver
model.  To this end, it must accept a pointer to a device structure and return
an integer.

Change-Id: I3c600ce1efb49c0864aae7b09663ca40d6289372
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
Peter Mitsis 2015-07-06 16:31:38 -04:00 committed by Anas Nashif
commit 6e95fe0356
8 changed files with 35 additions and 13 deletions

View file

@ -160,14 +160,16 @@ void _timer_int_handler(void *unused)
* This routine is used to program the ARCv2 timer to deliver interrupts at the * This routine is used to program the ARCv2 timer to deliver interrupts at the
* rate specified via the 'sys_clock_us_per_tick' global variable. * rate specified via the 'sys_clock_us_per_tick' global variable.
* *
* @return N/A * @return 0
*/ */
void _sys_clock_driver_init(void) int _sys_clock_driver_init(struct device *device)
{ {
int irq = CONFIG_ARCV2_TIMER0_INT_LVL; int irq = CONFIG_ARCV2_TIMER0_INT_LVL;
int prio = CONFIG_ARCV2_TIMER0_INT_PRI; int prio = CONFIG_ARCV2_TIMER0_INT_PRI;
ARG_UNUSED(device);
/* ensure that the timer will not generate interrupts */ /* ensure that the timer will not generate interrupts */
_arc_v2_aux_reg_write(_ARC_V2_TMR0_CONTROL, 0); _arc_v2_aux_reg_write(_ARC_V2_TMR0_CONTROL, 0);
_arc_v2_aux_reg_write(_ARC_V2_TMR0_COUNT, 0); /* clear the count value */ _arc_v2_aux_reg_write(_ARC_V2_TMR0_COUNT, 0); /* clear the count value */
@ -183,6 +185,8 @@ void _sys_clock_driver_init(void)
/* everything has been configured: safe to enable the interrupt */ /* everything has been configured: safe to enable the interrupt */
irq_enable(CONFIG_ARCV2_TIMER0_INT_LVL); irq_enable(CONFIG_ARCV2_TIMER0_INT_LVL);
return 0;
} }
/** /**

View file

@ -613,13 +613,15 @@ void _timer_idle_exit(void)
* This routine is used to program the systick to deliver interrupts at the * This routine is used to program the systick to deliver interrupts at the
* rate specified via the 'sys_clock_us_per_tick' global variable. * rate specified via the 'sys_clock_us_per_tick' global variable.
* *
* @return N/A * @return 0
*/ */
void _sys_clock_driver_init(void) int _sys_clock_driver_init(struct device *device)
{ {
/* enable counter, interrupt and set clock src to system clock */ /* enable counter, interrupt and set clock src to system clock */
union __stcsr stcsr = {.bit = {1, 1, 1, 0, 0, 0} }; union __stcsr stcsr = {.bit = {1, 1, 1, 0, 0, 0} };
ARG_UNUSED(device);
/* /*
* Determine the reload value to achieve the configured tick rate. * Determine the reload value to achieve the configured tick rate.
*/ */
@ -640,6 +642,8 @@ void _sys_clock_driver_init(void)
_ScbExcPrioSet(_EXC_SYSTICK, _EXC_IRQ_DEFAULT_PRIO); _ScbExcPrioSet(_EXC_SYSTICK, _EXC_IRQ_DEFAULT_PRIO);
__scs.systick.stcsr.val = stcsr.val; __scs.systick.stcsr.val = stcsr.val;
return 0;
} }
/** /**

View file

@ -494,10 +494,10 @@ void _timer_idle_exit(void)
* This routine is used to program the HPET to deliver interrupts at the * This routine is used to program the HPET to deliver interrupts at the
* rate specified via the 'sys_clock_us_per_tick' global variable. * rate specified via the 'sys_clock_us_per_tick' global variable.
* *
* @return N/A * @return 0
*/ */
void _sys_clock_driver_init(void) int _sys_clock_driver_init(struct device *device)
{ {
uint64_t hpetClockPeriod; uint64_t hpetClockPeriod;
uint64_t tickFempto; uint64_t tickFempto;
@ -505,6 +505,8 @@ void _sys_clock_driver_init(void)
uint32_t counter_load_value; uint32_t counter_load_value;
#endif #endif
ARG_UNUSED(device);
/* /*
* Initial state of HPET is unknown, so put it back in a reset-like * Initial state of HPET is unknown, so put it back in a reset-like
* state * state
@ -614,6 +616,8 @@ void _sys_clock_driver_init(void)
*_HPET_GENERAL_CONFIG |= HPET_ENABLE_CNF; *_HPET_GENERAL_CONFIG |= HPET_ENABLE_CNF;
*_HPET_TIMER0_CONFIG_CAPS |= HPET_Tn_INT_ENB_CNF; *_HPET_TIMER0_CONFIG_CAPS |= HPET_Tn_INT_ENB_CNF;
return 0;
} }
/** /**

View file

@ -473,11 +473,13 @@ void _timer_idle_exit(void)
* This routine is used to program the PIT to deliver interrupts at the * This routine is used to program the PIT to deliver interrupts at the
* rate specified via the 'sys_clock_us_per_tick' global variable. * rate specified via the 'sys_clock_us_per_tick' global variable.
* *
* @return N/A * @return 0
*/ */
void _sys_clock_driver_init(void) int _sys_clock_driver_init(struct device *device)
{ {
ARG_UNUSED(device);
/* determine the PIT counter value (in timer clock cycles/system tick) /* determine the PIT counter value (in timer clock cycles/system tick)
*/ */
@ -496,6 +498,8 @@ void _sys_clock_driver_init(void)
/* Everything has been configured. It is now safe to enable the /* Everything has been configured. It is now safe to enable the
* interrupt */ * interrupt */
irq_enable(PIT_INT_LVL); irq_enable(PIT_INT_LVL);
return 0;
} }
/** /**

View file

@ -537,11 +537,13 @@ void _timer_idle_exit(void)
* This routine is used to program the PIT to deliver interrupts at the * This routine is used to program the PIT to deliver interrupts at the
* rate specified via the 'sys_clock_us_per_tick' global variable. * rate specified via the 'sys_clock_us_per_tick' global variable.
* *
* @return N/A * @return 0
*/ */
void _sys_clock_driver_init(void) int _sys_clock_driver_init(struct device *device)
{ {
ARG_UNUSED(device);
/* determine the PIT counter value (in timer clock cycles/system tick) /* determine the PIT counter value (in timer clock cycles/system tick)
*/ */
@ -565,6 +567,8 @@ void _sys_clock_driver_init(void)
/* Everything has been configured. It is now safe to enable the /* Everything has been configured. It is now safe to enable the
* interrupt */ * interrupt */
irq_enable(LOAPIC_TIMER_IRQ); irq_enable(LOAPIC_TIMER_IRQ);
return 0;
} }
/** /**

View file

@ -45,8 +45,10 @@ GTEXT(_timer_int_handler)
#else /* _ASMLANGUAGE */ #else /* _ASMLANGUAGE */
#include <device.h>
extern uint32_t timer_read(void); extern uint32_t timer_read(void);
extern void _sys_clock_driver_init(void); extern int _sys_clock_driver_init(struct device *device);
/* /*
* Timer interrupt handler is one of the routines that the driver * Timer interrupt handler is one of the routines that the driver
* has to implement, but it is not necessarily an external function. * has to implement, but it is not necessarily an external function.

View file

@ -63,7 +63,7 @@ uint32_t _sys_idle_elapsed_ticks = 1;
void nano_time_init(void) void nano_time_init(void)
{ {
_sys_clock_driver_init(); _sys_clock_driver_init(NULL);
} }
SYS_PREKERNEL_INIT(nano_time_init, 250); SYS_PREKERNEL_INIT(nano_time_init, 250);

View file

@ -966,7 +966,7 @@ def kernel_main_c_driver_init():
"void _k_init_drivers(void)\n" + "void _k_init_drivers(void)\n" +
"{\n" + "{\n" +
"#ifdef CONFIG_SYS_CLOCK_EXISTS\n" + "#ifdef CONFIG_SYS_CLOCK_EXISTS\n" +
" _sys_clock_driver_init();\n" + " _sys_clock_driver_init(NULL);\n" +
"#endif\n") "#endif\n")
for driver_call in driver_list: for driver_call in driver_list:
kernel_main_c_out(" " + driver_call + ";\n") kernel_main_c_out(" " + driver_call + ";\n")