1 /* $OpenBSD: com_isapnp.c,v 1.1 2001/09/30 00:11:57 art Exp $ */ 2 /* 3 * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name(s) of the author(s) nor the name OpenBSD 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 /*- 30 * Copyright (c) 1993, 1994, 1995, 1996 31 * Charles M. Hannum. All rights reserved. 32 * Copyright (c) 1991 The Regents of the University of California. 33 * All rights reserved. 34 * 35 * Redistribution and use in source and binary forms, with or without 36 * modification, are permitted provided that the following conditions 37 * are met: 38 * 1. Redistributions of source code must retain the above copyright 39 * notice, this list of conditions and the following disclaimer. 40 * 2. Redistributions in binary form must reproduce the above copyright 41 * notice, this list of conditions and the following disclaimer in the 42 * documentation and/or other materials provided with the distribution. 43 * 3. All advertising materials mentioning features or use of this software 44 * must display the following acknowledgement: 45 * This product includes software developed by the University of 46 * California, Berkeley and its contributors. 47 * 4. Neither the name of the University nor the names of its contributors 48 * may be used to endorse or promote products derived from this software 49 * without specific prior written permission. 50 * 51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 61 * SUCH DAMAGE. 62 * 63 * @(#)com.c 7.5 (Berkeley) 5/16/91 64 */ 65 66 #include <sys/param.h> 67 #include <sys/systm.h> 68 #include <sys/tty.h> 69 #include <sys/device.h> 70 71 #include <machine/intr.h> 72 #include <machine/bus.h> 73 74 #include <dev/ic/comreg.h> 75 #include <dev/ic/comvar.h> 76 77 #include <dev/isa/isavar.h> 78 79 #if NCOM_ISAPNP 80 struct cfattach com_isapnp_ca = { 81 sizeof(struct com_softc), comprobe, comattach 82 }; 83 #endif 84 85 int com_isapnp_probe(struct device *, void *, void *); 86 int com_isapnp_attach(struct device *, struct device *, void *); 87 88 int 89 com_isapnp_probe(struct device *parent, void *match, void *aux) 90 { 91 struct isa_attach_args *ia = aux; 92 bus_space_tag_t iot; 93 bus_space_handle_t ioh; 94 int iobase; 95 96 iot = ia->ia_iot; 97 iobase = ia->ia_iobase; 98 ioh = ia->ia_ioh; 99 100 #ifdef KGDB 101 if (iobase == com_kgdb_addr) 102 return (1); 103 #endif 104 /* if it's in use as console, it's there. */ 105 if (iobase == comconsaddr && !comconsattached) 106 return (1); 107 108 return comprobe1(iot, ioh); 109 } 110 111 int 112 com_isapnp_attach(struct device *parent, struct device *self, void *aux) 113 { 114 struct com_softc *sc = (void *)self; 115 int iobase; 116 int irq; 117 bus_space_tag_t iot; 118 bus_space_handle_t ioh; 119 struct isa_attach_args *ia = aux; 120 121 /* 122 * XXX should be broken out into functions for isa attach and 123 * XXX for commulti attach, with a helper function that contains 124 * XXX most of the interesting stuff. 125 */ 126 sc->sc_hwflags = 0; 127 sc->sc_swflags = 0; 128 129 /* 130 * We're living on an isa. 131 */ 132 iobase = ia->ia_iobase; 133 iot = ia->ia_iot; 134 /* No console support! */ 135 ioh = ia->ia_ioh; 136 137 sc->sc_iot = iot; 138 sc->sc_ioh = ioh; 139 sc->sc_iobase = iobase; 140 sc->sc_frequency = COM_FREQ; 141 142 com_attach_subr(sc); 143 144 irq = ia->ia_irq; 145 if (irq != IRQUNK) { 146 #ifdef KGDB 147 if (iobase == com_kgdb_addr) { 148 sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, 149 IST_EDGE, IPL_HIGH, kgdbintr, sc, 150 sc->sc_dev.dv_xname); 151 } else { 152 sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, 153 IST_EDGE, IPL_TTY, comintr, sc, 154 sc->sc_dev.dv_xname); 155 } 156 #else 157 sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, 158 IST_EDGE, IPL_TTY, comintr, sc, 159 sc->sc_dev.dv_xname); 160 #endif /* KGDB */ 161 } 162 } 163