FreeBSD/Linux Kernel Cross Reference
sys/dev/bi/uba_bi.c
1 /* $NetBSD: uba_bi.c,v 1.8 2002/10/02 16:33:39 thorpej Exp $ */
2 /*
3 * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
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. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed at Ludd, University of
17 * Lule}, Sweden and its contributors.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /*
34 * DWBUA BI-Unibus adapter
35 */
36
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.8 2002/10/02 16:33:39 thorpej Exp $");
39
40 #include <sys/param.h>
41 #include <sys/kernel.h>
42 #include <sys/buf.h>
43 #include <sys/device.h>
44 #include <sys/proc.h>
45 #include <sys/user.h>
46 #include <sys/malloc.h>
47 #include <sys/systm.h>
48
49 #include <machine/sid.h>
50 #include <machine/pte.h>
51 #include <machine/pcb.h>
52 #include <machine/trap.h>
53 #include <machine/scb.h>
54
55 #include <vax/bi/bireg.h>
56 #include <vax/bi/bivar.h>
57
58 #include <vax/uba/ubareg.h>
59 #include <vax/uba/ubavar.h>
60
61 #include "locators.h"
62
63 #define BUA(uba) ((struct dwbua_regs *)(uba))
64
65 static int uba_bi_match __P((struct device *, struct cfdata *, void *));
66 static void uba_bi_attach __P((struct device *, struct device *, void *));
67 static void bua_init __P((struct uba_softc *));
68 static void bua_purge __P((struct uba_softc *, int));
69
70 /* bua_csr */
71 #define BUACSR_ERR 0x80000000 /* composite error */
72 #define BUACSR_BIF 0x10000000 /* BI failure */
73 #define BUACSR_SSYNTO 0x08000000 /* slave sync timeout */
74 #define BUACSR_UIE 0x04000000 /* unibus interlock error */
75 #define BUACSR_IVMR 0x02000000 /* invalid map register */
76 #define BUACSR_BADBDP 0x01000000 /* bad BDP select */
77 #define BUACSR_BUAEIE 0x00100000 /* bua error interrupt enable (?) */
78 #define BUACSR_UPI 0x00020000 /* unibus power init */
79 #define BUACSR_UREGDUMP 0x00010000 /* microdiag register dump */
80 #define BUACSR_IERRNO 0x000000ff /* mask for internal errror number */
81
82 /* bua_offset */
83 #define BUAOFFSET_MASK 0x00003e00 /* hence max offset = 15872 */
84
85 /* bua_dpr */
86 #define BUADPR_DPSEL 0x00e00000 /* data path select (?) */
87 #define BUADPR_PURGE 0x00000001 /* purge bdp */
88
89 /* bua_map -- in particular, those bits that are not in DW780s & DW750s */
90 #define BUAMR_IOADR 0x40000000 /* I/O address space */
91 #define BUAMR_LAE 0x04000000 /* longword access enable */
92
93 static int allocvec;
94
95 CFATTACH_DECL(uba_bi, sizeof(struct uba_softc),
96 uba_bi_match, uba_bi_attach, NULL, NULL);
97
98 struct dwbua_regs {
99 struct biiregs bn_biic; /* interface */
100 int pad1[396];
101 int bn_csr;
102 int bn_vor; /* Vector offset from SCB */
103 int bn_fubar; /* Failed Unibus address register */
104 int bn_bifar; /* BI failed address register */
105 int bn_mdiag[5]; /* microdiag regs for BDP */
106 int pad2[3];
107 int bn_dpcsr[6]; /* Data path control and status register */
108 int pad3[38];
109 struct pte bn_map[UBAPAGES]; /* Unibus map registers */
110 int pad4[UBAIOPAGES];
111 };
112
113 /*
114 * Poke at a supposed DWBUA to see if it is there.
115 */
116 static int
117 uba_bi_match(parent, cf, aux)
118 struct device *parent;
119 struct cfdata *cf;
120 void *aux;
121 {
122 struct bi_attach_args *ba = aux;
123
124 if ((ba->ba_node->biic.bi_dtype != BIDT_DWBUA) &&
125 (ba->ba_node->biic.bi_dtype != BIDT_KLESI))
126 return 0;
127
128 if (cf->cf_loc[BICF_NODE] != BICF_NODE_DEFAULT &&
129 cf->cf_loc[BICF_NODE] != ba->ba_nodenr)
130 return 0;
131
132 return 1;
133 }
134
135 void
136 uba_bi_attach(parent, self, aux)
137 struct device *parent, *self;
138 void *aux;
139 {
140 struct uba_softc *sc = (void *)self;
141 struct bi_attach_args *ba = aux;
142 volatile int timo;
143
144 if (ba->ba_node->biic.bi_dtype == BIDT_DWBUA)
145 printf(": DWBUA\n");
146 else
147 printf(": KLESI-B\n");
148
149 /*
150 * Fill in bus specific data.
151 */
152 sc->uh_uba = (void *)ba->ba_node;
153 sc->uh_nbdp = NBDPBUA;
154 /* sc->uh_nr is 0; uninteresting here */
155 /* sc->uh_afterscan; not used */
156 /* sc->uh_errchk; not used */
157 /* sc->uh_beforescan */
158 sc->uh_ubapurge = bua_purge;
159 sc->uh_ubainit = bua_init;
160 /* sc->uh_type not used */
161 sc->uh_memsize = UBAPAGES;
162 sc->uh_mr = BUA(sc->uh_uba)->bn_map;
163
164 #ifdef notdef
165 /* Can we get separate interrupts? */
166 scb->scb_nexvec[1][ba->ba_nodenr] = &sc->sc_ivec;
167 #endif
168 BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_ARB_NONE;
169 BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_STS | BICSR_INIT;
170 DELAY(1000);
171 timo = 1000;
172 while (BUA(sc->uh_uba)->bn_biic.bi_csr & BICSR_BROKE)
173 if (timo == 0) {
174 printf("%s: BROKE bit set\n", self->dv_xname);
175 return;
176 }
177
178 BUA(sc->uh_uba)->bn_biic.bi_intrdes = ba->ba_intcpu;
179 BUA(sc->uh_uba)->bn_biic.bi_csr =
180 (BUA(sc->uh_uba)->bn_biic.bi_csr&~BICSR_ARB_MASK) | BICSR_ARB_HIGH;
181 BUA(sc->uh_uba)->bn_vor = VAX_NBPG + (VAX_NBPG * allocvec++);
182
183 uba_attach(sc, BUA(sc->uh_uba)->bn_biic.bi_sadr + UBAPAGES * VAX_NBPG);
184 }
185
186
187 void
188 bua_init(sc)
189 struct uba_softc *sc;
190 {
191 BUA(sc->uh_uba)->bn_csr |= BUACSR_UPI;
192 DELAY(500000);
193 };
194
195 void
196 bua_purge(sc, bdp)
197 struct uba_softc *sc;
198 int bdp;
199 {
200 BUA(sc->uh_uba)->bn_dpcsr[bdp] |= BUADPR_PURGE;
201 }
Cache object: b3c703430c78070743a1ef06aaf21049
|