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