lpt_ebus.c revision 1.19.6.1 1 /* $NetBSD: lpt_ebus.c,v 1.19.6.1 2006/04/22 11:37:59 simonb Exp $ */
2
3 /*
4 * Copyright (c) 1999, 2000 Matthew R. Green
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 /*
32 * NS Super I/O PC87332VLJ "lpt" to ebus attachment
33 */
34
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: lpt_ebus.c,v 1.19.6.1 2006/04/22 11:37:59 simonb Exp $");
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42 #include <sys/tty.h>
43
44 #include <machine/bus.h>
45
46 #include <dev/ebus/ebusreg.h>
47 #include <dev/ebus/ebusvar.h>
48
49 #include <dev/ic/lptvar.h>
50
51 int lpt_ebus_match(struct device *, struct cfdata *, void *);
52 void lpt_ebus_attach(struct device *, struct device *, void *);
53
54 CFATTACH_DECL(lpt_ebus, sizeof(struct lpt_softc),
55 lpt_ebus_match, lpt_ebus_attach, NULL, NULL);
56
57 #define ROM_LPT_NAME "ecpp"
58
59 int
60 lpt_ebus_match(struct device *parent, struct cfdata *match, void *aux)
61 {
62 struct ebus_attach_args *ea = aux;
63
64 if (strcmp(ea->ea_name, ROM_LPT_NAME) == 0)
65 return (1);
66
67 return (0);
68 }
69
70 void
71 lpt_ebus_attach(struct device *parent, struct device *self, void *aux)
72 {
73 struct lpt_softc *sc = (void *)self;
74 struct ebus_attach_args *ea = aux;
75 int i;
76
77 sc->sc_iot = ea->ea_bustag;
78 /*
79 * Addresses that should be supplied by the prom:
80 * - normal lpt registers
81 * - ns873xx configuration registers
82 * - DMA space
83 * The `lpt' driver does not use DMA accesses, so we can
84 * ignore that for now. We should enable the lpt port in
85 * the ns873xx registers here. XXX
86 *
87 * Use the prom address if there.
88 */
89 if (ea->ea_nvaddr)
90 sparc_promaddr_to_handle(sc->sc_iot, ea->ea_vaddr[0],
91 &sc->sc_ioh);
92 else if (bus_space_map(sc->sc_iot,
93 EBUS_ADDR_FROM_REG(&ea->ea_reg[0]),
94 ea->ea_reg[0].size,
95 0,
96 &sc->sc_ioh) != 0) {
97 printf(": can't map register space\n");
98 return;
99 }
100
101 for (i = 0; i < ea->ea_nintr; i++)
102 bus_intr_establish(ea->ea_bustag, ea->ea_intr[i],
103 IPL_SERIAL, lptintr, sc);
104 printf("\n");
105
106 lpt_attach_subr(sc);
107 }
108