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