1 /* $NetBSD: com_supio.c,v 1.26 2008/04/28 20:23:12 martin Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
33 * Copyright (c) 1991 The Regents of the University of California.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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.
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
60 * @(#)com.c 7.5 (Berkeley) 5/16/91
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD: com_supio.c,v 1.26 2008/04/28 20:23:12 martin Exp $");
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/ioctl.h>
69 #include <sys/select.h>
75 #include <sys/kernel.h>
76 #include <sys/syslog.h>
77 #include <sys/types.h>
78 #include <sys/device.h>
80 #include <machine/intr.h>
81 #include <machine/bus.h>
83 /*#include <dev/isa/isavar.h>*/
84 #include <dev/ic/comreg.h>
85 #include <dev/ic/comvar.h>
87 #include <amiga/dev/supio.h>
89 struct comsupio_softc
{
90 struct com_softc sc_com
;
94 int com_supio_match(device_t
, cfdata_t
, void *);
95 void com_supio_attach(device_t
, device_t
, void *);
97 CFATTACH_DECL_NEW(com_supio
, sizeof(struct comsupio_softc
),
98 com_supio_match
, com_supio_attach
, NULL
, NULL
);
101 com_supio_match(device_t parent
, cfdata_t match
, void *aux
)
104 struct supio_attach_args
*supa
= aux
;
106 if (strcmp(supa
->supio_name
,"com"))
113 com_supio_attach(device_t parent
, device_t self
, void *aux
)
115 struct comsupio_softc
*sc
= device_private(self
);
116 struct com_softc
*csc
= &sc
->sc_com
;
119 bus_space_handle_t ioh
;
120 struct supio_attach_args
*supa
= aux
;
126 * We're living on a superio chip.
128 iobase
= supa
->supio_iobase
;
129 iot
= supa
->supio_iot
;
130 aprint_normal(" port 0x%04x ipl %d", iobase
, supa
->supio_ipl
);
132 if (bus_space_map(iot
, iobase
, COM_NPORTS
, 0, &ioh
))
133 panic("comattach: io mapping failed");
134 COM_INIT_REGS(csc
->sc_regs
, iot
, ioh
, iobase
);
136 csc
->sc_frequency
= supa
->supio_arg
;
138 com_attach_subr(csc
);
140 /* XXX this should be really in the interrupt stuff */
141 needpsl
= PSL_S
| (supa
->supio_ipl
<< 8);
143 if (ipl2spl_table
[IPL_SERIAL
] < needpsl
) {
144 aprint_normal_dev(self
, "raising ipl2spl_table[IPL_SERIAL] "
145 "from 0x%x to 0x%x\n", ipl2spl_table
[IPL_SERIAL
], needpsl
);
146 ipl2spl_table
[IPL_SERIAL
] = needpsl
;
148 sc
->sc_isr
.isr_intr
= comintr
;
149 sc
->sc_isr
.isr_arg
= csc
;
150 sc
->sc_isr
.isr_ipl
= supa
->supio_ipl
;
151 add_isr(&sc
->sc_isr
);
153 if (!pmf_device_register1(self
, com_suspend
, com_resume
, com_cleanup
)) {
154 aprint_error_dev(self
, "could not establish shutdown hook");