bi.c revision 1.24 1 1.24 matt /* $NetBSD: bi.c,v 1.24 2008/03/11 05:34:01 matt Exp $ */
2 1.1 ragge /*
3 1.1 ragge * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 1.1 ragge * All rights reserved.
5 1.1 ragge *
6 1.1 ragge * Redistribution and use in source and binary forms, with or without
7 1.1 ragge * modification, are permitted provided that the following conditions
8 1.1 ragge * are met:
9 1.1 ragge * 1. Redistributions of source code must retain the above copyright
10 1.1 ragge * notice, this list of conditions and the following disclaimer.
11 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 ragge * notice, this list of conditions and the following disclaimer in the
13 1.1 ragge * documentation and/or other materials provided with the distribution.
14 1.1 ragge * 3. All advertising materials mentioning features or use of this software
15 1.1 ragge * must display the following acknowledgement:
16 1.20 perry * This product includes software developed at Ludd, University of
17 1.1 ragge * Lule}, Sweden and its contributors.
18 1.1 ragge * 4. The name of the author may not be used to endorse or promote products
19 1.1 ragge * derived from this software without specific prior written permission
20 1.1 ragge *
21 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 ragge * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 ragge * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 ragge * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 ragge * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 ragge * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 ragge * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 ragge * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 ragge * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 ragge * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 ragge */
32 1.1 ragge
33 1.1 ragge
34 1.1 ragge
35 1.1 ragge /*
36 1.1 ragge * VAXBI specific routines.
37 1.1 ragge */
38 1.1 ragge /*
39 1.1 ragge * TODO
40 1.1 ragge * handle BIbus errors more gracefully.
41 1.1 ragge */
42 1.17 lukem
43 1.17 lukem #include <sys/cdefs.h>
44 1.24 matt __KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.24 2008/03/11 05:34:01 matt Exp $");
45 1.1 ragge
46 1.1 ragge #include <sys/param.h>
47 1.7 ragge #include <sys/systm.h>
48 1.1 ragge
49 1.23 ad #include <sys/bus.h>
50 1.23 ad #include <sys/cpu.h>
51 1.1 ragge
52 1.13 ragge #include <dev/bi/bireg.h>
53 1.13 ragge #include <dev/bi/bivar.h>
54 1.1 ragge
55 1.19 perry static int bi_print(void *, const char *);
56 1.1 ragge
57 1.24 matt static const struct bi_list bi_list[] = {
58 1.16 ragge {BIDT_MS820, DT_HAVDRV, "ms820"},
59 1.16 ragge {BIDT_DRB32, DT_UNSUPP, "drb32"},
60 1.16 ragge {BIDT_DWBUA, DT_HAVDRV|DT_ADAPT, "dwbua"},
61 1.16 ragge {BIDT_KLESI, DT_HAVDRV|DT_ADAPT, "klesi"},
62 1.16 ragge {BIDT_KA820, DT_HAVDRV, "ka820"},
63 1.16 ragge {BIDT_DB88, DT_HAVDRV|DT_QUIET, "db88"},
64 1.16 ragge {BIDT_CIBCA, DT_UNSUPP, "cibca"},
65 1.16 ragge {BIDT_DMB32, DT_UNSUPP, "dmb32"},
66 1.16 ragge {BIDT_CIBCI, DT_UNSUPP, "cibci"},
67 1.16 ragge {BIDT_KA800, DT_UNSUPP, "ka800"},
68 1.16 ragge {BIDT_KDB50, DT_HAVDRV|DT_VEC, "kdb50"},
69 1.16 ragge {BIDT_DWMBA, DT_HAVDRV|DT_QUIET, "dwmba"},
70 1.16 ragge {BIDT_KFBTA, DT_UNSUPP, "kfbta"},
71 1.16 ragge {BIDT_DEBNK, DT_HAVDRV|DT_VEC, "debnk"},
72 1.16 ragge {BIDT_DEBNA, DT_HAVDRV|DT_VEC, "debna"},
73 1.1 ragge {0,0,0}
74 1.1 ragge };
75 1.1 ragge
76 1.1 ragge int
77 1.24 matt bi_print(void *aux, const char *name)
78 1.1 ragge {
79 1.1 ragge struct bi_attach_args *ba = aux;
80 1.24 matt const struct bi_list *bl;
81 1.15 ragge u_int16_t nr;
82 1.1 ragge
83 1.15 ragge nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
84 1.7 ragge for (bl = &bi_list[0]; bl->bl_nr; bl++)
85 1.15 ragge if (bl->bl_nr == nr)
86 1.7 ragge break;
87 1.7 ragge
88 1.1 ragge if (name) {
89 1.1 ragge if (bl->bl_nr == 0)
90 1.18 thorpej aprint_normal("unknown device 0x%x", nr);
91 1.7 ragge else
92 1.18 thorpej aprint_normal(bl->bl_name);
93 1.18 thorpej aprint_normal(" at %s", name);
94 1.1 ragge }
95 1.18 thorpej aprint_normal(" node %d", ba->ba_nodenr);
96 1.16 ragge if (bl->bl_havedriver & DT_VEC)
97 1.18 thorpej aprint_normal(" vec %o", ba->ba_ivec & 511);
98 1.8 ragge #ifdef DEBUG
99 1.13 ragge if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
100 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
101 1.18 thorpej aprint_debug(" [sadr %x eadr %x]",
102 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
103 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
104 1.8 ragge #endif
105 1.16 ragge if (bl->bl_havedriver & DT_QUIET)
106 1.18 thorpej aprint_normal("\n");
107 1.16 ragge return bl->bl_havedriver & DT_QUIET ? QUIET :
108 1.16 ragge bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
109 1.1 ragge }
110 1.1 ragge
111 1.1 ragge void
112 1.24 matt bi_attach(struct bi_softc *sc)
113 1.1 ragge {
114 1.1 ragge struct bi_attach_args ba;
115 1.1 ragge int nodenr;
116 1.1 ragge
117 1.24 matt aprint_normal("\n");
118 1.1 ragge
119 1.13 ragge ba.ba_iot = sc->sc_iot;
120 1.13 ragge ba.ba_busnr = sc->sc_busnr;
121 1.14 ragge ba.ba_dmat = sc->sc_dmat;
122 1.14 ragge ba.ba_intcpu = sc->sc_intcpu;
123 1.16 ragge ba.ba_icookie = sc;
124 1.13 ragge /*
125 1.20 perry * Interrupt numbers. Assign them as described in
126 1.16 ragge * VAX 8800 system maintenance manual; this means like nexus
127 1.16 ragge * adapters have them assigned.
128 1.16 ragge * XXX - must address Unibus adapters.
129 1.13 ragge */
130 1.1 ragge for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
131 1.13 ragge if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
132 1.15 ragge BI_NODESIZE, 0, &ba.ba_ioh)) {
133 1.24 matt aprint_error_dev(sc->sc_dev,
134 1.24 matt "bus_space_map failed, node %d\n", nodenr);
135 1.13 ragge return;
136 1.13 ragge }
137 1.22 christos if (badaddr((void *)ba.ba_ioh, 4) ||
138 1.16 ragge (bus_space_read_2(ba.ba_iot, ba.ba_ioh, 0) == 0)) {
139 1.16 ragge bus_space_unmap(ba.ba_iot, ba.ba_ioh, BI_NODESIZE);
140 1.14 ragge continue;
141 1.11 ragge }
142 1.14 ragge ba.ba_nodenr = nodenr;
143 1.16 ragge ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */
144 1.24 matt config_found(sc->sc_dev, &ba, bi_print);
145 1.1 ragge }
146 1.1 ragge }
147