Home | History | Annotate | Line # | Download | only in hpcmips
      1 /*	$NetBSD: clock.c,v 1.22 2011/03/16 14:43:36 tsutsui Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 Shin Takemura, All rights reserved.
      5  * Copyright (c) 1999-2001 SATO Kazumi, All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  *
     30  */
     31 
     32 /*
     33  * Copyright (c) 1988 University of Utah.
     34  * Copyright (c) 1992, 1993
     35  *	The Regents of the University of California.  All rights reserved.
     36  *
     37  * This code is derived from software contributed to Berkeley by
     38  * the Systems Programming Group of the University of Utah Computer
     39  * Science Department and Ralph Campbell.
     40  *
     41  * Redistribution and use in source and binary forms, with or without
     42  * modification, are permitted provided that the following conditions
     43  * are met:
     44  * 1. Redistributions of source code must retain the above copyright
     45  *    notice, this list of conditions and the following disclaimer.
     46  * 2. Redistributions in binary form must reproduce the above copyright
     47  *    notice, this list of conditions and the following disclaimer in the
     48  *    documentation and/or other materials provided with the distribution.
     49  * 3. Neither the name of the University nor the names of its contributors
     50  *    may be used to endorse or promote products derived from this software
     51  *    without specific prior written permission.
     52  *
     53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63  * SUCH DAMAGE.
     64  *
     65  * from: Utah Hdr: clock.c 1.18 91/01/21
     66  *
     67  *	@(#)clock.c	8.1 (Berkeley) 6/10/93
     68  */
     69 
     70 #include <sys/cdefs.h>
     71 __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.22 2011/03/16 14:43:36 tsutsui Exp $");
     72 
     73 #include <sys/param.h>
     74 #include <sys/systm.h>
     75 #include <sys/kernel.h>			/* hz */
     76 
     77 #include <dev/clock_subr.h>
     78 #include <machine/sysconf.h>		/* platform */
     79 
     80 /*
     81  * platform_clock_attach:
     82  *
     83  *	Register CPU(VR41XX or TX39XX) dependent clock routine to system.
     84  */
     85 void
     86 platform_clock_attach(device_t dev, struct platform_clock *clock)
     87 {
     88 
     89 	printf("\n");
     90 
     91 	clock->self = dev;
     92 	platform.clock = clock;
     93 }
     94 
     95 /*
     96  * cpu_initclocks:
     97  *
     98  *	starts periodic timer, which provides hardclock interrupts to
     99  *	kern_clock.c.
    100  *	Leave stathz 0 since there are no other timers available.
    101  */
    102 void
    103 cpu_initclocks(void)
    104 {
    105 	struct platform_clock *clock = platform.clock;
    106 
    107 	if (clock == NULL)
    108 		panic("cpu_initclocks: no clock attached");
    109 
    110 	hz = clock->hz;
    111 	tick = 1000000 / hz;
    112 
    113 	/* start periodic timer */
    114 	(*clock->init)(clock->self);
    115 }
    116 
    117 /*
    118  * setstatclockrate:
    119  *
    120  *	We assume newhz is either stathz or profhz, and that neither will
    121  *	change after being set up above.  Could recalculate intervals here
    122  *	but that would be a drag.
    123  */
    124 void
    125 setstatclockrate(int newhz)
    126 {
    127 
    128 	/* nothing we can do */
    129 }
    130 
    131 /*
    132  * delay:
    133  *
    134  *	Wait at least "n" microseconds.
    135  */
    136 void
    137 delay(int n)
    138 {
    139 
    140         DELAY(n);
    141 }
    142