xref: /netbsd-src/sys/dev/tc/stic.c (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: stic.c,v 1.1 1997/11/11 04:47:57 jonathan 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@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.1  1997/11/11 04:47:57  jonathan
67  * chipset driver for DEC pixelstamp  and STIC (stamp Interface chip).
68  *
69  * Revision 2.3  93/02/05  08:06:14  danner
70  * 	Mods to *compile* on Flamingo.
71  * 	[93/02/04  01:51:39  af]
72  *
73  * Revision 2.2  92/05/22  15:47:02  jfriedl
74  * 	Disable interrupts on exit.
75  * 	[92/05/20  22:53:19  af]
76  *
77  * 	Created, with some Ultrix code.
78  * 	[92/05/09            af]
79  *
80  */
81 /*
82  *	File: ga_misc.c
83  * 	Author: Alessandro Forin, Carnegie Mellon University
84  *	Date:	5/92
85  *
86  *	Driver for the PMAG-CA 2D graphic board.
87  *
88  */
89 
90 /************************************************************************
91  *									*
92  *			Copyright (c) 1989 by				*
93  *		Digital Equipment Corporation, Maynard, MA		*
94  *			All rights reserved.				*
95  *									*
96  *   This software is furnished under a license and may be used and	*
97  *   copied  only  in accordance with the terms of such license and	*
98  *   with the  inclusion  of  the  above  copyright  notice.   This	*
99  *   software  or  any  other copies thereof may not be provided or	*
100  *   otherwise made available to any other person.  No title to and	*
101  *   ownership of the software is hereby transferred.			*
102  *									*
103  *   The information in this software is subject to change  without	*
104  *   notice  and should not be construed as a commitment by Digital	*
105  *   Equipment Corporation.						*
106  *									*
107  *   Digital assumes no responsibility for the use  or  reliability	*
108  *   of its software on equipment which is not supplied by Digital.	*
109  *									*
110  ************************************************************************/
111 
112 #include <sys/cdefs.h>
113 __KERNEL_RCSID(0, "$NetBSD: stic.c,v 1.1 1997/11/11 04:47:57 jonathan Exp $");
114 
115 
116 /*
117  * Support for the DEC pixelstamp and stamp asic (STIC)
118  * chips used on 2-D (PMAG-C) and 3-D (PMAG-D, PMAG-E, PMAG-F)
119  * DEC turbochannel option cards.
120  */
121 
122 #include <sys/param.h>
123 #include <sys/systm.h>
124 
125 #include <dev/tc/tcvar.h>
126 #include <dev/tc/sticvar.h>
127 
128 #include <machine/cpu.h>
129 #include <machine/bus.h>
130 
131 int	stic_init __P((struct stic_softc *stic_sc));
132 
133 int
134 stic_init(stic_sc)
135 	struct stic_softc *stic_sc;
136 {
137 	int modtype, xconfig, yconfig, config;
138 	volatile struct stic_regs *stic = STICADDR(stic_sc->stic_addr);
139 	void *stamp_addr = (void*)(stic_sc->stamp_addr);
140 
141 	/*
142 	 *  Initialize STIC interface chip registers.
143 	 *  magic sequence from logic analyser.
144 	 */
145 	stic->sticsr = 0x00000030;	/* Get the STIC's attention. */
146 	tc_wmb();
147 	DELAY(4000);			/* wait 4ms for STIC to respond. */
148 	stic->sticsr = 0x00000000;	/* Hit the STIC's csr again... */
149 	stic->buscsr = 0xffffffff;	/* and bash its bus-acess csr. */
150 	tc_wmb();			/* Blam! */
151 
152 	DELAY(20000);			/* wait until the stic recovers... */
153 
154 #ifdef notyet
155 	/* init vdac */
156 	bt459_init(stic_sc->vdac_addr);
157 #endif
158 
159 	/*
160 	 * the following code is taken from  Mach 3.0 MK85 source.
161 	 */
162 
163 	/*
164 	 *  Initialize Stamp config register for model 0.
165 	 */
166 	modtype = stic->modcl;
167 	xconfig = (modtype & 0x800) >> 11;
168 	yconfig = (modtype & 0x600) >> 9;
169 	config = (yconfig << 1) | xconfig;
170 
171 	/* stamp0 config */
172 	*(int32_t *)(stamp_addr+0x000b0) = config;
173 	*(int32_t *)(stamp_addr+0x000b4) = 0x0;
174 
175 	if (yconfig > 0) {
176 		/*
177 		 * pixelstamp v1 configuration
178 		 */
179 		*(int *)(stamp_addr+0x100b0) = 0x8|config;
180 		*(int *)(stamp_addr+0x100b4) = 0x0;
181 		if (yconfig > 1) {
182 			/* pixelstamp v2 & v3 config */
183 		}
184 	}
185 
186     /*
187      * Initialize STIC video registers.
188      * (if we knew what we were doing, we might be able to frob this
189      * to work at different montior frequencies.)
190      */
191     stic->vblank = (1024 << 16) | 1063;
192     stic->vsync = (1027 << 16) | 1030;
193     stic->hblank = (255 << 16) | 340;
194     stic->hsync2 = 245;
195     stic->hsync = (261 << 16) | 293;
196 
197     tc_wmb();	/* wbflush() */
198 
199     stic->ipdvint = STIC_INT_CLR;
200     stic->sticsr = 0x00000008;
201     tc_wmb();	/* wbflush() */
202     return (0);
203 }
204