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