Home | History | Annotate | Line # | Download | only in gio
gio.c revision 1.22.2.1
      1  1.22.2.1        ad /*	$NetBSD: gio.c,v 1.22.2.1 2007/01/12 01:00:57 ad Exp $	*/
      2       1.1     soren 
      3       1.1     soren /*
      4       1.1     soren  * Copyright (c) 2000 Soren S. Jorvang
      5       1.1     soren  * All rights reserved.
      6       1.2    simonb  *
      7       1.1     soren  * Redistribution and use in source and binary forms, with or without
      8       1.1     soren  * modification, are permitted provided that the following conditions
      9       1.1     soren  * are met:
     10       1.1     soren  * 1. Redistributions of source code must retain the above copyright
     11       1.1     soren  *    notice, this list of conditions and the following disclaimer.
     12       1.1     soren  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1     soren  *    notice, this list of conditions and the following disclaimer in the
     14       1.1     soren  *    documentation and/or other materials provided with the distribution.
     15       1.1     soren  * 3. All advertising materials mentioning features or use of this software
     16       1.1     soren  *    must display the following acknowledgement:
     17       1.1     soren  *          This product includes software developed for the
     18      1.11    keihan  *          NetBSD Project.  See http://www.NetBSD.org/ for
     19       1.1     soren  *          information about NetBSD.
     20       1.1     soren  * 4. The name of the author may not be used to endorse or promote products
     21       1.1     soren  *    derived from this software without specific prior written permission.
     22       1.2    simonb  *
     23       1.1     soren  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24       1.1     soren  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1     soren  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1     soren  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27       1.1     soren  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28       1.1     soren  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29       1.1     soren  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30       1.1     soren  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31       1.1     soren  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32       1.1     soren  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1     soren  */
     34      1.10     lukem 
     35      1.10     lukem #include <sys/cdefs.h>
     36  1.22.2.1        ad __KERNEL_RCSID(0, "$NetBSD: gio.c,v 1.22.2.1 2007/01/12 01:00:57 ad Exp $");
     37       1.1     soren 
     38       1.1     soren #include "opt_ddb.h"
     39       1.1     soren 
     40       1.1     soren #include <sys/param.h>
     41       1.1     soren #include <sys/systm.h>
     42       1.1     soren #include <sys/device.h>
     43       1.1     soren 
     44      1.22    rumble #define _SGIMIPS_BUS_DMA_PRIVATE
     45      1.12  lonewolf #include <machine/bus.h>
     46      1.22    rumble #include <machine/machtype.h>
     47  1.22.2.1        ad #include <machine/sysconf.h>
     48      1.12  lonewolf 
     49       1.1     soren #include <sgimips/gio/gioreg.h>
     50       1.1     soren #include <sgimips/gio/giovar.h>
     51      1.14    sekiya #include <sgimips/gio/giodevs_data.h>
     52       1.1     soren 
     53       1.1     soren #include "locators.h"
     54      1.12  lonewolf #include "newport.h"
     55      1.16    sekiya #include "grtwo.h"
     56  1.22.2.1        ad #include "light.h"
     57      1.22    rumble #include "imc.h"
     58      1.22    rumble #include "pic.h"
     59      1.12  lonewolf 
     60      1.12  lonewolf #if (NNEWPORT > 0)
     61      1.12  lonewolf #include <sgimips/gio/newportvar.h>
     62      1.12  lonewolf #endif
     63       1.1     soren 
     64      1.16    sekiya #if (NGRTWO > 0)
     65      1.16    sekiya #include <sgimips/gio/grtwovar.h>
     66      1.16    sekiya #endif
     67      1.16    sekiya 
     68  1.22.2.1        ad #if (NLIGHT > 0)
     69  1.22.2.1        ad #include <sgimips/gio/lightvar.h>
     70  1.22.2.1        ad #endif
     71  1.22.2.1        ad 
     72      1.22    rumble #if (NIMC > 0)
     73      1.22    rumble extern int imc_gio64_arb_config(int, uint32_t);
     74      1.22    rumble #endif
     75      1.22    rumble 
     76      1.22    rumble #if (NPIC > 0)
     77      1.22    rumble extern int pic_gio32_arb_config(int, uint32_t);
     78      1.22    rumble #endif
     79      1.22    rumble 
     80      1.22    rumble 
     81       1.1     soren struct gio_softc {
     82       1.1     soren 	struct	device sc_dev;
     83       1.1     soren };
     84       1.1     soren 
     85       1.1     soren static int	gio_match(struct device *, struct cfdata *, void *);
     86       1.1     soren static void	gio_attach(struct device *, struct device *, void *);
     87       1.1     soren static int	gio_print(void *, const char *);
     88      1.19  drochner static int	gio_search(struct device *, struct cfdata *,
     89      1.20  drochner 			   const int *, void *);
     90      1.18  drochner static int	gio_submatch(struct device *, struct cfdata *,
     91      1.20  drochner 			     const int *, void *);
     92       1.1     soren 
     93       1.6   thorpej CFATTACH_DECL(gio, sizeof(struct gio_softc),
     94       1.7   thorpej     gio_match, gio_attach, NULL, NULL);
     95       1.1     soren 
     96  1.22.2.1        ad struct gio_probe {
     97  1.22.2.1        ad 	uint32_t slot;
     98  1.22.2.1        ad 	uint32_t base;
     99  1.22.2.1        ad 	uint32_t mach_type;
    100  1.22.2.1        ad 	uint32_t mach_subtype;
    101  1.22.2.1        ad };
    102  1.22.2.1        ad 
    103  1.22.2.1        ad /*
    104  1.22.2.1        ad  * Expansion Slot Base Addresses
    105  1.22.2.1        ad  *
    106  1.22.2.1        ad  * IP12, IP20 and IP24 have two GIO connectors: GIO_SLOT_EXP0 and
    107  1.22.2.1        ad  * GIO_SLOT_EXP1.
    108  1.22.2.1        ad  *
    109  1.22.2.1        ad  * On IP24 these slots exist on the graphics board or the IOPLUS
    110  1.22.2.1        ad  * "mezzanine" on Indy and Challenge S, respectively. The IOPLUS or
    111  1.22.2.1        ad  * graphics board connects to the mainboard via a single GIO64 connector.
    112  1.22.2.1        ad  *
    113  1.22.2.1        ad  * IP22 has either three or four physical connectors, but only two
    114  1.22.2.1        ad  * electrically distinct slots: GIO_SLOT_GFX and GIO_SLOT_EXP0.
    115  1.22.2.1        ad  *
    116  1.22.2.1        ad  * It should also be noted that DMA is (mostly) not supported in Challenge
    117  1.22.2.1        ad  * S's GIO_SLOT_EXP1. See gio(4) for the story.
    118  1.22.2.1        ad  */
    119  1.22.2.1        ad static const struct gio_probe slot_bases[] = {
    120  1.22.2.1        ad 	{ GIO_SLOT_GFX,  0x1f000000, MACH_SGI_IP22, MACH_SGI_IP22_FULLHOUSE },
    121  1.22.2.1        ad 
    122  1.22.2.1        ad 	{ GIO_SLOT_EXP0, 0x1f400000, MACH_SGI_IP12, -1 },
    123  1.22.2.1        ad 	{ GIO_SLOT_EXP0, 0x1f400000, MACH_SGI_IP20, -1 },
    124  1.22.2.1        ad 	{ GIO_SLOT_EXP0, 0x1f400000, MACH_SGI_IP22, -1 },
    125  1.22.2.1        ad 
    126  1.22.2.1        ad 	{ GIO_SLOT_EXP1, 0x1f600000, MACH_SGI_IP12, -1 },
    127  1.22.2.1        ad 	{ GIO_SLOT_EXP1, 0x1f600000, MACH_SGI_IP20, -1 },
    128  1.22.2.1        ad 	{ GIO_SLOT_EXP1, 0x1f600000, MACH_SGI_IP22, MACH_SGI_IP22_GUINNESS },
    129  1.22.2.1        ad 
    130  1.22.2.1        ad 	{ 0, 0, 0, 0 }
    131  1.22.2.1        ad };
    132  1.22.2.1        ad 
    133  1.22.2.1        ad /*
    134  1.22.2.1        ad  * Graphic Board Base Addresses
    135  1.22.2.1        ad  *
    136  1.22.2.1        ad  * Graphics boards are not treated like expansion slot cards. Their base
    137  1.22.2.1        ad  * addresses do not necessarily correspond to GIO slot addresses and they
    138  1.22.2.1        ad  * do not contain product identification words.
    139  1.22.2.1        ad  */
    140  1.22.2.1        ad static const struct gio_probe gfx_bases[] = {
    141  1.22.2.1        ad 	/* grtwo, and newport on IP22 */
    142  1.22.2.1        ad 	{ -1, 0x1f000000, MACH_SGI_IP12, -1 },
    143  1.22.2.1        ad 	{ -1, 0x1f000000, MACH_SGI_IP20, -1 },
    144  1.22.2.1        ad 	{ -1, 0x1f000000, MACH_SGI_IP22, -1 },
    145  1.22.2.1        ad 
    146  1.22.2.1        ad 	/* light */
    147  1.22.2.1        ad 	{ -1, 0x1f3f0000, MACH_SGI_IP12, -1 },
    148  1.22.2.1        ad 	{ -1, 0x1f3f0000, MACH_SGI_IP20, -1 },
    149  1.22.2.1        ad 
    150  1.22.2.1        ad 	/* light (dual headed) */
    151  1.22.2.1        ad 	{ -1, 0x1f3f8000, MACH_SGI_IP12, -1 },
    152  1.22.2.1        ad 	{ -1, 0x1f3f8000, MACH_SGI_IP20, -1 },
    153  1.22.2.1        ad 
    154  1.22.2.1        ad 	/* grtwo, and newport on IP22 */
    155  1.22.2.1        ad 	{ -1, 0x1f400000, MACH_SGI_IP12, -1 },
    156  1.22.2.1        ad 	{ -1, 0x1f400000, MACH_SGI_IP20, -1 },
    157  1.22.2.1        ad 	{ -1, 0x1f400000, MACH_SGI_IP22, -1 },
    158  1.22.2.1        ad 
    159  1.22.2.1        ad 	/* grtwo */
    160  1.22.2.1        ad 	{ -1, 0x1f600000, MACH_SGI_IP12, -1 },
    161  1.22.2.1        ad 	{ -1, 0x1f600000, MACH_SGI_IP20, -1 },
    162  1.22.2.1        ad 	{ -1, 0x1f600000, MACH_SGI_IP22, -1 },
    163  1.22.2.1        ad 
    164  1.22.2.1        ad 	/* newport */
    165  1.22.2.1        ad 	{ -1, 0x1f800000, MACH_SGI_IP22, MACH_SGI_IP22_FULLHOUSE },
    166  1.22.2.1        ad 
    167  1.22.2.1        ad 	/* newport */
    168  1.22.2.1        ad 	{ -1, 0x1fc00000, MACH_SGI_IP22, MACH_SGI_IP22_FULLHOUSE },
    169  1.22.2.1        ad 
    170  1.22.2.1        ad 	{ 0, 0, 0, 0 }
    171      1.12  lonewolf };
    172      1.12  lonewolf 
    173  1.22.2.1        ad /* maximum number of graphics boards possible (arbitrarily large estimate) */
    174  1.22.2.1        ad #define MAXGFX 8
    175  1.22.2.1        ad 
    176       1.1     soren static int
    177      1.12  lonewolf gio_match(struct device *parent, struct cfdata *match, void *aux)
    178       1.1     soren {
    179       1.1     soren 
    180       1.2    simonb 	return 1;
    181       1.1     soren }
    182       1.1     soren 
    183       1.1     soren static void
    184      1.12  lonewolf gio_attach(struct device *parent, struct device *self, void *aux)
    185       1.1     soren {
    186       1.1     soren 	struct gio_attach_args ga;
    187  1.22.2.1        ad 	uint32_t gfx[MAXGFX];
    188  1.22.2.1        ad 	int i, j, ngfx;
    189       1.1     soren 
    190       1.1     soren 	printf("\n");
    191       1.1     soren 
    192  1.22.2.1        ad 	ngfx = 0;
    193  1.22.2.1        ad 	memset(gfx, 0, sizeof(gfx));
    194  1.22.2.1        ad 
    195  1.22.2.1        ad 	/*
    196  1.22.2.1        ad 	 * Attach graphics devices first. They do not contain a Product
    197  1.22.2.1        ad 	 * Identification Word and have no slot number.
    198  1.22.2.1        ad 	 *
    199  1.22.2.1        ad 	 * Record addresses to which graphics devices attach so that
    200  1.22.2.1        ad 	 * we do not confuse them with expansion slots, should the
    201  1.22.2.1        ad 	 * addresses coincide.
    202  1.22.2.1        ad 	 */
    203  1.22.2.1        ad 	for (i = 0; gfx_bases[i].base != 0; i++) {
    204  1.22.2.1        ad 		/* skip slots that don't apply to us */
    205  1.22.2.1        ad 		if (gfx_bases[i].mach_type != mach_type)
    206  1.22.2.1        ad 			continue;
    207  1.22.2.1        ad 
    208  1.22.2.1        ad 		if (gfx_bases[i].mach_subtype != -1 &&
    209  1.22.2.1        ad 		    gfx_bases[i].mach_subtype != mach_subtype)
    210  1.22.2.1        ad 			continue;
    211  1.22.2.1        ad 
    212  1.22.2.1        ad 		ga.ga_slot = -1;
    213  1.22.2.1        ad 		ga.ga_addr = gfx_bases[i].base;
    214  1.22.2.1        ad 		ga.ga_iot = SGIMIPS_BUS_SPACE_NORMAL;
    215  1.22.2.1        ad 		ga.ga_ioh = MIPS_PHYS_TO_KSEG1(ga.ga_addr);
    216      1.22    rumble 		ga.ga_dmat = &sgimips_default_bus_dma_tag;
    217  1.22.2.1        ad 		ga.ga_product = -1;
    218  1.22.2.1        ad 
    219  1.22.2.1        ad 		if (platform.badaddr((void *)ga.ga_ioh, sizeof(uint32_t)))
    220  1.22.2.1        ad 			continue;
    221      1.12  lonewolf 
    222  1.22.2.1        ad 		if (config_found_sm_loc(self, "gio", NULL, &ga, gio_print,
    223  1.22.2.1        ad 		    gio_submatch)) {
    224  1.22.2.1        ad 			if (ngfx == MAXGFX)
    225  1.22.2.1        ad 				panic("gio_attach: MAXGFX");
    226  1.22.2.1        ad 			gfx[ngfx++] = gfx_bases[i].base;
    227  1.22.2.1        ad 		}
    228  1.22.2.1        ad 	}
    229  1.22.2.1        ad 
    230  1.22.2.1        ad 	/*
    231  1.22.2.1        ad 	 * Now attach any GIO expansion cards.
    232  1.22.2.1        ad 	 *
    233  1.22.2.1        ad 	 * Be sure to skip any addresses to which a graphics device has
    234  1.22.2.1        ad 	 * already been attached.
    235  1.22.2.1        ad 	 */
    236  1.22.2.1        ad 	for (i = 0; slot_bases[i].base != 0; i++) {
    237  1.22.2.1        ad 		boolean_t skip = FALSE;
    238  1.22.2.1        ad 
    239  1.22.2.1        ad 		/* skip slots that don't apply to us */
    240  1.22.2.1        ad 		if (slot_bases[i].mach_type != mach_type)
    241  1.22.2.1        ad 			continue;
    242  1.22.2.1        ad 
    243  1.22.2.1        ad 		if (slot_bases[i].mach_subtype != -1 &&
    244  1.22.2.1        ad 		    slot_bases[i].mach_subtype != mach_subtype)
    245      1.12  lonewolf 			continue;
    246  1.22.2.1        ad 
    247  1.22.2.1        ad 		for (j = 0; j < ngfx; j++) {
    248  1.22.2.1        ad 			if (slot_bases[i].base == gfx[j]) {
    249  1.22.2.1        ad 				skip = TRUE;
    250  1.22.2.1        ad 				break;
    251  1.22.2.1        ad 			}
    252  1.22.2.1        ad 		}
    253  1.22.2.1        ad 		if (skip)
    254  1.22.2.1        ad 			continue;
    255  1.22.2.1        ad 
    256  1.22.2.1        ad 		ga.ga_slot = slot_bases[i].slot;
    257  1.22.2.1        ad 		ga.ga_addr = slot_bases[i].base;
    258  1.22.2.1        ad 		ga.ga_iot = SGIMIPS_BUS_SPACE_NORMAL;
    259  1.22.2.1        ad 		ga.ga_ioh = MIPS_PHYS_TO_KSEG1(ga.ga_addr);
    260  1.22.2.1        ad 		ga.ga_dmat = &sgimips_default_bus_dma_tag;
    261  1.22.2.1        ad 
    262  1.22.2.1        ad 		if (platform.badaddr((void *)ga.ga_ioh, sizeof(uint32_t)))
    263      1.12  lonewolf 			continue;
    264      1.12  lonewolf 
    265      1.12  lonewolf 		ga.ga_product = bus_space_read_4(ga.ga_iot, ga.ga_ioh, 0);
    266      1.12  lonewolf 
    267      1.18  drochner 		config_found_sm_loc(self, "gio", NULL, &ga, gio_print,
    268  1.22.2.1        ad 		    gio_submatch);
    269      1.12  lonewolf 	}
    270      1.12  lonewolf 
    271      1.19  drochner 	config_search_ia(gio_search, self, "gio", &ga);
    272       1.1     soren }
    273       1.1     soren 
    274       1.1     soren static int
    275      1.12  lonewolf gio_print(void *aux, const char *pnp)
    276       1.1     soren {
    277       1.1     soren 	struct gio_attach_args *ga = aux;
    278      1.13    sekiya 	int i = 0;
    279       1.1     soren 
    280  1.22.2.1        ad 	/* gfx probe */
    281  1.22.2.1        ad 	if (ga->ga_product == -1)
    282  1.22.2.1        ad 		return (QUIET);
    283  1.22.2.1        ad 
    284      1.12  lonewolf 	if (pnp != NULL) {
    285      1.12  lonewolf 	  	int product, revision;
    286      1.12  lonewolf 
    287      1.12  lonewolf 		product = GIO_PRODUCT_PRODUCTID(ga->ga_product);
    288      1.12  lonewolf 
    289      1.12  lonewolf 		if (GIO_PRODUCT_32BIT_ID(ga->ga_product))
    290      1.12  lonewolf 			revision = GIO_PRODUCT_REVISION(ga->ga_product);
    291      1.12  lonewolf 		else
    292      1.12  lonewolf 			revision = 0;
    293      1.12  lonewolf 
    294      1.13    sekiya 		while (gio_knowndevs[i].productid != 0) {
    295      1.13    sekiya 			if (gio_knowndevs[i].productid == product) {
    296      1.13    sekiya 				aprint_normal("%s", gio_knowndevs[i].product);
    297      1.13    sekiya 				break;
    298      1.13    sekiya 			}
    299      1.13    sekiya 			i++;
    300      1.13    sekiya 		}
    301      1.13    sekiya 
    302      1.13    sekiya 		if (gio_knowndevs[i].productid == 0)
    303      1.13    sekiya 			aprint_normal("unknown GIO card");
    304      1.13    sekiya 
    305      1.13    sekiya 		aprint_normal(" (product 0x%02x revision 0x%02x) at %s",
    306      1.12  lonewolf 		    product, revision, pnp);
    307      1.12  lonewolf 	}
    308       1.1     soren 
    309       1.1     soren 	if (ga->ga_slot != GIOCF_SLOT_DEFAULT)
    310       1.9   thorpej 		aprint_normal(" slot %d", ga->ga_slot);
    311       1.8   thorpej 	if (ga->ga_addr != (uint32_t) GIOCF_ADDR_DEFAULT)
    312       1.9   thorpej 		aprint_normal(" addr 0x%x", ga->ga_addr);
    313       1.1     soren 
    314       1.1     soren 	return UNCONF;
    315       1.1     soren }
    316       1.1     soren 
    317       1.1     soren static int
    318      1.19  drochner gio_search(struct device *parent, struct cfdata *cf,
    319      1.20  drochner 	   const int *ldesc, void *aux)
    320       1.2    simonb {
    321       1.1     soren 	struct gio_attach_args *ga = aux;
    322       1.1     soren 
    323       1.1     soren 	do {
    324      1.12  lonewolf 		/* Handled by direct configuration, so skip here */
    325      1.12  lonewolf 		if (cf->cf_loc[GIOCF_ADDR] == GIOCF_ADDR_DEFAULT)
    326      1.12  lonewolf 			return 0;
    327      1.12  lonewolf 
    328       1.1     soren 		ga->ga_slot = cf->cf_loc[GIOCF_SLOT];
    329       1.1     soren 		ga->ga_addr = cf->cf_loc[GIOCF_ADDR];
    330       1.1     soren 		ga->ga_iot = 0;
    331       1.1     soren 		ga->ga_ioh = MIPS_PHYS_TO_KSEG1(ga->ga_addr);
    332      1.12  lonewolf 
    333       1.4   thorpej 		if (config_match(parent, cf, ga) > 0)
    334       1.1     soren 			config_attach(parent, cf, ga, gio_print);
    335       1.1     soren 	} while (cf->cf_fstate == FSTATE_STAR);
    336       1.1     soren 
    337       1.1     soren 	return 0;
    338      1.12  lonewolf }
    339      1.12  lonewolf 
    340      1.12  lonewolf static int
    341      1.18  drochner gio_submatch(struct device *parent, struct cfdata *cf,
    342      1.20  drochner 	     const int *ldesc, void *aux)
    343      1.12  lonewolf {
    344      1.12  lonewolf 	struct gio_attach_args *ga = aux;
    345      1.12  lonewolf 
    346      1.12  lonewolf 	if (cf->cf_loc[GIOCF_SLOT] != GIOCF_SLOT_DEFAULT &&
    347      1.12  lonewolf 	    cf->cf_loc[GIOCF_SLOT] != ga->ga_slot)
    348      1.12  lonewolf 		return 0;
    349      1.12  lonewolf 
    350      1.12  lonewolf 	if (cf->cf_loc[GIOCF_ADDR] != GIOCF_ADDR_DEFAULT &&
    351      1.12  lonewolf 	    cf->cf_loc[GIOCF_ADDR] != ga->ga_addr)
    352      1.12  lonewolf 		return 0;
    353      1.12  lonewolf 
    354      1.12  lonewolf 	return config_match(parent, cf, aux);
    355      1.12  lonewolf }
    356      1.12  lonewolf 
    357      1.12  lonewolf int
    358      1.12  lonewolf gio_cnattach()
    359      1.12  lonewolf {
    360      1.12  lonewolf 	struct gio_attach_args ga;
    361      1.12  lonewolf 	int i;
    362  1.22.2.1        ad 
    363  1.22.2.1        ad 	for (i = 0; gfx_bases[i].base != 0; i++) {
    364  1.22.2.1        ad 		/* skip bases that don't apply to us */
    365  1.22.2.1        ad 		if (gfx_bases[i].mach_type != mach_type)
    366      1.12  lonewolf 			continue;
    367      1.12  lonewolf 
    368  1.22.2.1        ad 		if (gfx_bases[i].mach_subtype != -1 &&
    369  1.22.2.1        ad 		    gfx_bases[i].mach_subtype != mach_subtype)
    370      1.12  lonewolf 			continue;
    371      1.12  lonewolf 
    372  1.22.2.1        ad 		ga.ga_slot = -1;
    373  1.22.2.1        ad 		ga.ga_addr = gfx_bases[i].base;
    374  1.22.2.1        ad 		ga.ga_iot = SGIMIPS_BUS_SPACE_NORMAL;
    375  1.22.2.1        ad 		ga.ga_ioh = MIPS_PHYS_TO_KSEG1(ga.ga_addr);
    376  1.22.2.1        ad 		ga.ga_dmat = &sgimips_default_bus_dma_tag;
    377  1.22.2.1        ad 		ga.ga_product = -1;
    378  1.22.2.1        ad 
    379  1.22.2.1        ad 		if (platform.badaddr((void *)ga.ga_ioh,sizeof(uint32_t)))
    380  1.22.2.1        ad 			continue;
    381      1.12  lonewolf 
    382      1.15    sekiya #if (NGRTWO > 0)
    383      1.15    sekiya 		if (grtwo_cnattach(&ga) == 0)
    384      1.15    sekiya 			return 0;
    385      1.15    sekiya #endif
    386      1.15    sekiya 
    387  1.22.2.1        ad #if (NLIGHT > 0)
    388  1.22.2.1        ad 		if (light_cnattach(&ga) == 0)
    389  1.22.2.1        ad 			return 0;
    390  1.22.2.1        ad #endif
    391  1.22.2.1        ad 
    392      1.12  lonewolf #if (NNEWPORT > 0)
    393      1.12  lonewolf 		if (newport_cnattach(&ga) == 0)
    394      1.12  lonewolf 			return 0;
    395      1.12  lonewolf #endif
    396      1.15    sekiya 
    397      1.12  lonewolf 	}
    398      1.12  lonewolf 
    399      1.12  lonewolf 	return ENXIO;
    400       1.1     soren }
    401      1.22    rumble 
    402      1.22    rumble /*
    403      1.22    rumble  * Devices living in the expansion slots must enable or disable some
    404      1.22    rumble  * GIO arbiter settings. This is accomplished via imc(4) or pic(4)
    405      1.22    rumble  * registers, depending on the machine in question.
    406      1.22    rumble  */
    407      1.22    rumble int
    408      1.22    rumble gio_arb_config(int slot, uint32_t flags)
    409      1.22    rumble {
    410      1.22    rumble 
    411      1.22    rumble 	if (flags == 0)
    412      1.22    rumble 		return (EINVAL);
    413      1.22    rumble 
    414      1.22    rumble 	if (flags & ~(GIO_ARB_RT | GIO_ARB_LB | GIO_ARB_MST | GIO_ARB_SLV |
    415      1.22    rumble 	    GIO_ARB_PIPE | GIO_ARB_NOPIPE))
    416      1.22    rumble 		return (EINVAL);
    417      1.22    rumble 
    418      1.22    rumble 	if (((flags & GIO_ARB_RT)   && (flags & GIO_ARB_LB))  ||
    419      1.22    rumble 	    ((flags & GIO_ARB_MST)  && (flags & GIO_ARB_SLV)) ||
    420      1.22    rumble 	    ((flags & GIO_ARB_PIPE) && (flags & GIO_ARB_NOPIPE)))
    421      1.22    rumble 		return (EINVAL);
    422      1.22    rumble 
    423      1.22    rumble #if (NPIC > 0)
    424      1.22    rumble 	if (mach_type == MACH_SGI_IP12)
    425      1.22    rumble 		return (pic_gio32_arb_config(slot, flags));
    426      1.22    rumble #endif
    427      1.22    rumble 
    428      1.22    rumble #if (NIMC > 0)
    429      1.22    rumble 	if (mach_type == MACH_SGI_IP20 || mach_type == MACH_SGI_IP22)
    430      1.22    rumble 		return (imc_gio64_arb_config(slot, flags));
    431      1.22    rumble #endif
    432      1.22    rumble 
    433      1.22    rumble 	return (EINVAL);
    434      1.22    rumble }
    435      1.22    rumble 
    436      1.22    rumble /*
    437      1.22    rumble  * Establish an interrupt handler for the specified slot.
    438  1.22.2.1        ad  *
    439  1.22.2.1        ad  * Indy and Challenge S have an interrupt per GIO slot. Indigo and Indigo2
    440  1.22.2.1        ad  * share a single interrupt, however.
    441      1.22    rumble  */
    442      1.22    rumble void *
    443      1.22    rumble gio_intr_establish(int slot, int level, int (*func)(void *), void *arg)
    444      1.22    rumble {
    445      1.22    rumble 	int intr;
    446      1.22    rumble 
    447      1.22    rumble 	switch (mach_type) {
    448      1.22    rumble 	case MACH_SGI_IP12:
    449      1.22    rumble 	case MACH_SGI_IP20:
    450      1.22    rumble 		if (slot == GIO_SLOT_GFX)
    451      1.22    rumble 			panic("gio_intr_establish: slot %d", slot);
    452  1.22.2.1        ad 		intr = 6;
    453      1.22    rumble 		break;
    454      1.22    rumble 
    455      1.22    rumble 	case MACH_SGI_IP22:
    456      1.22    rumble 		if (mach_subtype == MACH_SGI_IP22_FULLHOUSE) {
    457      1.22    rumble 			if (slot == GIO_SLOT_EXP1)
    458      1.22    rumble 				panic("gio_intr_establish: slot %d", slot);
    459  1.22.2.1        ad 			intr = 6;
    460      1.22    rumble 		} else {
    461      1.22    rumble 			if (slot == GIO_SLOT_GFX)
    462      1.22    rumble 				panic("gio_intr_establish: slot %d", slot);
    463      1.22    rumble 			intr = (slot == GIO_SLOT_EXP0) ? 22 : 23;
    464      1.22    rumble 		}
    465      1.22    rumble 		break;
    466      1.22    rumble 
    467      1.22    rumble 	default:
    468      1.22    rumble 		panic("gio_intr_establish: mach_type");
    469      1.22    rumble 	}
    470      1.22    rumble 
    471      1.22    rumble 	return (cpu_intr_establish(intr, level, func, arg));
    472      1.22    rumble }
    473      1.22    rumble 
    474      1.22    rumble const char *
    475      1.22    rumble gio_product_string(int prid)
    476      1.22    rumble {
    477      1.22    rumble 	int i;
    478      1.22    rumble 
    479      1.22    rumble 	for (i = 0; gio_knowndevs[i].product != NULL; i++)
    480      1.22    rumble 		if (gio_knowndevs[i].productid == prid)
    481      1.22    rumble 			return (gio_knowndevs[i].product);
    482      1.22    rumble 
    483      1.22    rumble 	return (NULL);
    484      1.22    rumble }
    485