com_opb.c revision 1.4.2.2 1 1.4.2.2 gehenna /* $NetBSD: com_opb.c,v 1.4.2.2 2002/08/31 13:45:43 gehenna Exp $ */
2 1.4.2.2 gehenna
3 1.4.2.2 gehenna /*
4 1.4.2.2 gehenna * Copyright 2001 Wasabi Systems, Inc.
5 1.4.2.2 gehenna * All rights reserved.
6 1.4.2.2 gehenna *
7 1.4.2.2 gehenna * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 1.4.2.2 gehenna *
9 1.4.2.2 gehenna * Redistribution and use in source and binary forms, with or without
10 1.4.2.2 gehenna * modification, are permitted provided that the following conditions
11 1.4.2.2 gehenna * are met:
12 1.4.2.2 gehenna * 1. Redistributions of source code must retain the above copyright
13 1.4.2.2 gehenna * notice, this list of conditions and the following disclaimer.
14 1.4.2.2 gehenna * 2. Redistributions in binary form must reproduce the above copyright
15 1.4.2.2 gehenna * notice, this list of conditions and the following disclaimer in the
16 1.4.2.2 gehenna * documentation and/or other materials provided with the distribution.
17 1.4.2.2 gehenna * 3. All advertising materials mentioning features or use of this software
18 1.4.2.2 gehenna * must display the following acknowledgement:
19 1.4.2.2 gehenna * This product includes software developed for the NetBSD Project by
20 1.4.2.2 gehenna * Wasabi Systems, Inc.
21 1.4.2.2 gehenna * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.4.2.2 gehenna * or promote products derived from this software without specific prior
23 1.4.2.2 gehenna * written permission.
24 1.4.2.2 gehenna *
25 1.4.2.2 gehenna * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.4.2.2 gehenna * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.4.2.2 gehenna * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.4.2.2 gehenna * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.4.2.2 gehenna * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.4.2.2 gehenna * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.4.2.2 gehenna * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.4.2.2 gehenna * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.4.2.2 gehenna * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.4.2.2 gehenna * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.4.2.2 gehenna * POSSIBILITY OF SUCH DAMAGE.
36 1.4.2.2 gehenna */
37 1.4.2.2 gehenna
38 1.4.2.2 gehenna #include <sys/param.h>
39 1.4.2.2 gehenna #include <sys/device.h>
40 1.4.2.2 gehenna #include <sys/tty.h>
41 1.4.2.2 gehenna #include <sys/systm.h>
42 1.4.2.2 gehenna #include <sys/properties.h>
43 1.4.2.2 gehenna
44 1.4.2.2 gehenna #include <lib/libkern/libkern.h>
45 1.4.2.2 gehenna
46 1.4.2.2 gehenna #include <machine/cpu.h>
47 1.4.2.2 gehenna
48 1.4.2.2 gehenna #include <powerpc/ibm4xx/dev/opbvar.h>
49 1.4.2.2 gehenna
50 1.4.2.2 gehenna #include <dev/ic/comreg.h>
51 1.4.2.2 gehenna #include <dev/ic/comvar.h>
52 1.4.2.2 gehenna
53 1.4.2.2 gehenna struct com_opb_softc {
54 1.4.2.2 gehenna struct com_softc sc_com;
55 1.4.2.2 gehenna void *sc_ih;
56 1.4.2.2 gehenna };
57 1.4.2.2 gehenna
58 1.4.2.2 gehenna static int com_opb_probe(struct device *, struct cfdata *, void *);
59 1.4.2.2 gehenna static void com_opb_attach(struct device *, struct device *, void *);
60 1.4.2.2 gehenna
61 1.4.2.2 gehenna struct cfattach com_opb_ca = {
62 1.4.2.2 gehenna sizeof(struct com_opb_softc), com_opb_probe, com_opb_attach
63 1.4.2.2 gehenna };
64 1.4.2.2 gehenna
65 1.4.2.2 gehenna int
66 1.4.2.2 gehenna com_opb_probe(struct device *parent, struct cfdata *cf, void *aux)
67 1.4.2.2 gehenna {
68 1.4.2.2 gehenna struct opb_attach_args *oaa = aux;
69 1.4.2.2 gehenna
70 1.4.2.2 gehenna /* match only com devices */
71 1.4.2.2 gehenna if (strcmp(oaa->opb_name, cf->cf_driver->cd_name) != 0)
72 1.4.2.2 gehenna return 0;
73 1.4.2.2 gehenna
74 1.4.2.2 gehenna return (1);
75 1.4.2.2 gehenna }
76 1.4.2.2 gehenna
77 1.4.2.2 gehenna void
78 1.4.2.2 gehenna com_opb_attach(struct device *parent, struct device *self, void *aux)
79 1.4.2.2 gehenna {
80 1.4.2.2 gehenna struct com_opb_softc *msc = (void *)self;
81 1.4.2.2 gehenna struct com_softc *sc = &msc->sc_com;
82 1.4.2.2 gehenna struct opb_attach_args *oaa = aux;
83 1.4.2.2 gehenna
84 1.4.2.2 gehenna sc->sc_iot = oaa->opb_bt;
85 1.4.2.2 gehenna sc->sc_iobase = oaa->opb_addr;
86 1.4.2.2 gehenna
87 1.4.2.2 gehenna bus_space_map(sc->sc_iot, oaa->opb_addr, COM_NPORTS, 0,
88 1.4.2.2 gehenna &sc->sc_ioh);
89 1.4.2.2 gehenna
90 1.4.2.2 gehenna if (board_info_get("com-opb-frequency", &sc->sc_frequency,
91 1.4.2.2 gehenna sizeof(sc->sc_frequency)) == -1)
92 1.4.2.2 gehenna panic("com_opb_attach: no com-opb-frequency property");
93 1.4.2.2 gehenna
94 1.4.2.2 gehenna /* XXX console check */
95 1.4.2.2 gehenna
96 1.4.2.2 gehenna com_attach_subr(sc);
97 1.4.2.2 gehenna
98 1.4.2.2 gehenna intr_establish(oaa->opb_irq, IST_LEVEL, IPL_SERIAL, comintr, sc);
99 1.4.2.2 gehenna }
100