bi.c revision 1.22 1 1.22 christos /* $NetBSD: bi.c,v 1.22 2007/03/04 06:01:44 christos 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.22 christos __KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.22 2007/03/04 06:01:44 christos 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.13 ragge #include <machine/bus.h>
50 1.1 ragge #include <machine/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.1 ragge 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.1 ragge bi_print(aux, name)
78 1.1 ragge void *aux;
79 1.2 cgd const char *name;
80 1.1 ragge {
81 1.1 ragge struct bi_attach_args *ba = aux;
82 1.1 ragge struct bi_list *bl;
83 1.15 ragge u_int16_t nr;
84 1.1 ragge
85 1.15 ragge nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
86 1.7 ragge for (bl = &bi_list[0]; bl->bl_nr; bl++)
87 1.15 ragge if (bl->bl_nr == nr)
88 1.7 ragge break;
89 1.7 ragge
90 1.1 ragge if (name) {
91 1.1 ragge if (bl->bl_nr == 0)
92 1.18 thorpej aprint_normal("unknown device 0x%x", nr);
93 1.7 ragge else
94 1.18 thorpej aprint_normal(bl->bl_name);
95 1.18 thorpej aprint_normal(" at %s", name);
96 1.1 ragge }
97 1.18 thorpej aprint_normal(" node %d", ba->ba_nodenr);
98 1.16 ragge if (bl->bl_havedriver & DT_VEC)
99 1.18 thorpej aprint_normal(" vec %o", ba->ba_ivec & 511);
100 1.8 ragge #ifdef DEBUG
101 1.13 ragge if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
102 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
103 1.18 thorpej aprint_debug(" [sadr %x eadr %x]",
104 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
105 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
106 1.8 ragge #endif
107 1.16 ragge if (bl->bl_havedriver & DT_QUIET)
108 1.18 thorpej aprint_normal("\n");
109 1.16 ragge return bl->bl_havedriver & DT_QUIET ? QUIET :
110 1.16 ragge bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
111 1.1 ragge }
112 1.1 ragge
113 1.1 ragge void
114 1.13 ragge bi_attach(sc)
115 1.13 ragge struct bi_softc *sc;
116 1.1 ragge {
117 1.1 ragge struct bi_attach_args ba;
118 1.1 ragge int nodenr;
119 1.1 ragge
120 1.4 christos printf("\n");
121 1.1 ragge
122 1.13 ragge ba.ba_iot = sc->sc_iot;
123 1.13 ragge ba.ba_busnr = sc->sc_busnr;
124 1.14 ragge ba.ba_dmat = sc->sc_dmat;
125 1.14 ragge ba.ba_intcpu = sc->sc_intcpu;
126 1.16 ragge ba.ba_icookie = sc;
127 1.13 ragge /*
128 1.20 perry * Interrupt numbers. Assign them as described in
129 1.16 ragge * VAX 8800 system maintenance manual; this means like nexus
130 1.16 ragge * adapters have them assigned.
131 1.16 ragge * XXX - must address Unibus adapters.
132 1.13 ragge */
133 1.1 ragge for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
134 1.13 ragge if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
135 1.15 ragge BI_NODESIZE, 0, &ba.ba_ioh)) {
136 1.20 perry printf("bi_attach: bus_space_map failed, node %d\n",
137 1.13 ragge nodenr);
138 1.13 ragge return;
139 1.13 ragge }
140 1.22 christos if (badaddr((void *)ba.ba_ioh, 4) ||
141 1.16 ragge (bus_space_read_2(ba.ba_iot, ba.ba_ioh, 0) == 0)) {
142 1.16 ragge bus_space_unmap(ba.ba_iot, ba.ba_ioh, BI_NODESIZE);
143 1.14 ragge continue;
144 1.11 ragge }
145 1.14 ragge ba.ba_nodenr = nodenr;
146 1.16 ragge ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */
147 1.14 ragge config_found(&sc->sc_dev, &ba, bi_print);
148 1.1 ragge }
149 1.1 ragge }
150