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