Home | History | Annotate | Line # | Download | only in pci
mcpcia.c revision 1.12.4.2
      1  1.12.4.2  nathanw /* $NetBSD: mcpcia.c,v 1.12.4.2 2002/06/20 03:37:43 nathanw Exp $ */
      2  1.12.4.2  nathanw 
      3  1.12.4.2  nathanw /*-
      4  1.12.4.2  nathanw  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.12.4.2  nathanw  * All rights reserved.
      6  1.12.4.2  nathanw  *
      7  1.12.4.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.12.4.2  nathanw  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.12.4.2  nathanw  * NASA Ames Research Center.
     10  1.12.4.2  nathanw  *
     11  1.12.4.2  nathanw  * Redistribution and use in source and binary forms, with or without
     12  1.12.4.2  nathanw  * modification, are permitted provided that the following conditions
     13  1.12.4.2  nathanw  * are met:
     14  1.12.4.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     15  1.12.4.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     16  1.12.4.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.12.4.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     18  1.12.4.2  nathanw  *    documentation and/or other materials provided with the distribution.
     19  1.12.4.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     20  1.12.4.2  nathanw  *    must display the following acknowledgement:
     21  1.12.4.2  nathanw  *	This product includes software developed by the NetBSD
     22  1.12.4.2  nathanw  *	Foundation, Inc. and its contributors.
     23  1.12.4.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.12.4.2  nathanw  *    contributors may be used to endorse or promote products derived
     25  1.12.4.2  nathanw  *    from this software without specific prior written permission.
     26  1.12.4.2  nathanw  *
     27  1.12.4.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.12.4.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.12.4.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.12.4.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.12.4.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.12.4.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.12.4.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.12.4.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.12.4.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.12.4.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.12.4.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     38  1.12.4.2  nathanw  */
     39  1.12.4.2  nathanw 
     40  1.12.4.2  nathanw /*
     41  1.12.4.2  nathanw  * Copyright (c) 1998 by Matthew Jacob
     42  1.12.4.2  nathanw  * NASA AMES Research Center.
     43  1.12.4.2  nathanw  * All rights reserved.
     44  1.12.4.2  nathanw  *
     45  1.12.4.2  nathanw  * Redistribution and use in source and binary forms, with or without
     46  1.12.4.2  nathanw  * modification, are permitted provided that the following conditions
     47  1.12.4.2  nathanw  * are met:
     48  1.12.4.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     49  1.12.4.2  nathanw  *    notice immediately at the beginning of the file, without modification,
     50  1.12.4.2  nathanw  *    this list of conditions, and the following disclaimer.
     51  1.12.4.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     52  1.12.4.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     53  1.12.4.2  nathanw  *    documentation and/or other materials provided with the distribution.
     54  1.12.4.2  nathanw  * 3. The name of the author may not be used to endorse or promote products
     55  1.12.4.2  nathanw  *    derived from this software without specific prior written permission.
     56  1.12.4.2  nathanw  *
     57  1.12.4.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     58  1.12.4.2  nathanw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     59  1.12.4.2  nathanw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     60  1.12.4.2  nathanw  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     61  1.12.4.2  nathanw  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     62  1.12.4.2  nathanw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     63  1.12.4.2  nathanw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     64  1.12.4.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     65  1.12.4.2  nathanw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     66  1.12.4.2  nathanw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     67  1.12.4.2  nathanw  * SUCH DAMAGE.
     68  1.12.4.2  nathanw  */
     69  1.12.4.2  nathanw 
     70  1.12.4.2  nathanw /*
     71  1.12.4.2  nathanw  * MCPCIA mcbus to PCI bus adapter
     72  1.12.4.2  nathanw  * found on AlphaServer 4100 systems.
     73  1.12.4.2  nathanw  */
     74  1.12.4.2  nathanw 
     75  1.12.4.2  nathanw #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     76  1.12.4.2  nathanw 
     77  1.12.4.2  nathanw __KERNEL_RCSID(0, "$NetBSD: mcpcia.c,v 1.12.4.2 2002/06/20 03:37:43 nathanw Exp $");
     78  1.12.4.2  nathanw 
     79  1.12.4.2  nathanw #include <sys/param.h>
     80  1.12.4.2  nathanw #include <sys/systm.h>
     81  1.12.4.2  nathanw #include <sys/device.h>
     82  1.12.4.2  nathanw #include <sys/malloc.h>
     83  1.12.4.2  nathanw 
     84  1.12.4.2  nathanw #include <machine/autoconf.h>
     85  1.12.4.2  nathanw #include <machine/rpb.h>
     86  1.12.4.2  nathanw #include <machine/sysarch.h>
     87  1.12.4.2  nathanw 
     88  1.12.4.2  nathanw #include <alpha/mcbus/mcbusreg.h>
     89  1.12.4.2  nathanw #include <alpha/mcbus/mcbusvar.h>
     90  1.12.4.2  nathanw #include <alpha/pci/mcpciareg.h>
     91  1.12.4.2  nathanw #include <alpha/pci/mcpciavar.h>
     92  1.12.4.2  nathanw #include <alpha/pci/pci_kn300.h>
     93  1.12.4.2  nathanw 
     94  1.12.4.2  nathanw #define KV(_addr)	((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr)))
     95  1.12.4.2  nathanw #define	MCPCIA_SYSBASE(mc)	\
     96  1.12.4.2  nathanw 	((((unsigned long) (mc)->cc_gid) << MCBUS_GID_SHIFT) | \
     97  1.12.4.2  nathanw 	 (((unsigned long) (mc)->cc_mid) << MCBUS_MID_SHIFT) | \
     98  1.12.4.2  nathanw 	 (MCBUS_IOSPACE))
     99  1.12.4.2  nathanw 
    100  1.12.4.2  nathanw #define	MCPCIA_PROBE(mid, gid)	\
    101  1.12.4.2  nathanw 	badaddr((void *)KV(((((unsigned long) gid) << MCBUS_GID_SHIFT) | \
    102  1.12.4.2  nathanw 	 (((unsigned long) mid) << MCBUS_MID_SHIFT) | \
    103  1.12.4.2  nathanw 	 (MCBUS_IOSPACE) | MCPCIA_PCI_BRIDGE | _MCPCIA_PCI_REV)), \
    104  1.12.4.2  nathanw 	sizeof(u_int32_t))
    105  1.12.4.2  nathanw 
    106  1.12.4.2  nathanw static int	mcpciamatch __P((struct device *, struct cfdata *, void *));
    107  1.12.4.2  nathanw static void	mcpciaattach __P((struct device *, struct device *, void *));
    108  1.12.4.2  nathanw struct cfattach mcpcia_ca = {
    109  1.12.4.2  nathanw 	sizeof(struct mcpcia_softc), mcpciamatch, mcpciaattach
    110  1.12.4.2  nathanw };
    111  1.12.4.2  nathanw 
    112  1.12.4.2  nathanw static int	mcpciaprint __P((void *, const char *));
    113  1.12.4.2  nathanw 
    114  1.12.4.2  nathanw void	mcpcia_init0 __P((struct mcpcia_config *, int));
    115  1.12.4.2  nathanw 
    116  1.12.4.2  nathanw /*
    117  1.12.4.2  nathanw  * We have one statically-allocated mcpcia_config structure; this is
    118  1.12.4.2  nathanw  * the one used for the console (which, coincidentally, is the only
    119  1.12.4.2  nathanw  * MCPCIA with an EISA adapter attached to it).
    120  1.12.4.2  nathanw  */
    121  1.12.4.2  nathanw struct mcpcia_config mcpcia_console_configuration;
    122  1.12.4.2  nathanw 
    123  1.12.4.2  nathanw int	mcpcia_bus_get_window __P((int, int,
    124  1.12.4.2  nathanw 	    struct alpha_bus_space_translation *abst));
    125  1.12.4.2  nathanw 
    126  1.12.4.2  nathanw static int
    127  1.12.4.2  nathanw mcpciaprint(aux, pnp)
    128  1.12.4.2  nathanw 	void *aux;
    129  1.12.4.2  nathanw 	const char *pnp;
    130  1.12.4.2  nathanw {
    131  1.12.4.2  nathanw 	register struct pcibus_attach_args *pba = aux;
    132  1.12.4.2  nathanw 	/* only PCIs can attach to MCPCIA for now */
    133  1.12.4.2  nathanw 	if (pnp)
    134  1.12.4.2  nathanw 		printf("%s at %s", pba->pba_busname, pnp);
    135  1.12.4.2  nathanw 	printf(" bus %d", pba->pba_bus);
    136  1.12.4.2  nathanw 	return (UNCONF);
    137  1.12.4.2  nathanw }
    138  1.12.4.2  nathanw 
    139  1.12.4.2  nathanw static int
    140  1.12.4.2  nathanw mcpciamatch(parent, cf, aux)
    141  1.12.4.2  nathanw 	struct device *parent;
    142  1.12.4.2  nathanw 	struct cfdata *cf;
    143  1.12.4.2  nathanw 	void *aux;
    144  1.12.4.2  nathanw {
    145  1.12.4.2  nathanw 	struct mcbus_dev_attach_args *ma = aux;
    146  1.12.4.2  nathanw 	if (ma->ma_type == MCBUS_TYPE_PCI)
    147  1.12.4.2  nathanw 		return (1);
    148  1.12.4.2  nathanw 	return (0);
    149  1.12.4.2  nathanw }
    150  1.12.4.2  nathanw 
    151  1.12.4.2  nathanw static void
    152  1.12.4.2  nathanw mcpciaattach(parent, self, aux)
    153  1.12.4.2  nathanw 	struct device *parent;
    154  1.12.4.2  nathanw 	struct device *self;
    155  1.12.4.2  nathanw 	void *aux;
    156  1.12.4.2  nathanw {
    157  1.12.4.2  nathanw 	static int first = 1;
    158  1.12.4.2  nathanw 	struct mcbus_dev_attach_args *ma = aux;
    159  1.12.4.2  nathanw 	struct mcpcia_softc *mcp = (struct mcpcia_softc *)self;
    160  1.12.4.2  nathanw 	struct mcpcia_config *ccp;
    161  1.12.4.2  nathanw 	struct pcibus_attach_args pba;
    162  1.12.4.2  nathanw 	u_int32_t ctl;
    163  1.12.4.2  nathanw 
    164  1.12.4.2  nathanw 	/*
    165  1.12.4.2  nathanw 	 * Make sure this MCPCIA exists...
    166  1.12.4.2  nathanw 	 */
    167  1.12.4.2  nathanw 	if (MCPCIA_PROBE(ma->ma_mid, ma->ma_gid)) {
    168  1.12.4.2  nathanw 		mcp->mcpcia_cc = NULL;
    169  1.12.4.2  nathanw 		printf(" (not present)\n");
    170  1.12.4.2  nathanw 		return;
    171  1.12.4.2  nathanw 	}
    172  1.12.4.2  nathanw 	printf("\n");
    173  1.12.4.2  nathanw 
    174  1.12.4.2  nathanw 	/*
    175  1.12.4.2  nathanw 	 * Determine if we're the console's MCPCIA.
    176  1.12.4.2  nathanw 	 */
    177  1.12.4.2  nathanw 	if (ma->ma_mid == mcpcia_console_configuration.cc_mid &&
    178  1.12.4.2  nathanw 	    ma->ma_gid == mcpcia_console_configuration.cc_gid)
    179  1.12.4.2  nathanw 		ccp = &mcpcia_console_configuration;
    180  1.12.4.2  nathanw 	else {
    181  1.12.4.2  nathanw 		ccp = malloc(sizeof(struct mcpcia_config), M_DEVBUF, M_WAITOK);
    182  1.12.4.2  nathanw 		memset(ccp, 0, sizeof(struct mcpcia_config));
    183  1.12.4.2  nathanw 
    184  1.12.4.2  nathanw 		ccp->cc_mid = ma->ma_mid;
    185  1.12.4.2  nathanw 		ccp->cc_gid = ma->ma_gid;
    186  1.12.4.2  nathanw 	}
    187  1.12.4.2  nathanw 
    188  1.12.4.2  nathanw 	mcp->mcpcia_cc = ccp;
    189  1.12.4.2  nathanw 	ccp->cc_sc = mcp;
    190  1.12.4.2  nathanw 
    191  1.12.4.2  nathanw 	/* This initializes cc_sysbase so we can do register access. */
    192  1.12.4.2  nathanw 	mcpcia_init0(ccp, 1);
    193  1.12.4.2  nathanw 
    194  1.12.4.2  nathanw 	ctl = REGVAL(MCPCIA_PCI_REV(ccp));
    195  1.12.4.2  nathanw 	printf("%s: Horse Revision %d, %s Handed Saddle Revision %d,"
    196  1.12.4.2  nathanw 	    " CAP Revision %d\n", mcp->mcpcia_dev.dv_xname, HORSE_REV(ctl),
    197  1.12.4.2  nathanw 	    (SADDLE_TYPE(ctl) & 1)? "Right": "Left", SADDLE_REV(ctl),
    198  1.12.4.2  nathanw 	    CAP_REV(ctl));
    199  1.12.4.2  nathanw 
    200  1.12.4.2  nathanw 	mcpcia_dma_init(ccp);
    201  1.12.4.2  nathanw 
    202  1.12.4.2  nathanw 	/*
    203  1.12.4.2  nathanw 	 * Set up interrupts
    204  1.12.4.2  nathanw 	 */
    205  1.12.4.2  nathanw 	pci_kn300_pickintr(ccp, first);
    206  1.12.4.2  nathanw 	first = 0;
    207  1.12.4.2  nathanw 
    208  1.12.4.2  nathanw 	/*
    209  1.12.4.2  nathanw 	 * Attach PCI bus
    210  1.12.4.2  nathanw 	 */
    211  1.12.4.2  nathanw 	pba.pba_busname = "pci";
    212  1.12.4.2  nathanw 	pba.pba_iot = &ccp->cc_iot;
    213  1.12.4.2  nathanw 	pba.pba_memt = &ccp->cc_memt;
    214  1.12.4.2  nathanw 	pba.pba_dmat =	/* start with direct, may change... */
    215  1.12.4.2  nathanw 	    alphabus_dma_get_tag(&ccp->cc_dmat_direct, ALPHA_BUS_PCI);
    216  1.12.4.2  nathanw 	pba.pba_pc = &ccp->cc_pc;
    217  1.12.4.2  nathanw 	pba.pba_bus = 0;
    218  1.12.4.2  nathanw 	pba.pba_bridgetag = NULL;
    219  1.12.4.2  nathanw 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
    220  1.12.4.2  nathanw 	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
    221  1.12.4.2  nathanw 	(void) config_found(self, &pba, mcpciaprint);
    222  1.12.4.2  nathanw 
    223  1.12.4.2  nathanw 	/*
    224  1.12.4.2  nathanw 	 * Clear any errors that may have occurred during the probe
    225  1.12.4.2  nathanw 	 * sequence.
    226  1.12.4.2  nathanw 	 */
    227  1.12.4.2  nathanw 	REGVAL(MCPCIA_CAP_ERR(ccp)) = 0xFFFFFFFF;
    228  1.12.4.2  nathanw 	alpha_mb();
    229  1.12.4.2  nathanw }
    230  1.12.4.2  nathanw 
    231  1.12.4.2  nathanw void
    232  1.12.4.2  nathanw mcpcia_init()
    233  1.12.4.2  nathanw {
    234  1.12.4.2  nathanw 	struct mcpcia_config *ccp = &mcpcia_console_configuration;
    235  1.12.4.2  nathanw 	int i;
    236  1.12.4.2  nathanw 
    237  1.12.4.2  nathanw 	/*
    238  1.12.4.2  nathanw 	 * Look for all of the MCPCIAs on the system.  One of them
    239  1.12.4.2  nathanw 	 * will have an EISA attached to it.  This MCPCIA is the
    240  1.12.4.2  nathanw 	 * only one that can be used for the console.  Once we find
    241  1.12.4.2  nathanw 	 * that one, initialize it.
    242  1.12.4.2  nathanw 	 */
    243  1.12.4.2  nathanw 
    244  1.12.4.2  nathanw 	for (i = 0; i < MCPCIA_PER_MCBUS; i++) {
    245  1.12.4.2  nathanw 		ccp->cc_mid = mcbus_mcpcia_probe_order[i];
    246  1.12.4.2  nathanw 		/*
    247  1.12.4.2  nathanw 		 * XXX If we ever support more than one MCBUS, we'll
    248  1.12.4.2  nathanw 		 * XXX have to probe for them, and map them to unit
    249  1.12.4.2  nathanw 		 * XXX numbers.
    250  1.12.4.2  nathanw 		 */
    251  1.12.4.2  nathanw 		ccp->cc_gid = MCBUS_GID_FROM_INSTANCE(0);
    252  1.12.4.2  nathanw 		ccp->cc_sysbase = MCPCIA_SYSBASE(ccp);
    253  1.12.4.2  nathanw 
    254  1.12.4.2  nathanw 		if (badaddr((void *)ALPHA_PHYS_TO_K0SEG(MCPCIA_PCI_REV(ccp)),
    255  1.12.4.2  nathanw 		    sizeof(u_int32_t)))
    256  1.12.4.2  nathanw 			continue;
    257  1.12.4.2  nathanw 
    258  1.12.4.2  nathanw 		if (EISA_PRESENT(REGVAL(MCPCIA_PCI_REV(ccp)))) {
    259  1.12.4.2  nathanw 			mcpcia_init0(ccp, 0);
    260  1.12.4.2  nathanw 
    261  1.12.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 2;
    262  1.12.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 3;
    263  1.12.4.2  nathanw 
    264  1.12.4.2  nathanw 			alpha_bus_get_window = mcpcia_bus_get_window;
    265  1.12.4.2  nathanw 			return;
    266  1.12.4.2  nathanw 		}
    267  1.12.4.2  nathanw 	}
    268  1.12.4.2  nathanw 
    269  1.12.4.2  nathanw 	panic("mcpcia_init: unable to find EISA bus");
    270  1.12.4.2  nathanw }
    271  1.12.4.2  nathanw 
    272  1.12.4.2  nathanw void
    273  1.12.4.2  nathanw mcpcia_init0(ccp, mallocsafe)
    274  1.12.4.2  nathanw 	struct mcpcia_config *ccp;
    275  1.12.4.2  nathanw 	int mallocsafe;
    276  1.12.4.2  nathanw {
    277  1.12.4.2  nathanw 	u_int32_t ctl;
    278  1.12.4.2  nathanw 
    279  1.12.4.2  nathanw 	if (ccp->cc_initted == 0) {
    280  1.12.4.2  nathanw 		/* don't do these twice since they set up extents */
    281  1.12.4.2  nathanw 		mcpcia_bus_io_init(&ccp->cc_iot, ccp);
    282  1.12.4.2  nathanw 		mcpcia_bus_mem_init(&ccp->cc_memt, ccp);
    283  1.12.4.2  nathanw 	}
    284  1.12.4.2  nathanw 	ccp->cc_mallocsafe = mallocsafe;
    285  1.12.4.2  nathanw 
    286  1.12.4.2  nathanw 	mcpcia_pci_init(&ccp->cc_pc, ccp);
    287  1.12.4.2  nathanw 
    288  1.12.4.2  nathanw 	/*
    289  1.12.4.2  nathanw 	 * Establish a precalculated base for convenience's sake.
    290  1.12.4.2  nathanw 	 */
    291  1.12.4.2  nathanw 	ccp->cc_sysbase = MCPCIA_SYSBASE(ccp);
    292  1.12.4.2  nathanw 
    293  1.12.4.2  nathanw 	/*
    294  1.12.4.2  nathanw  	 * Disable interrupts and clear errors prior to probing
    295  1.12.4.2  nathanw 	 */
    296  1.12.4.2  nathanw 	REGVAL(MCPCIA_INT_MASK0(ccp)) = 0;
    297  1.12.4.2  nathanw 	REGVAL(MCPCIA_INT_MASK1(ccp)) = 0;
    298  1.12.4.2  nathanw 	REGVAL(MCPCIA_CAP_ERR(ccp)) = 0xFFFFFFFF;
    299  1.12.4.2  nathanw 	alpha_mb();
    300  1.12.4.2  nathanw 
    301  1.12.4.2  nathanw 	if (ccp == &mcpcia_console_configuration) {
    302  1.12.4.2  nathanw 		/*
    303  1.12.4.2  nathanw 		 * Use this opportunity to also find out the MID and CPU
    304  1.12.4.2  nathanw 		 * type of the currently running CPU (that's us, billybob....)
    305  1.12.4.2  nathanw 		 */
    306  1.12.4.2  nathanw 		ctl = REGVAL(MCPCIA_WHOAMI(ccp));
    307  1.12.4.2  nathanw 		mcbus_primary.mcbus_cpu_mid = MCBUS_CPU_MID(ctl);
    308  1.12.4.2  nathanw 		if ((MCBUS_CPU_INFO(ctl) & CPU_Fill_Err) == 0 &&
    309  1.12.4.2  nathanw 		    mcbus_primary.mcbus_valid == 0) {
    310  1.12.4.2  nathanw 			mcbus_primary.mcbus_bcache =
    311  1.12.4.2  nathanw 			    MCBUS_CPU_INFO(ctl) & CPU_BCacheMask;
    312  1.12.4.2  nathanw 			mcbus_primary.mcbus_valid = 1;
    313  1.12.4.2  nathanw 		}
    314  1.12.4.2  nathanw 		alpha_mb();
    315  1.12.4.2  nathanw 	}
    316  1.12.4.2  nathanw 
    317  1.12.4.2  nathanw 	ccp->cc_initted = 1;
    318  1.12.4.2  nathanw }
    319  1.12.4.2  nathanw 
    320  1.12.4.2  nathanw #ifdef TEST_PROBE_DEATH
    321  1.12.4.2  nathanw static void
    322  1.12.4.2  nathanw die_heathen_dog(arg)
    323  1.12.4.2  nathanw 	void *arg;
    324  1.12.4.2  nathanw {
    325  1.12.4.2  nathanw 	struct mcpcia_config *ccp = arg;
    326  1.12.4.2  nathanw 
    327  1.12.4.2  nathanw 	/* this causes a fatal machine check (0x670) */
    328  1.12.4.2  nathanw 	REGVAL(MCPCIA_CAP_DIAG(ccp)) |= CAP_DIAG_MC_ADRPE;
    329  1.12.4.2  nathanw }
    330  1.12.4.2  nathanw #endif
    331  1.12.4.2  nathanw 
    332  1.12.4.2  nathanw void
    333  1.12.4.2  nathanw mcpcia_config_cleanup()
    334  1.12.4.2  nathanw {
    335  1.12.4.2  nathanw 	volatile u_int32_t ctl;
    336  1.12.4.2  nathanw 	struct mcpcia_softc *mcp;
    337  1.12.4.2  nathanw 	struct mcpcia_config *ccp;
    338  1.12.4.2  nathanw 	int i;
    339  1.12.4.2  nathanw 	extern struct cfdriver mcpcia_cd;
    340  1.12.4.2  nathanw 
    341  1.12.4.2  nathanw 	/*
    342  1.12.4.2  nathanw 	 * Turn on Hard, Soft error interrupts. Maybe i2c too.
    343  1.12.4.2  nathanw 	 */
    344  1.12.4.2  nathanw 	for (i = 0; i < mcpcia_cd.cd_ndevs; i++) {
    345  1.12.4.2  nathanw 		if ((mcp = mcpcia_cd.cd_devs[i]) == NULL)
    346  1.12.4.2  nathanw 			continue;
    347  1.12.4.2  nathanw 
    348  1.12.4.2  nathanw 		ccp = mcp->mcpcia_cc;
    349  1.12.4.2  nathanw 		if (ccp == NULL)
    350  1.12.4.2  nathanw 			continue;
    351  1.12.4.2  nathanw 
    352  1.12.4.2  nathanw 		ctl = REGVAL(MCPCIA_INT_MASK0(ccp));
    353  1.12.4.2  nathanw 		ctl |= MCPCIA_GEN_IENABL;
    354  1.12.4.2  nathanw 		REGVAL(MCPCIA_INT_MASK0(ccp)) = ctl;
    355  1.12.4.2  nathanw 		alpha_mb();
    356  1.12.4.2  nathanw 
    357  1.12.4.2  nathanw 		/* force stall while write completes */
    358  1.12.4.2  nathanw 		ctl = REGVAL(MCPCIA_INT_MASK0(ccp));
    359  1.12.4.2  nathanw 	}
    360  1.12.4.2  nathanw #ifdef TEST_PROBE_DEATH
    361  1.12.4.2  nathanw 	(void) timeout (die_heathen_dog, &mcpcia_console_configuration,
    362  1.12.4.2  nathanw 	    30 * hz);
    363  1.12.4.2  nathanw #endif
    364  1.12.4.2  nathanw }
    365  1.12.4.2  nathanw 
    366  1.12.4.2  nathanw int
    367  1.12.4.2  nathanw mcpcia_bus_get_window(type, window, abst)
    368  1.12.4.2  nathanw 	int type, window;
    369  1.12.4.2  nathanw 	struct alpha_bus_space_translation *abst;
    370  1.12.4.2  nathanw {
    371  1.12.4.2  nathanw 	struct mcpcia_config *ccp = &mcpcia_console_configuration;
    372  1.12.4.2  nathanw 	bus_space_tag_t st;
    373  1.12.4.2  nathanw 
    374  1.12.4.2  nathanw 	switch (type) {
    375  1.12.4.2  nathanw 	case ALPHA_BUS_TYPE_PCI_IO:
    376  1.12.4.2  nathanw 		st = &ccp->cc_iot;
    377  1.12.4.2  nathanw 		break;
    378  1.12.4.2  nathanw 
    379  1.12.4.2  nathanw 	case ALPHA_BUS_TYPE_PCI_MEM:
    380  1.12.4.2  nathanw 		st = &ccp->cc_memt;
    381  1.12.4.2  nathanw 		break;
    382  1.12.4.2  nathanw 
    383  1.12.4.2  nathanw 	default:
    384  1.12.4.2  nathanw 		panic("mcpcia_bus_get_window");
    385  1.12.4.2  nathanw 	}
    386  1.12.4.2  nathanw 
    387  1.12.4.2  nathanw 	return (alpha_bus_space_get_window(st, window, abst));
    388  1.12.4.2  nathanw }
    389