Home | History | Annotate | Line # | Download | only in isa
com_multi.c revision 1.5
      1 /*	$NetBSD: com_multi.c,v 1.5 1997/08/23 14:03:55 drochner Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1993, 1994, 1995, 1996
      5  *	Charles M. Hannum.  All rights reserved.
      6  * Copyright (c) 1991 The Regents of the University of California.
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by the University of
     20  *	California, Berkeley and its contributors.
     21  * 4. Neither the name of the University nor the names of its contributors
     22  *    may be used to endorse or promote products derived from this software
     23  *    without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  * SUCH DAMAGE.
     36  *
     37  *	@(#)com.c	7.5 (Berkeley) 5/16/91
     38  */
     39 
     40 /*
     41  * COM driver, uses National Semiconductor NS16450/NS16550AF UART
     42  */
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/ioctl.h>
     46 #include <sys/select.h>
     47 #include <sys/tty.h>
     48 #include <sys/proc.h>
     49 #include <sys/user.h>
     50 #include <sys/conf.h>
     51 #include <sys/file.h>
     52 #include <sys/uio.h>
     53 #include <sys/kernel.h>
     54 #include <sys/syslog.h>
     55 #include <sys/types.h>
     56 #include <sys/device.h>
     57 
     58 #include <machine/intr.h>
     59 #include <machine/bus.h>
     60 
     61 #include <dev/isa/isavar.h>
     62 #include <dev/isa/comreg.h>
     63 #include <dev/isa/comvar.h>
     64 #include <dev/isa/com_multi.h>
     65 
     66 int com_multi_probe __P((struct device *, void *, void *));
     67 void com_multi_attach __P((struct device *, struct device *, void *));
     68 
     69 struct cfattach com_multi_ca = {
     70 	sizeof(struct com_softc), com_multi_probe, com_multi_attach
     71 };
     72 
     73 int
     74 com_multi_probe(parent, match, aux)
     75 	struct device *parent;
     76 	void *match, *aux;
     77 {
     78 	int iobase;
     79 	struct cfdata *cf = match;
     80 	struct commulti_attach_args *ca = aux;
     81 
     82 	if (cf->cf_loc[COMMULTICF_SLAVE] != COMMULTICF_SLAVE_DEFAULT &&
     83 	    cf->cf_loc[COMMULTICF_SLAVE] != ca->ca_slave)
     84 		return (0);
     85 
     86 	iobase = ca->ca_iobase;
     87 
     88 	/* if it's in use as console, it's there. */
     89 	if (com_is_console(ca->ca_iot, iobase, 0))
     90 		return 1;
     91 
     92 	return comprobe1(ca->ca_iot, ca->ca_ioh, iobase);
     93 }
     94 
     95 void
     96 com_multi_attach(parent, self, aux)
     97 	struct device *parent, *self;
     98 	void *aux;
     99 {
    100 	struct com_softc *sc = (void *)self;
    101 	struct commulti_attach_args *ca = aux;
    102 
    103 	/*
    104 	 * We're living on a commulti.
    105 	 */
    106 	sc->sc_iot = ca->ca_iot;
    107 	sc->sc_ioh = ca->ca_ioh;
    108 	sc->sc_iobase = ca->ca_iobase;
    109 
    110 	if (ca->ca_noien)
    111 		sc->sc_hwflags |= COM_HW_NOIEN;
    112 
    113 	com_attach_subr(sc);
    114 }
    115