Home | History | Annotate | Line # | Download | only in tc
px.c revision 1.1
      1  1.1  jonathan /*	$NetBSD: px.c,v 1.1 1997/11/08 07:27:49 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 #include <sys/cdefs.h>
     35  1.1  jonathan __KERNEL_RCSID(0, "$NetBSD: px.c,v 1.1 1997/11/08 07:27:49 jonathan Exp $");
     36  1.1  jonathan 
     37  1.1  jonathan /*
     38  1.1  jonathan  * px.c: placebo driver for the DEC TURBOchannel 2-d and 3-d
     39  1.1  jonathan  * accelerated framebuffers with PixelStamp blitter asics and i860
     40  1.1  jonathan  * accelerators.
     41  1.1  jonathan  */
     42  1.1  jonathan 
     43  1.1  jonathan #include <sys/param.h>
     44  1.1  jonathan #include <sys/systm.h>
     45  1.1  jonathan #include <sys/device.h>
     46  1.1  jonathan 
     47  1.1  jonathan #include <dev/tc/tcvar.h>
     48  1.1  jonathan #include <dev/tc/sticvar.h>
     49  1.1  jonathan 
     50  1.1  jonathan #include <machine/autoconf.h>
     51  1.1  jonathan #include <machine/cpu.h>
     52  1.1  jonathan #include <machine/bus.h>
     53  1.1  jonathan 
     54  1.1  jonathan /*
     55  1.1  jonathan  * hardware offsets  within PX board's TC slot.
     56  1.1  jonathan  */
     57  1.1  jonathan #define PX_STIC_POLL_OFFSET	0x000000
     58  1.1  jonathan #define PX_STAMP_OFFSET		0x0c0000	/* pixelstamp space on STIC */
     59  1.1  jonathan #define PX_STIC_OFFSET		0x180000	/* STIC registers */
     60  1.1  jonathan #define PX_VDAC_OFFSET		0x200000
     61  1.1  jonathan #define PX_ROM_OFFSET		0x300000
     62  1.1  jonathan 
     63  1.1  jonathan 
     64  1.1  jonathan struct px_softc {
     65  1.1  jonathan 	struct 	device sc_dv;		/* device information */
     66  1.1  jonathan 	tc_addr_t px_slotbase;		/* kva of slot base. */
     67  1.1  jonathan   	struct stic_softc px_stic;	/* address of pixelstamp and stic. */
     68  1.1  jonathan };
     69  1.1  jonathan 
     70  1.1  jonathan /*
     71  1.1  jonathan  * Local prototypes.
     72  1.1  jonathan  */
     73  1.1  jonathan int	px_match __P((struct device *, struct cfdata *, void *));
     74  1.1  jonathan void	px_attach __P((struct device *, struct device *, void *));
     75  1.1  jonathan int	px_intr __P((void *xxx_sc));
     76  1.1  jonathan void	px_vblank_ctl __P((struct px_softc *sc, int onoff));
     77  1.1  jonathan void	px_blank __P((struct  px_softc *sc));
     78  1.1  jonathan void	px_unblank __P((struct  px_softc *sc));
     79  1.1  jonathan 
     80  1.1  jonathan struct cfattach px_ca = {
     81  1.1  jonathan 	sizeof (struct px_softc), px_match, px_attach,
     82  1.1  jonathan };
     83  1.1  jonathan 
     84  1.1  jonathan struct cfdriver px_cd = {
     85  1.1  jonathan 	NULL, "px", DV_DULL
     86  1.1  jonathan };
     87  1.1  jonathan 
     88  1.1  jonathan /*
     89  1.1  jonathan  * Match a PMAG-C pixelstamp board.
     90  1.1  jonathan  */
     91  1.1  jonathan int
     92  1.1  jonathan px_match(parent, match, aux)
     93  1.1  jonathan 	struct device *parent;
     94  1.1  jonathan 	struct cfdata *match;
     95  1.1  jonathan 	void *aux;
     96  1.1  jonathan {
     97  1.1  jonathan 	struct tc_attach_args *ta = aux;
     98  1.1  jonathan 	void *pxaddr;
     99  1.1  jonathan 
    100  1.1  jonathan 	if (strncmp("PMAG-CA ", ta->ta_modname, TC_ROM_LLEN))
    101  1.1  jonathan 		return (0);
    102  1.1  jonathan 
    103  1.1  jonathan 	pxaddr = (void*)ta->ta_addr;
    104  1.1  jonathan #if 0
    105  1.1  jonathan 	if (tc_badaddr(pxaddr + 0))
    106  1.1  jonathan 		return (0);
    107  1.1  jonathan #endif
    108  1.1  jonathan 
    109  1.1  jonathan 	return (1);
    110  1.1  jonathan }
    111  1.1  jonathan 
    112  1.1  jonathan 
    113  1.1  jonathan /*
    114  1.1  jonathan  * Attach a PMAG-C pixelstamp graphics board.
    115  1.1  jonathan  */
    116  1.1  jonathan void
    117  1.1  jonathan px_attach(parent, self, aux)
    118  1.1  jonathan 	struct device *parent, *self;
    119  1.1  jonathan 	void *aux;
    120  1.1  jonathan {
    121  1.1  jonathan 	struct px_softc *sc  = (struct px_softc*)self;
    122  1.1  jonathan 	struct tc_attach_args *ta = aux;
    123  1.1  jonathan 
    124  1.1  jonathan 	sc->px_slotbase = TC_PHYS_TO_UNCACHED(ta->ta_addr);
    125  1.1  jonathan 	sc->px_stic.stic_pktbuf=
    126  1.1  jonathan 	     (void*)(sc->px_slotbase + PX_STIC_POLL_OFFSET);
    127  1.1  jonathan 	sc->px_stic.stic_addr = (void*)(sc->px_slotbase + PX_STIC_OFFSET);
    128  1.1  jonathan 	sc->px_stic.stamp_addr = (void*)(sc->px_slotbase + PX_STAMP_OFFSET);
    129  1.1  jonathan 	sc->px_stic.vdac_addr = (void*)(sc->px_slotbase + PX_VDAC_OFFSET);
    130  1.1  jonathan 
    131  1.1  jonathan 
    132  1.1  jonathan 	/* Turn off vertical-blank interrupts, unless we're debugging. */
    133  1.1  jonathan #if !defined(DIAGNOSTIC) && !defined(DEBUG)
    134  1.1  jonathan 	px_vblank_ctl(sc, 0);
    135  1.1  jonathan #endif
    136  1.1  jonathan 
    137  1.1  jonathan 	tc_intr_establish(parent, ta->ta_cookie, TC_IPL_NONE, px_intr, sc);
    138  1.1  jonathan 
    139  1.1  jonathan 	/* driver does nothing yet, except silently dismisses interrupts. */
    140  1.1  jonathan 	printf(": no raster-console or X11 support.\n");
    141  1.1  jonathan 
    142  1.1  jonathan }
    143  1.1  jonathan 
    144  1.1  jonathan /*
    145  1.1  jonathan  * pixelstamp board interrupt hanlder.
    146  1.1  jonathan  * XXX examine pixelstamp blitter-chip packet area, and
    147  1.1  jonathan  * send new packets.
    148  1.1  jonathan  *
    149  1.1  jonathan  * For now, we ignore interrupts from the blitter chip or i860,
    150  1.1  jonathan  * and just handle vertical-retrace interrupt.
    151  1.1  jonathan  */
    152  1.1  jonathan int
    153  1.1  jonathan px_intr(xxx_sc)
    154  1.1  jonathan     void *xxx_sc;
    155  1.1  jonathan {
    156  1.1  jonathan 	struct px_softc *sc = (struct px_softc *)xxx_sc;
    157  1.1  jonathan 
    158  1.1  jonathan 	volatile struct stic_regs * stic =
    159  1.1  jonathan 	   STICADDR(sc->px_stic.stic_addr);
    160  1.1  jonathan 
    161  1.1  jonathan 	register int intr_status = stic->ipdvint;
    162  1.1  jonathan 
    163  1.1  jonathan 	/* Clear packet-done intr so we don't interrupt again. */
    164  1.1  jonathan 	/* Packet interrupt? */
    165  1.1  jonathan 	if (intr_status & STIC_INT_P) {
    166  1.1  jonathan 
    167  1.1  jonathan 		/*
    168  1.1  jonathan 		 * Clear *only* packet done interrupt
    169  1.1  jonathan 		 */
    170  1.1  jonathan 		stic->ipdvint = (stic->ipdvint | STIC_INT_P_WE) &
    171  1.1  jonathan 		     ~(STIC_INT_E_WE | STIC_INT_V_WE | STIC_INT_P);
    172  1.1  jonathan 		tc_wmb();
    173  1.1  jonathan 
    174  1.1  jonathan 	}
    175  1.1  jonathan 	/* Vertical-retrace interrupt ? */
    176  1.1  jonathan 	else if (intr_status & STIC_INT_V) {
    177  1.1  jonathan 
    178  1.1  jonathan 		stic->ipdvint = (stic->ipdvint | STIC_INT_V_WE) &
    179  1.1  jonathan 			~(STIC_INT_E_WE | STIC_INT_P_WE | STIC_INT_V);
    180  1.1  jonathan 		tc_wmb();
    181  1.1  jonathan 
    182  1.1  jonathan #ifdef notyet
    183  1.1  jonathan 		/* Poll for LK-201 LED status, update LEDs */
    184  1.1  jonathan 		lk201_led(unit);
    185  1.1  jonathan #endif
    186  1.1  jonathan 
    187  1.1  jonathan 	/* Error, stray interrupt ?*/
    188  1.1  jonathan 	} else if (intr_status & STIC_INT_E) {
    189  1.1  jonathan #if defined(DIAGNOSTIC) || 1
    190  1.1  jonathan 		 /* XXX not for me */
    191  1.1  jonathan 		printf("px_intr: stray intr INT_E, %x %x %x %x %x",
    192  1.1  jonathan 		       intr_status,
    193  1.1  jonathan 		       stic->sticsr, stic->buscsr,
    194  1.1  jonathan 		       stic->busadr, stic->busdat);
    195  1.1  jonathan 		DELAY(1000000);
    196  1.1  jonathan 		/*panic("px_intr: no intr condition\n");*/
    197  1.1  jonathan #endif
    198  1.1  jonathan 	} else {
    199  1.1  jonathan #if defined(DIAGNOSTIC) || 1
    200  1.1  jonathan 		DELAY(1000000);
    201  1.1  jonathan 		 /* XXX not for me */
    202  1.1  jonathan 		printf("px_intr:, no intr? %x %x %x %x %x",
    203  1.1  jonathan 		       intr_status,
    204  1.1  jonathan 		       stic->sticsr, stic->buscsr,
    205  1.1  jonathan 		       stic->busadr, stic->busdat);
    206  1.1  jonathan 		 DELAY(100000);
    207  1.1  jonathan 		/*panic("px_intr: no intr condition\n");*/
    208  1.1  jonathan #endif
    209  1.1  jonathan 	}
    210  1.1  jonathan 
    211  1.1  jonathan 	return(0); /* XXX forme */
    212  1.1  jonathan }
    213  1.1  jonathan 
    214  1.1  jonathan 
    215  1.1  jonathan /*
    216  1.1  jonathan  * Turn vertical retrace interrupt on or off
    217  1.1  jonathan  */
    218  1.1  jonathan void
    219  1.1  jonathan px_vblank_ctl(sc, switch_on)
    220  1.1  jonathan 	struct px_softc	*sc;
    221  1.1  jonathan 	int	switch_on;
    222  1.1  jonathan 
    223  1.1  jonathan {
    224  1.1  jonathan 	register volatile struct stic_regs *stic =
    225  1.1  jonathan 	    STICADDR(sc->px_stic.stic_addr);
    226  1.1  jonathan 
    227  1.1  jonathan 	stic->ipdvint = (switch_on) ?
    228  1.1  jonathan 		STIC_INT_V_WE | STIC_INT_V_EN :
    229  1.1  jonathan 		STIC_INT_V_WE;
    230  1.1  jonathan 
    231  1.1  jonathan 	tc_wmb();
    232  1.1  jonathan }
    233  1.1  jonathan 
    234  1.1  jonathan void
    235  1.1  jonathan px_blank(sc)
    236  1.1  jonathan 	struct  px_softc *sc;
    237  1.1  jonathan {
    238  1.1  jonathan 
    239  1.1  jonathan }
    240  1.1  jonathan 
    241  1.1  jonathan 
    242  1.1  jonathan void
    243  1.1  jonathan px_unblank(sc)
    244  1.1  jonathan 	struct  px_softc *sc;
    245  1.1  jonathan {
    246  1.1  jonathan }
    247