xref: /netbsd/sys/arch/hpcmips/hpcmips/cpu.c (revision 6550d01e)
1 /*	$NetBSD: cpu.c,v 1.16 2009/12/14 00:46:04 matt Exp $	*/
2 /*-
3  * Copyright (c) 1999 Shin Takemura, All rights reserved.
4  * Copyright (c) 1999-2001 SATO Kazumi, All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 /*
32  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
33  * All rights reserved.
34  *
35  * Author: Chris G. Demetriou
36  *
37  * Permission to use, copy, modify and distribute this software and
38  * its documentation is hereby granted, provided that both the copyright
39  * notice and this permission notice appear in all copies of the
40  * software, derivative works or modified versions, and any portions
41  * thereof, and that both notices appear in supporting documentation.
42  *
43  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
44  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
45  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46  *
47  * Carnegie Mellon requests users of this software to return to
48  *
49  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
50  *  School of Computer Science
51  *  Carnegie Mellon University
52  *  Pittsburgh PA 15213-3890
53  *
54  * any improvements or extensions that they make and grant Carnegie the
55  * rights to redistribute these changes.
56  */
57 
58 #include <sys/cdefs.h>
59 __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.16 2009/12/14 00:46:04 matt Exp $");
60 
61 #include <sys/param.h>
62 #include <sys/systm.h>
63 #include <sys/device.h>
64 #include <sys/bus.h>
65 
66 #include <machine/sysconf.h>
67 #include <machine/autoconf.h>
68 
69 /* Definition of the driver for autoconfig. */
70 static int	cpumatch(struct device *, struct cfdata *, void *);
71 static void	cpuattach(struct device *, struct device *, void *);
72 
73 CFATTACH_DECL(cpu, sizeof (struct device),
74     cpumatch, cpuattach, NULL, NULL);
75 
76 extern struct cfdriver cpu_cd;
77 
78 static int
79 cpumatch(struct device *parent, struct cfdata *cf, void *aux)
80 {
81 	struct mainbus_attach_args *ma = aux;
82 
83 	/* make sure that we're looking for a CPU. */
84 	return (strcmp(ma->ma_name, cpu_cd.cd_name) != 0 ? 0 : 1);
85 }
86 
87 static void
88 cpuattach(struct device *parent, struct device *dev, void *aux)
89 {
90 
91 	printf(": ");
92 
93 	cpu_identify();
94 
95 	/* install CPU specific idle routine if any. */
96 	if (platform.cpu_idle != NULL)
97 		mips_locoresw.lsw_cpu_idle = platform.cpu_idle;
98 }
99