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