xref: /original-bsd/sys/sparc/sparc/auxreg.c (revision a043e977)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratories.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)auxreg.c	7.3 (Berkeley) 10/11/92
17  *
18  * from: $Header: auxreg.c,v 1.7 92/06/17 05:21:54 torek Exp $ (LBL)
19  */
20 
21 #include <sys/param.h>
22 #include <sys/device.h>
23 #include <sys/kernel.h>
24 
25 #include <machine/autoconf.h>
26 
27 #include <sparc/sparc/vaddrs.h>
28 #include <sparc/sparc/auxreg.h>
29 
30 static void auxregattach __P((struct device *, struct device *, void *));
31 struct cfdriver auxregcd =
32     { NULL, "auxiliary-io", matchbyname, auxregattach,
33       DV_DULL, sizeof(struct device) };
34 
35 #ifdef BLINK
36 static int
37 blink(zero)
38 	void *zero;
39 {
40 	register int s;
41 	register fixpt_t lav;
42 
43 	s = splhigh();
44 	*AUXIO_REG = (*AUXIO_REG | AUXIO_MB1) ^ AUXIO_LED;
45 	splx(s);
46 	/*
47 	 * Blink rate is:
48 	 *	full cycle every second if completely idle (loadav = 0)
49 	 *	full cycle every 2 seconds if loadav = 1
50 	 *	full cycle every 3 seconds if loadav = 2
51 	 * etc.
52 	 */
53 	s = (((averunnable[0] + FSCALE) * hz) >> (FSHIFT + 1));
54 	timeout(blink, (caddr_t)0, s);
55 }
56 #endif
57 
58 /* ARGSUSED */
59 static void
60 auxregattach(parent, self, aux)
61 	struct device *parent, *self;
62 	void *aux;
63 {
64 	struct romaux *ra = aux;
65 
66 	(void)mapdev(ra->ra_paddr, AUXREG_VA, sizeof(long));
67 	printf("\n");
68 #ifdef BLINK
69 	blink((caddr_t)0);
70 #endif
71 }
72