From owner-svn-src-head@FreeBSD.ORG Wed Feb 26 22:06:12 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF1C62E8; Wed, 26 Feb 2014 22:06:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 997141201; Wed, 26 Feb 2014 22:06:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1QM6CY1028957; Wed, 26 Feb 2014 22:06:12 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1QM6Aw7028945; Wed, 26 Feb 2014 22:06:10 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201402262206.s1QM6Aw7028945@svn.freebsd.org> From: Ian Lepore Date: Wed, 26 Feb 2014 22:06:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262534 - in head/sys/arm: allwinner arm broadcom/bcm2835 freescale/imx include lpc mv ti/am335x X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Feb 2014 22:06:12 -0000 Author: ian Date: Wed Feb 26 22:06:10 2014 New Revision: 262534 URL: http://svnweb.freebsd.org/changeset/base/262534 Log: 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. Modified: head/sys/arm/allwinner/timer.c head/sys/arm/arm/generic_timer.c head/sys/arm/arm/machdep.c head/sys/arm/arm/mpcore_timer.c head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c head/sys/arm/freescale/imx/imx_gpt.c head/sys/arm/include/machdep.h head/sys/arm/lpc/lpc_timer.c head/sys/arm/mv/timer.c head/sys/arm/ti/am335x/am335x_dmtimer.c Modified: head/sys/arm/allwinner/timer.c ============================================================================== --- head/sys/arm/allwinner/timer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/allwinner/timer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -295,12 +295,6 @@ a10_timer_get_timerfreq(struct a10_timer return (sc->timer0_freq); } -void -cpu_initclocks(void) -{ - cpu_initclocks_bsp(); -} - static int a10_timer_hardclock(void *arg) { Modified: head/sys/arm/arm/generic_timer.c ============================================================================== --- head/sys/arm/arm/generic_timer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/arm/generic_timer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -332,16 +332,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) { int32_t counts, counts_per_usec; Modified: head/sys/arm/arm/machdep.c ============================================================================== --- head/sys/arm/arm/machdep.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/arm/machdep.c Wed Feb 26 22:06:10 2014 (r262534) @@ -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) { Modified: head/sys/arm/arm/mpcore_timer.c ============================================================================== --- head/sys/arm/arm/mpcore_timer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/arm/mpcore_timer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -359,25 +359,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 * Modified: head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -278,12 +278,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) { int32_t counts; Modified: head/sys/arm/freescale/imx/imx_gpt.c ============================================================================== --- head/sys/arm/freescale/imx/imx_gpt.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/freescale/imx/imx_gpt.c Wed Feb 26 22:06:10 2014 (r262534) @@ -319,17 +319,6 @@ imx_gpt_get_timerfreq(struct imx_gpt_sof 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) { Modified: head/sys/arm/include/machdep.h ============================================================================== --- head/sys/arm/include/machdep.h Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/include/machdep.h Wed Feb 26 22:06:10 2014 (r262534) @@ -32,6 +32,7 @@ vm_offset_t freebsd_parse_boot_param(str 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 Modified: head/sys/arm/lpc/lpc_timer.c ============================================================================== --- head/sys/arm/lpc/lpc_timer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/lpc/lpc_timer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -280,12 +280,6 @@ lpc_get_timecount(struct timecounter *tc } void -cpu_initclocks(void) -{ - cpu_initclocks_bsp(); -} - -void DELAY(int usec) { uint32_t counter; Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/mv/timer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -224,13 +224,6 @@ mv_timer_get_timecount(struct timecounte } void -cpu_initclocks(void) -{ - - cpu_initclocks_bsp(); -} - -void DELAY(int usec) { uint32_t val, val_temp; Modified: head/sys/arm/ti/am335x/am335x_dmtimer.c ============================================================================== --- head/sys/arm/ti/am335x/am335x_dmtimer.c Wed Feb 26 21:38:42 2014 (r262533) +++ head/sys/arm/ti/am335x/am335x_dmtimer.c Wed Feb 26 22:06:10 2014 (r262534) @@ -662,12 +662,6 @@ DRIVER_MODULE(am335x_dmtimer, simplebus, MODULE_DEPEND(am335x_dmtimer, am335x_prcm, 1, 1, 1); void -cpu_initclocks(void) -{ - cpu_initclocks_bsp(); -} - -void DELAY(int usec) { struct am335x_dmtimer_softc *sc;