com_jazzio.c revision 1.5 1 1.5 lukem /* $NetBSD: com_jazzio.c,v 1.5 2003/07/15 00:04:49 lukem Exp $ */
2 1.1 ur /* $OpenBSD: com_lbus.c,v 1.7 1998/03/16 09:38:41 pefo Exp $ */
3 1.1 ur /* NetBSD: com_isa.c,v 1.12 1998/08/15 17:47:17 mycroft Exp */
4 1.1 ur
5 1.1 ur /*-
6 1.1 ur * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 1.1 ur * All rights reserved.
8 1.1 ur *
9 1.1 ur * This code is derived from software contributed to The NetBSD Foundation
10 1.1 ur * by Charles M. Hannum.
11 1.1 ur *
12 1.1 ur * Redistribution and use in source and binary forms, with or without
13 1.1 ur * modification, are permitted provided that the following conditions
14 1.1 ur * are met:
15 1.1 ur * 1. Redistributions of source code must retain the above copyright
16 1.1 ur * notice, this list of conditions and the following disclaimer.
17 1.1 ur * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 ur * notice, this list of conditions and the following disclaimer in the
19 1.1 ur * documentation and/or other materials provided with the distribution.
20 1.1 ur * 3. All advertising materials mentioning features or use of this software
21 1.1 ur * must display the following acknowledgement:
22 1.1 ur * This product includes software developed by the NetBSD
23 1.1 ur * Foundation, Inc. and its contributors.
24 1.1 ur * 4. Neither the name of The NetBSD Foundation nor the names of its
25 1.1 ur * contributors may be used to endorse or promote products derived
26 1.1 ur * from this software without specific prior written permission.
27 1.1 ur *
28 1.1 ur * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 1.1 ur * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 1.1 ur * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 1.1 ur * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 1.1 ur * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 1.1 ur * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 1.1 ur * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 1.1 ur * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 1.1 ur * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 1.1 ur * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 1.1 ur * POSSIBILITY OF SUCH DAMAGE.
39 1.1 ur */
40 1.1 ur
41 1.1 ur /*-
42 1.1 ur * Copyright (c) 1991 The Regents of the University of California.
43 1.1 ur * All rights reserved.
44 1.1 ur *
45 1.1 ur * Redistribution and use in source and binary forms, with or without
46 1.1 ur * modification, are permitted provided that the following conditions
47 1.1 ur * are met:
48 1.1 ur * 1. Redistributions of source code must retain the above copyright
49 1.1 ur * notice, this list of conditions and the following disclaimer.
50 1.1 ur * 2. Redistributions in binary form must reproduce the above copyright
51 1.1 ur * notice, this list of conditions and the following disclaimer in the
52 1.1 ur * documentation and/or other materials provided with the distribution.
53 1.1 ur * 3. All advertising materials mentioning features or use of this software
54 1.1 ur * must display the following acknowledgement:
55 1.1 ur * This product includes software developed by the University of
56 1.1 ur * California, Berkeley and its contributors.
57 1.1 ur * 4. Neither the name of the University nor the names of its contributors
58 1.1 ur * may be used to endorse or promote products derived from this software
59 1.1 ur * without specific prior written permission.
60 1.1 ur *
61 1.1 ur * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
62 1.1 ur * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 1.1 ur * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 1.1 ur * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
65 1.1 ur * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 1.1 ur * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 1.1 ur * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 1.1 ur * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 1.1 ur * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 1.1 ur * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 1.1 ur * SUCH DAMAGE.
72 1.1 ur *
73 1.1 ur * @(#)com.c 7.5 (Berkeley) 5/16/91
74 1.1 ur */
75 1.5 lukem
76 1.5 lukem #include <sys/cdefs.h>
77 1.5 lukem __KERNEL_RCSID(0, "$NetBSD: com_jazzio.c,v 1.5 2003/07/15 00:04:49 lukem Exp $");
78 1.1 ur
79 1.1 ur #include <sys/param.h>
80 1.1 ur #include <sys/systm.h>
81 1.1 ur #include <sys/device.h>
82 1.1 ur #include <sys/tty.h>
83 1.1 ur
84 1.1 ur #include <machine/autoconf.h>
85 1.1 ur #include <machine/bus.h>
86 1.1 ur #include <machine/intr.h>
87 1.1 ur
88 1.1 ur #include <arc/jazz/jazziovar.h>
89 1.1 ur
90 1.1 ur #include <dev/isa/isavar.h> /* XXX for isa_chipset_tag_t in com_softc */
91 1.1 ur
92 1.1 ur #include <dev/ic/comreg.h>
93 1.1 ur #include <dev/ic/comvar.h>
94 1.1 ur #include <dev/ic/ns16550reg.h>
95 1.1 ur
96 1.1 ur extern int com_freq;
97 1.1 ur
98 1.1 ur int com_jazzio_probe __P((struct device *, struct cfdata *, void *));
99 1.1 ur void com_jazzio_attach __P((struct device *, struct device *, void *));
100 1.1 ur
101 1.3 thorpej CFATTACH_DECL(com_jazzio, sizeof(struct com_softc),
102 1.3 thorpej com_jazzio_probe, com_jazzio_attach, NULL, NULL);
103 1.1 ur
104 1.1 ur int
105 1.1 ur com_jazzio_probe(parent, match, aux)
106 1.1 ur struct device *parent;
107 1.1 ur struct cfdata *match;
108 1.1 ur void *aux;
109 1.1 ur {
110 1.1 ur struct jazzio_attach_args *ja = aux;
111 1.1 ur bus_space_tag_t iot;
112 1.1 ur bus_space_handle_t ioh;
113 1.1 ur int iobase;
114 1.1 ur int rv = 1;
115 1.1 ur
116 1.4 tsutsui if (strcmp(ja->ja_name, "COM1") != 0 &&
117 1.4 tsutsui strcmp(ja->ja_name, "COM2") != 0)
118 1.1 ur return (0);
119 1.1 ur
120 1.1 ur iot = ja->ja_bust;
121 1.1 ur iobase = ja->ja_addr;
122 1.1 ur
123 1.1 ur /* if it's in use as console, it's there. */
124 1.1 ur if (!com_is_console(iot, iobase, 0)) {
125 1.1 ur if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
126 1.1 ur return 0;
127 1.1 ur }
128 1.1 ur rv = comprobe1(iot, ioh);
129 1.1 ur bus_space_unmap(iot, ioh, COM_NPORTS);
130 1.1 ur }
131 1.1 ur return (rv);
132 1.1 ur }
133 1.1 ur
134 1.1 ur void
135 1.1 ur com_jazzio_attach(parent, self, aux)
136 1.1 ur struct device *parent, *self;
137 1.1 ur void *aux;
138 1.1 ur {
139 1.1 ur struct jazzio_attach_args *ja = aux;
140 1.1 ur struct com_softc *sc = (void *)self;
141 1.1 ur int iobase;
142 1.1 ur bus_space_tag_t iot;
143 1.1 ur
144 1.1 ur sc->sc_iobase = iobase = ja->ja_addr;
145 1.1 ur sc->sc_iot = iot = ja->ja_bust;
146 1.1 ur
147 1.1 ur if (!com_is_console(iot, iobase, &sc->sc_ioh) &&
148 1.1 ur bus_space_map(iot, iobase, COM_NPORTS, 0, &sc->sc_ioh)) {
149 1.1 ur printf(": can't map i/o space\n");
150 1.1 ur return;
151 1.1 ur }
152 1.1 ur
153 1.1 ur sc->sc_frequency = com_freq;
154 1.1 ur SET(sc->sc_hwflags, COM_HW_TXFIFO_DISABLE); /* XXX - NEC M403 */
155 1.1 ur jazzio_intr_establish(ja->ja_intr, comintr, sc);
156 1.1 ur
157 1.1 ur com_attach_subr(sc);
158 1.1 ur }
159