Annotation of sys/dev/isa/cy_isa.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: cy_isa.c,v 1.9 2002/09/15 21:30:25 art Exp $ */
2: /*
3: * Copyright (c) 1996 Timo Rossi.
4: * All rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
11: * 2. Redistributions in binary form must reproduce the above copyright
12: * notice, this list of conditions and the following disclaimer in the
13: * documentation and/or other materials provided with the distribution.
14: * 3. Neither the name of the author nor the names of contributors
15: * may be used to endorse or promote products derived from this software
16: * without specific prior written permission.
17: *
18: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28: * SUCH DAMAGE.
29: */
30:
31: /*
32: * cy_isa.c
33: *
34: * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
35: * (currently not tested with Cyclom-32 cards)
36: *
37: * Timo Rossi, 1996
38: */
39:
40: #include <sys/param.h>
41: #include <sys/systm.h>
42: #include <sys/device.h>
43:
44: #include <machine/bus.h>
45:
46: #include <dev/isa/isavar.h>
47: #include <dev/isa/isareg.h>
48:
49: #include <dev/ic/cd1400reg.h>
50: #include <dev/ic/cyreg.h>
51:
52: static int cy_isa_probe(struct device *, void *, void *);
53: void cy_isa_attach(struct device *, struct device *, void *);
54:
55: struct cfattach cy_isa_ca = {
56: sizeof(struct cy_softc), cy_isa_probe, cy_isa_attach
57: };
58:
59: int
60: cy_isa_probe(parent, match, aux)
61: struct device *parent;
62: void *match, *aux;
63: {
64: int card = ((struct device *)match)->dv_unit;
65: struct isa_attach_args *ia = aux;
66: bus_space_tag_t memt;
67: bus_space_handle_t memh;
68: int ret;
69:
70: if (ia->ia_irq == IRQUNK) {
71: printf("cy%d error: interrupt not defined\n", card);
72: return (0);
73: }
74:
75: memt = ia->ia_memt;
76: if (bus_space_map(memt, ia->ia_maddr, 0x2000, 0, &memh) != 0)
77: return (0);
78:
79: ret = cy_probe_common(memt, memh, CY_BUSTYPE_ISA);
80: bus_space_unmap(memt, memh, 0x2000);
81: if (ret == 0)
82: return (0);
83:
84: ia->ia_iosize = 0;
85: ia->ia_msize = 0x2000;
86: return (1);
87: }
88:
89: void
90: cy_isa_attach(parent, self, aux)
91: struct device *parent, *self;
92: void *aux;
93: {
94: struct cy_softc *sc = (struct cy_softc *)self;
95: struct isa_attach_args *ia = aux;
96:
97: sc->sc_bustype = CY_BUSTYPE_ISA;
98: sc->sc_memt = ia->ia_memt;
99:
100: if (bus_space_map(ia->ia_memt, ia->ia_maddr, 0x2000, 0,
101: &sc->sc_memh) != 0)
102: return;
103:
104: sc->sc_nr_cd1400s = cy_probe_common(sc->sc_memt, sc->sc_memh,
105: CY_BUSTYPE_ISA);
106:
107: cy_attach(parent, self);
108:
109: sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
110: IST_EDGE, IPL_TTY, cy_intr, sc, sc->sc_dev.dv_xname);
111:
112: if (sc->sc_ih == NULL)
113: panic("cy: couldn't establish interrupt");
114: }
CVSweb