bi.c revision 1.14 1 1.14 ragge /* $NetBSD: bi.c,v 1.14 2000/03/26 11:45:04 ragge 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.1 ragge * 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.1 ragge
43 1.1 ragge #include <sys/param.h>
44 1.7 ragge #include <sys/systm.h>
45 1.1 ragge
46 1.13 ragge #include <machine/bus.h>
47 1.1 ragge #include <machine/cpu.h>
48 1.1 ragge
49 1.13 ragge #include <dev/bi/bireg.h>
50 1.13 ragge #include <dev/bi/bivar.h>
51 1.1 ragge
52 1.2 cgd static int bi_print __P((void *, const char *));
53 1.1 ragge
54 1.1 ragge struct bi_list bi_list[] = {
55 1.1 ragge {BIDT_MS820, 1, "ms820"},
56 1.1 ragge {BIDT_DRB32, 0, "drb32"},
57 1.1 ragge {BIDT_DWBUA, 0, "dwbua"},
58 1.1 ragge {BIDT_KLESI, 0, "klesi"},
59 1.1 ragge {BIDT_KA820, 1, "ka820"},
60 1.1 ragge {BIDT_DB88, 0, "db88"},
61 1.1 ragge {BIDT_CIBCA, 0, "cibca"},
62 1.1 ragge {BIDT_DMB32, 0, "dmb32"},
63 1.1 ragge {BIDT_CIBCI, 0, "cibci"},
64 1.1 ragge {BIDT_KA800, 0, "ka800"},
65 1.1 ragge {BIDT_KDB50, 0, "kdb50"},
66 1.1 ragge {BIDT_DWMBA, 0, "dwmba"},
67 1.1 ragge {BIDT_KFBTA, 0, "kfbta"},
68 1.1 ragge {BIDT_DEBNK, 0, "debnk"},
69 1.1 ragge {BIDT_DEBNA, 0, "debna"},
70 1.1 ragge {0,0,0}
71 1.1 ragge };
72 1.1 ragge
73 1.1 ragge int
74 1.1 ragge bi_print(aux, name)
75 1.1 ragge void *aux;
76 1.2 cgd const char *name;
77 1.1 ragge {
78 1.1 ragge struct bi_attach_args *ba = aux;
79 1.1 ragge struct bi_list *bl;
80 1.1 ragge
81 1.7 ragge for (bl = &bi_list[0]; bl->bl_nr; bl++)
82 1.13 ragge if (bl->bl_nr == bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0))
83 1.7 ragge break;
84 1.7 ragge
85 1.1 ragge if (name) {
86 1.1 ragge if (bl->bl_nr == 0)
87 1.4 christos printf("unknown device 0x%x",
88 1.13 ragge bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0));
89 1.7 ragge else
90 1.7 ragge printf(bl->bl_name);
91 1.4 christos printf(" at %s", name);
92 1.1 ragge }
93 1.4 christos printf(" node %d", ba->ba_nodenr);
94 1.8 ragge #ifdef DEBUG
95 1.13 ragge if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
96 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
97 1.13 ragge printf(" [sadr %x eadr %x]",
98 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
99 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
100 1.8 ragge #endif
101 1.1 ragge return bl->bl_havedriver ? UNCONF : UNSUPP;
102 1.1 ragge }
103 1.1 ragge
104 1.13 ragge static int lastiv = 0;
105 1.1 ragge
106 1.1 ragge void
107 1.13 ragge bi_attach(sc)
108 1.13 ragge struct bi_softc *sc;
109 1.1 ragge {
110 1.1 ragge struct bi_attach_args ba;
111 1.1 ragge int nodenr;
112 1.1 ragge
113 1.4 christos printf("\n");
114 1.1 ragge
115 1.13 ragge ba.ba_iot = sc->sc_iot;
116 1.13 ragge ba.ba_busnr = sc->sc_busnr;
117 1.14 ragge ba.ba_dmat = sc->sc_dmat;
118 1.14 ragge ba.ba_intcpu = sc->sc_intcpu;
119 1.13 ragge /*
120 1.13 ragge * Interrupt numbers. All vectors from 256-512 are free, use
121 1.13 ragge * them for BI devices and just count them up.
122 1.13 ragge * Above 512 are only interrupt vectors for unibus devices.
123 1.13 ragge */
124 1.1 ragge for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
125 1.13 ragge if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
126 1.13 ragge NODESIZE, 0, &ba.ba_ioh)) {
127 1.13 ragge printf("bi_attach: bus_space_map failed, node %d\n",
128 1.13 ragge nodenr);
129 1.13 ragge return;
130 1.13 ragge }
131 1.13 ragge if (badaddr((caddr_t)ba.ba_ioh, 4)) {
132 1.13 ragge bus_space_unmap(sc->sc_iot, ba.ba_ioh, NODESIZE);
133 1.14 ragge continue;
134 1.11 ragge }
135 1.14 ragge ba.ba_nodenr = nodenr;
136 1.14 ragge ba.ba_ivec = 256 + lastiv;
137 1.14 ragge lastiv += 4;
138 1.14 ragge config_found(&sc->sc_dev, &ba, bi_print);
139 1.1 ragge }
140 1.1 ragge }
141