lpt_mace.c revision 1.4 1 /* $NetBSD: lpt_mace.c,v 1.4 2004/07/12 13:45:40 tsutsui Exp $ */
2
3 /*
4 * Copyright (c) 2003 Christopher SEKIYA
5 * Copyright (c) 2000 Soren S. Jorvang
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed for the
19 * NetBSD Project. See http://www.NetBSD.org/ for
20 * information about NetBSD.
21 * 4. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: lpt_mace.c,v 1.4 2004/07/12 13:45:40 tsutsui Exp $");
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/file.h>
47 #include <sys/uio.h>
48 #include <sys/kernel.h>
49 #include <sys/syslog.h>
50 #include <sys/types.h>
51 #include <sys/device.h>
52
53 #include <machine/cpu.h>
54 #include <machine/locore.h>
55 #include <machine/autoconf.h>
56 #include <machine/bus.h>
57 #include <machine/machtype.h>
58
59 #include <sgimips/mace/macevar.h>
60
61 #include <dev/ic/lptreg.h>
62 #include <dev/ic/lptvar.h>
63
64 struct lpt_mace_softc {
65 struct lpt_softc sc_lpt;
66
67 /* XXX intr cookie */
68 };
69
70 static int lpt_mace_match(struct device *, struct cfdata *, void *);
71 static void lpt_mace_attach(struct device *, struct device *, void *);
72
73 CFATTACH_DECL(lpt_mace, sizeof(struct lpt_mace_softc),
74 lpt_mace_match, lpt_mace_attach, NULL, NULL);
75
76 static int
77 lpt_mace_match(parent, match, aux)
78 struct device *parent;
79 struct cfdata *match;
80 void *aux;
81 {
82
83 return 1;
84 }
85
86 static void
87 lpt_mace_attach(parent, self, aux)
88 struct device *parent;
89 struct device *self;
90 void *aux;
91 {
92 struct lpt_mace_softc *msc = (void *)self;
93 struct lpt_softc *sc = &msc->sc_lpt;
94 struct mace_attach_args *maa = aux;
95
96 sc->sc_iot = maa->maa_st;
97
98 /* XXX should use bus_space_map() */
99 if (bus_space_subregion(sc->sc_iot, maa->maa_sh,
100 maa->maa_offset, LPT_NPORTS, &sc->sc_ioh) != 0) {
101 printf(": can't map i/o space\n");
102 return;
103 }
104
105 printf("\n");
106
107 lpt_attach_subr(sc);
108
109 cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, lptintr, sc);
110
111 return;
112 }
113