- initialize cpuspeed and curcpu() according to cobalt model id
- switch to cpu cyclecounter based delay(9), taken from evbmips
This commit is contained in:
parent
24f29ca641
commit
661d2895e2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.17 2006/04/05 15:03:27 tsutsui Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.18 2006/04/21 16:52:15 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2006/04/05 15:03:27 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.18 2006/04/21 16:52:15 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -41,8 +41,6 @@ extern int netboot;
|
|||
extern int bootunit;
|
||||
extern int bootpart;
|
||||
|
||||
int cpuspeed = 100; /* Until we know more precisely. */
|
||||
|
||||
void
|
||||
cpu_configure(void)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clock.c,v 1.11 2006/04/15 13:33:04 tsutsui Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.12 2006/04/21 16:52:15 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2006/04/15 13:33:04 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12 2006/04/21 16:52:15 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -36,6 +36,8 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2006/04/15 13:33:04 tsutsui Exp $");
|
|||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <mips/locore.h>
|
||||
|
||||
#include <cobalt/cobalt/clockvar.h>
|
||||
|
||||
static todr_chip_handle_t todr_handle;
|
||||
|
@ -172,3 +174,29 @@ microtime(struct timeval *tvp)
|
|||
lasttime = *tvp;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
delay(unsigned int n)
|
||||
{
|
||||
uint32_t cur, last, delta, usecs;
|
||||
|
||||
last = mips3_cp0_count_read();
|
||||
delta = usecs = 0;
|
||||
|
||||
while (n > usecs) {
|
||||
cur = mips3_cp0_count_read();
|
||||
|
||||
/* Check to see if the timer has wrapped around. */
|
||||
if (cur < last)
|
||||
delta += ((curcpu()->ci_cycles_per_hz - last) + cur);
|
||||
else
|
||||
delta += (cur - last);
|
||||
|
||||
last = cur;
|
||||
|
||||
if (delta >= curcpu()->ci_divisor_delay) {
|
||||
usecs += delta / curcpu()->ci_divisor_delay;
|
||||
delta %= curcpu()->ci_divisor_delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.61 2006/04/21 16:27:33 tsutsui Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.62 2006/04/21 16:52:15 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.61 2006/04/21 16:27:33 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.62 2006/04/21 16:52:15 tsutsui Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
|
@ -104,6 +104,8 @@ char * root_bstr = NULL;
|
|||
int bootunit = -1;
|
||||
int bootpart = -1;
|
||||
|
||||
int cpuspeed;
|
||||
|
||||
u_int cobalt_id;
|
||||
static const char * const cobalt_model[] =
|
||||
{
|
||||
|
@ -201,6 +203,29 @@ mach_init(unsigned int memsize, u_int bim, char *bip)
|
|||
else
|
||||
strcpy(cpu_model, cobalt_model[cobalt_id]);
|
||||
|
||||
switch (cobalt_id) {
|
||||
case COBALT_ID_QUBE2700:
|
||||
case COBALT_ID_RAQ:
|
||||
cpuspeed = 150; /* MHz */
|
||||
break;
|
||||
case COBALT_ID_QUBE2:
|
||||
case COBALT_ID_RAQ2:
|
||||
cpuspeed = 250; /* MHz */
|
||||
break;
|
||||
default:
|
||||
/* assume the fastest, so that delay(9) works */
|
||||
cpuspeed = 250;
|
||||
break;
|
||||
}
|
||||
curcpu()->ci_cpu_freq = cpuspeed * 1000 * 1000;
|
||||
curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz;
|
||||
curcpu()->ci_divisor_delay =
|
||||
((curcpu()->ci_cpu_freq + (1000000 / 2)) / 1000000);
|
||||
/* all models have Rm5200, which is CPU_MIPS_DOUBLE_COUNT */
|
||||
curcpu()->ci_cycles_per_hz /= 2;
|
||||
curcpu()->ci_divisor_delay /= 2;
|
||||
MIPS_SET_CI_RECIPRICAL(curcpu());
|
||||
|
||||
physmem = btoc(memsize - MIPS_KSEG0_START);
|
||||
|
||||
consinit();
|
||||
|
@ -370,16 +395,6 @@ cpu_reboot(int howto, char *bootstr)
|
|||
;
|
||||
}
|
||||
|
||||
unsigned long cpuspeed;
|
||||
|
||||
inline void
|
||||
delay(unsigned long n)
|
||||
{
|
||||
volatile register long N = cpuspeed * n;
|
||||
|
||||
while (--N > 0);
|
||||
}
|
||||
|
||||
#define NINTR 6
|
||||
|
||||
static struct cobalt_intrhand intrtab[NINTR];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: param.h,v 1.11 2006/02/16 20:17:13 perry Exp $ */
|
||||
/* $NetBSD: param.h,v 1.12 2006/04/21 16:52:15 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -112,7 +112,7 @@
|
|||
#ifdef _KERNEL
|
||||
#ifndef _LOCORE
|
||||
|
||||
__inline extern void delay(unsigned long);
|
||||
void delay(unsigned int);
|
||||
#define DELAY(n) delay(n)
|
||||
|
||||
#include <machine/intr.h>
|
||||
|
|
Loading…
Reference in New Issue