lpt_supio.c revision 1.6.20.1 1 /* $NetBSD: lpt_supio.c,v 1.6.20.1 2002/02/28 04:06:52 nathanw Exp $ */
2
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: lpt_supio.c,v 1.6.20.1 2002/02/28 04:06:52 nathanw Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/ioctl.h>
45 #include <sys/select.h>
46 #include <sys/tty.h>
47 #include <sys/proc.h>
48 #include <sys/user.h>
49 #include <sys/conf.h>
50 #include <sys/file.h>
51 #include <sys/uio.h>
52 #include <sys/kernel.h>
53 #include <sys/syslog.h>
54 #include <sys/types.h>
55 #include <sys/device.h>
56
57 #include <machine/intr.h>
58 #include <machine/bus.h>
59
60 #include <dev/ic/lptreg.h>
61 #include <dev/ic/lptvar.h>
62
63 #include <amiga/dev/supio.h>
64
65 struct lptsupio_softc {
66 struct lpt_softc sc_lpt;
67 struct isr sc_isr;
68 void (*sc_intack)(void *);
69 };
70
71 int lpt_supio_match(struct device *, struct cfdata *, void *);
72 void lpt_supio_attach(struct device *, struct device *, void *);
73 int lpt_supio_intr(void *p);
74
75 struct cfattach lpt_supio_ca = {
76 sizeof(struct lptsupio_softc), lpt_supio_match, lpt_supio_attach
77 };
78
79 int
80 lpt_supio_match(struct device *parent, struct cfdata *match, void *aux)
81 {
82 struct supio_attach_args *supa = aux;
83
84 if (strcmp(supa->supio_name,"lpt"))
85 return 0;
86
87 return (1);
88 }
89
90 int
91 lpt_supio_intr(void *p)
92 {
93 struct lptsupio_softc *sc = (void *)p;
94 int rc;
95
96 rc = lptintr(&sc->sc_lpt);
97 if (sc->sc_intack)
98 (*sc->sc_intack)(p);
99 return (rc);
100 }
101
102 void
103 lpt_supio_attach(struct device *parent, struct device *self, void *aux)
104 {
105 struct lptsupio_softc *sc = (void *)self;
106 struct lpt_softc *lsc = &sc->sc_lpt;
107 int iobase;
108 bus_space_tag_t iot;
109 struct supio_attach_args *supa = aux;
110
111 /*
112 * We're living on a superio chip.
113 */
114 iobase = supa->supio_iobase;
115 iot = lsc->sc_iot = supa->supio_iot;
116 sc->sc_intack = (void *)supa->supio_arg;
117
118 if (bus_space_map(iot, iobase, LPT_NPORTS, 0, &lsc->sc_ioh))
119 panic("lpt_supio_attach: io mapping failed");
120
121 printf(" port 0x%04x ipl %d\n", iobase, supa->supio_ipl);
122 lpt_attach_subr(lsc);
123
124 sc->sc_isr.isr_intr = lpt_supio_intr;
125 sc->sc_isr.isr_arg = sc;
126 sc->sc_isr.isr_ipl = supa->supio_ipl;
127 add_isr(&sc->sc_isr);
128 }
129