xref: /netbsd/sys/arch/arc/arc/mainbus.c (revision 6550d01e)
1 /*	$NetBSD: mainbus.c,v 1.22 2008/07/05 08:46:25 tsutsui Exp $	*/
2 /*	$OpenBSD: mainbus.c,v 1.4 1998/10/15 21:30:15 imp Exp $	*/
3 /*	NetBSD: mainbus.c,v 1.3 1995/06/28 02:45:10 cgd Exp 	*/
4 
5 /*
6  * Copyright (c) 1997 Per Fogelstrom.
7  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
8  * All rights reserved.
9  *
10  * Author: Chris G. Demetriou
11  *
12  * Permission to use, copy, modify and distribute this software and
13  * its documentation is hereby granted, provided that both the copyright
14  * notice and this permission notice appear in all copies of the
15  * software, derivative works or modified versions, and any portions
16  * thereof, and that both notices appear in supporting documentation.
17  *
18  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
19  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
20  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21  *
22  * Carnegie Mellon requests users of this software to return to
23  *
24  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
25  *  School of Computer Science
26  *  Carnegie Mellon University
27  *  Pittsburgh PA 15213-3890
28  *
29  * any improvements or extensions that they make and grant Carnegie the
30  * rights to redistribute these changes.
31  */
32 
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.22 2008/07/05 08:46:25 tsutsui Exp $");
35 
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
39 
40 #include <machine/autoconf.h>
41 #include <machine/platform.h>
42 
43 /* Definition of the mainbus driver. */
44 static int	mbmatch(device_t, cfdata_t, void *);
45 static void	mbattach(device_t, device_t, void *);
46 static int	mbprint(void *, const char *);
47 
48 CFATTACH_DECL_NEW(mainbus, 0,
49     mbmatch, mbattach, NULL, NULL);
50 
51 static int mainbus_found;
52 
53 static int
54 mbmatch(device_t parent, cfdata_t cf, void *aux)
55 {
56 
57 	if (mainbus_found)
58 		return 0;
59 
60 	return 1;
61 }
62 
63 static void
64 mbattach(device_t parent, device_t self, void *aux)
65 {
66 	struct confargs nca;
67 	int i;
68 
69 	mainbus_found = 1;
70 
71 	aprint_normal("\n");
72 
73 	/*
74 	 * Try to find and attach all of the CPUs in the machine.
75 	 * ( Right now only one CPU so code is simple )
76 	 */
77 
78 	nca.ca_name = "cpu";
79 	nca.ca_slot = 0;
80 	nca.ca_offset = 0;
81 	config_found(self, &nca, mbprint);
82 
83 	for (i = 0; platform->mainbusdevs[i] != NULL; i++) {
84 		nca.ca_name = platform->mainbusdevs[i];
85 		nca.ca_slot = 0;
86 		nca.ca_offset = 0;
87 		config_found(self, &nca, mbprint);
88 	}
89 }
90 
91 static int
92 mbprint(void *aux, const char *pnp)
93 {
94 
95 	if (pnp)
96 		return QUIET;
97 	return UNCONF;
98 }
99