cy_isa.c revision 1.9 1 /* $NetBSD: cy_isa.c,v 1.9 1998/01/31 11:23:35 christos 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 #ifdef __BROKEN_INDIRECT_CONFIG
28 static int cy_probe_isa __P((struct device *, void *, void *));
29 #else
30 static int cy_probe_isa __P((struct device *, struct cfdata *, void *));
31 #endif
32 static void cy_attach_isa __P((struct device *, struct device *, void *));
33
34 struct cfattach cy_isa_ca = {
35 sizeof(struct cy_softc), cy_probe_isa, cy_attach_isa
36 };
37
38 static int
39 cy_probe_isa(parent, match, aux)
40 struct device *parent;
41 #ifdef __BROKEN_INDIRECT_CONFIG
42 void *match;
43 #else
44 struct cfdata *match;
45 #endif
46 void *aux;
47 {
48 struct isa_attach_args *ia = aux;
49 struct cy_softc sc;
50 int found;
51
52 memcpy(&sc.sc_dev, match, sizeof(struct device));
53
54 sc.sc_memt = ia->ia_memt;
55 sc.sc_bustype = CY_BUSTYPE_ISA;
56
57 /* Disallow wildcarded memory address. */
58 if (ia->ia_maddr == ISACF_IOMEM_DEFAULT) {
59 printf("%s: memory addr not defined\n", sc.sc_dev.dv_xname);
60 return (0);
61 }
62
63 if (ia->ia_irq == IRQUNK) {
64 printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
65 return 0;
66 }
67
68 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
69 &sc.sc_bsh) != 0)
70 return 0;
71
72 found = cy_find(&sc);
73
74 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
75
76 if (found) {
77 ia->ia_iosize = 0;
78 ia->ia_msize = CY_MEMSIZE;
79 }
80
81 return found;
82 }
83
84 static void
85 cy_attach_isa(parent, self, aux)
86 struct device *parent, *self;
87 void *aux;
88 {
89 struct cy_softc *sc = (void *) self;
90 struct isa_attach_args *ia = aux;
91
92 sc->sc_memt = ia->ia_memt;
93 sc->sc_bustype = CY_BUSTYPE_ISA;
94
95 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
96 &sc->sc_bsh) != 0) {
97 printf(": cannot map mem space\n");
98 return;
99 }
100
101 if (cy_find(sc) == 0) {
102 printf(": cy_find failed\n");
103 return;
104 }
105
106 cy_attach(parent, self, aux);
107
108 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
109 IST_EDGE, IPL_TTY, cy_intr, sc);
110
111 if (sc->sc_ih == NULL)
112 printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
113 }
114