Replace many pasted identical definitions of cpu_initclocks() with a common

implementation in arm/machdep.c.  Most arm platforms either don't need to
do anything, or just need to call the standard eventtimer init routines.
A generic implementation that does that is now provided via weak linkage.
Any platform that needs to do something different can provide a its own
implementation to override the generic one.
This commit is contained in:
Ian Lepore 2014-02-26 22:06:10 +00:00
parent 85bf1d2f07
commit f0455d6562
10 changed files with 25 additions and 71 deletions

View File

@ -295,12 +295,6 @@ a10_timer_get_timerfreq(struct a10_timer_softc *sc)
return (sc->timer0_freq);
}
void
cpu_initclocks(void)
{
cpu_initclocks_bsp();
}
static int
a10_timer_hardclock(void *arg)
{

View File

@ -331,16 +331,6 @@ static devclass_t arm_tmr_devclass;
DRIVER_MODULE(timer, simplebus, arm_tmr_driver, arm_tmr_devclass, 0, 0);
void
cpu_initclocks(void)
{
if (PCPU_GET(cpuid) == 0)
cpu_initclocks_bsp();
else
cpu_initclocks_ap();
}
void
DELAY(int usec)
{

View File

@ -456,6 +456,30 @@ cpu_idle_wakeup(int cpu)
return (0);
}
/*
* Most ARM platforms don't need to do anything special to init their clocks
* (they get intialized during normal device attachment), and by not defining a
* cpu_initclocks() function they get this generic one. Any platform that needs
* to do something special can just provide their own implementation, which will
* override this one due to the weak linkage.
*/
void
arm_generic_initclocks(void)
{
#ifndef NO_EVENTTIMERS
#ifdef SMP
if (PCPU_GET(cpuid) == 0)
cpu_initclocks_bsp();
else
cpu_initclocks_ap();
#else
cpu_initclocks_bsp();
#endif
#endif
}
__weak_reference(arm_generic_initclocks, cpu_initclocks);
int
fill_regs(struct thread *td, struct reg *regs)
{

View File

@ -358,25 +358,6 @@ static devclass_t arm_tmr_devclass;
DRIVER_MODULE(mp_tmr, simplebus, arm_tmr_driver, arm_tmr_devclass, 0, 0);
/**
* cpu_initclocks - called by system to initialise the cpu clocks
*
* This is a boilerplat function, most of the setup has already been done
* when the driver was attached. Therefore this function must only be called
* after the driver is attached.
*
* RETURNS
* nothing
*/
void
cpu_initclocks(void)
{
if (PCPU_GET(cpuid) == 0)
cpu_initclocks_bsp();
else
cpu_initclocks_ap();
}
/**
* DELAY - Delay for at least usec microseconds.
* @usec: number of microseconds to delay by

View File

@ -277,12 +277,6 @@ static devclass_t bcm_systimer_devclass;
DRIVER_MODULE(bcm_systimer, simplebus, bcm_systimer_driver, bcm_systimer_devclass, 0, 0);
void
cpu_initclocks(void)
{
cpu_initclocks_bsp();
}
void
DELAY(int usec)
{

View File

@ -319,17 +319,6 @@ imx_gpt_get_timerfreq(struct imx_gpt_softc *sc)
return (sc->clkfreq);
}
void
cpu_initclocks(void)
{
if (imx_gpt_sc == NULL) {
panic("%s: i.MX GPT driver has not been initialized!", __func__);
}
cpu_initclocks_bsp();
}
static int
imx_gpt_intr(void *arg)
{

View File

@ -32,6 +32,7 @@ vm_offset_t freebsd_parse_boot_param(struct arm_boot_params *abp);
vm_offset_t linux_parse_boot_param(struct arm_boot_params *abp);
vm_offset_t fake_preload_metadata(struct arm_boot_params *abp);
vm_offset_t parse_boot_param(struct arm_boot_params *abp);
void arm_generic_initclocks(void);
/*
* Initialization functions called by the common initarm() function in

View File

@ -279,12 +279,6 @@ lpc_get_timecount(struct timecounter *tc)
return timer1_read_4(timer_softc, LPC_TIMER_TC);
}
void
cpu_initclocks(void)
{
cpu_initclocks_bsp();
}
void
DELAY(int usec)
{

View File

@ -223,13 +223,6 @@ mv_timer_get_timecount(struct timecounter *tc)
return (INITIAL_TIMECOUNTER - mv_get_timer(1));
}
void
cpu_initclocks(void)
{
cpu_initclocks_bsp();
}
void
DELAY(int usec)
{

View File

@ -661,12 +661,6 @@ static devclass_t am335x_dmtimer_devclass;
DRIVER_MODULE(am335x_dmtimer, simplebus, am335x_dmtimer_driver, am335x_dmtimer_devclass, 0, 0);
MODULE_DEPEND(am335x_dmtimer, am335x_prcm, 1, 1, 1);
void
cpu_initclocks(void)
{
cpu_initclocks_bsp();
}
void
DELAY(int usec)
{