Add __HAVE_GENERIC_CPU_INITCLOCKS option. If set, don't export

cpu_initclocks from device drivers as common code (in this case FDT) will
provide its own copy.
This commit is contained in:
jmcneill 2017-08-24 13:06:23 +00:00
parent 78070145bc
commit 8ae9876451
6 changed files with 47 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.arm,v 1.133 2017/06/28 23:48:23 jmcneill Exp $
# $NetBSD: files.arm,v 1.134 2017/08/24 13:06:23 jmcneill Exp $
# temporary define to allow easy moving to ../arch/arm/arm32
defflag ARM32
@ -84,6 +84,9 @@ defflag opt_arm_bus_space.h __BUS_SPACE_HAS_STREAM_METHODS
_ARM32_NEED_BUS_DMA_BOUNCE
BUSDMA_COUNTERS
# Timer options
defflag opt_arm_timer.h __HAVE_GENERIC_CPU_INITCLOCKS
# Floating point emulator
obsolete defflag ARMFPE

View File

@ -1,4 +1,4 @@
/* $NetBSD: gtmr.c,v 1.18 2017/06/17 22:49:37 jmcneill Exp $ */
/* $NetBSD: gtmr.c,v 1.19 2017/08/24 13:06:23 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.18 2017/06/17 22:49:37 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.19 2017/08/24 13:06:23 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -223,7 +223,7 @@ gtmr_init_cpu_clock(struct cpu_info *ci)
}
void
cpu_initclocks(void)
gtmr_cpu_initclocks(void)
{
struct gtmr_softc * const sc = &gtmr_sc;

View File

@ -1,4 +1,4 @@
/* $NetBSD: gtmr_var.h,v 1.6 2015/04/02 03:11:21 matt Exp $ */
/* $NetBSD: gtmr_var.h,v 1.7 2017/08/24 13:06:23 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
@ -45,11 +45,17 @@ struct gtmr_softc {
};
#ifdef _KERNEL
#include "opt_arm_timer.h"
struct cpu_info;
int gtmr_intr(void *);
void gtmr_init_cpu_clock(struct cpu_info *);
void gtmr_delay(unsigned int n);
void gtmr_bootdelay(unsigned int n);
#ifdef __HAVE_GENERIC_CPU_INITCLOCKS
void gtmr_cpu_initclocks(void);
#else
#define gtmr_cpu_initclocks cpu_initclocks
#endif
#endif
#endif /* _ARM_CORTEX_GTMR_VAR_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: arm_fdt.c,v 1.4 2017/06/29 20:55:10 jmcneill Exp $ */
/* $NetBSD: arm_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca>
@ -26,8 +26,10 @@
* SUCH DAMAGE.
*/
#include "opt_arm_timer.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.4 2017/06/29 20:55:10 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -61,6 +63,7 @@ static TAILQ_HEAD(, arm_fdt_cpu_hatch_cb) arm_fdt_cpu_hatch_cbs =
TAILQ_HEAD_INITIALIZER(arm_fdt_cpu_hatch_cbs);
static void (*_arm_fdt_irq_handler)(void *) = NULL;
static void (*_arm_fdt_timer_init)(void) = NULL;
int
arm_fdt_match(device_t parent, cfdata_t cf, void *aux)
@ -144,6 +147,18 @@ arm_fdt_irq_handler(void *tf)
_arm_fdt_irq_handler(tf);
}
void
arm_fdt_timer_register(void (*timerfn)(void))
{
if (_arm_fdt_timer_init != NULL) {
#ifdef DIAGNOSTIC
aprint_verbose("%s: timer already registered\n", __func__);
#endif
return;
}
_arm_fdt_timer_init = timerfn;
}
void
arm_fdt_memory_dump(paddr_t pa)
{
@ -166,3 +181,13 @@ arm_fdt_memory_dump(paddr_t pa)
bus_space_read_4(bst, bsh, i + 12));
}
}
#ifdef __HAVE_GENERIC_CPU_INITCLOCKS
void
cpu_initclocks(void)
{
if (_arm_fdt_timer_init == NULL)
panic("cpu_initclocks: no timer registered");
_arm_fdt_timer_init();
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: arm_fdtvar.h,v 1.6 2017/06/29 20:55:10 jmcneill Exp $ */
/* $NetBSD: arm_fdtvar.h,v 1.7 2017/08/24 13:06:23 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca>
@ -68,6 +68,8 @@ const struct arm_platform * arm_fdt_platform(void);
void arm_fdt_cpu_hatch_register(void *, void (*)(void *, struct cpu_info *));
void arm_fdt_cpu_hatch(struct cpu_info *);
void arm_fdt_timer_register(void (*)(void));
void arm_fdt_irq_set_handler(void (*)(void *));
void arm_fdt_irq_handler(void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: gtmr_fdt.c,v 1.4 2017/07/20 01:52:17 jmcneill Exp $ */
/* $NetBSD: gtmr_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.4 2017/07/20 01:52:17 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -78,6 +78,7 @@ gtmr_fdt_attach(device_t parent, device_t self, void *aux)
config_found(self, &mpcaa, NULL);
arm_fdt_cpu_hatch_register(self, gtmr_fdt_cpu_hatch);
arm_fdt_timer_register(gtmr_cpu_initclocks);
}
static void