This source file includes following definitions.
- bha_isa_probe
- bha_isa_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/device.h>
44
45 #include <machine/bus.h>
46 #include <machine/intr.h>
47
48 #include <scsi/scsi_all.h>
49 #include <scsi/scsiconf.h>
50
51 #include <dev/isa/isavar.h>
52 #include <dev/isa/isadmavar.h>
53
54 #include <dev/ic/bhareg.h>
55 #include <dev/ic/bhavar.h>
56
57 #include "aha.h"
58 #if NAHA > 0
59 int btports[8];
60 int nbtports;
61 #endif
62
63 #define BHA_ISA_IOSIZE 4
64
65 int bha_isa_probe(struct device *, void *, void *);
66 void bha_isa_attach(struct device *, struct device *, void *);
67
68 struct cfattach bha_isa_ca = {
69 sizeof(struct bha_softc), bha_isa_probe, bha_isa_attach
70 };
71
72
73
74
75
76
77 int
78 bha_isa_probe(parent, match, aux)
79 struct device *parent;
80 void *aux, *match;
81 {
82 struct isa_attach_args *ia = aux;
83 bus_space_tag_t iot = ia->ia_iot;
84 bus_space_handle_t ioh;
85 struct bha_probe_data bpd;
86 #if NAHA > 0
87 struct bha_digit digit;
88 #endif
89 int rv;
90
91
92 if (ia->ia_iobase == IOBASEUNK)
93 return (0);
94
95 if (bus_space_map(iot, ia->ia_iobase, BHA_ISA_IOSIZE, 0, &ioh))
96 return (0);
97
98 rv = bha_find(iot, ioh, &bpd);
99
100 #if NAHA > 0
101 if (rv) {
102
103 digit.reply.digit = '@';
104 digit.cmd.opcode = BHA_INQUIRE_REVISION_3;
105 bha_cmd(iot, ioh, NULL, sizeof(digit.cmd), (u_char *)&digit.cmd,
106 sizeof(digit.reply), (u_char *)&digit.reply);
107 if (digit.reply.digit == '@')
108 return 1;
109 }
110 #endif
111
112 bus_space_unmap(iot, ioh, BHA_ISA_IOSIZE);
113
114 if (rv) {
115 if (ia->ia_irq != -1 && ia->ia_irq != bpd.sc_irq)
116 return (0);
117 if (ia->ia_drq != -1 && ia->ia_drq != bpd.sc_drq)
118 return (0);
119 ia->ia_irq = bpd.sc_irq;
120 ia->ia_drq = bpd.sc_drq;
121 ia->ia_msize = 0;
122 ia->ia_iosize = BHA_ISA_IOSIZE;
123 }
124 return (rv);
125 }
126
127
128
129
130 void
131 bha_isa_attach(parent, self, aux)
132 struct device *parent, *self;
133 void *aux;
134 {
135 struct isa_attach_args *ia = aux;
136 struct bha_softc *sc = (void *)self;
137 bus_space_tag_t iot = ia->ia_iot;
138 bus_space_handle_t ioh;
139 struct bha_probe_data bpd;
140 isa_chipset_tag_t ic = ia->ia_ic;
141 #ifndef __OpenBSD__
142 int error;
143 #endif
144
145 printf("\n");
146
147 if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) {
148 printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
149 return;
150 }
151
152 sc->sc_iot = iot;
153 sc->sc_ioh = ioh;
154 sc->sc_dmat = ia->ia_dmat;
155 if (!bha_find(iot, ioh, &bpd)) {
156 printf("%s: bha_find failed\n", sc->sc_dev.dv_xname);
157 return;
158 }
159
160 sc->sc_dmaflags = 0;
161 if (bpd.sc_drq != DRQUNK) {
162 #ifdef __OpenBSD__
163 isa_dmacascade(ic, bpd.sc_drq);
164 #else
165 if ((error = isa_dmacascade(ic, bpd.sc_drq)) != 0) {
166 printf("%s: unable to cascade DRQ, error = %d\n",
167 sc->sc_dev.dv_xname, error);
168 return;
169 }
170 #endif
171 } else {
172
173
174
175
176
177
178 bha_inquire_setup_information(sc);
179 if (strcmp(sc->sc_firmware, "3.37") < 0)
180 printf("%s: buggy VLB controller, disabling 32-bit DMA\n",
181 sc->sc_dev.dv_xname);
182 else
183 sc->sc_dmaflags = ISABUS_DMA_32BIT;
184 }
185
186 sc->sc_ih = isa_intr_establish(ic, bpd.sc_irq, IST_EDGE, IPL_BIO,
187 bha_intr, sc, sc->sc_dev.dv_xname);
188 if (sc->sc_ih == NULL) {
189 printf("%s: couldn't establish interrupt\n",
190 sc->sc_dev.dv_xname);
191 return;
192 }
193
194 bha_attach(sc, &bpd);
195
196 #if NAHA > 0
197
198 btports[nbtports++] = ia->ia_iobase;
199 #endif
200 }