No empty .Rs/.Re
[netbsd-mini2440.git] / sys / dev / isa / cy_isa.c
bloba54a4eebf802ebc6854a25878e0192325cee4e8f
1 /* $NetBSD: cy_isa.c,v 1.22 2007/10/19 12:00:15 ad Exp $ */
3 /*
4 * cy.c
6 * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
7 * (currently not tested with Cyclom-32 cards)
9 * Timo Rossi, 1996
12 #include <sys/cdefs.h>
13 __KERNEL_RCSID(0, "$NetBSD: cy_isa.c,v 1.22 2007/10/19 12:00:15 ad Exp $");
15 #include <sys/param.h>
16 #include <sys/systm.h>
17 #include <sys/device.h>
19 #include <sys/bus.h>
20 #include <sys/intr.h>
22 #include <dev/isa/isavar.h>
23 #include <dev/isa/isareg.h>
25 #include <dev/ic/cd1400reg.h>
26 #include <dev/ic/cyreg.h>
27 #include <dev/ic/cyvar.h>
29 int cy_isa_probe(device_t, cfdata_t, void *);
30 void cy_isa_attach(device_t, device_t, void *);
32 CFATTACH_DECL_NEW(cy_isa, sizeof(struct cy_softc),
33 cy_isa_probe, cy_isa_attach, NULL, NULL);
35 int
36 cy_isa_probe(device_t parent, cfdata_t match, void *aux)
38 struct isa_attach_args *ia = aux;
39 struct cy_softc sc;
40 int found;
42 if (ia->ia_niomem < 1)
43 return (0);
44 if (ia->ia_nirq < 1)
45 return (0);
47 sc.sc_memt = ia->ia_memt;
48 sc.sc_bustype = CY_BUSTYPE_ISA;
50 /* Disallow wildcarded memory address. */
51 if (ia->ia_iomem[0].ir_addr == ISA_UNKNOWN_IOMEM)
52 return 0;
53 if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
54 return 0;
56 if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
57 &sc.sc_bsh) != 0)
58 return 0;
60 found = cy_find(&sc);
62 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
64 if (found) {
65 ia->ia_niomem = 1;
66 ia->ia_iomem[0].ir_size = CY_MEMSIZE;
68 ia->ia_nirq = 1;
70 ia->ia_nio = 0;
71 ia->ia_ndrq = 0;
73 return (found);
76 void
77 cy_isa_attach(device_t parent, device_t self, void *aux)
79 struct cy_softc *sc = device_private(self);
80 struct isa_attach_args *ia = aux;
82 sc->sc_dev = self;
83 sc->sc_memt = ia->ia_memt;
84 sc->sc_bustype = CY_BUSTYPE_ISA;
86 printf(": Cyclades-Y multiport serial\n");
88 if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
89 &sc->sc_bsh) != 0) {
90 aprint_error_dev(sc->sc_dev,
91 "unable to map device registers\n");
92 return;
95 if (cy_find(sc) == 0) {
96 aprint_error_dev(sc->sc_dev, "unable to find CD1400s\n");
97 return;
100 cy_attach(sc);
102 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
103 IST_EDGE, IPL_TTY, cy_intr, sc);
104 if (sc->sc_ih == NULL)
105 aprint_error_dev(sc->sc_dev, "unable to establish interrupt\n");