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