cy_isa.c revision 1.7 1 /* $NetBSD: cy_isa.c,v 1.7 1997/10/20 18:43:08 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
13 #include <sys/param.h>
14 #include <sys/systm.h>
15 #include <sys/device.h>
16
17 #include <machine/bus.h>
18 #include <machine/intr.h>
19
20 #include <dev/isa/isavar.h>
21 #include <dev/isa/isareg.h>
22
23 #include <dev/ic/cd1400reg.h>
24 #include <dev/ic/cyreg.h>
25 #include <dev/ic/cyvar.h>
26
27 static int cy_probe_isa __P((struct device *, void *, void *));
28 static void cy_attach_isa __P((struct device *, struct device *, void *));
29
30 struct cfattach cy_isa_ca = {
31 sizeof(struct cy_softc), cy_probe_isa, cy_attach_isa
32 };
33
34 static int
35 cy_probe_isa(parent, match, aux)
36 struct device *parent;
37 void *match, *aux;
38 {
39 struct isa_attach_args *ia = aux;
40 struct cy_softc sc;
41 int found;
42
43 memcpy(&sc.sc_dev, match, sizeof(struct device));
44
45 sc.sc_memt = ia->ia_memt;
46 sc.sc_bustype = CY_BUSTYPE_ISA;
47
48 /* Disallow wildcarded i/o address. */
49 if (ia->ia_iobase == ISACF_PORT_DEFAULT)
50 return (0);
51
52 if (ia->ia_irq == IRQUNK) {
53 printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
54 return 0;
55 }
56
57 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
58 &sc.sc_bsh) != 0)
59 return 0;
60
61 found = cy_find(&sc);
62
63 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
64
65 if (found) {
66 ia->ia_iosize = 0;
67 ia->ia_msize = CY_MEMSIZE;
68 }
69
70 return found;
71 }
72
73 static void
74 cy_attach_isa(parent, self, aux)
75 struct device *parent, *self;
76 void *aux;
77 {
78 struct cy_softc *sc = (void *) self;
79 struct isa_attach_args *ia = aux;
80
81 sc->sc_memt = ia->ia_memt;
82 sc->sc_bustype = CY_BUSTYPE_ISA;
83
84 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
85 &sc->sc_bsh) != 0) {
86 printf(": cannot map mem space\n");
87 return;
88 }
89
90 if (cy_find(sc) == 0) {
91 printf(": cy_find failed\n");
92 return;
93 }
94
95 cy_attach(parent, self, aux);
96
97 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
98 IST_EDGE, IPL_TTY, cy_intr, sc);
99
100 if (sc->sc_ih == NULL)
101 printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
102 }
103