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