Explicitly initialize the MFP Timer-B for delay(9) from atari_hwinit()

rather than using if(!atari_realconfig) in clockmatch().
(I doubt the latter one has actually been called..)
This commit is contained in:
tsutsui 2009-07-07 15:37:02 +00:00
parent 0745bac2ee
commit d41c06b17d
3 changed files with 31 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atari_init.c,v 1.81 2009/07/06 12:55:24 tsutsui Exp $ */ /* $NetBSD: atari_init.c,v 1.82 2009/07/07 15:37:02 tsutsui Exp $ */
/* /*
* Copyright (c) 1995 Leo Weppelman * Copyright (c) 1995 Leo Weppelman
@ -33,7 +33,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.81 2009/07/06 12:55:24 tsutsui Exp $"); __KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.82 2009/07/07 15:37:02 tsutsui Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_mbtype.h" #include "opt_mbtype.h"
@ -74,6 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.81 2009/07/06 12:55:24 tsutsui Exp
#include <atari/atari/intr.h> #include <atari/atari/intr.h>
#include <atari/atari/stalloc.h> #include <atari/atari/stalloc.h>
#include <atari/dev/clockvar.h>
#include <atari/dev/ym2149reg.h> #include <atari/dev/ym2149reg.h>
#include "pci.h" #include "pci.h"
@ -707,6 +708,11 @@ atari_hwinit(void)
} }
#endif /* defined(_ATARIHW_) */ #endif /* defined(_ATARIHW_) */
/*
* Initialize a timer for delay(9).
*/
init_delay();
#if NPCI > 0 #if NPCI > 0
if (machineid & (ATARI_HADES|ATARI_MILAN)) { if (machineid & (ATARI_HADES|ATARI_MILAN)) {
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.47 2009/07/07 15:15:08 tsutsui Exp $ */ /* $NetBSD: clock.c,v 1.48 2009/07/07 15:37:02 tsutsui Exp $ */
/* /*
* Copyright (c) 1982, 1990 The Regents of the University of California. * Copyright (c) 1982, 1990 The Regents of the University of California.
@ -77,7 +77,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.47 2009/07/07 15:15:08 tsutsui Exp $"); __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.48 2009/07/07 15:37:02 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/kernel.h> #include <sys/kernel.h>
@ -96,6 +96,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.47 2009/07/07 15:15:08 tsutsui Exp $");
#include <machine/iomap.h> #include <machine/iomap.h>
#include <machine/mfp.h> #include <machine/mfp.h>
#include <atari/dev/clockreg.h> #include <atari/dev/clockreg.h>
#include <atari/dev/clockvar.h>
#include <atari/atari/device.h> #include <atari/atari/device.h>
#if defined(GPROF) && defined(PROFTIMER) #if defined(GPROF) && defined(PROFTIMER)
@ -186,21 +187,6 @@ static int clk2min; /* current, from above choices */
int int
clockmatch(struct device *pdp, struct cfdata *cfp, void *auxp) clockmatch(struct device *pdp, struct cfdata *cfp, void *auxp)
{ {
if (!atari_realconfig) {
/*
* Initialize Timer-B in the ST-MFP. This timer is used by
* the 'delay' function below. This timer is setup to be
* continueously counting from 255 back to zero at a
* frequency of 614400Hz. We do this *early* in the
* initialisation process.
*/
MFP->mf_tbcr = 0; /* Stop timer */
MFP->mf_iera &= ~IA_TIMB; /* Disable timer interrupts */
MFP->mf_tbdr = 0;
MFP->mf_tbcr = T_Q004; /* Start timer */
return 0;
}
if(!strcmp("clock", auxp)) if(!strcmp("clock", auxp))
return(1); return(1);
return(0); return(0);
@ -342,6 +328,23 @@ clk_getcounter(struct timecounter *tc)
#define TIMB_FREQ 614400 #define TIMB_FREQ 614400
#define TIMB_LIMIT 256 #define TIMB_LIMIT 256
void
init_delay(void)
{
/*
* Initialize Timer-B in the ST-MFP. This timer is used by
* the 'delay' function below. This timer is setup to be
* continueously counting from 255 back to zero at a
* frequency of 614400Hz. We do this *early* in the
* initialisation process.
*/
MFP->mf_tbcr = 0; /* Stop timer */
MFP->mf_iera &= ~IA_TIMB; /* Disable timer interrupts */
MFP->mf_tbdr = 0;
MFP->mf_tbcr = T_Q004; /* Start timer */
}
/* /*
* Wait "n" microseconds. * Wait "n" microseconds.
* Relies on MFP-Timer B counting down from TIMB_LIMIT at TIMB_FREQ Hz. * Relies on MFP-Timer B counting down from TIMB_LIMIT at TIMB_FREQ Hz.

View File

@ -0,0 +1,3 @@
/* $NetBSD: clockvar.h,v 1.1 2009/07/07 15:37:02 tsutsui Exp $ */
void init_delay(void);