Home | History | Annotate | Line # | Download | only in dev
imc.c revision 1.2
      1  1.2  thorpej /*	$NetBSD: imc.c,v 1.2 2001/07/08 23:59:31 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*
      4  1.1  thorpej  * Copyright (c) 2001 Rafal K. Boni
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
      8  1.1  thorpej  * modification, are permitted provided that the following conditions
      9  1.1  thorpej  * are met:
     10  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     11  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     12  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     15  1.1  thorpej  * 3. The name of the author may not be used to endorse or promote products
     16  1.1  thorpej  *    derived from this software without specific prior written permission.
     17  1.1  thorpej  *
     18  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  1.1  thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  1.1  thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  1.1  thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  1.1  thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23  1.1  thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  1.1  thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  1.1  thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  1.1  thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  1.1  thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.1  thorpej  */
     29  1.1  thorpej 
     30  1.1  thorpej #include <sys/param.h>
     31  1.1  thorpej #include <sys/device.h>
     32  1.1  thorpej #include <sys/systm.h>
     33  1.1  thorpej 
     34  1.1  thorpej #include <machine/cpu.h>
     35  1.1  thorpej #include <machine/locore.h>
     36  1.1  thorpej #include <machine/autoconf.h>
     37  1.1  thorpej #include <machine/bus.h>
     38  1.2  thorpej #include <machine/machtype.h>
     39  1.1  thorpej 
     40  1.1  thorpej #include "locators.h"
     41  1.1  thorpej 
     42  1.1  thorpej struct imc_softc {
     43  1.1  thorpej 	struct device sc_dev;
     44  1.1  thorpej 
     45  1.1  thorpej 	int eisa_present : 1;
     46  1.1  thorpej };
     47  1.1  thorpej 
     48  1.1  thorpej static int	imc_match(struct device *, struct cfdata *, void *);
     49  1.1  thorpej static void	imc_attach(struct device *, struct device *, void *);
     50  1.1  thorpej static int	imc_print(void *, const char *);
     51  1.1  thorpej 
     52  1.1  thorpej struct cfattach imc_ca = {
     53  1.1  thorpej 	sizeof(struct imc_softc), imc_match, imc_attach
     54  1.1  thorpej };
     55  1.1  thorpej 
     56  1.1  thorpej struct imc_attach_args {
     57  1.1  thorpej 	const char* iaa_name;
     58  1.1  thorpej 
     59  1.1  thorpej 	bus_space_tag_t iaa_st;
     60  1.1  thorpej 	bus_space_handle_t iaa_sh;
     61  1.1  thorpej 
     62  1.1  thorpej /* ? */
     63  1.1  thorpej         long	iaa_offset;
     64  1.1  thorpej         int	iaa_intr;
     65  1.1  thorpej #if 0
     66  1.1  thorpej         int	iaa_stride;
     67  1.1  thorpej #endif
     68  1.1  thorpej };
     69  1.1  thorpej 
     70  1.1  thorpej static int
     71  1.1  thorpej imc_match(parent, match, aux)
     72  1.1  thorpej 	struct device *parent;
     73  1.1  thorpej 	struct cfdata *match;
     74  1.1  thorpej 	void *aux;
     75  1.1  thorpej {
     76  1.1  thorpej 
     77  1.1  thorpej 	/*
     78  1.1  thorpej 	 * The IMC is an INDY/INDIGO2 thing.
     79  1.1  thorpej 	 */
     80  1.2  thorpej 	if (mach_type != MACH_SGI_IP22)
     81  1.2  thorpej 		return (0);
     82  1.2  thorpej 
     83  1.2  thorpej 	/* Make sure it's actually there and readable */
     84  1.2  thorpej 	if (badaddr((void*)MIPS_PHYS_TO_KSEG1(0x1fa0001c), sizeof(u_int32_t)))
     85  1.2  thorpej 		return (0);
     86  1.2  thorpej 
     87  1.2  thorpej 	return (1);
     88  1.1  thorpej }
     89  1.1  thorpej 
     90  1.1  thorpej static void
     91  1.1  thorpej imc_attach(parent, self, aux)
     92  1.1  thorpej 	struct device *parent;
     93  1.1  thorpej 	struct device *self;
     94  1.1  thorpej 	void *aux;
     95  1.1  thorpej {
     96  1.1  thorpej 	u_int32_t reg;
     97  1.1  thorpej 	struct imc_attach_args iaa;
     98  1.1  thorpej 	struct imc_softc *isc = (void *) self;
     99  1.1  thorpej         u_int32_t sysid = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0001c);
    100  1.1  thorpej 
    101  1.1  thorpej 	isc->eisa_present = (sysid >> 4) & 1;
    102  1.1  thorpej 
    103  1.1  thorpej 	printf("\nimc0: Revision %d", (sysid & 0x03));
    104  1.1  thorpej 
    105  1.1  thorpej 	if (isc->eisa_present)
    106  1.1  thorpej 	    printf(", EISA bus present");
    107  1.1  thorpej 
    108  1.1  thorpej 	printf("\n");
    109  1.1  thorpej 
    110  1.1  thorpej 	/* Clear CPU/GIO error status registers to clear any leftover bits. */
    111  1.1  thorpej 	*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa000ec) = 0;
    112  1.1  thorpej 	*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa000fc) = 0;
    113  1.1  thorpej 
    114  1.1  thorpej 	/*
    115  1.1  thorpej 	 * Enable parity reporting on memory/GIO accesses, turn off parity
    116  1.1  thorpej 	 * checking on CPU reads from memory (flags cribbed from Linux --
    117  1.1  thorpej 	 * why is the last one off?).  Also, enable MC interrupt writes to
    118  1.1  thorpej 	 * the CPU.
    119  1.1  thorpej 	 */
    120  1.1  thorpej 	reg = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00004);
    121  1.1  thorpej 	reg |= 0x4002060;
    122  1.1  thorpej 	*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00004) = reg;
    123  1.1  thorpej 
    124  1.1  thorpej 	/* Setup the MC write buffer depth */
    125  1.1  thorpej 	reg = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0000c);
    126  1.1  thorpej 	reg &= ~0xf;
    127  1.1  thorpej 	reg |= 0xd;
    128  1.1  thorpej 	*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0000c) = reg;
    129  1.1  thorpej 
    130  1.1  thorpej 	/* Set GIO64 arbitrator configuration register. */
    131  1.1  thorpej 
    132  1.1  thorpej 	/* GIO64 invariant for all IP22 platforms: one GIO bus, HPC1 @ 64 */
    133  1.1  thorpej 	reg = 0x401;
    134  1.1  thorpej 
    135  1.1  thorpej 	/* XXXrkb: I2 setting for now */
    136  1.1  thorpej 	reg |= 0xc222;	/* GFX, HPC2 @ 64, EXP1,2 pipelined, EISA masters */
    137  1.1  thorpej 	*(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00084) = reg;
    138  1.1  thorpej 
    139  1.1  thorpej 	if (isc->eisa_present) {
    140  1.1  thorpej #if notyet
    141  1.1  thorpej 	    memset(&iaa, 0, sizeof(iaa));
    142  1.1  thorpej 
    143  1.1  thorpej 	    iaa.iaa_name = "eisa";
    144  1.1  thorpej 	    (void)config_found(self, (void*)&iaa, imc_print);
    145  1.1  thorpej #endif
    146  1.1  thorpej 	}
    147  1.1  thorpej 
    148  1.1  thorpej 	memset(&iaa, 0, sizeof(iaa));
    149  1.1  thorpej 
    150  1.1  thorpej 	iaa.iaa_name = "gio";
    151  1.1  thorpej 	(void)config_found(self, (void*)&iaa, imc_print);
    152  1.1  thorpej }
    153  1.1  thorpej 
    154  1.1  thorpej 
    155  1.1  thorpej static int
    156  1.1  thorpej imc_print(aux, name)
    157  1.1  thorpej 	void *aux;
    158  1.1  thorpej 	const char *name;
    159  1.1  thorpej {
    160  1.1  thorpej 	struct imc_attach_args* iaa = aux;
    161  1.1  thorpej 
    162  1.1  thorpej 	if (name)
    163  1.1  thorpej 		printf("%s at %s", iaa->iaa_name, name);
    164  1.1  thorpej 
    165  1.1  thorpej 	return UNCONF;
    166  1.1  thorpej }
    167  1.1  thorpej 
    168