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