xref: /netbsd/sys/arch/cobalt/cobalt/mainbus.c (revision bf9ec67e)
1 /*	$NetBSD: mainbus.c,v 1.2 2000/03/31 14:51:50 soren Exp $	*/
2 
3 /*
4  * Copyright (c) 2000 Soren S. Jorvang.  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  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/device.h>
31 
32 #include <dev/pci/pcivar.h>
33 
34 #include <mips/cpuregs.h>
35 
36 #include <machine/autoconf.h>
37 
38 #include "locators.h"
39 #include "pci.h"
40 
41 static int	mainbus_match(struct device *, struct cfdata *, void *);
42 static void	mainbus_attach(struct device *, struct device *, void *);
43 static int	mainbus_search(struct device *, struct cfdata *, void *);
44 int		mainbus_print(void *, const char *);
45 
46 struct cfattach mainbus_ca = {
47 	sizeof(struct device), mainbus_match, mainbus_attach
48 };
49 
50 static int
51 mainbus_match(parent, match, aux)
52 	struct device *parent;
53 	struct cfdata *match;
54 	void *aux;
55 {
56 	return 1;
57 }
58 
59 static void
60 mainbus_attach(parent, self, aux)
61 	struct device *parent;
62 	struct device *self;
63 	void *aux;
64 {
65 	struct mainbus_attach_args *ma = aux;
66 
67 	/*
68 	 * XXX Check for Qube/RaQ 1 vs. 2.
69 	 */
70 
71 	printf("\n");
72 
73 	config_search(mainbus_search, self, ma);
74 }
75 
76 static int
77 mainbus_search(parent, cf, aux)
78 	struct device *parent;
79 	struct cfdata *cf;
80 	void *aux;
81 {
82 	struct mainbus_attach_args *ma = aux;
83 
84 	do {
85 		ma->ma_addr = cf->cf_loc[MAINBUSCF_ADDR];
86 		ma->ma_iot = 0;
87 		ma->ma_ioh = MIPS_PHYS_TO_KSEG1(ma->ma_addr);
88 		ma->ma_level = cf->cf_loc[MAINBUSCF_LEVEL];
89 		if ((*cf->cf_attach->ca_match)(parent, cf, ma) > 0)
90 			config_attach(parent, cf, ma, mainbus_print);
91 	} while (cf->cf_fstate == FSTATE_STAR);
92 
93 	return 0;
94 }
95 
96 int
97 mainbus_print(aux, pnp)
98 	void *aux;
99 	const char *pnp;
100 {
101 	struct mainbus_attach_args *ma = aux;
102 
103 	if (pnp != 0)
104 		return QUIET;
105 
106 	if (ma->ma_addr != MAINBUSCF_ADDR_DEFAULT)
107 		printf(" addr 0x%lx", ma->ma_addr);
108 	if (ma->ma_level != MAINBUSCF_LEVEL_DEFAULT)
109 		printf(" level %d", ma->ma_level);
110 
111 	return UNCONF;
112 }
113