From f19c04e3ed0402153e3332695841216f48bf76fc Mon Sep 17 00:00:00 2001 From: pk Date: Thu, 28 Nov 2002 14:18:31 +0000 Subject: [PATCH] Move timer{match,attach}_mainbus() back into timer.c, since the `timer at mainbus' configuration declaration is orthogonal to the configured SUN4[CM] platform options. --- sys/arch/sparc/sparc/timer.c | 28 +++++++++++++- sys/arch/sparc/sparc/timer_sun4.c | 63 +++++++++++++------------------ sys/arch/sparc/sparc/timervar.h | 4 +- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/sys/arch/sparc/sparc/timer.c b/sys/arch/sparc/sparc/timer.c index ad0edea1a24d..af8d8a75f890 100644 --- a/sys/arch/sparc/sparc/timer.c +++ b/sys/arch/sparc/sparc/timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: timer.c,v 1.11 2002/11/26 14:43:39 pk Exp $ */ +/* $NetBSD: timer.c,v 1.12 2002/11/28 14:18:31 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -194,3 +194,29 @@ timerattach_obio(struct device *parent, struct device *self, void *aux) CFATTACH_DECL(timer_obio, sizeof(struct device), timermatch_obio, timerattach_obio, NULL, NULL); + +/* + * Only sun4c attaches a timer at mainbus + */ +static int +timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) +{ +#if defined(SUN4C) + struct mainbus_attach_args *ma = aux; + + return (strcmp("counter-timer", ma->ma_name) == 0); +#else + return (0); +#endif +} + +static void +timerattach_mainbus(struct device *parent, struct device *self, void *aux) +{ +#if defined(SUN4C) + timerattach_mainbus_4c(parent, self, aux); +#endif /* SUN4C */ +} + +CFATTACH_DECL(timer_mainbus, sizeof(struct device), + timermatch_mainbus, timerattach_mainbus, NULL, NULL); diff --git a/sys/arch/sparc/sparc/timer_sun4.c b/sys/arch/sparc/sparc/timer_sun4.c index 8117184cbbce..9fd5f44e7b24 100644 --- a/sys/arch/sparc/sparc/timer_sun4.c +++ b/sys/arch/sparc/sparc/timer_sun4.c @@ -1,4 +1,4 @@ -/* $NetBSD: timer_sun4.c,v 1.4 2002/10/02 16:02:12 thorpej Exp $ */ +/* $NetBSD: timer_sun4.c,v 1.5 2002/11/28 14:18:31 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -129,42 +129,6 @@ statintr_4(void *cap) return (1); } -#if defined(SUN4C) -static int -timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) -{ - struct mainbus_attach_args *ma = aux; - - return (strcmp("counter-timer", ma->ma_name) == 0); -} - -static void -timerattach_mainbus(struct device *parent, struct device *self, void *aux) -{ - struct mainbus_attach_args *ma = aux; - bus_space_handle_t bh; - - /* - * This time we ignore any existing virtual address because - * we have a fixed virtual address for the timer, to make - * microtime() faster. - */ - if (bus_space_map2(ma->ma_bustag, - ma->ma_paddr, - sizeof(struct timerreg_4), - BUS_SPACE_MAP_LINEAR, - TIMERREG_VA, &bh) != 0) { - printf(": can't map registers\n"); - return; - } - - timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit); -} - -CFATTACH_DECL(timer_mainbus, sizeof(struct device), - timermatch_mainbus, timerattach_mainbus, NULL, NULL); -#endif /* SUN4C */ - #if defined(SUN4) void timerattach_obio_4(struct device *parent, struct device *self, void *aux) @@ -186,3 +150,28 @@ timerattach_obio_4(struct device *parent, struct device *self, void *aux) timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit); } #endif /* SUN4 */ + +#if defined(SUN4C) +void +timerattach_mainbus_4c(struct device *parent, struct device *self, void *aux) +{ + struct mainbus_attach_args *ma = aux; + bus_space_handle_t bh; + + /* + * This time we ignore any existing virtual address because + * we have a fixed virtual address for the timer, to make + * microtime() faster. + */ + if (bus_space_map2(ma->ma_bustag, + ma->ma_paddr, + sizeof(struct timerreg_4), + BUS_SPACE_MAP_LINEAR, + TIMERREG_VA, &bh) != 0) { + printf(": can't map registers\n"); + return; + } + + timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit); +} +#endif /* SUN4C */ diff --git a/sys/arch/sparc/sparc/timervar.h b/sys/arch/sparc/sparc/timervar.h index bddb39b09b5a..2289576b0b85 100644 --- a/sys/arch/sparc/sparc/timervar.h +++ b/sys/arch/sparc/sparc/timervar.h @@ -1,4 +1,4 @@ -/* $NetBSD: timervar.h,v 1.1 2002/08/25 16:10:36 thorpej Exp $ */ +/* $NetBSD: timervar.h,v 1.2 2002/11/28 14:18:31 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -50,6 +50,7 @@ int statintr_4(void *); void timer_init_4(void); void timerattach_obio_4(struct device *, struct device *, void *); +void timerattach_mainbus_4c(struct device *, struct device *, void *); #endif /* SUN4 || SUN4C */ #if defined(SUN4M) @@ -65,6 +66,7 @@ extern int statvar, statmin, statint; extern int timerblurb; extern void (*timer_init)(void); +/* Common timer attach routine in timer.c: */ void timerattach(volatile int *, volatile int *); static __inline u_long __attribute__((__unused__))