1 /* $NetBSD: lpt_supio.c,v 1.12 2008/04/28 20:23:12 martin Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
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.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: lpt_supio.c,v 1.12 2008/04/28 20:23:12 martin Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/ioctl.h>
38 #include <sys/select.h>
44 #include <sys/kernel.h>
45 #include <sys/syslog.h>
46 #include <sys/types.h>
47 #include <sys/device.h>
49 #include <machine/intr.h>
50 #include <machine/bus.h>
52 #include <dev/ic/lptreg.h>
53 #include <dev/ic/lptvar.h>
55 #include <amiga/dev/supio.h>
57 struct lptsupio_softc
{
58 struct lpt_softc sc_lpt
;
60 void (*sc_intack
)(void *);
63 int lpt_supio_match(device_t
, cfdata_t
, void *);
64 void lpt_supio_attach(device_t
, device_t
, void *);
65 int lpt_supio_intr(void *p
);
67 CFATTACH_DECL_NEW(lpt_supio
, sizeof(struct lptsupio_softc
),
68 lpt_supio_match
, lpt_supio_attach
, NULL
, NULL
);
71 lpt_supio_match(device_t parent
, cfdata_t match
, void *aux
)
73 struct supio_attach_args
*supa
= aux
;
75 if (strcmp(supa
->supio_name
,"lpt"))
82 lpt_supio_intr(void *p
)
84 struct lptsupio_softc
*sc
= (void *)p
;
87 rc
= lptintr(&sc
->sc_lpt
);
94 lpt_supio_attach(device_t parent
, device_t self
, void *aux
)
96 struct lptsupio_softc
*sc
= device_private(self
);
97 struct lpt_softc
*lsc
= &sc
->sc_lpt
;
100 struct supio_attach_args
*supa
= aux
;
103 * We're living on a superio chip.
106 iobase
= supa
->supio_iobase
;
107 iot
= lsc
->sc_iot
= supa
->supio_iot
;
108 sc
->sc_intack
= (void *)supa
->supio_arg
;
110 aprint_normal(" port 0x%04x ipl %d\n", iobase
, supa
->supio_ipl
);
111 if (bus_space_map(iot
, iobase
, LPT_NPORTS
, 0, &lsc
->sc_ioh
)) {
112 aprint_error_dev(self
, "io mapping failed\n");
116 lpt_attach_subr(lsc
);
118 sc
->sc_isr
.isr_intr
= lpt_supio_intr
;
119 sc
->sc_isr
.isr_arg
= sc
;
120 sc
->sc_isr
.isr_ipl
= supa
->supio_ipl
;
121 add_isr(&sc
->sc_isr
);