cy_isa.c revision 1.9 1 1.9 christos /* $NetBSD: cy_isa.c,v 1.9 1998/01/31 11:23:35 christos Exp $ */
2 1.1 christos
3 1.1 christos /*
4 1.1 christos * cy.c
5 1.1 christos *
6 1.1 christos * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
7 1.1 christos * (currently not tested with Cyclom-32 cards)
8 1.1 christos *
9 1.1 christos * Timo Rossi, 1996
10 1.1 christos *
11 1.1 christos */
12 1.1 christos
13 1.1 christos #include <sys/param.h>
14 1.1 christos #include <sys/systm.h>
15 1.1 christos #include <sys/device.h>
16 1.1 christos
17 1.1 christos #include <machine/bus.h>
18 1.1 christos #include <machine/intr.h>
19 1.1 christos
20 1.1 christos #include <dev/isa/isavar.h>
21 1.1 christos #include <dev/isa/isareg.h>
22 1.1 christos
23 1.1 christos #include <dev/ic/cd1400reg.h>
24 1.1 christos #include <dev/ic/cyreg.h>
25 1.1 christos #include <dev/ic/cyvar.h>
26 1.1 christos
27 1.8 drochner #ifdef __BROKEN_INDIRECT_CONFIG
28 1.1 christos static int cy_probe_isa __P((struct device *, void *, void *));
29 1.8 drochner #else
30 1.8 drochner static int cy_probe_isa __P((struct device *, struct cfdata *, void *));
31 1.8 drochner #endif
32 1.1 christos static void cy_attach_isa __P((struct device *, struct device *, void *));
33 1.1 christos
34 1.1 christos struct cfattach cy_isa_ca = {
35 1.1 christos sizeof(struct cy_softc), cy_probe_isa, cy_attach_isa
36 1.1 christos };
37 1.1 christos
38 1.1 christos static int
39 1.1 christos cy_probe_isa(parent, match, aux)
40 1.1 christos struct device *parent;
41 1.8 drochner #ifdef __BROKEN_INDIRECT_CONFIG
42 1.8 drochner void *match;
43 1.8 drochner #else
44 1.8 drochner struct cfdata *match;
45 1.8 drochner #endif
46 1.8 drochner void *aux;
47 1.1 christos {
48 1.1 christos struct isa_attach_args *ia = aux;
49 1.1 christos struct cy_softc sc;
50 1.2 thorpej int found;
51 1.1 christos
52 1.1 christos memcpy(&sc.sc_dev, match, sizeof(struct device));
53 1.1 christos
54 1.5 thorpej sc.sc_memt = ia->ia_memt;
55 1.1 christos sc.sc_bustype = CY_BUSTYPE_ISA;
56 1.6 thorpej
57 1.9 christos /* Disallow wildcarded memory address. */
58 1.9 christos if (ia->ia_maddr == ISACF_IOMEM_DEFAULT) {
59 1.9 christos printf("%s: memory addr not defined\n", sc.sc_dev.dv_xname);
60 1.6 thorpej return (0);
61 1.9 christos }
62 1.1 christos
63 1.1 christos if (ia->ia_irq == IRQUNK) {
64 1.4 christos printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
65 1.1 christos return 0;
66 1.1 christos }
67 1.1 christos
68 1.5 thorpej if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
69 1.5 thorpej &sc.sc_bsh) != 0)
70 1.1 christos return 0;
71 1.1 christos
72 1.2 thorpej found = cy_find(&sc);
73 1.1 christos
74 1.5 thorpej bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
75 1.1 christos
76 1.2 thorpej if (found) {
77 1.2 thorpej ia->ia_iosize = 0;
78 1.2 thorpej ia->ia_msize = CY_MEMSIZE;
79 1.2 thorpej }
80 1.1 christos
81 1.2 thorpej return found;
82 1.1 christos }
83 1.1 christos
84 1.1 christos static void
85 1.1 christos cy_attach_isa(parent, self, aux)
86 1.1 christos struct device *parent, *self;
87 1.1 christos void *aux;
88 1.1 christos {
89 1.1 christos struct cy_softc *sc = (void *) self;
90 1.1 christos struct isa_attach_args *ia = aux;
91 1.1 christos
92 1.5 thorpej sc->sc_memt = ia->ia_memt;
93 1.1 christos sc->sc_bustype = CY_BUSTYPE_ISA;
94 1.1 christos
95 1.5 thorpej if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
96 1.7 thorpej &sc->sc_bsh) != 0) {
97 1.7 thorpej printf(": cannot map mem space\n");
98 1.7 thorpej return;
99 1.7 thorpej }
100 1.1 christos
101 1.7 thorpej if (cy_find(sc) == 0) {
102 1.7 thorpej printf(": cy_find failed\n");
103 1.7 thorpej return;
104 1.7 thorpej }
105 1.1 christos
106 1.1 christos cy_attach(parent, self, aux);
107 1.1 christos
108 1.1 christos sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
109 1.1 christos IST_EDGE, IPL_TTY, cy_intr, sc);
110 1.1 christos
111 1.1 christos if (sc->sc_ih == NULL)
112 1.4 christos printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
113 1.1 christos }
114