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