uba_mainbus.c revision 1.7 1 /* $NetBSD: uba_mainbus.c,v 1.7 2003/08/07 16:30:15 agc Exp $ */
2 /*
3 * Copyright (c) 1982, 1986 The Regents of the University of California.
4 * 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. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)uba.c 7.10 (Berkeley) 12/16/90
31 * @(#)autoconf.c 7.20 (Berkeley) 5/9/91
32 */
33
34 /*
35 * Copyright (c) 1996 Jonathan Stone.
36 * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)uba.c 7.10 (Berkeley) 12/16/90
67 * @(#)autoconf.c 7.20 (Berkeley) 5/9/91
68 */
69
70 #include <sys/cdefs.h>
71 __KERNEL_RCSID(0, "$NetBSD: uba_mainbus.c,v 1.7 2003/08/07 16:30:15 agc Exp $");
72
73 #include <sys/param.h>
74 #include <sys/device.h>
75 #include <sys/systm.h>
76
77 #define _VAX_BUS_DMA_PRIVATE
78 #include <machine/bus.h>
79 #include <machine/mtpr.h>
80 #include <machine/nexus.h>
81 #include <machine/cpu.h>
82 #include <machine/sgmap.h>
83
84 #include <dev/qbus/ubavar.h>
85
86 #include <arch/vax/uba/uba_common.h>
87
88 /* Some Qbus-specific defines */
89 #define QBASIZE (8192 * VAX_NBPG)
90 #define QBAMAP 0x20088000
91 #define QIOPAGE 0x20000000
92
93 /*
94 * The Q22 bus is the main IO bus on MicroVAX II/MicroVAX III systems.
95 * It has an address space of 4MB (22 address bits), therefore the name,
96 * and is hardware compatible with all 16 and 18 bits Q-bus devices.
97 */
98 static int qba_match __P((struct device *, struct cfdata *, void *));
99 static void qba_attach __P((struct device *, struct device *, void *));
100 static void qba_beforescan __P((struct uba_softc*));
101 static void qba_init __P((struct uba_softc*));
102
103 CFATTACH_DECL(uba_mainbus, sizeof(struct uba_vsoftc),
104 qba_match, qba_attach, NULL, NULL);
105
106 extern struct vax_bus_space vax_mem_bus_space;
107
108 int
109 qba_match(parent, vcf, aux)
110 struct device *parent;
111 struct cfdata *vcf;
112 void *aux;
113 {
114 struct bp_conf *bp = aux;
115
116 if (strcmp(bp->type, "uba"))
117 return 0;
118
119 return 1;
120 }
121
122 void
123 qba_attach(parent, self, aux)
124 struct device *parent, *self;
125 void *aux;
126 {
127 struct uba_vsoftc *sc = (void *)self;
128
129 printf(": Q22\n");
130 /*
131 * Fill in bus specific data.
132 */
133 sc->uv_sc.uh_beforescan = qba_beforescan;
134 sc->uv_sc.uh_ubainit = qba_init;
135 sc->uv_sc.uh_iot = &vax_mem_bus_space;
136 sc->uv_sc.uh_dmat = &sc->uv_dmat;
137
138 /*
139 * Fill in variables used by the sgmap system.
140 */
141 sc->uv_size = QBASIZE; /* Size in bytes of Qbus space */
142 sc->uv_addr = QBAMAP; /* Physical address of map registers */
143
144 uba_dma_init(sc);
145 uba_attach(&sc->uv_sc, QIOPAGE);
146 }
147
148 /*
149 * Called when the QBA is set up; to enable DMA access from
150 * QBA devices to main memory.
151 */
152 void
153 qba_beforescan(sc)
154 struct uba_softc *sc;
155 {
156 #define QIPCR 0x1f40
157 #define Q_LMEAE 0x20
158 bus_space_write_2(sc->uh_tag, sc->uh_ioh, QIPCR, Q_LMEAE);
159 }
160
161 void
162 qba_init(sc)
163 struct uba_softc *sc;
164 {
165 mtpr(0, PR_IUR);
166 DELAY(500000);
167 qba_beforescan(sc);
168 }
169