cy_isa.c revision 1.12 1 /* $NetBSD: cy_isa.c,v 1.12 2001/01/20 02:26:39 thorpej Exp $ */
2
3 /*
4 * cy.c
5 *
6 * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
7 * (currently not tested with Cyclom-32 cards)
8 *
9 * Timo Rossi, 1996
10 */
11
12 #include <sys/param.h>
13 #include <sys/systm.h>
14 #include <sys/device.h>
15
16 #include <machine/bus.h>
17 #include <machine/intr.h>
18
19 #include <dev/isa/isavar.h>
20 #include <dev/isa/isareg.h>
21
22 #include <dev/ic/cd1400reg.h>
23 #include <dev/ic/cyreg.h>
24 #include <dev/ic/cyvar.h>
25
26 int cy_isa_probe(struct device *, struct cfdata *, void *);
27 void cy_isa_attach(struct device *, struct device *, void *);
28
29 struct cfattach cy_isa_ca = {
30 sizeof(struct cy_softc), cy_isa_probe, cy_isa_attach
31 };
32
33 int
34 cy_isa_probe(struct device *parent, struct cfdata *match, void *aux)
35 {
36 struct isa_attach_args *ia = aux;
37 struct cy_softc sc;
38 int found;
39
40 memcpy(&sc.sc_dev, match, sizeof(struct device));
41
42 sc.sc_memt = ia->ia_memt;
43 sc.sc_bustype = CY_BUSTYPE_ISA;
44
45 /* Disallow wildcarded memory address. */
46 if (ia->ia_maddr == ISACF_IOMEM_DEFAULT)
47 return (0);
48
49 if (ia->ia_irq == IRQUNK)
50 return 0;
51
52 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
53 &sc.sc_bsh) != 0)
54 return 0;
55
56 found = cy_find(&sc);
57
58 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
59
60 if (found) {
61 ia->ia_iosize = 0;
62 ia->ia_msize = CY_MEMSIZE;
63 }
64
65 return (found);
66 }
67
68 void
69 cy_isa_attach(struct device *parent, struct device *self, void *aux)
70 {
71 struct cy_softc *sc = (void *) self;
72 struct isa_attach_args *ia = aux;
73
74 sc->sc_memt = ia->ia_memt;
75 sc->sc_bustype = CY_BUSTYPE_ISA;
76
77 printf(": Cyclades-Y multiport serial\n");
78
79 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
80 &sc->sc_bsh) != 0) {
81 printf("%s: unable to map device registers\n",
82 sc->sc_dev.dv_xname);
83 return;
84 }
85
86 if (cy_find(sc) == 0) {
87 printf("%s: unable to find CD1400s\n", sc->sc_dev.dv_xname);
88 return;
89 }
90
91 cy_attach(sc);
92
93 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
94 IST_EDGE, IPL_TTY, cy_intr, sc);
95 if (sc->sc_ih == NULL)
96 printf("%s: unable to establish interrupt",
97 sc->sc_dev.dv_xname);
98 }
99