Home | History | Annotate | Line # | Download | only in isapnp
com_isapnp.c revision 1.1
      1 /*	$NetBSD: com_isapnp.c,v 1.1 1997/04/25 15:26:11 explorer Exp $	*/
      2 
      3 /*
      4  * Copyright 1997 by Michael Graff <explorer (at) flame.org>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by
     18  *      Michael Graff <explorer (at) flame.org>
     19  * 4. Neither the name of the Author nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  */
     35 
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 #include <sys/errno.h>
     39 #include <sys/ioctl.h>
     40 #include <sys/syslog.h>
     41 #include <sys/device.h>
     42 #include <sys/proc.h>
     43 #include <sys/termios.h>
     44 
     45 #include <machine/bus.h>
     46 
     47 #include <dev/isa/isavar.h>
     48 #include <dev/isa/isadmavar.h>
     49 
     50 #include <dev/isapnp/isapnpreg.h>
     51 #include <dev/isapnp/isapnpvar.h>
     52 
     53 #include <dev/isa/comvar.h>
     54 
     55 int	com_isapnp_match __P((struct device *, void *, void *));
     56 void	com_isapnp_attach __P((struct device *, struct device *, void *));
     57 
     58 struct cfattach com_isapnp_ca = {
     59 	sizeof(struct com_softc), com_isapnp_match, com_isapnp_attach
     60 };
     61 
     62 int
     63 com_isapnp_match(parent, match, aux)
     64 	struct device *parent;
     65 	void *match, *aux;
     66 {
     67 	struct isapnp_attach_args *ipa = aux;
     68 
     69 	if (strcmp(ipa->ipa_devlogic, "ROK0010") == 0)
     70 		return 1;
     71 
     72 	return 0;
     73 }
     74 
     75 void
     76 com_isapnp_attach(parent, self, aux)
     77 	struct device *parent, *self;
     78 	void *aux;
     79 {
     80 	struct com_softc *sc = (struct com_softc *)self;
     81 	struct isapnp_attach_args *ipa = aux;
     82 
     83 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     84 		printf("%s: error in region allocation\n",
     85 		       sc->sc_dev.dv_xname);
     86 		return;
     87 	}
     88 
     89 	sc->sc_iot = ipa->ipa_iot;
     90 	sc->sc_iobase = ipa->ipa_io[0].base;
     91 	sc->sc_ioh = ipa->ipa_io[0].h;
     92 
     93 	/*
     94 	 * if the chip isn't something we recognise skip it.
     95 	 */
     96 	if (comprobe1(sc->sc_iot, sc->sc_ioh, sc->sc_iobase) == 0)
     97 		return;
     98 
     99 	com_attach_subr(sc);
    100 
    101 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    102 				       IST_EDGE, IPL_SERIAL, comintr, sc);
    103 }
    104