obio.c revision 1.7.2.4 1 1.7.2.4 skrll /* $NetBSD: obio.c,v 1.7.2.4 2004/12/18 09:31:15 skrll Exp $ */
2 1.1 wdk
3 1.1 wdk /*-
4 1.1 wdk * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1 wdk * All rights reserved.
6 1.1 wdk *
7 1.1 wdk * This code is derived from software contributed to The NetBSD Foundation
8 1.1 wdk * by Wayne Knowles
9 1.1 wdk *
10 1.1 wdk * Redistribution and use in source and binary forms, with or without
11 1.1 wdk * modification, are permitted provided that the following conditions
12 1.1 wdk * are met:
13 1.1 wdk * 1. Redistributions of source code must retain the above copyright
14 1.1 wdk * notice, this list of conditions and the following disclaimer.
15 1.1 wdk * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 wdk * notice, this list of conditions and the following disclaimer in the
17 1.1 wdk * documentation and/or other materials provided with the distribution.
18 1.1 wdk * 3. All advertising materials mentioning features or use of this software
19 1.1 wdk * must display the following acknowledgement:
20 1.1 wdk * This product includes software developed by the NetBSD
21 1.1 wdk * Foundation, Inc. and its contributors.
22 1.1 wdk * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 wdk * contributors may be used to endorse or promote products derived
24 1.1 wdk * from this software without specific prior written permission.
25 1.1 wdk *
26 1.1 wdk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 wdk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 wdk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 wdk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 wdk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 wdk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 wdk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 wdk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 wdk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 wdk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 wdk * POSSIBILITY OF SUCH DAMAGE.
37 1.1 wdk */
38 1.1 wdk
39 1.7.2.1 skrll #include <sys/cdefs.h>
40 1.7.2.4 skrll __KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.7.2.4 2004/12/18 09:31:15 skrll Exp $");
41 1.7.2.4 skrll
42 1.7.2.4 skrll #include "locators.h"
43 1.7.2.1 skrll
44 1.1 wdk #include <sys/param.h>
45 1.1 wdk #include <sys/systm.h>
46 1.1 wdk #include <sys/device.h>
47 1.1 wdk
48 1.1 wdk #include <machine/autoconf.h>
49 1.1 wdk #include <machine/mainboard.h>
50 1.1 wdk #include <machine/bus.h>
51 1.2 wdk #include <machine/sysconf.h>
52 1.1 wdk
53 1.1 wdk static int obio_match __P((struct device *, struct cfdata *, void *));
54 1.1 wdk static void obio_attach __P((struct device *, struct device *, void *));
55 1.1 wdk static int obio_search __P((struct device *, struct cfdata *, void *));
56 1.1 wdk static int obio_print __P((void *, const char *));
57 1.2 wdk static void obio_intr_establish __P((bus_space_tag_t, int, int, int,
58 1.2 wdk int (*)(void *), void *));
59 1.1 wdk
60 1.6 thorpej CFATTACH_DECL(obio, sizeof(struct device),
61 1.6 thorpej obio_match, obio_attach, NULL, NULL);
62 1.1 wdk
63 1.1 wdk extern struct cfdriver obio_cd;
64 1.1 wdk
65 1.1 wdk struct mipsco_bus_space obio_bustag;
66 1.1 wdk struct mipsco_bus_dma_tag obio_dmatag;
67 1.1 wdk
68 1.1 wdk static int
69 1.1 wdk obio_match(parent, cf, aux)
70 1.1 wdk struct device *parent;
71 1.1 wdk struct cfdata *cf;
72 1.1 wdk void *aux;
73 1.1 wdk {
74 1.1 wdk struct confargs *ca = aux;
75 1.1 wdk
76 1.1 wdk if (strcmp(ca->ca_name, obio_cd.cd_name) != 0)
77 1.1 wdk return 0;
78 1.1 wdk
79 1.1 wdk return 1;
80 1.1 wdk }
81 1.1 wdk
82 1.1 wdk static void
83 1.1 wdk obio_attach(parent, self, aux)
84 1.1 wdk struct device *parent;
85 1.1 wdk struct device *self;
86 1.1 wdk void *aux;
87 1.1 wdk {
88 1.1 wdk struct confargs *ca = aux;
89 1.1 wdk
90 1.1 wdk /* PIZAZZ (Mips 3000 Magnum) Address Map */
91 1.1 wdk mipsco_bus_space_init(&obio_bustag, "obio",
92 1.1 wdk 0x18000000, 0xb8000000,
93 1.1 wdk 0xb8000000, 0x08000000);
94 1.1 wdk
95 1.1 wdk _bus_dma_tag_init(&obio_dmatag);
96 1.2 wdk obio_bustag.bs_intr_establish = obio_intr_establish; /* XXX */
97 1.2 wdk
98 1.1 wdk ca->ca_bustag = &obio_bustag;
99 1.1 wdk ca->ca_dmatag = &obio_dmatag;
100 1.1 wdk
101 1.1 wdk printf("\n");
102 1.1 wdk config_search(obio_search, self, ca);
103 1.1 wdk }
104 1.1 wdk
105 1.1 wdk static int
106 1.1 wdk obio_search(parent, cf, aux)
107 1.1 wdk struct device *parent;
108 1.1 wdk struct cfdata *cf;
109 1.1 wdk void *aux;
110 1.1 wdk {
111 1.1 wdk struct confargs *ca = aux;
112 1.1 wdk
113 1.1 wdk ca->ca_addr = cf->cf_addr;
114 1.3 thorpej ca->ca_name = cf->cf_name;
115 1.1 wdk
116 1.4 thorpej if (config_match(parent, cf, ca) != 0)
117 1.1 wdk config_attach(parent, cf, ca, obio_print);
118 1.1 wdk
119 1.1 wdk return 0;
120 1.1 wdk }
121 1.1 wdk
122 1.1 wdk /*
123 1.1 wdk * Print out the confargs. The (parent) name is non-NULL
124 1.1 wdk * when there was no match found by config_found().
125 1.1 wdk */
126 1.1 wdk static int
127 1.1 wdk obio_print(args, name)
128 1.1 wdk void *args;
129 1.1 wdk const char *name;
130 1.1 wdk {
131 1.1 wdk struct confargs *ca = args;
132 1.1 wdk
133 1.1 wdk if (name)
134 1.1 wdk return(QUIET);
135 1.1 wdk
136 1.1 wdk if (ca->ca_addr != -1)
137 1.7 thorpej aprint_normal(" addr 0x%x", ca->ca_addr);
138 1.1 wdk
139 1.1 wdk return(UNCONF);
140 1.1 wdk }
141 1.1 wdk
142 1.2 wdk void
143 1.2 wdk obio_intr_establish(bst, level, pri, flags, func, arg)
144 1.2 wdk bus_space_tag_t bst;
145 1.2 wdk int level;
146 1.2 wdk int pri;
147 1.2 wdk int flags;
148 1.2 wdk int (*func) __P((void *));
149 1.2 wdk void *arg;
150 1.2 wdk {
151 1.2 wdk (*platform.intr_establish)(level, func, arg);
152 1.2 wdk }
153