This source file includes following definitions.
- cac_eisa_match
- cac_eisa_attach
- cac_eisa_l0_fifo_full
- cac_eisa_l0_submit
- cac_eisa_l0_completed
- cac_eisa_l0_intr_pending
- cac_eisa_l0_intr_enable
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 #include <sys/types.h>
72 #include <sys/param.h>
73 #include <sys/systm.h>
74 #include <sys/device.h>
75
76 #include <machine/bus.h>
77 #include <machine/intr.h>
78
79 #include <dev/eisa/eisavar.h>
80 #include <dev/eisa/eisadevs.h>
81
82 #include <scsi/scsi_all.h>
83 #include <scsi/scsi_disk.h>
84 #include <scsi/scsiconf.h>
85
86 #include <dev/ic/cacreg.h>
87 #include <dev/ic/cacvar.h>
88
89 #define CAC_EISA_SLOT_OFFSET 0x0c88
90 #define CAC_EISA_IOSIZE 0x0017
91 #define CAC_EISA_IOCONF 0x38
92
93 int cac_eisa_match(struct device *, void *, void *);
94 void cac_eisa_attach(struct device *, struct device *, void *);
95
96 struct cac_ccb *cac_eisa_l0_completed(struct cac_softc *);
97 int cac_eisa_l0_fifo_full(struct cac_softc *);
98 void cac_eisa_l0_intr_enable(struct cac_softc *, int);
99 int cac_eisa_l0_intr_pending(struct cac_softc *);
100 void cac_eisa_l0_submit(struct cac_softc *, struct cac_ccb *);
101
102 struct cfattach cac_eisa_ca = {
103 sizeof(struct cac_softc), cac_eisa_match, cac_eisa_attach
104 };
105
106 static const
107 struct cac_linkage cac_eisa_l0 = {
108 cac_eisa_l0_completed,
109 cac_eisa_l0_fifo_full,
110 cac_eisa_l0_intr_enable,
111 cac_eisa_l0_intr_pending,
112 cac_eisa_l0_submit
113 };
114
115 static const
116 struct cac_eisa_type {
117 const char *ct_prodstr;
118 const char *ct_typestr;
119 const struct cac_linkage *ct_linkage;
120 } cac_eisa_type[] = {
121 { "CPQ4001", "IDA", &cac_eisa_l0 },
122 { "CPQ4002", "IDA-2", &cac_eisa_l0 },
123 { "CPQ4010", "IEAS", &cac_eisa_l0 },
124 { "CPQ4020", "SMART", &cac_eisa_l0 },
125 { "CPQ4030", "SMART-2/E", &cac_l0 },
126 };
127
128 int
129 cac_eisa_match(parent, match, aux)
130 struct device *parent;
131 void *match, *aux;
132 {
133 struct eisa_attach_args *ea;
134 int i;
135
136 ea = aux;
137
138 for (i = 0; i < sizeof(cac_eisa_type) / sizeof(cac_eisa_type[0]); i++)
139 if (strcmp(ea->ea_idstring, cac_eisa_type[i].ct_prodstr) == 0)
140 return (1);
141
142 return (0);
143 }
144
145 void
146 cac_eisa_attach(parent, self, aux)
147 struct device *parent;
148 struct device *self;
149 void *aux;
150 {
151 struct eisa_attach_args *ea;
152 bus_space_handle_t ioh;
153 eisa_chipset_tag_t ec;
154 eisa_intr_handle_t ih;
155 struct cac_softc *sc;
156 bus_space_tag_t iot;
157 const char *intrstr;
158 int irq, i;
159
160 ea = aux;
161 sc = (struct cac_softc *)self;
162 iot = ea->ea_iot;
163 ec = ea->ea_ec;
164
165 if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
166 CAC_EISA_SLOT_OFFSET, CAC_EISA_IOSIZE, 0, &ioh)) {
167 printf(": can't map i/o space\n");
168 return;
169 }
170
171 sc->sc_iot = iot;
172 sc->sc_ioh = ioh;
173 sc->sc_dmat = ea->ea_dmat;
174
175
176
177
178 switch (bus_space_read_1(iot, ioh, CAC_EISA_IOCONF) & 0xf0) {
179 case 0x20:
180 irq = 10;
181 break;
182 case 0x10:
183 irq = 11;
184 break;
185 case 0x40:
186 irq = 14;
187 break;
188 case 0x80:
189 irq = 15;
190 break;
191 default:
192 printf(": controller on invalid IRQ\n");
193 return;
194 }
195
196 if (eisa_intr_map(ec, irq, &ih)) {
197 printf(": can't map interrupt (%d)\n", irq);
198 return;
199 }
200
201 intrstr = eisa_intr_string(ec, ih);
202 if ((sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
203 cac_intr, sc, sc->sc_dv.dv_xname)) == NULL) {
204 printf(": can't establish interrupt");
205 if (intrstr != NULL)
206 printf(" at %s", intrstr);
207 printf("\n");
208 return;
209 }
210
211
212
213
214 for (i = 0; i < sizeof(cac_eisa_type) / sizeof(cac_eisa_type[0]); i++)
215 if (strcmp(ea->ea_idstring, cac_eisa_type[i].ct_prodstr) == 0)
216 break;
217
218 printf(" %s: Compaq %s\n", intrstr, cac_eisa_type[i].ct_typestr);
219 sc->sc_cl = cac_eisa_type[i].ct_linkage;
220 cac_init(sc, 0);
221 }
222
223
224
225
226
227 int
228 cac_eisa_l0_fifo_full(struct cac_softc *sc)
229 {
230
231 return ((cac_inb(sc, CAC_EISAREG_SYSTEM_DOORBELL) &
232 CAC_EISA_CHANNEL_CLEAR) == 0);
233 }
234
235 void
236 cac_eisa_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
237 {
238 u_int16_t size;
239
240
241
242
243
244 size = letoh16(ccb->ccb_hdr.size) << 2;
245 ccb->ccb_hdr.size = 0;
246
247 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, (caddr_t)ccb - sc->sc_ccbs,
248 sizeof(struct cac_ccb), BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
249
250 cac_outb(sc, CAC_EISAREG_SYSTEM_DOORBELL, CAC_EISA_CHANNEL_CLEAR);
251 cac_outl(sc, CAC_EISAREG_LIST_ADDR, ccb->ccb_paddr);
252 cac_outw(sc, CAC_EISAREG_LIST_LEN, size);
253 cac_outb(sc, CAC_EISAREG_LOCAL_DOORBELL, CAC_EISA_CHANNEL_BUSY);
254 }
255
256 struct cac_ccb *
257 cac_eisa_l0_completed(struct cac_softc *sc)
258 {
259 struct cac_ccb *ccb;
260 u_int32_t off;
261 u_int8_t status;
262
263 if ((cac_inb(sc, CAC_EISAREG_SYSTEM_DOORBELL) &
264 CAC_EISA_CHANNEL_BUSY) == 0)
265 return (NULL);
266
267 cac_outb(sc, CAC_EISAREG_SYSTEM_DOORBELL, CAC_EISA_CHANNEL_BUSY);
268 off = cac_inl(sc, CAC_EISAREG_COMPLETE_ADDR);
269 status = cac_inb(sc, CAC_EISAREG_LIST_STATUS);
270 cac_outb(sc, CAC_EISAREG_LOCAL_DOORBELL, CAC_EISA_CHANNEL_CLEAR);
271
272 if (off == 0)
273 return (NULL);
274
275 off = (off & ~3) - sc->sc_ccbs_paddr;
276 ccb = (struct cac_ccb *)(sc->sc_ccbs + off);
277
278 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, off, sizeof(struct cac_ccb),
279 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
280
281 ccb->ccb_req.error = status;
282 return (ccb);
283 }
284
285 int
286 cac_eisa_l0_intr_pending(struct cac_softc *sc)
287 {
288
289 return (cac_inb(sc, CAC_EISAREG_SYSTEM_DOORBELL) &
290 CAC_EISA_CHANNEL_BUSY);
291 }
292
293 void
294 cac_eisa_l0_intr_enable(struct cac_softc *sc, int state)
295 {
296
297 if (state) {
298 cac_outb(sc, CAC_EISAREG_SYSTEM_DOORBELL,
299 ~CAC_EISA_CHANNEL_CLEAR);
300 cac_outb(sc, CAC_EISAREG_LOCAL_DOORBELL,
301 CAC_EISA_CHANNEL_BUSY);
302 cac_outb(sc, CAC_EISAREG_INTR_MASK, CAC_INTR_ENABLE);
303 cac_outb(sc, CAC_EISAREG_SYSTEM_MASK, CAC_INTR_ENABLE);
304 } else
305 cac_outb(sc, CAC_EISAREG_SYSTEM_MASK, CAC_INTR_DISABLE);
306 }