xref: /netbsd-src/sys/dev/isa/com_multi.c (revision d0fed6c87ddc40a8bffa6f99e7433ddfc864dd83)
1 /*	$NetBSD: com_multi.c,v 1.1 1997/04/04 20:56:37 mycroft 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[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
83 		return (0);
84 
85 	iobase = ca->ca_iobase;
86 
87 	/* if it's in use as console, it's there. */
88 	if (iobase == comconsaddr && !comconsattached)
89 		return 1;
90 
91 	return comprobe1(ca->ca_iot, ca->ca_ioh, iobase);
92 }
93 
94 void
95 com_multi_attach(parent, self, aux)
96 	struct device *parent, *self;
97 	void *aux;
98 {
99 	struct com_softc *sc = (void *)self;
100 	struct commulti_attach_args *ca = aux;
101 
102 	/*
103 	 * We're living on a commulti.
104 	 */
105 	sc->sc_iot = ca->ca_iot;
106 	sc->sc_ioh = ca->ca_ioh;
107 	sc->sc_iobase = ca->ca_iobase;
108 
109 	if (ca->ca_noien)
110 		sc->sc_hwflags |= COM_HW_NOIEN;
111 
112 	com_attach_subr(sc);
113 }
114