Home | History | Annotate | Line # | Download | only in isa
com_multi.c revision 1.2.2.4
      1 /*	$NetBSD: com_multi.c,v 1.2.2.4 1997/10/14 10:23:22 thorpej 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 #ifdef __BROKEN_INDIRECT_CONFIG
     67 int com_multi_probe __P((struct device *, void *, void *));
     68 #else
     69 int com_multi_probe __P((struct device *, struct cfdata *, void *));
     70 #endif
     71 void com_multi_attach __P((struct device *, struct device *, void *));
     72 
     73 struct cfattach com_multi_ca = {
     74 	sizeof(struct com_softc), com_multi_probe, com_multi_attach
     75 };
     76 
     77 int
     78 com_multi_probe(parent, match, aux)
     79 	struct device *parent;
     80 #ifdef __BROKEN_INDIRECT_CONFIG
     81 	void *match;
     82 #else
     83 	struct cfdata *match;
     84 #endif
     85 	void *aux;
     86 {
     87 	int iobase;
     88 	struct cfdata *cf = match;
     89 	struct commulti_attach_args *ca = aux;
     90 
     91 	if (cf->cf_loc[COMMULTICF_SLAVE] != COMMULTICF_SLAVE_DEFAULT &&
     92 	    cf->cf_loc[COMMULTICF_SLAVE] != ca->ca_slave)
     93 		return (0);
     94 
     95 	iobase = ca->ca_iobase;
     96 
     97 	/* if it's in use as console, it's there. */
     98 	if (com_is_console(ca->ca_iot, iobase, 0))
     99 		return 1;
    100 
    101 	return comprobe1(ca->ca_iot, ca->ca_ioh, iobase);
    102 }
    103 
    104 void
    105 com_multi_attach(parent, self, aux)
    106 	struct device *parent, *self;
    107 	void *aux;
    108 {
    109 	struct com_softc *sc = (void *)self;
    110 	struct commulti_attach_args *ca = aux;
    111 
    112 	/*
    113 	 * We're living on a commulti.
    114 	 */
    115 	sc->sc_iot = ca->ca_iot;
    116 	sc->sc_ioh = ca->ca_ioh;
    117 	sc->sc_iobase = ca->ca_iobase;
    118 	sc->sc_frequency = 115200 * 16;
    119 
    120 	if (ca->ca_noien)
    121 		sc->sc_hwflags |= COM_HW_NOIEN;
    122 
    123 	com_attach_subr(sc);
    124 }
    125