lpt_supio.c revision 1.4 1 /* $NetBSD: lpt_supio.c,v 1.4 1999/02/16 22:46:57 is Exp $ */
2
3 /*-
4 * Copyright (c) 1999 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/param.h>
40 #include <sys/systm.h>
41 #include <sys/ioctl.h>
42 #include <sys/select.h>
43 #include <sys/tty.h>
44 #include <sys/proc.h>
45 #include <sys/user.h>
46 #include <sys/conf.h>
47 #include <sys/file.h>
48 #include <sys/uio.h>
49 #include <sys/kernel.h>
50 #include <sys/syslog.h>
51 #include <sys/types.h>
52 #include <sys/device.h>
53
54 #include <machine/intr.h>
55 #include <machine/bus.h>
56
57 #include <dev/ic/lptreg.h>
58 #include <dev/ic/lptvar.h>
59
60 #include <amiga/dev/supio.h>
61
62 struct lptsupio_softc {
63 struct lpt_softc sc_lpt;
64 struct isr sc_isr;
65 void (*sc_intack)__P((void *));
66 };
67
68 int lpt_supio_match __P((struct device *, struct cfdata *, void *));
69 void lpt_supio_attach __P((struct device *, struct device *, void *));
70 int lpt_supio_intr __P((void *p));
71
72 struct cfattach lpt_supio_ca = {
73 sizeof(struct lptsupio_softc), lpt_supio_match, lpt_supio_attach
74 };
75
76 int
77 lpt_supio_match(parent, match, aux)
78 struct device *parent;
79 struct cfdata *match;
80 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(p)
92 void *p;
93 {
94 struct lptsupio_softc *sc = (void *)p;
95 int rc;
96
97 rc = lptintr(&sc->sc_lpt);
98 if (sc->sc_intack)
99 (*sc->sc_intack)(p);
100 return (rc);
101 }
102
103 void
104 lpt_supio_attach(parent, self, aux)
105 struct device *parent, *self;
106 void *aux;
107 {
108 struct lptsupio_softc *sc = (void *)self;
109 struct lpt_softc *lsc = &sc->sc_lpt;
110 int iobase;
111 bus_space_tag_t iot;
112 struct supio_attach_args *supa = aux;
113
114 /*
115 * We're living on a superio chip.
116 */
117 iobase = supa->supio_iobase;
118 iot = lsc->sc_iot = supa->supio_iot;
119 sc->sc_intack = (void *)supa->supio_arg;
120
121 if (bus_space_map(iot, iobase, LPT_NPORTS, 0, &lsc->sc_ioh))
122 panic("lpt_supio_attach: io mapping failed");
123
124 printf(" port 0x%x ipl %d\n", iobase, supa->supio_ipl);
125 lpt_attach_subr(lsc);
126
127 sc->sc_isr.isr_intr = lpt_supio_intr;
128 sc->sc_isr.isr_arg = sc;
129 sc->sc_isr.isr_ipl = supa->supio_ipl;
130 add_isr(&sc->sc_isr);
131 }
132