This source file includes following definitions.
- bha_eisa_address
- bha_eisa_match
- bha_eisa_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/eisa/eisavar.h>
52 #include <dev/eisa/eisadevs.h>
53
54 #include <dev/ic/bhareg.h>
55 #include <dev/ic/bhavar.h>
56
57 #define BHA_EISA_SLOT_OFFSET 0x0c80
58 #define BHA_EISA_IOSIZE 0x0010
59 #define BHA_ISA_IOSIZE 0x0004
60
61 #define BHA_EISA_IOCONF 0x0c
62
63 int bha_eisa_address(bus_space_tag_t, bus_space_handle_t, int *);
64 int bha_eisa_match(struct device *, void *, void *);
65 void bha_eisa_attach(struct device *, struct device *, void *);
66
67 struct cfattach bha_eisa_ca = {
68 sizeof(struct bha_softc), bha_eisa_match, bha_eisa_attach
69 };
70
71 int
72 bha_eisa_address(iot, ioh, portp)
73 bus_space_tag_t iot;
74 bus_space_handle_t ioh;
75 int *portp;
76 {
77 int port;
78
79 switch (bus_space_read_1(iot, ioh, BHA_EISA_IOCONF) & 0x07) {
80 case 0x00:
81 port = 0x330;
82 break;
83 case 0x01:
84 port = 0x334;
85 break;
86 case 0x02:
87 port = 0x230;
88 break;
89 case 0x03:
90 port = 0x234;
91 break;
92 case 0x04:
93 port = 0x130;
94 break;
95 case 0x05:
96 port = 0x134;
97 break;
98 default:
99 return (1);
100 }
101
102 *portp = port;
103 return (0);
104 }
105
106
107
108
109
110
111 int
112 bha_eisa_match(parent, match, aux)
113 struct device *parent;
114 void *aux, *match;
115 {
116 struct eisa_attach_args *ea = aux;
117 bus_space_tag_t iot = ea->ea_iot;
118 bus_space_handle_t ioh, ioh2;
119 int port;
120 int rv;
121
122
123 if (strcmp(ea->ea_idstring, "BUS4201") &&
124 strcmp(ea->ea_idstring, "BUS4202"))
125 return (0);
126
127 if (bus_space_map(iot,
128 EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
129 0, &ioh))
130 return (0);
131
132 if (bha_eisa_address(iot, ioh, &port) ||
133 bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) {
134 bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE);
135 return (0);
136 }
137
138 rv = bha_find(iot, ioh2, NULL);
139
140 bus_space_unmap(iot, ioh2, BHA_ISA_IOSIZE);
141 bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE);
142
143 return (rv);
144 }
145
146
147
148
149 void
150 bha_eisa_attach(parent, self, aux)
151 struct device *parent, *self;
152 void *aux;
153 {
154 struct eisa_attach_args *ea = aux;
155 struct bha_softc *sc = (void *)self;
156 bus_space_tag_t iot = ea->ea_iot;
157 bus_space_handle_t ioh, ioh2;
158 int port;
159 struct bha_probe_data bpd;
160 eisa_chipset_tag_t ec = ea->ea_ec;
161 eisa_intr_handle_t ih;
162 const char *model, *intrstr;
163
164 if (!strcmp(ea->ea_idstring, "BUS4201"))
165 model = EISA_PRODUCT_BUS4201;
166 else if (!strcmp(ea->ea_idstring, "BUS4202"))
167 model = EISA_PRODUCT_BUS4202;
168 else
169 model = "unknown model!";
170
171 if (bus_space_map(iot,
172 EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
173 0, &ioh)) {
174 printf(": could not map EISA slot\n");
175 return;
176 }
177
178 if (bha_eisa_address(iot, ioh, &port) ||
179 bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) {
180 printf(": could not map ISA address\n");
181 return;
182 }
183
184 sc->sc_iot = iot;
185 sc->sc_ioh = ioh2;
186 sc->sc_dmat = ea->ea_dmat;
187 if (!bha_find(iot, ioh2, &bpd)) {
188 printf(": bha_find failed\n");
189 return;
190 }
191
192 sc->sc_dmaflags = 0;
193
194 if (eisa_intr_map(ec, bpd.sc_irq, &ih)) {
195 printf(": couldn't map interrupt (%d)\n", bpd.sc_irq);
196 return;
197 }
198 intrstr = eisa_intr_string(ec, ih);
199 sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
200 bha_intr, sc, sc->sc_dev.dv_xname);
201 if (sc->sc_ih == NULL) {
202 printf(": couldn't establish interrupt");
203 if (intrstr != NULL)
204 printf(" at %s", intrstr);
205 printf("\n");
206 return;
207 }
208 printf(": %s, %s\n", intrstr, model);
209
210 bha_attach(sc, &bpd);
211 }