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