Annotation of src/sys/dev/isa/cy_isa.c, Revision 1.22
1.22 ! ad 1: /* $NetBSD: cy_isa.c,v 1.21 2006/11/16 01:33:00 christos Exp $ */
1.1 christos 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: */
1.13 lukem 11:
12: #include <sys/cdefs.h>
1.22 ! ad 13: __KERNEL_RCSID(0, "$NetBSD: cy_isa.c,v 1.21 2006/11/16 01:33:00 christos Exp $");
1.1 christos 14:
15: #include <sys/param.h>
16: #include <sys/systm.h>
17: #include <sys/device.h>
18:
1.22 ! ad 19: #include <sys/bus.h>
! 20: #include <sys/intr.h>
1.1 christos 21:
22: #include <dev/isa/isavar.h>
23: #include <dev/isa/isareg.h>
24:
25: #include <dev/ic/cd1400reg.h>
26: #include <dev/ic/cyreg.h>
27: #include <dev/ic/cyvar.h>
28:
1.11 thorpej 29: int cy_isa_probe(struct device *, struct cfdata *, void *);
30: void cy_isa_attach(struct device *, struct device *, void *);
1.1 christos 31:
1.17 thorpej 32: CFATTACH_DECL(cy_isa, sizeof(struct cy_softc),
33: cy_isa_probe, cy_isa_attach, NULL, NULL);
1.1 christos 34:
1.11 thorpej 35: int
1.21 christos 36: cy_isa_probe(struct device *parent, struct cfdata *match, void *aux)
1.1 christos 37: {
38: struct isa_attach_args *ia = aux;
39: struct cy_softc sc;
1.2 thorpej 40: int found;
1.1 christos 41:
1.14 thorpej 42: if (ia->ia_niomem < 1)
43: return (0);
44: if (ia->ia_nirq < 1)
45: return (0);
46:
1.1 christos 47: memcpy(&sc.sc_dev, match, sizeof(struct device));
48:
1.5 thorpej 49: sc.sc_memt = ia->ia_memt;
1.1 christos 50: sc.sc_bustype = CY_BUSTYPE_ISA;
1.6 thorpej 51:
1.9 christos 52: /* Disallow wildcarded memory address. */
1.18 drochner 53: if (ia->ia_iomem[0].ir_addr == ISA_UNKNOWN_IOMEM)
1.14 thorpej 54: return 0;
1.18 drochner 55: if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
1.1 christos 56: return 0;
57:
1.14 thorpej 58: if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
1.5 thorpej 59: &sc.sc_bsh) != 0)
1.1 christos 60: return 0;
61:
1.2 thorpej 62: found = cy_find(&sc);
1.1 christos 63:
1.5 thorpej 64: bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
1.1 christos 65:
1.2 thorpej 66: if (found) {
1.14 thorpej 67: ia->ia_niomem = 1;
68: ia->ia_iomem[0].ir_size = CY_MEMSIZE;
69:
70: ia->ia_nirq = 1;
71:
72: ia->ia_nio = 0;
73: ia->ia_ndrq = 0;
1.2 thorpej 74: }
1.11 thorpej 75: return (found);
1.1 christos 76: }
77:
1.11 thorpej 78: void
1.21 christos 79: cy_isa_attach(struct device *parent, struct device *self, void *aux)
1.1 christos 80: {
81: struct cy_softc *sc = (void *) self;
82: struct isa_attach_args *ia = aux;
83:
1.5 thorpej 84: sc->sc_memt = ia->ia_memt;
1.1 christos 85: sc->sc_bustype = CY_BUSTYPE_ISA;
86:
1.11 thorpej 87: printf(": Cyclades-Y multiport serial\n");
88:
1.14 thorpej 89: if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
1.7 thorpej 90: &sc->sc_bsh) != 0) {
1.11 thorpej 91: printf("%s: unable to map device registers\n",
92: sc->sc_dev.dv_xname);
1.7 thorpej 93: return;
94: }
1.1 christos 95:
1.7 thorpej 96: if (cy_find(sc) == 0) {
1.11 thorpej 97: printf("%s: unable to find CD1400s\n", sc->sc_dev.dv_xname);
1.7 thorpej 98: return;
99: }
1.1 christos 100:
1.12 thorpej 101: cy_attach(sc);
1.1 christos 102:
1.14 thorpej 103: sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
1.1 christos 104: IST_EDGE, IPL_TTY, cy_intr, sc);
105: if (sc->sc_ih == NULL)
1.11 thorpej 106: printf("%s: unable to establish interrupt",
107: sc->sc_dev.dv_xname);
1.1 christos 108: }
CVSweb <webmaster@jp.NetBSD.org>