cy_isa.c revision 1.8 1 /* $NetBSD: cy_isa.c,v 1.8 1998/01/14 12:14:47 drochner 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 i/o address. */
58 if (ia->ia_iobase == ISACF_PORT_DEFAULT)
59 return (0);
60
61 if (ia->ia_irq == IRQUNK) {
62 printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
63 return 0;
64 }
65
66 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
67 &sc.sc_bsh) != 0)
68 return 0;
69
70 found = cy_find(&sc);
71
72 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
73
74 if (found) {
75 ia->ia_iosize = 0;
76 ia->ia_msize = CY_MEMSIZE;
77 }
78
79 return found;
80 }
81
82 static void
83 cy_attach_isa(parent, self, aux)
84 struct device *parent, *self;
85 void *aux;
86 {
87 struct cy_softc *sc = (void *) self;
88 struct isa_attach_args *ia = aux;
89
90 sc->sc_memt = ia->ia_memt;
91 sc->sc_bustype = CY_BUSTYPE_ISA;
92
93 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
94 &sc->sc_bsh) != 0) {
95 printf(": cannot map mem space\n");
96 return;
97 }
98
99 if (cy_find(sc) == 0) {
100 printf(": cy_find failed\n");
101 return;
102 }
103
104 cy_attach(parent, self, aux);
105
106 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
107 IST_EDGE, IPL_TTY, cy_intr, sc);
108
109 if (sc->sc_ih == NULL)
110 printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
111 }
112