stic.c revision 1.2 1 /* $NetBSD: stic.c,v 1.2 1999/01/16 06:36:42 nisimura Exp $ */
2
3 /*
4 * Copyright (c) 1997 Jonathan Stone
5 * 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 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Jonathan Stone for
18 * the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * Some portions derived from Mach: ga_hdw.c 2.5 93/05/17 15:16:52 rvb
36 */
37
38 /*
39 * Mach Operating System
40 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
41 * All Rights Reserved.
42 *
43 * Permission to use, copy, modify and distribute this software and its
44 * documentation is hereby granted, provided that both the copyright
45 * notice and this permission notice appear in all copies of the
46 * software, derivative works or modified versions, and any portions
47 * thereof, and that both notices appear in supporting documentation.
48 *
49 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
50 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
51 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
52 *
53 * Carnegie Mellon requests users of this software to return to
54 *
55 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
56 * School of Computer Science
57 * Carnegie Mellon University
58 * Pittsburgh PA 15213-3890
59 *
60 * any improvements or extensions that they make and grant Carnegie Mellon
61 * the rights to redistribute these changes.
62 */
63 /*
64 * HISTORY
65 * $Log: stic.c,v $
66 * Revision 1.2 1999/01/16 06:36:42 nisimura
67 * - Don't use void pointer for arithmetic.
68 *
69 * Revision 1.1 1997/11/11 04:47:57 jonathan
70 * chipset driver for DEC pixelstamp and STIC (stamp Interface chip).
71 *
72 * Revision 2.3 93/02/05 08:06:14 danner
73 * Mods to *compile* on Flamingo.
74 * [93/02/04 01:51:39 af]
75 *
76 * Revision 2.2 92/05/22 15:47:02 jfriedl
77 * Disable interrupts on exit.
78 * [92/05/20 22:53:19 af]
79 *
80 * Created, with some Ultrix code.
81 * [92/05/09 af]
82 *
83 */
84 /*
85 * File: ga_misc.c
86 * Author: Alessandro Forin, Carnegie Mellon University
87 * Date: 5/92
88 *
89 * Driver for the PMAG-CA 2D graphic board.
90 *
91 */
92
93 /************************************************************************
94 * *
95 * Copyright (c) 1989 by *
96 * Digital Equipment Corporation, Maynard, MA *
97 * All rights reserved. *
98 * *
99 * This software is furnished under a license and may be used and *
100 * copied only in accordance with the terms of such license and *
101 * with the inclusion of the above copyright notice. This *
102 * software or any other copies thereof may not be provided or *
103 * otherwise made available to any other person. No title to and *
104 * ownership of the software is hereby transferred. *
105 * *
106 * The information in this software is subject to change without *
107 * notice and should not be construed as a commitment by Digital *
108 * Equipment Corporation. *
109 * *
110 * Digital assumes no responsibility for the use or reliability *
111 * of its software on equipment which is not supplied by Digital. *
112 * *
113 ************************************************************************/
114
115 #include <sys/cdefs.h>
116 __KERNEL_RCSID(0, "$NetBSD: stic.c,v 1.2 1999/01/16 06:36:42 nisimura Exp $");
117
118
119 /*
120 * Support for the DEC pixelstamp and stamp asic (STIC)
121 * chips used on 2-D (PMAG-C) and 3-D (PMAG-D, PMAG-E, PMAG-F)
122 * DEC turbochannel option cards.
123 */
124
125 #include <sys/param.h>
126 #include <sys/systm.h>
127
128 #include <dev/tc/tcvar.h>
129 #include <dev/tc/sticvar.h>
130
131 #include <machine/cpu.h>
132 #include <machine/bus.h>
133
134 int stic_init __P((struct stic_softc *stic_sc));
135
136 int
137 stic_init(stic_sc)
138 struct stic_softc *stic_sc;
139 {
140 int modtype, xconfig, yconfig, config;
141 volatile struct stic_regs *stic = STICADDR(stic_sc->stic_addr);
142 caddr_t stamp_addr = stic_sc->stamp_addr;
143
144 /*
145 * Initialize STIC interface chip registers.
146 * magic sequence from logic analyser.
147 */
148 stic->sticsr = 0x00000030; /* Get the STIC's attention. */
149 tc_wmb();
150 DELAY(4000); /* wait 4ms for STIC to respond. */
151 stic->sticsr = 0x00000000; /* Hit the STIC's csr again... */
152 stic->buscsr = 0xffffffff; /* and bash its bus-acess csr. */
153 tc_wmb(); /* Blam! */
154
155 DELAY(20000); /* wait until the stic recovers... */
156
157 #ifdef notyet
158 /* init vdac */
159 bt459_init(stic_sc->vdac_addr);
160 #endif
161
162 /*
163 * the following code is taken from Mach 3.0 MK85 source.
164 */
165
166 /*
167 * Initialize Stamp config register for model 0.
168 */
169 modtype = stic->modcl;
170 xconfig = (modtype & 0x800) >> 11;
171 yconfig = (modtype & 0x600) >> 9;
172 config = (yconfig << 1) | xconfig;
173
174 /* stamp0 config */
175 *(int32_t *)(stamp_addr+0x000b0) = config;
176 *(int32_t *)(stamp_addr+0x000b4) = 0x0;
177
178 if (yconfig > 0) {
179 /*
180 * pixelstamp v1 configuration
181 */
182 *(int *)(stamp_addr+0x100b0) = 0x8|config;
183 *(int *)(stamp_addr+0x100b4) = 0x0;
184 if (yconfig > 1) {
185 /* pixelstamp v2 & v3 config */
186 }
187 }
188
189 /*
190 * Initialize STIC video registers.
191 * (if we knew what we were doing, we might be able to frob this
192 * to work at different montior frequencies.)
193 */
194 stic->vblank = (1024 << 16) | 1063;
195 stic->vsync = (1027 << 16) | 1030;
196 stic->hblank = (255 << 16) | 340;
197 stic->hsync2 = 245;
198 stic->hsync = (261 << 16) | 293;
199
200 tc_wmb(); /* wbflush() */
201
202 stic->ipdvint = STIC_INT_CLR;
203 stic->sticsr = 0x00000008;
204 tc_wmb(); /* wbflush() */
205 return (0);
206 }
207