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