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