This source file includes following definitions.
- com_pcmcia_match
- com_pcmcia_activate
- com_pcmcia_attach
- com_pcmcia_detach
- com_pcmcia_enable
- com_pcmcia_enable1
- com_pcmcia_disable
- com_pcmcia_disable1
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 #include <sys/param.h>
99 #include <sys/systm.h>
100 #include <sys/ioctl.h>
101 #include <sys/selinfo.h>
102 #include <sys/tty.h>
103 #include <sys/proc.h>
104 #include <sys/user.h>
105 #include <sys/conf.h>
106 #include <sys/file.h>
107 #include <sys/uio.h>
108 #include <sys/kernel.h>
109 #include <sys/syslog.h>
110 #include <sys/types.h>
111 #include <sys/device.h>
112
113 #include <machine/intr.h>
114 #include <machine/bus.h>
115
116 #include <dev/pcmcia/pcmciavar.h>
117 #include <dev/pcmcia/pcmciareg.h>
118 #include <dev/pcmcia/pcmciadevs.h>
119
120 #include "com.h"
121 #ifdef i386
122 #include "pccom.h"
123 #endif
124
125 #include <dev/ic/comreg.h>
126 #if NPCCOM > 0
127 #include <i386/isa/pccomvar.h>
128 #endif
129 #if NCOM > 0
130 #include <dev/ic/comvar.h>
131 #endif
132 #include <dev/ic/ns16550reg.h>
133
134 #include <dev/isa/isareg.h>
135
136 #define com_lcr com_cfcr
137
138
139 struct com_pcmcia_product {
140 char *cis1_info[4];
141 } com_pcmcia_prod[] = {
142 { PCMCIA_CIS_MEGAHERTZ_XJ2288 },
143 { PCMCIA_CIS_NOVATEL_NRM6831 },
144 };
145
146 int com_pcmcia_match(struct device *, void *, void *);
147 void com_pcmcia_attach(struct device *, struct device *, void *);
148 int com_pcmcia_detach(struct device *, int);
149 void com_pcmcia_cleanup(void *);
150 int com_pcmcia_activate(struct device *, enum devact);
151
152 int com_pcmcia_enable(struct com_softc *);
153 void com_pcmcia_disable(struct com_softc *);
154 int com_pcmcia_enable1(struct com_softc *);
155 void com_pcmcia_disable1(struct com_softc *);
156
157 struct com_pcmcia_softc {
158 struct com_softc sc_com;
159
160
161 struct pcmcia_io_handle sc_pcioh;
162 int sc_io_window;
163 struct pcmcia_function *sc_pf;
164 void *sc_ih;
165 };
166
167 #if NCOM
168 struct cfattach com_pcmcia_ca = {
169 sizeof(struct com_pcmcia_softc), com_pcmcia_match, com_pcmcia_attach,
170 com_pcmcia_detach, com_pcmcia_activate
171 };
172 #elif NPCCOM
173 struct cfattach pccom_pcmcia_ca = {
174 sizeof(struct com_pcmcia_softc), com_pcmcia_match, com_pcmcia_attach,
175 com_pcmcia_detach, com_pcmcia_activate
176 };
177 #endif
178
179 int
180 com_pcmcia_match(parent, match, aux)
181 struct device *parent;
182 void *match, *aux;
183 {
184 struct pcmcia_attach_args *pa = aux;
185 struct pcmcia_config_entry *cfe;
186 int i, j, comportmask;
187
188
189 if (pa->pf->function == PCMCIA_FUNCTION_SERIAL)
190 return 1;
191
192
193 comportmask = 0;
194 SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
195 switch (cfe->iospace[0].start) {
196 case IO_COM1:
197 comportmask |= 1;
198 break;
199 case IO_COM2:
200 comportmask |= 2;
201 break;
202 case IO_COM3:
203 comportmask |= 4;
204 break;
205 case IO_COM4:
206 comportmask |= 8;
207 break;
208 }
209 }
210
211 if (comportmask == 15)
212 return 1;
213
214
215 for (i = 0; i < sizeof(com_pcmcia_prod)/sizeof(com_pcmcia_prod[0]);
216 i++) {
217 for (j = 0; j < 4; j++)
218 if (com_pcmcia_prod[i].cis1_info[j] &&
219 pa->card->cis1_info[j] &&
220 strcmp(pa->card->cis1_info[j],
221 com_pcmcia_prod[i].cis1_info[j]))
222 break;
223 if (j == 4)
224 return 1;
225 }
226
227 return 0;
228 }
229
230 int
231 com_pcmcia_activate(dev, act)
232 struct device *dev;
233 enum devact act;
234 {
235 struct com_pcmcia_softc *sc = (void *) dev;
236 int s;
237
238 s = spltty();
239 switch (act) {
240 case DVACT_ACTIVATE:
241 pcmcia_function_enable(sc->sc_pf);
242 sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_TTY,
243 comintr, sc, sc->sc_com.sc_dev.dv_xname);
244 break;
245
246 case DVACT_DEACTIVATE:
247 pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
248 pcmcia_function_disable(sc->sc_pf);
249 break;
250 }
251 splx(s);
252 return (0);
253 }
254
255 void
256 com_pcmcia_attach(parent, self, aux)
257 struct device *parent, *self;
258 void *aux;
259 {
260 struct com_pcmcia_softc *psc = (void *) self;
261 struct com_softc *sc = &psc->sc_com;
262 struct pcmcia_attach_args *pa = aux;
263 struct pcmcia_config_entry *cfe;
264 const char *intrstr;
265 int autoalloc = 0;
266
267 psc->sc_pf = pa->pf;
268
269 retry:
270
271
272 for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe;
273 cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
274 #if 0
275
276
277
278
279 if (cfe->num_memspace != 0)
280 continue;
281 #endif
282
283 if (cfe->num_iospace != 1)
284 continue;
285
286 if (!pcmcia_io_alloc(pa->pf,
287 autoalloc ? 0 : cfe->iospace[0].start,
288 cfe->iospace[0].length, COM_NPORTS, &psc->sc_pcioh)) {
289 goto found;
290 }
291 }
292 if (autoalloc == 0) {
293 autoalloc = 1;
294 goto retry;
295 } else if (!cfe) {
296 printf(": can't allocate i/o space\n");
297 return;
298 }
299
300 found:
301 sc->sc_iot = psc->sc_pcioh.iot;
302 sc->sc_ioh = psc->sc_pcioh.ioh;
303
304
305 pcmcia_function_init(pa->pf, cfe);
306 if (com_pcmcia_enable1(sc))
307 printf(": function enable failed\n");
308
309 sc->enabled = 1;
310
311
312
313 if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
314 PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), 0, psc->sc_pcioh.size,
315 &psc->sc_pcioh, &psc->sc_io_window)) {
316 printf(": can't map i/o space\n");
317 return;
318 }
319
320 printf(" port 0x%lx/%lu", psc->sc_pcioh.addr,
321 (u_long)psc->sc_pcioh.size);
322
323 sc->sc_iobase = -1;
324 sc->enable = com_pcmcia_enable;
325 sc->disable = com_pcmcia_disable;
326 sc->sc_frequency = COM_FREQ;
327
328 sc->sc_hwflags = 0;
329 sc->sc_swflags = 0;
330
331 if (psc->sc_pf->sc->card.manufacturer == PCMCIA_VENDOR_AUDIOVOX &&
332 psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_AUDIOVOX_RTM8000)
333 sc->sc_fifolen = 16;
334
335 com_attach_subr(sc);
336
337
338 psc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_TTY, comintr, sc,
339 sc->sc_dev.dv_xname);
340 intrstr = pcmcia_intr_string(psc->sc_pf, psc->sc_ih);
341 if (*intrstr)
342 printf(", %s", intrstr);
343
344 #ifdef notyet
345 sc->enabled = 0;
346
347 com_pcmcia_disable1(sc);
348 #endif
349 }
350
351 int
352 com_pcmcia_detach(dev, flags)
353 struct device *dev;
354 int flags;
355 {
356 struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *)dev;
357 int error;
358
359
360 error = com_detach(dev, flags);
361 if (error)
362 return (error);
363
364 pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
365 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
366
367 return (0);
368 }
369
370 int
371 com_pcmcia_enable(sc)
372 struct com_softc *sc;
373 {
374 struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc;
375 struct pcmcia_function *pf = psc->sc_pf;
376
377
378 psc->sc_ih = pcmcia_intr_establish(pf, IPL_TTY, comintr, sc,
379 sc->sc_dev.dv_xname);
380 if (psc->sc_ih == NULL) {
381 printf("%s: couldn't establish interrupt\n",
382 sc->sc_dev.dv_xname);
383 return (1);
384 }
385 return com_pcmcia_enable1(sc);
386 }
387
388 int
389 com_pcmcia_enable1(sc)
390 struct com_softc *sc;
391 {
392 struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc;
393 struct pcmcia_function *pf = psc->sc_pf;
394 int ret;
395
396 if ((ret = pcmcia_function_enable(pf)))
397 return(ret);
398
399 if ((psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3C562) ||
400 (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556) ||
401 (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556B)) {
402 int reg;
403
404
405
406 reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION);
407 if (reg & 0x08) {
408 reg &= ~0x08;
409 pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg);
410 }
411 }
412
413 return(ret);
414 }
415
416 void
417 com_pcmcia_disable(sc)
418 struct com_softc *sc;
419 {
420 struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc;
421
422 pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
423 com_pcmcia_disable1(sc);
424 }
425
426 void
427 com_pcmcia_disable1(sc)
428 struct com_softc *sc;
429 {
430 struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc;
431
432 pcmcia_function_disable(psc->sc_pf);
433 }