zs_pcc.c revision 1.9 1 1.9 tsutsui /* $NetBSD: zs_pcc.c,v 1.9 2008/03/29 19:15:34 tsutsui Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1997, 1999
5 1.1 drochner * Matthias Drochner. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Redistribution and use in source and binary forms, with or without
8 1.1 drochner * modification, are permitted provided that the following conditions
9 1.1 drochner * are met:
10 1.1 drochner * 1. Redistributions of source code must retain the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer.
12 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 drochner * notice, this list of conditions and the following disclaimer in the
14 1.1 drochner * documentation and/or other materials provided with the distribution.
15 1.1 drochner *
16 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 drochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.1 drochner *
27 1.1 drochner */
28 1.4 lukem
29 1.4 lukem #include <sys/cdefs.h>
30 1.9 tsutsui __KERNEL_RCSID(0, "$NetBSD: zs_pcc.c,v 1.9 2008/03/29 19:15:34 tsutsui Exp $");
31 1.1 drochner
32 1.1 drochner #include <sys/param.h>
33 1.1 drochner #include <sys/systm.h>
34 1.1 drochner #include <sys/proc.h>
35 1.1 drochner #include <sys/device.h>
36 1.1 drochner #include <sys/conf.h>
37 1.1 drochner #include <sys/file.h>
38 1.1 drochner #include <sys/ioctl.h>
39 1.1 drochner #include <sys/tty.h>
40 1.1 drochner #include <sys/time.h>
41 1.1 drochner #include <sys/kernel.h>
42 1.1 drochner #include <sys/syslog.h>
43 1.1 drochner
44 1.1 drochner #include <dev/cons.h>
45 1.1 drochner #include <dev/ic/z8530reg.h>
46 1.1 drochner #include <machine/z8530var.h>
47 1.1 drochner
48 1.1 drochner #include <machine/cpu.h>
49 1.1 drochner #include <machine/autoconf.h>
50 1.1 drochner
51 1.1 drochner #include <cesfic/cesfic/isr.h>
52 1.1 drochner
53 1.1 drochner #include <cesfic/dev/zsvar.h>
54 1.1 drochner
55 1.9 tsutsui extern void sic_enable_int(int, int, int, int, int);
56 1.1 drochner
57 1.9 tsutsui static int zsc_pcc_match(device_t, cfdata_t, void *);
58 1.9 tsutsui static void zsc_pcc_attach(device_t, device_t, void *);
59 1.1 drochner
60 1.1 drochner static char *zsbase;
61 1.1 drochner
62 1.9 tsutsui CFATTACH_DECL_NEW(zsc_pcc, sizeof(struct zsc_softc),
63 1.3 thorpej zsc_pcc_match, zsc_pcc_attach, NULL, NULL);
64 1.1 drochner
65 1.1 drochner static int
66 1.9 tsutsui zsc_pcc_match(device_t parent, cfdata_t cf, void *aux)
67 1.1 drochner {
68 1.9 tsutsui
69 1.1 drochner return (1);
70 1.1 drochner }
71 1.1 drochner
72 1.1 drochner static void
73 1.9 tsutsui zsc_pcc_attach(device_t parent, device_t self, void *aux)
74 1.1 drochner {
75 1.9 tsutsui struct zsc_softc *zsc = device_private(self);
76 1.1 drochner static int didintr;
77 1.1 drochner
78 1.9 tsutsui zsc->zsc_dev = self;
79 1.9 tsutsui
80 1.1 drochner if (!zsbase)
81 1.5 cl mainbus_map(0x58000000, 0x10000, 0, (void *)&zsbase);
82 1.1 drochner
83 1.1 drochner /* Do common parts of SCC configuration. */
84 1.1 drochner zs_config(zsc, zsbase);
85 1.1 drochner
86 1.1 drochner /*
87 1.1 drochner * Now safe to install interrupt handlers. Note the arguments
88 1.1 drochner * to the interrupt handlers aren't used. Note, we only do this
89 1.1 drochner * once since both SCCs interrupt at the same level and vector.
90 1.1 drochner */
91 1.1 drochner if (didintr == 0) {
92 1.1 drochner didintr = 1;
93 1.1 drochner (void) isrlink(zshard, zsc, 4, ISRPRI_TTY);
94 1.1 drochner sic_enable_int(19, 0, 4, 4, 0);
95 1.1 drochner }
96 1.8 ad zsc->zsc_softintr_cookie = softint_establish(SOFTINT_SERIAL,
97 1.7 tsutsui (void (*)(void *))zsc_intr_soft, zsc);
98 1.1 drochner
99 1.1 drochner zs_write_reg(zsc->zsc_cs[0], 2, 0x18 + ZSHARD_PRI);
100 1.1 drochner zs_write_reg(zsc->zsc_cs[0], 9, ZSWR9_MASTER_IE);
101 1.1 drochner }
102 1.1 drochner
103 1.1 drochner void
104 1.9 tsutsui zs_cnattach(void *base)
105 1.1 drochner {
106 1.9 tsutsui
107 1.1 drochner zsbase = base;
108 1.1 drochner
109 1.1 drochner zs_cninit(zsbase);
110 1.1 drochner }
111