com_mace.c revision 1.9 1 1.9 dyoung /* $NetBSD: com_mace.c,v 1.9 2011/07/01 18:53:47 dyoung Exp $ */
2 1.1 sekiya
3 1.1 sekiya /*
4 1.1 sekiya * Copyright (c) 2000 Soren S. Jorvang
5 1.1 sekiya * All rights reserved.
6 1.1 sekiya *
7 1.1 sekiya * Redistribution and use in source and binary forms, with or without
8 1.1 sekiya * modification, are permitted provided that the following conditions
9 1.1 sekiya * are met:
10 1.1 sekiya * 1. Redistributions of source code must retain the above copyright
11 1.1 sekiya * notice, this list of conditions and the following disclaimer.
12 1.1 sekiya * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 sekiya * notice, this list of conditions and the following disclaimer in the
14 1.1 sekiya * documentation and/or other materials provided with the distribution.
15 1.1 sekiya * 3. All advertising materials mentioning features or use of this software
16 1.1 sekiya * must display the following acknowledgement:
17 1.1 sekiya * This product includes software developed for the
18 1.1 sekiya * NetBSD Project. See http://www.NetBSD.org/ for
19 1.1 sekiya * information about NetBSD.
20 1.1 sekiya * 4. The name of the author may not be used to endorse or promote products
21 1.1 sekiya * derived from this software without specific prior written permission.
22 1.1 sekiya *
23 1.1 sekiya * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1 sekiya * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1 sekiya * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1 sekiya * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1 sekiya * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1 sekiya * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1 sekiya * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1 sekiya * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1 sekiya * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1 sekiya * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1 sekiya */
34 1.1 sekiya
35 1.1 sekiya #include <sys/cdefs.h>
36 1.9 dyoung __KERNEL_RCSID(0, "$NetBSD: com_mace.c,v 1.9 2011/07/01 18:53:47 dyoung Exp $");
37 1.1 sekiya
38 1.1 sekiya #include <sys/param.h>
39 1.1 sekiya #include <sys/systm.h>
40 1.1 sekiya #include <sys/ioctl.h>
41 1.1 sekiya #include <sys/select.h>
42 1.1 sekiya #include <sys/tty.h>
43 1.1 sekiya #include <sys/proc.h>
44 1.1 sekiya #include <sys/file.h>
45 1.1 sekiya #include <sys/uio.h>
46 1.1 sekiya #include <sys/kernel.h>
47 1.1 sekiya #include <sys/syslog.h>
48 1.1 sekiya #include <sys/types.h>
49 1.1 sekiya #include <sys/device.h>
50 1.1 sekiya
51 1.1 sekiya #include <machine/cpu.h>
52 1.1 sekiya #include <machine/locore.h>
53 1.1 sekiya #include <machine/autoconf.h>
54 1.9 dyoung #include <sys/bus.h>
55 1.2 sekiya #include <machine/machtype.h>
56 1.1 sekiya
57 1.1 sekiya #include <sgimips/mace/macevar.h>
58 1.1 sekiya
59 1.1 sekiya #include <dev/arcbios/arcbios.h>
60 1.1 sekiya #include <dev/arcbios/arcbiosvar.h>
61 1.1 sekiya
62 1.1 sekiya #include <dev/ic/comreg.h>
63 1.1 sekiya #include <dev/ic/comvar.h>
64 1.1 sekiya
65 1.1 sekiya struct com_mace_softc {
66 1.1 sekiya struct com_softc sc_com;
67 1.1 sekiya
68 1.1 sekiya /* XXX intr cookie */
69 1.1 sekiya };
70 1.1 sekiya
71 1.7 cube static int com_mace_match(device_t, cfdata_t , void *);
72 1.7 cube static void com_mace_attach(device_t, device_t, void *);
73 1.1 sekiya
74 1.7 cube CFATTACH_DECL_NEW(com_mace, sizeof(struct com_mace_softc),
75 1.1 sekiya com_mace_match, com_mace_attach, NULL, NULL);
76 1.1 sekiya
77 1.1 sekiya static int
78 1.7 cube com_mace_match(device_t parent, cfdata_t match, void *aux)
79 1.1 sekiya {
80 1.3 sekiya return 1;
81 1.1 sekiya }
82 1.1 sekiya
83 1.1 sekiya static void
84 1.7 cube com_mace_attach(device_t parent, device_t self, void *aux)
85 1.1 sekiya {
86 1.7 cube struct com_mace_softc *msc = device_private(self);
87 1.1 sekiya struct com_softc *sc = &msc->sc_com;
88 1.1 sekiya struct mace_attach_args *maa = aux;
89 1.6 gdamore bus_space_handle_t ioh;
90 1.1 sekiya
91 1.7 cube sc->sc_dev = self;
92 1.7 cube
93 1.1 sekiya /*
94 1.1 sekiya * XXX should check com_is_console() and
95 1.1 sekiya * XXX use bus_space_map().
96 1.1 sekiya */
97 1.6 gdamore ioh = maa->maa_sh + maa->maa_offset;
98 1.6 gdamore /* note that ioh on mac is *also* the iobase address */
99 1.6 gdamore COM_INIT_REGS(sc->sc_regs, maa->maa_st, ioh, ioh);
100 1.1 sekiya
101 1.1 sekiya sc->sc_frequency = COM_FREQ;
102 1.1 sekiya
103 1.1 sekiya delay(10000);
104 1.1 sekiya com_attach_subr(sc);
105 1.1 sekiya delay(10000);
106 1.1 sekiya
107 1.1 sekiya cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, comintr, sc);
108 1.1 sekiya
109 1.1 sekiya return;
110 1.1 sekiya }
111