1 /* $NetBSD: com_jazzio.c,v 1.10 2008/03/14 15:09:09 cube Exp $ */
2 /* $OpenBSD: com_lbus.c,v 1.7 1998/03/16 09:38:41 pefo Exp $ */
3 /* NetBSD: com_isa.c,v 1.12 1998/08/15 17:47:17 mycroft Exp */
6 * Copyright (c) 1998 The NetBSD Foundation, Inc.
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Charles M. Hannum.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
35 * Copyright (c) 1991 The Regents of the University of California.
36 * All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * @(#)com.c 7.5 (Berkeley) 5/16/91
65 #include <sys/cdefs.h>
66 __KERNEL_RCSID(0, "$NetBSD: com_jazzio.c,v 1.10 2008/03/14 15:09:09 cube Exp $");
68 #include <sys/param.h>
69 #include <sys/systm.h>
70 #include <sys/device.h>
73 #include <machine/autoconf.h>
74 #include <machine/bus.h>
75 #include <machine/intr.h>
77 #include <arc/jazz/jazziovar.h>
79 #include <dev/isa/isavar.h> /* XXX for isa_chipset_tag_t in com_softc */
81 #include <dev/ic/comreg.h>
82 #include <dev/ic/comvar.h>
83 #include <dev/ic/ns16550reg.h>
87 int com_jazzio_probe(device_t
, cfdata_t
, void *);
88 void com_jazzio_attach(device_t
, device_t
, void *);
90 CFATTACH_DECL_NEW(com_jazzio
, sizeof(struct com_softc
),
91 com_jazzio_probe
, com_jazzio_attach
, NULL
, NULL
);
94 com_jazzio_probe(device_t parent
, cfdata_t match
, void *aux
)
96 struct jazzio_attach_args
*ja
= aux
;
98 bus_space_handle_t ioh
;
102 if (strcmp(ja
->ja_name
, "COM1") != 0 &&
103 strcmp(ja
->ja_name
, "COM2") != 0)
107 iobase
= ja
->ja_addr
;
109 /* if it's in use as console, it's there. */
110 if (!com_is_console(iot
, iobase
, 0)) {
111 if (bus_space_map(iot
, iobase
, COM_NPORTS
, 0, &ioh
)) {
114 rv
= comprobe1(iot
, ioh
);
115 bus_space_unmap(iot
, ioh
, COM_NPORTS
);
121 com_jazzio_attach(device_t parent
, device_t self
, void *aux
)
123 struct jazzio_attach_args
*ja
= aux
;
124 struct com_softc
*sc
= device_private(self
);
127 bus_space_handle_t ioh
;
130 iobase
= ja
->ja_addr
;
133 if (!com_is_console(iot
, iobase
, &ioh
) &&
134 bus_space_map(iot
, iobase
, COM_NPORTS
, 0, &ioh
)) {
135 aprint_error(": can't map i/o space\n");
138 COM_INIT_REGS(sc
->sc_regs
, iot
, ioh
, iobase
);
139 sc
->sc_frequency
= com_freq
;
140 SET(sc
->sc_hwflags
, COM_HW_TXFIFO_DISABLE
); /* XXX - NEC M403 */
141 jazzio_intr_establish(ja
->ja_intr
, comintr
, sc
);