Home | History | Annotate | Line # | Download | only in nubus
grf_nubus.c revision 1.52.12.1
      1  1.52.12.1  itojun /*	$NetBSD: grf_nubus.c,v 1.52.12.1 1999/11/30 13:32:41 itojun Exp $	*/
      2        1.1  briggs 
      3        1.1  briggs /*
      4        1.1  briggs  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
      5        1.1  briggs  *
      6        1.1  briggs  * Redistribution and use in source and binary forms, with or without
      7        1.1  briggs  * modification, are permitted provided that the following conditions
      8        1.1  briggs  * are met:
      9        1.1  briggs  * 1. Redistributions of source code must retain the above copyright
     10        1.1  briggs  *    notice, this list of conditions and the following disclaimer.
     11        1.1  briggs  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1  briggs  *    notice, this list of conditions and the following disclaimer in the
     13        1.1  briggs  *    documentation and/or other materials provided with the distribution.
     14        1.1  briggs  * 3. All advertising materials mentioning features or use of this software
     15        1.1  briggs  *    must display the following acknowledgement:
     16        1.1  briggs  *	This product includes software developed by Allen Briggs.
     17        1.1  briggs  * 4. The name of the author may not be used to endorse or promote products
     18        1.1  briggs  *    derived from this software without specific prior written permission.
     19        1.1  briggs  *
     20        1.1  briggs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21        1.1  briggs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22        1.1  briggs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23        1.1  briggs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24        1.1  briggs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25        1.1  briggs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26        1.1  briggs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27        1.1  briggs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28        1.1  briggs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29        1.1  briggs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30        1.1  briggs  */
     31        1.1  briggs /*
     32        1.1  briggs  * Device-specific routines for handling Nubus-based video cards.
     33        1.1  briggs  */
     34       1.47  scottr 
     35       1.47  scottr #include "opt_grf.h"
     36        1.1  briggs 
     37        1.1  briggs #include <sys/param.h>
     38        1.1  briggs 
     39        1.1  briggs #include <sys/device.h>
     40        1.1  briggs #include <sys/ioctl.h>
     41        1.1  briggs #include <sys/file.h>
     42        1.1  briggs #include <sys/malloc.h>
     43        1.1  briggs #include <sys/mman.h>
     44        1.1  briggs #include <sys/proc.h>
     45        1.8  briggs #include <sys/systm.h>
     46        1.1  briggs 
     47       1.16  scottr #include <machine/bus.h>
     48        1.8  briggs #include <machine/cpu.h>
     49        1.1  briggs #include <machine/grfioctl.h>
     50        1.8  briggs #include <machine/viareg.h>
     51        1.1  briggs 
     52       1.43  scottr #include <mac68k/nubus/nubus.h>
     53       1.31  scottr #include <mac68k/dev/grfvar.h>
     54        1.1  briggs 
     55        1.8  briggs static void	load_image_data __P((caddr_t data, struct image_data *image));
     56        1.1  briggs 
     57       1.41  scottr static void	grfmv_intr_generic_write1 __P((void *vsc));
     58       1.41  scottr static void	grfmv_intr_generic_write4 __P((void *vsc));
     59       1.41  scottr static void	grfmv_intr_generic_or4 __P((void *vsc));
     60       1.41  scottr 
     61       1.41  scottr static void	grfmv_intr_cb264 __P((void *vsc));
     62       1.41  scottr static void	grfmv_intr_cb364 __P((void *vsc));
     63       1.41  scottr static void	grfmv_intr_cmax __P((void *vsc));
     64       1.41  scottr static void	grfmv_intr_cti __P((void *vsc));
     65       1.41  scottr static void	grfmv_intr_radius __P((void *vsc));
     66       1.41  scottr static void	grfmv_intr_radius24 __P((void *vsc));
     67       1.41  scottr static void	grfmv_intr_supermacgfx __P((void *vsc));
     68       1.41  scottr static void	grfmv_intr_lapis __P((void *vsc));
     69       1.41  scottr static void	grfmv_intr_formac __P((void *vsc));
     70       1.44  briggs static void	grfmv_intr_vimage __P((void *vsc));
     71       1.48  briggs static void	grfmv_intr_gvimage __P((void *vsc));
     72        1.1  briggs 
     73        1.8  briggs static int	grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
     74       1.15  scottr static int	grfmv_match __P((struct device *, struct cfdata *, void *));
     75        1.8  briggs static void	grfmv_attach __P((struct device *, struct device *, void *));
     76       1.11  scottr 
     77       1.11  scottr struct cfattach macvid_ca = {
     78       1.11  scottr 	sizeof(struct grfbus_softc), grfmv_match, grfmv_attach
     79        1.8  briggs };
     80        1.8  briggs 
     81        1.1  briggs static void
     82        1.1  briggs load_image_data(data, image)
     83        1.1  briggs 	caddr_t	data;
     84        1.1  briggs 	struct	image_data *image;
     85        1.1  briggs {
     86        1.1  briggs 	bcopy(data     , &image->size,       4);
     87        1.1  briggs 	bcopy(data +  4, &image->offset,     4);
     88        1.1  briggs 	bcopy(data +  8, &image->rowbytes,   2);
     89        1.1  briggs 	bcopy(data + 10, &image->top,        2);
     90        1.1  briggs 	bcopy(data + 12, &image->left,       2);
     91        1.1  briggs 	bcopy(data + 14, &image->bottom,     2);
     92        1.1  briggs 	bcopy(data + 16, &image->right,      2);
     93        1.1  briggs 	bcopy(data + 18, &image->version,    2);
     94        1.1  briggs 	bcopy(data + 20, &image->packType,   2);
     95        1.1  briggs 	bcopy(data + 22, &image->packSize,   4);
     96        1.1  briggs 	bcopy(data + 26, &image->hRes,       4);
     97        1.1  briggs 	bcopy(data + 30, &image->vRes,       4);
     98        1.1  briggs 	bcopy(data + 34, &image->pixelType,  2);
     99        1.1  briggs 	bcopy(data + 36, &image->pixelSize,  2);
    100        1.1  briggs 	bcopy(data + 38, &image->cmpCount,   2);
    101        1.1  briggs 	bcopy(data + 40, &image->cmpSize,    2);
    102        1.1  briggs 	bcopy(data + 42, &image->planeBytes, 4);
    103        1.1  briggs }
    104        1.1  briggs 
    105        1.1  briggs 
    106        1.7  briggs static int
    107       1.15  scottr grfmv_match(parent, cf, aux)
    108       1.11  scottr 	struct device *parent;
    109       1.15  scottr 	struct cfdata *cf;
    110       1.15  scottr 	void *aux;
    111        1.1  briggs {
    112       1.21  scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    113        1.1  briggs 
    114       1.15  scottr 	if (na->category != NUBUS_CATEGORY_DISPLAY)
    115        1.1  briggs 		return 0;
    116        1.1  briggs 
    117       1.15  scottr 	if (na->type != NUBUS_TYPE_VIDEO)
    118        1.1  briggs 		return 0;
    119        1.1  briggs 
    120       1.15  scottr 	if (na->drsw != NUBUS_DRSW_APPLE)
    121        1.1  briggs 		return 0;
    122        1.1  briggs 
    123        1.1  briggs 	/*
    124        1.1  briggs 	 * If we've gotten this far, then we're dealing with a real-live
    125        1.1  briggs 	 * Apple QuickDraw-compatible display card resource.  Now, how to
    126        1.1  briggs 	 * determine that this is an active resource???  Dunno.  But we'll
    127        1.1  briggs 	 * proceed like it is.
    128        1.1  briggs 	 */
    129        1.1  briggs 
    130        1.1  briggs 	return 1;
    131        1.1  briggs }
    132        1.1  briggs 
    133        1.8  briggs static void
    134        1.8  briggs grfmv_attach(parent, self, aux)
    135        1.8  briggs 	struct device *parent, *self;
    136        1.8  briggs 	void *aux;
    137        1.1  briggs {
    138       1.21  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)self;
    139       1.21  scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    140        1.1  briggs 	struct image_data image_store, image;
    141       1.15  scottr 	struct grfmode *gm;
    142       1.15  scottr 	char cardname[CARD_NAME_LEN];
    143       1.15  scottr 	nubus_dirent dirent;
    144       1.15  scottr 	nubus_dir dir, mode_dir;
    145       1.15  scottr 	int mode;
    146       1.15  scottr 
    147       1.46  scottr 	bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
    148       1.46  scottr 
    149       1.25  scottr 	sc->sc_tag = na->na_tag;
    150       1.15  scottr 	sc->card_id = na->drhw;
    151       1.49  scottr 	sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot);
    152       1.49  scottr 	sc->sc_fbofs = 0;
    153       1.15  scottr 
    154       1.49  scottr 	if (bus_space_map(sc->sc_tag, sc->sc_basepa, NBMEMSIZE,
    155       1.46  scottr 	    0, &sc->sc_handle)) {
    156       1.25  scottr 		printf(": grfmv_attach: failed to map slot %d\n", na->slot);
    157       1.25  scottr 		return;
    158       1.25  scottr 	}
    159       1.25  scottr 
    160       1.15  scottr 	nubus_get_main_dir(&sc->sc_slot, &dir);
    161        1.1  briggs 
    162       1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    163       1.25  scottr 	    &sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) {
    164       1.25  scottr bad:
    165       1.25  scottr 		bus_space_unmap(sc->sc_tag, sc->sc_handle, NBMEMSIZE);
    166       1.15  scottr 		return;
    167       1.25  scottr 	}
    168       1.15  scottr 
    169       1.15  scottr 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &sc->board_dir);
    170       1.15  scottr 
    171       1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    172       1.25  scottr 	    &sc->sc_slot, &sc->board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
    173       1.15  scottr 		if ((na->rsrcid != 128) ||
    174       1.25  scottr 		    (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    175       1.25  scottr 		    &sc->sc_slot, &dir, 129, &dirent) <= 0))
    176       1.25  scottr 			goto bad;
    177        1.8  briggs 
    178        1.1  briggs 	mode = NUBUS_RSRC_FIRSTMODE;
    179       1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    180       1.25  scottr 	    &sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) {
    181       1.25  scottr 		printf(": probe failed to get board rsrc.\n");
    182       1.25  scottr 		goto bad;
    183        1.8  briggs 	}
    184        1.1  briggs 
    185        1.1  briggs 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir);
    186        1.1  briggs 
    187       1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    188       1.25  scottr 	    &sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) {
    189       1.25  scottr 		printf(": probe failed to get mode dir.\n");
    190       1.25  scottr 		goto bad;
    191        1.8  briggs 	}
    192        1.1  briggs 
    193       1.25  scottr 	if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, &sc->sc_slot,
    194       1.25  scottr 	    &dirent, (caddr_t)&image_store, sizeof(struct image_data)) <= 0) {
    195       1.25  scottr 		printf(": probe failed to get indirect mode data.\n");
    196       1.25  scottr 		goto bad;
    197        1.8  briggs 	}
    198        1.1  briggs 
    199       1.15  scottr 	/* Need to load display info (and driver?), etc... (?) */
    200       1.15  scottr 
    201       1.21  scottr 	load_image_data((caddr_t)&image_store, &image);
    202        1.1  briggs 
    203       1.15  scottr 	gm = &sc->curr_mode;
    204       1.11  scottr 	gm->mode_id = mode;
    205       1.49  scottr 	gm->ptype = image.pixelType;
    206       1.49  scottr 	gm->psize = image.pixelSize;
    207       1.11  scottr 	gm->width = image.right - image.left;
    208       1.11  scottr 	gm->height = image.bottom - image.top;
    209       1.49  scottr 	gm->rowbytes = image.rowbytes;
    210       1.11  scottr 	gm->hres = image.hRes;
    211       1.11  scottr 	gm->vres = image.vRes;
    212       1.49  scottr 	gm->fbsize = gm->height * gm->rowbytes;
    213       1.49  scottr 	gm->fbbase = (caddr_t)sc->sc_handle;	/* XXX evil hack */
    214       1.49  scottr 	gm->fboff = image.offset;
    215        1.1  briggs 
    216       1.25  scottr 	strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_handle,
    217       1.25  scottr 	    &sc->sc_slot), CARD_NAME_LEN);
    218       1.11  scottr 	cardname[CARD_NAME_LEN-1] = '\0';
    219       1.21  scottr 	printf(": %s\n", cardname);
    220        1.1  briggs 
    221       1.18  briggs 	if (sc->card_id == NUBUS_DRHW_TFB) {
    222       1.18  briggs 		/*
    223       1.18  briggs 		 * This is the Toby card, but apparently some manufacturers
    224       1.18  briggs 		 * (like Cornerstone) didn't bother to get/use their own
    225       1.18  briggs 		 * value here, even though the cards are different, so we
    226       1.18  briggs 		 * so we try to differentiate here.
    227       1.18  briggs 		 */
    228       1.21  scottr 		if (strncmp(cardname, "Samsung 768", 11) == 0)
    229       1.18  briggs 			sc->card_id = NUBUS_DRHW_SAM768;
    230       1.21  scottr 		else if (strncmp(cardname, "Toby frame", 10) != 0)
    231       1.25  scottr 			printf("%s: This display card pretends to be a TFB!\n",
    232       1.21  scottr 			    sc->sc_dev.dv_xname);
    233       1.18  briggs 	}
    234       1.18  briggs 
    235       1.18  briggs 	switch (sc->card_id) {
    236       1.28  scottr 	case NUBUS_DRHW_TFB:
    237       1.18  briggs 	case NUBUS_DRHW_M2HRVC:
    238       1.27  scottr 	case NUBUS_DRHW_PVC:
    239       1.18  briggs 		sc->cli_offset = 0xa0000;
    240       1.22  briggs 		sc->cli_value = 0;
    241       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    242       1.18  briggs 		break;
    243       1.18  briggs 	case NUBUS_DRHW_WVC:
    244       1.18  briggs 		sc->cli_offset = 0xa00000;
    245       1.22  briggs 		sc->cli_value = 0;
    246       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    247       1.28  scottr 		break;
    248       1.32  scottr 	case NUBUS_DRHW_COLORMAX:
    249       1.32  scottr 		add_nubus_intr(na->slot, grfmv_intr_cmax, sc);
    250       1.32  scottr 		break;
    251       1.28  scottr 	case NUBUS_DRHW_SE30:
    252       1.28  scottr 		/* Do nothing--SE/30 interrupts are disabled */
    253       1.28  scottr 		break;
    254       1.28  scottr 	case NUBUS_DRHW_MDC:
    255       1.28  scottr 		sc->cli_offset = 0x200148;
    256       1.28  scottr 		sc->cli_value = 1;
    257       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    258       1.28  scottr 
    259       1.28  scottr 		/* Enable interrupts; to disable, write 0x7 to this location */
    260       1.28  scottr 		bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5);
    261       1.28  scottr 		break;
    262       1.28  scottr 	case NUBUS_DRHW_CB264:
    263       1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_cb264, sc);
    264       1.28  scottr 		break;
    265       1.28  scottr 	case NUBUS_DRHW_CB364:
    266       1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_cb364, sc);
    267       1.34  briggs 		break;
    268       1.34  briggs 	case NUBUS_DRHW_RPC8:
    269       1.34  briggs 		sc->cli_offset = 0xfdff8f;
    270       1.34  briggs 		sc->cli_value = 0xff;
    271       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    272       1.22  briggs 		break;
    273       1.23  briggs 	case NUBUS_DRHW_RPC8XJ:
    274       1.45  briggs 		sc->cli_value = 0x66;
    275       1.45  briggs 		add_nubus_intr(na->slot, grfmv_intr_radius, sc);
    276       1.45  briggs 		break;
    277       1.45  briggs 	case NUBUS_DRHW_RPC24X:
    278       1.45  briggs 		sc->cli_value = 0x64;
    279       1.25  scottr 		add_nubus_intr(na->slot, grfmv_intr_radius, sc);
    280       1.23  briggs 		break;
    281       1.40  briggs 	case NUBUS_DRHW_RPC24XP:
    282       1.40  briggs 		add_nubus_intr(na->slot, grfmv_intr_radius24, sc);
    283       1.40  briggs 		break;
    284       1.22  briggs 	case NUBUS_DRHW_FIILX:
    285       1.22  briggs 	case NUBUS_DRHW_FIISXDSP:
    286       1.35  briggs 	case NUBUS_DRHW_FUTURASX:
    287       1.26  scottr 		sc->cli_offset = 0xf05000;
    288       1.22  briggs 		sc->cli_value = 0x80;
    289       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    290       1.18  briggs 		break;
    291       1.18  briggs 	case NUBUS_DRHW_SAM768:
    292       1.25  scottr 		add_nubus_intr(na->slot, grfmv_intr_cti, sc);
    293       1.19  briggs 		break;
    294       1.33  briggs 	case NUBUS_DRHW_SUPRGFX:
    295       1.33  briggs 		add_nubus_intr(na->slot, grfmv_intr_supermacgfx, sc);
    296       1.33  briggs 		break;
    297       1.38  briggs 	case NUBUS_DRHW_SPECTRM8:
    298       1.38  briggs 		sc->cli_offset = 0x0de178;
    299       1.38  briggs 		sc->cli_value = 0x80;
    300       1.38  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_or4, sc);
    301       1.38  briggs 		break;
    302       1.36  briggs 	case NUBUS_DRHW_LAPIS:
    303       1.36  briggs 		add_nubus_intr(na->slot, grfmv_intr_lapis, sc);
    304       1.36  briggs 		break;
    305       1.40  briggs 	case NUBUS_DRHW_FORMAC:
    306       1.40  briggs 		add_nubus_intr(na->slot, grfmv_intr_formac, sc);
    307       1.42  briggs 		break;
    308       1.42  briggs 	case NUBUS_DRHW_ROPS24LXI:
    309  1.52.12.1  itojun 	case NUBUS_DRHW_ROPS24XLTV:
    310       1.42  briggs 		sc->cli_offset = 0xfb0010;
    311       1.42  briggs 		sc->cli_value = 0x00;
    312       1.42  briggs 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    313       1.40  briggs 		break;
    314       1.44  briggs 	case NUBUS_DRHW_VIMAGE:
    315       1.44  briggs 		add_nubus_intr(na->slot, grfmv_intr_vimage, sc);
    316       1.44  briggs 		break;
    317       1.48  briggs 	case NUBUS_DRHW_GVIMAGE:
    318       1.48  briggs 		add_nubus_intr(na->slot, grfmv_intr_gvimage, sc);
    319       1.51  scottr 		break;
    320       1.52  scottr 	case NUBUS_DRHW_MC2124NB:
    321       1.51  scottr 		sc->cli_offset = 0xfd1000;
    322       1.51  scottr 		sc->cli_value = 0x00;
    323       1.51  scottr 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    324       1.48  briggs 		break;
    325       1.18  briggs 	case NUBUS_DRHW_MICRON:
    326       1.18  briggs 		/* What do we know about this one? */
    327       1.18  briggs 	default:
    328       1.21  scottr 		printf("%s: Unknown video card ID 0x%x --",
    329       1.21  scottr 		    sc->sc_dev.dv_xname, sc->card_id);
    330       1.21  scottr 		printf(" Not installing interrupt routine.\n");
    331       1.18  briggs 		break;
    332       1.18  briggs 	}
    333        1.1  briggs 
    334       1.11  scottr 	/* Perform common video attachment. */
    335       1.46  scottr 	grf_establish(sc, &sc->sc_slot, grfmv_mode);
    336        1.1  briggs }
    337        1.1  briggs 
    338        1.8  briggs static int
    339        1.1  briggs grfmv_mode(gp, cmd, arg)
    340        1.1  briggs 	struct grf_softc *gp;
    341        1.1  briggs 	int cmd;
    342        1.1  briggs 	void *arg;
    343        1.1  briggs {
    344        1.1  briggs 	switch (cmd) {
    345        1.4  briggs 	case GM_GRFON:
    346        1.4  briggs 	case GM_GRFOFF:
    347        1.4  briggs 		return 0;
    348        1.1  briggs 	case GM_CURRMODE:
    349        1.1  briggs 		break;
    350        1.1  briggs 	case GM_NEWMODE:
    351        1.1  briggs 		break;
    352        1.1  briggs 	case GM_LISTMODES:
    353        1.1  briggs 		break;
    354        1.1  briggs 	}
    355        1.1  briggs 	return EINVAL;
    356       1.18  briggs }
    357       1.18  briggs 
    358       1.18  briggs /* Interrupt handlers... */
    359       1.18  briggs /*
    360       1.18  briggs  * Generic routine to clear interrupts for cards where it simply takes
    361       1.28  scottr  * a MOV.B to clear the interrupt.  The offset and value of this byte
    362       1.28  scottr  * varies between cards.
    363       1.18  briggs  */
    364       1.18  briggs /*ARGSUSED*/
    365       1.18  briggs static void
    366       1.41  scottr grfmv_intr_generic_write1(vsc)
    367       1.18  briggs 	void	*vsc;
    368       1.18  briggs {
    369       1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    370       1.26  scottr 
    371       1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle,
    372       1.28  scottr 	    sc->cli_offset, (u_int8_t)sc->cli_value);
    373       1.28  scottr }
    374       1.28  scottr 
    375       1.28  scottr /*
    376       1.28  scottr  * Generic routine to clear interrupts for cards where it simply takes
    377       1.28  scottr  * a MOV.L to clear the interrupt.  The offset and value of this byte
    378       1.28  scottr  * varies between cards.
    379       1.28  scottr  */
    380       1.28  scottr /*ARGSUSED*/
    381       1.28  scottr static void
    382       1.41  scottr grfmv_intr_generic_write4(vsc)
    383       1.28  scottr 	void	*vsc;
    384       1.28  scottr {
    385       1.28  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    386       1.28  scottr 
    387       1.28  scottr 	bus_space_write_4(sc->sc_tag, sc->sc_handle,
    388       1.26  scottr 	    sc->cli_offset, sc->cli_value);
    389       1.38  briggs }
    390       1.38  briggs 
    391       1.38  briggs /*
    392       1.38  briggs  * Generic routine to clear interrupts for cards where it simply takes
    393       1.38  briggs  * an OR.L to clear the interrupt.  The offset and value of this byte
    394       1.38  briggs  * varies between cards.
    395       1.38  briggs  */
    396       1.38  briggs /*ARGSUSED*/
    397       1.38  briggs static void
    398       1.41  scottr grfmv_intr_generic_or4(vsc)
    399       1.38  briggs 	void	*vsc;
    400       1.38  briggs {
    401       1.38  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    402       1.38  briggs 	unsigned long	scratch;
    403       1.38  briggs 
    404       1.38  briggs 	scratch = bus_space_read_4(sc->sc_tag, sc->sc_handle, sc->cli_offset);
    405       1.38  briggs 	scratch |= 0x80;
    406       1.38  briggs 	bus_space_write_4(sc->sc_tag, sc->sc_handle, sc->cli_offset, scratch);
    407       1.23  briggs }
    408       1.23  briggs 
    409       1.23  briggs /*
    410       1.26  scottr  * Routine to clear interrupts for the Radius PrecisionColor 8xj card.
    411       1.23  briggs  */
    412       1.23  briggs /*ARGSUSED*/
    413       1.23  briggs static void
    414       1.41  scottr grfmv_intr_radius(vsc)
    415       1.23  briggs 	void	*vsc;
    416       1.23  briggs {
    417       1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    418       1.26  scottr 	u_int8_t c;
    419       1.23  briggs 
    420       1.45  briggs 	c = sc->cli_value;
    421       1.23  briggs 
    422       1.23  briggs 	c |= 0x80;
    423       1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    424       1.26  scottr 	c &= 0x7f;
    425       1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    426       1.18  briggs }
    427       1.18  briggs 
    428       1.18  briggs /*
    429       1.40  briggs  * Routine to clear interrupts for the Radius PrecisionColor 24Xp card.
    430       1.40  briggs  * Is this what the 8xj routine is doing, too?
    431       1.40  briggs  */
    432       1.40  briggs /*ARGSUSED*/
    433       1.40  briggs static void
    434       1.41  scottr grfmv_intr_radius24(vsc)
    435       1.40  briggs 	void	*vsc;
    436       1.40  briggs {
    437       1.40  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    438       1.40  briggs 	u_int8_t c;
    439       1.40  briggs 
    440       1.40  briggs 	c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfffd8);
    441       1.40  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    442       1.40  briggs 	c &= 0x7f;
    443       1.40  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    444       1.40  briggs }
    445       1.40  briggs 
    446       1.40  briggs /*
    447       1.18  briggs  * Routine to clear interrupts on Samsung 768x1006 video controller.
    448       1.18  briggs  * This controller was manufactured by Cornerstone Technology, Inc.,
    449       1.18  briggs  * now known as Cornerstone Imaging.
    450       1.18  briggs  *
    451       1.18  briggs  * To clear this interrupt, we apparently have to set, then clear,
    452       1.18  briggs  * bit 2 at byte offset 0x80000 from the card's base.
    453       1.18  briggs  *	Information for this provided by Brad Salai <bsalai (at) servtech.com>
    454       1.18  briggs  */
    455       1.18  briggs /*ARGSUSED*/
    456       1.18  briggs static void
    457       1.41  scottr grfmv_intr_cti(vsc)
    458       1.18  briggs 	void	*vsc;
    459       1.18  briggs {
    460       1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    461       1.26  scottr 	u_int8_t c;
    462       1.18  briggs 
    463       1.26  scottr 	c = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x80000);
    464       1.26  scottr 	c |= 0x02;
    465       1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    466       1.26  scottr 	c &= 0xfd;
    467       1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    468       1.18  briggs }
    469       1.18  briggs 
    470       1.18  briggs /*ARGSUSED*/
    471       1.18  briggs static void
    472       1.41  scottr grfmv_intr_cb264(vsc)
    473       1.18  briggs 	void	*vsc;
    474       1.18  briggs {
    475       1.18  briggs 	struct grfbus_softc *sc;
    476       1.21  scottr 	volatile char *slotbase;
    477       1.18  briggs 
    478       1.21  scottr 	sc = (struct grfbus_softc *)vsc;
    479       1.25  scottr 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    480       1.18  briggs 	asm volatile("	movl	%0,a0
    481       1.18  briggs 			movl	a0@(0xff6028),d0
    482       1.18  briggs 			andl	#0x2,d0
    483       1.18  briggs 			beq	_mv_intr0
    484       1.18  briggs 			movql	#0x3,d0
    485       1.18  briggs 		_mv_intr0:
    486       1.18  briggs 			movl	a0@(0xff600c),d1
    487       1.18  briggs 			andl	#0x3,d1
    488       1.18  briggs 			cmpl	d1,d0
    489       1.18  briggs 			beq	_mv_intr_fin
    490       1.18  briggs 			movl	d0,a0@(0xff600c)
    491       1.18  briggs 			nop
    492       1.18  briggs 			tstb	d0
    493       1.18  briggs 			beq	_mv_intr1
    494       1.18  briggs 			movl	#0x0002,a0@(0xff6040)
    495       1.18  briggs 			movl	#0x0102,a0@(0xff6044)
    496       1.18  briggs 			movl	#0x0105,a0@(0xff6048)
    497       1.18  briggs 			movl	#0x000e,a0@(0xff604c)
    498       1.18  briggs 			movl	#0x001c,a0@(0xff6050)
    499       1.18  briggs 			movl	#0x00bc,a0@(0xff6054)
    500       1.18  briggs 			movl	#0x00c3,a0@(0xff6058)
    501       1.18  briggs 			movl	#0x0061,a0@(0xff605c)
    502       1.18  briggs 			movl	#0x0012,a0@(0xff6060)
    503       1.18  briggs 			bra	_mv_intr_fin
    504       1.18  briggs 		_mv_intr1:
    505       1.18  briggs 			movl	#0x0002,a0@(0xff6040)
    506       1.18  briggs 			movl	#0x0209,a0@(0xff6044)
    507       1.18  briggs 			movl	#0x020c,a0@(0xff6048)
    508       1.18  briggs 			movl	#0x000f,a0@(0xff604c)
    509       1.18  briggs 			movl	#0x0027,a0@(0xff6050)
    510       1.18  briggs 			movl	#0x00c7,a0@(0xff6054)
    511       1.18  briggs 			movl	#0x00d7,a0@(0xff6058)
    512       1.18  briggs 			movl	#0x006b,a0@(0xff605c)
    513       1.18  briggs 			movl	#0x0029,a0@(0xff6060)
    514       1.18  briggs 		_mv_intr_fin:
    515       1.18  briggs 			movl	#0x1,a0@(0xff6014)"
    516       1.18  briggs 		: : "g" (slotbase) : "a0","d0","d1");
    517       1.24  briggs }
    518       1.24  briggs 
    519       1.24  briggs /*
    520       1.24  briggs  * Support for the Colorboard 364 might be more complex than it needs to
    521       1.24  briggs  * be.  If we can find more information about this card, this might be
    522       1.24  briggs  * significantly simplified.  Contributions welcome...  :-)
    523       1.24  briggs  */
    524       1.24  briggs /*ARGSUSED*/
    525       1.24  briggs static void
    526       1.41  scottr grfmv_intr_cb364(vsc)
    527       1.24  briggs 	void	*vsc;
    528       1.24  briggs {
    529       1.24  briggs 	struct grfbus_softc *sc;
    530       1.24  briggs 	volatile char *slotbase;
    531       1.24  briggs 
    532       1.24  briggs 	sc = (struct grfbus_softc *)vsc;
    533       1.25  scottr 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    534       1.24  briggs 	asm volatile("	movl	%0,a0
    535       1.24  briggs 			movl	a0@(0xfe6028),d0
    536       1.24  briggs 			andl	#0x2,d0
    537       1.24  briggs 			beq	_cb364_intr4
    538       1.24  briggs 			movql	#0x3,d0
    539       1.24  briggs 			movl	a0@(0xfe6018),d1
    540       1.24  briggs 			movl	#0x3,a0@(0xfe6018)
    541       1.24  briggs 			movw	a0@(0xfe7010),d2
    542       1.24  briggs 			movl	d1,a0@(0xfe6018)
    543       1.24  briggs 			movl	a0@(0xfe6020),d1
    544       1.24  briggs 			btst	#0x06,d2
    545       1.24  briggs 			beq	_cb364_intr0
    546       1.24  briggs 			btst	#0x00,d1
    547       1.24  briggs 			beq	_cb364_intr5
    548       1.24  briggs 			bsr	_cb364_intr1
    549       1.24  briggs 			bra	_cb364_intr_out
    550       1.24  briggs 		_cb364_intr0:
    551       1.24  briggs 			btst	#0x00,d1
    552       1.24  briggs 			bne	_cb364_intr5
    553       1.24  briggs 			bsr	_cb364_intr1
    554       1.24  briggs 			bra	_cb364_intr_out
    555       1.24  briggs 		_cb364_intr1:
    556       1.24  briggs 			movl	d0,a0@(0xfe600c)
    557       1.24  briggs 			nop
    558       1.24  briggs 			tstb	d0
    559       1.24  briggs 			beq	_cb364_intr3
    560       1.24  briggs 			movl	#0x0002,a0@(0xfe6040)
    561       1.24  briggs 			movl	#0x0105,a0@(0xfe6048)
    562       1.24  briggs 			movl	#0x000e,a0@(0xfe604c)
    563       1.24  briggs 			movl	#0x00c3,a0@(0xfe6058)
    564       1.24  briggs 			movl	#0x0061,a0@(0xfe605c)
    565       1.24  briggs 			btst	#0x06,d2
    566       1.24  briggs 			beq	_cb364_intr2
    567       1.24  briggs 			movl	#0x001c,a0@(0xfe6050)
    568       1.24  briggs 			movl	#0x00bc,a0@(0xfe6054)
    569       1.24  briggs 			movl	#0x0012,a0@(0xfe6060)
    570       1.24  briggs 			movl	#0x000e,a0@(0xfe6044)
    571       1.24  briggs 			movl	#0x00c3,a0@(0xfe6064)
    572       1.24  briggs 			movl	#0x0061,a0@(0xfe6020)
    573       1.24  briggs 			rts
    574       1.24  briggs 		_cb364_intr2:
    575       1.24  briggs 			movl	#0x0016,a0@(0xfe6050)
    576       1.24  briggs 			movl	#0x00b6,a0@(0xfe6054)
    577       1.24  briggs 			movl	#0x0011,a0@(0xfe6060)
    578       1.24  briggs 			movl	#0x0101,a0@(0xfe6044)
    579       1.24  briggs 			movl	#0x00bf,a0@(0xfe6064)
    580       1.24  briggs 			movl	#0x0001,a0@(0xfe6020)
    581       1.24  briggs 			rts
    582       1.24  briggs 		_cb364_intr3:
    583       1.24  briggs 			movl	#0x0002,a0@(0xfe6040)
    584       1.24  briggs 			movl	#0x0209,a0@(0xfe6044)
    585       1.24  briggs 			movl	#0x020c,a0@(0xfe6048)
    586       1.24  briggs 			movl	#0x000f,a0@(0xfe604c)
    587       1.24  briggs 			movl	#0x0027,a0@(0xfe6050)
    588       1.24  briggs 			movl	#0x00c7,a0@(0xfe6054)
    589       1.24  briggs 			movl	#0x00d7,a0@(0xfe6058)
    590       1.24  briggs 			movl	#0x006b,a0@(0xfe605c)
    591       1.24  briggs 			movl	#0x0029,a0@(0xfe6060)
    592       1.24  briggs 			oril	#0x0040,a0@(0xfe6064)
    593       1.24  briggs 			movl	#0x0000,a0@(0xfe6020)
    594       1.24  briggs 			rts
    595       1.24  briggs 		_cb364_intr4:
    596       1.24  briggs 			movq	#0x00,d0
    597       1.24  briggs 		_cb364_intr5:
    598       1.24  briggs 			movl	a0@(0xfe600c),d1
    599       1.24  briggs 			andl	#0x3,d1
    600       1.24  briggs 			cmpl	d1,d0
    601       1.24  briggs 			beq	_cb364_intr_out
    602       1.24  briggs 			bsr	_cb364_intr1
    603       1.24  briggs 		_cb364_intr_out:
    604       1.24  briggs 			movl	#0x1,a0@(0xfe6014)
    605       1.24  briggs 		_cb364_intr_quit:
    606       1.24  briggs 		" : : "g" (slotbase) : "a0","d0","d1","d2");
    607       1.33  briggs }
    608       1.33  briggs 
    609       1.33  briggs /*
    610       1.33  briggs  * Interrupt clearing routine for SuperMac GFX card.
    611       1.33  briggs  */
    612       1.33  briggs /*ARGSUSED*/
    613       1.33  briggs static void
    614       1.41  scottr grfmv_intr_supermacgfx(vsc)
    615       1.33  briggs 	void	*vsc;
    616       1.33  briggs {
    617       1.33  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    618       1.33  briggs 	u_int8_t dummy;
    619       1.33  briggs 
    620       1.33  briggs 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xE70D3);
    621       1.32  scottr }
    622       1.32  scottr 
    623       1.32  scottr /*
    624       1.32  scottr  * Routine to clear interrupts for the Sigma Designs ColorMax card.
    625       1.32  scottr  */
    626       1.32  scottr /*ARGSUSED*/
    627       1.32  scottr static void
    628       1.41  scottr grfmv_intr_cmax(vsc)
    629       1.32  scottr 	void	*vsc;
    630       1.32  scottr {
    631       1.32  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    632       1.32  scottr 	u_int32_t dummy;
    633       1.32  scottr 
    634       1.32  scottr 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf501c);
    635       1.32  scottr 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf5018);
    636       1.36  briggs }
    637       1.36  briggs 
    638       1.36  briggs /*
    639       1.37  scottr  * Routine to clear interrupts for the Lapis ProColorServer 8 PDS card
    640       1.37  scottr  * (for the SE/30).
    641       1.36  briggs  */
    642       1.36  briggs /*ARGSUSED*/
    643       1.36  briggs static void
    644       1.41  scottr grfmv_intr_lapis(vsc)
    645       1.36  briggs 	void	*vsc;
    646       1.36  briggs {
    647       1.36  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    648       1.36  briggs 
    649       1.36  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x08);
    650       1.36  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x0C);
    651       1.40  briggs }
    652       1.40  briggs 
    653       1.40  briggs /*
    654       1.40  briggs  * Routine to clear interrupts for the Formac Color Card II
    655       1.40  briggs  */
    656       1.40  briggs /*ARGSUSED*/
    657       1.40  briggs static void
    658       1.41  scottr grfmv_intr_formac(vsc)
    659       1.40  briggs 	void	*vsc;
    660       1.40  briggs {
    661       1.40  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    662       1.40  briggs 	u_int8_t dummy;
    663       1.40  briggs 
    664       1.40  briggs 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80db);
    665       1.40  briggs 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80d3);
    666       1.44  briggs }
    667       1.44  briggs 
    668       1.44  briggs /*
    669       1.44  briggs  * Routine to clear interrupts for the Vimage by Interware Co., Ltd.
    670       1.44  briggs  */
    671       1.44  briggs /*ARGSUSED*/
    672       1.44  briggs static void
    673       1.44  briggs grfmv_intr_vimage(vsc)
    674       1.44  briggs 	void	*vsc;
    675       1.44  briggs {
    676       1.44  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    677       1.44  briggs 
    678       1.44  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0x67);
    679       1.44  briggs 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0xE7);
    680       1.48  briggs }
    681       1.48  briggs 
    682       1.48  briggs /*
    683       1.50  briggs  * Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd.
    684       1.48  briggs  */
    685       1.48  briggs /*ARGSUSED*/
    686       1.48  briggs static void
    687       1.48  briggs grfmv_intr_gvimage(vsc)
    688       1.48  briggs 	void	*vsc;
    689       1.48  briggs {
    690       1.48  briggs 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    691       1.48  briggs 	u_int8_t dummy;
    692       1.48  briggs 
    693       1.48  briggs 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xf00000);
    694        1.1  briggs }
    695