Home | History | Annotate | Line # | Download | only in pci
cia.c revision 1.57.4.3
      1  1.57.4.3  nathanw /* $NetBSD: cia.c,v 1.57.4.3 2002/10/18 02:34:19 nathanw Exp $ */
      2  1.57.4.2  nathanw 
      3  1.57.4.2  nathanw /*-
      4  1.57.4.2  nathanw  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
      5  1.57.4.2  nathanw  * All rights reserved.
      6  1.57.4.2  nathanw  *
      7  1.57.4.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.57.4.2  nathanw  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.57.4.2  nathanw  * NASA Ames Research Center.
     10  1.57.4.2  nathanw  *
     11  1.57.4.2  nathanw  * Redistribution and use in source and binary forms, with or without
     12  1.57.4.2  nathanw  * modification, are permitted provided that the following conditions
     13  1.57.4.2  nathanw  * are met:
     14  1.57.4.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     15  1.57.4.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     16  1.57.4.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.57.4.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     18  1.57.4.2  nathanw  *    documentation and/or other materials provided with the distribution.
     19  1.57.4.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     20  1.57.4.2  nathanw  *    must display the following acknowledgement:
     21  1.57.4.2  nathanw  *	This product includes software developed by the NetBSD
     22  1.57.4.2  nathanw  *	Foundation, Inc. and its contributors.
     23  1.57.4.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.57.4.2  nathanw  *    contributors may be used to endorse or promote products derived
     25  1.57.4.2  nathanw  *    from this software without specific prior written permission.
     26  1.57.4.2  nathanw  *
     27  1.57.4.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.57.4.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.57.4.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.57.4.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.57.4.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.57.4.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.57.4.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.57.4.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.57.4.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.57.4.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.57.4.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     38  1.57.4.2  nathanw  */
     39  1.57.4.2  nathanw 
     40  1.57.4.2  nathanw /*
     41  1.57.4.2  nathanw  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
     42  1.57.4.2  nathanw  * All rights reserved.
     43  1.57.4.2  nathanw  *
     44  1.57.4.2  nathanw  * Author: Chris G. Demetriou
     45  1.57.4.2  nathanw  *
     46  1.57.4.2  nathanw  * Permission to use, copy, modify and distribute this software and
     47  1.57.4.2  nathanw  * its documentation is hereby granted, provided that both the copyright
     48  1.57.4.2  nathanw  * notice and this permission notice appear in all copies of the
     49  1.57.4.2  nathanw  * software, derivative works or modified versions, and any portions
     50  1.57.4.2  nathanw  * thereof, and that both notices appear in supporting documentation.
     51  1.57.4.2  nathanw  *
     52  1.57.4.2  nathanw  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     53  1.57.4.2  nathanw  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     54  1.57.4.2  nathanw  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     55  1.57.4.2  nathanw  *
     56  1.57.4.2  nathanw  * Carnegie Mellon requests users of this software to return to
     57  1.57.4.2  nathanw  *
     58  1.57.4.2  nathanw  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     59  1.57.4.2  nathanw  *  School of Computer Science
     60  1.57.4.2  nathanw  *  Carnegie Mellon University
     61  1.57.4.2  nathanw  *  Pittsburgh PA 15213-3890
     62  1.57.4.2  nathanw  *
     63  1.57.4.2  nathanw  * any improvements or extensions that they make and grant Carnegie the
     64  1.57.4.2  nathanw  * rights to redistribute these changes.
     65  1.57.4.2  nathanw  */
     66  1.57.4.2  nathanw 
     67  1.57.4.2  nathanw #include "opt_dec_eb164.h"
     68  1.57.4.2  nathanw #include "opt_dec_kn20aa.h"
     69  1.57.4.2  nathanw #include "opt_dec_550.h"
     70  1.57.4.2  nathanw #include "opt_dec_1000a.h"
     71  1.57.4.2  nathanw #include "opt_dec_1000.h"
     72  1.57.4.2  nathanw 
     73  1.57.4.2  nathanw #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     74  1.57.4.2  nathanw 
     75  1.57.4.3  nathanw __KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.57.4.3 2002/10/18 02:34:19 nathanw Exp $");
     76  1.57.4.2  nathanw 
     77  1.57.4.2  nathanw #include <sys/param.h>
     78  1.57.4.2  nathanw #include <sys/systm.h>
     79  1.57.4.2  nathanw #include <sys/kernel.h>
     80  1.57.4.2  nathanw #include <sys/malloc.h>
     81  1.57.4.2  nathanw #include <sys/device.h>
     82  1.57.4.2  nathanw 
     83  1.57.4.2  nathanw #include <uvm/uvm_extern.h>
     84  1.57.4.2  nathanw 
     85  1.57.4.2  nathanw #include <machine/autoconf.h>
     86  1.57.4.2  nathanw #include <machine/rpb.h>
     87  1.57.4.2  nathanw #include <machine/sysarch.h>
     88  1.57.4.2  nathanw #include <machine/alpha.h>
     89  1.57.4.2  nathanw 
     90  1.57.4.2  nathanw #include <dev/isa/isareg.h>
     91  1.57.4.2  nathanw #include <dev/isa/isavar.h>
     92  1.57.4.2  nathanw 
     93  1.57.4.2  nathanw #include <dev/pci/pcireg.h>
     94  1.57.4.2  nathanw #include <dev/pci/pcivar.h>
     95  1.57.4.2  nathanw #include <alpha/pci/ciareg.h>
     96  1.57.4.2  nathanw #include <alpha/pci/ciavar.h>
     97  1.57.4.2  nathanw 
     98  1.57.4.2  nathanw #ifdef DEC_KN20AA
     99  1.57.4.2  nathanw #include <alpha/pci/pci_kn20aa.h>
    100  1.57.4.2  nathanw #endif
    101  1.57.4.2  nathanw #ifdef DEC_EB164
    102  1.57.4.2  nathanw #include <alpha/pci/pci_eb164.h>
    103  1.57.4.2  nathanw #endif
    104  1.57.4.2  nathanw #ifdef DEC_550
    105  1.57.4.2  nathanw #include <alpha/pci/pci_550.h>
    106  1.57.4.2  nathanw #endif
    107  1.57.4.2  nathanw #ifdef DEC_1000A
    108  1.57.4.2  nathanw #include <alpha/pci/pci_1000a.h>
    109  1.57.4.2  nathanw #endif
    110  1.57.4.2  nathanw #ifdef DEC_1000
    111  1.57.4.2  nathanw #include <alpha/pci/pci_1000.h>
    112  1.57.4.2  nathanw #endif
    113  1.57.4.2  nathanw 
    114  1.57.4.2  nathanw int	ciamatch __P((struct device *, struct cfdata *, void *));
    115  1.57.4.2  nathanw void	ciaattach __P((struct device *, struct device *, void *));
    116  1.57.4.2  nathanw 
    117  1.57.4.3  nathanw CFATTACH_DECL(cia, sizeof(struct cia_softc),
    118  1.57.4.3  nathanw     ciamatch, ciaattach, NULL, NULL);
    119  1.57.4.2  nathanw 
    120  1.57.4.2  nathanw extern struct cfdriver cia_cd;
    121  1.57.4.2  nathanw 
    122  1.57.4.2  nathanw static int	ciaprint __P((void *, const char *pnp));
    123  1.57.4.2  nathanw 
    124  1.57.4.2  nathanw int	cia_bus_get_window __P((int, int,
    125  1.57.4.2  nathanw 	    struct alpha_bus_space_translation *));
    126  1.57.4.2  nathanw 
    127  1.57.4.2  nathanw /* There can be only one. */
    128  1.57.4.2  nathanw int ciafound;
    129  1.57.4.2  nathanw struct cia_config cia_configuration;
    130  1.57.4.2  nathanw 
    131  1.57.4.2  nathanw /*
    132  1.57.4.2  nathanw  * This determines if we attempt to use BWX for PCI bus and config space
    133  1.57.4.2  nathanw  * access.  Some systems, notably with Pyxis, don't fare so well unless
    134  1.57.4.2  nathanw  * BWX is used.
    135  1.57.4.2  nathanw  *
    136  1.57.4.2  nathanw  * EXCEPT!  Some devices have a really hard time if BWX is used (WHY?!).
    137  1.57.4.2  nathanw  * So, we decouple the uses for PCI config space and PCI bus space.
    138  1.57.4.2  nathanw  *
    139  1.57.4.2  nathanw  * FURTHERMORE!  The Pyxis, most notably earlier revs, really don't
    140  1.57.4.2  nathanw  * do so well if you don't use BWX for bus access.  So we default to
    141  1.57.4.2  nathanw  * forcing BWX on those chips.
    142  1.57.4.2  nathanw  *
    143  1.57.4.2  nathanw  * Geez.
    144  1.57.4.2  nathanw  */
    145  1.57.4.2  nathanw 
    146  1.57.4.2  nathanw #ifndef CIA_PCI_USE_BWX
    147  1.57.4.2  nathanw #define	CIA_PCI_USE_BWX	1
    148  1.57.4.2  nathanw #endif
    149  1.57.4.2  nathanw 
    150  1.57.4.2  nathanw #ifndef	CIA_BUS_USE_BWX
    151  1.57.4.2  nathanw #define	CIA_BUS_USE_BWX	0
    152  1.57.4.2  nathanw #endif
    153  1.57.4.2  nathanw 
    154  1.57.4.2  nathanw #ifndef CIA_PYXIS_FORCE_BWX
    155  1.57.4.2  nathanw #define	CIA_PYXIS_FORCE_BWX 0
    156  1.57.4.2  nathanw #endif
    157  1.57.4.2  nathanw 
    158  1.57.4.2  nathanw int	cia_pci_use_bwx = CIA_PCI_USE_BWX;
    159  1.57.4.2  nathanw int	cia_bus_use_bwx = CIA_BUS_USE_BWX;
    160  1.57.4.2  nathanw int	cia_pyxis_force_bwx = CIA_PYXIS_FORCE_BWX;
    161  1.57.4.2  nathanw 
    162  1.57.4.2  nathanw int
    163  1.57.4.2  nathanw ciamatch(parent, match, aux)
    164  1.57.4.2  nathanw 	struct device *parent;
    165  1.57.4.2  nathanw 	struct cfdata *match;
    166  1.57.4.2  nathanw 	void *aux;
    167  1.57.4.2  nathanw {
    168  1.57.4.2  nathanw 	struct mainbus_attach_args *ma = aux;
    169  1.57.4.2  nathanw 
    170  1.57.4.2  nathanw 	/* Make sure that we're looking for a CIA. */
    171  1.57.4.2  nathanw 	if (strcmp(ma->ma_name, cia_cd.cd_name) != 0)
    172  1.57.4.2  nathanw 		return (0);
    173  1.57.4.2  nathanw 
    174  1.57.4.2  nathanw 	if (ciafound)
    175  1.57.4.2  nathanw 		return (0);
    176  1.57.4.2  nathanw 
    177  1.57.4.2  nathanw 	return (1);
    178  1.57.4.2  nathanw }
    179  1.57.4.2  nathanw 
    180  1.57.4.2  nathanw /*
    181  1.57.4.2  nathanw  * Set up the chipset's function pointers.
    182  1.57.4.2  nathanw  */
    183  1.57.4.2  nathanw void
    184  1.57.4.2  nathanw cia_init(ccp, mallocsafe)
    185  1.57.4.2  nathanw 	struct cia_config *ccp;
    186  1.57.4.2  nathanw 	int mallocsafe;
    187  1.57.4.2  nathanw {
    188  1.57.4.2  nathanw 	int pci_use_bwx = cia_pci_use_bwx;
    189  1.57.4.2  nathanw 	int bus_use_bwx = cia_bus_use_bwx;
    190  1.57.4.2  nathanw 
    191  1.57.4.2  nathanw 	ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM);
    192  1.57.4.2  nathanw 	ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO);
    193  1.57.4.2  nathanw 	ccp->cc_rev = REGVAL(CIA_CSR_REV) & REV_MASK;
    194  1.57.4.2  nathanw 
    195  1.57.4.2  nathanw 	/*
    196  1.57.4.2  nathanw 	 * Determine if we have a Pyxis.  Only two systypes can
    197  1.57.4.2  nathanw 	 * have this: the EB164 systype (AlphaPC164LX and AlphaPC164SX)
    198  1.57.4.2  nathanw 	 * and the DEC_550 systype (Miata).
    199  1.57.4.2  nathanw 	 */
    200  1.57.4.2  nathanw 	if ((cputype == ST_EB164 &&
    201  1.57.4.2  nathanw 	     (hwrpb->rpb_variation & SV_ST_MASK) >= SV_ST_ALPHAPC164LX_400) ||
    202  1.57.4.2  nathanw 	    cputype == ST_DEC_550) {
    203  1.57.4.2  nathanw 		ccp->cc_flags |= CCF_ISPYXIS;
    204  1.57.4.2  nathanw 		if (cia_pyxis_force_bwx)
    205  1.57.4.2  nathanw 			pci_use_bwx = bus_use_bwx = 1;
    206  1.57.4.2  nathanw 	}
    207  1.57.4.2  nathanw 
    208  1.57.4.2  nathanw 	/*
    209  1.57.4.2  nathanw 	 * ALCOR/ALCOR2 Revisions >= 2 and Pyxis have the CNFG register.
    210  1.57.4.2  nathanw 	 */
    211  1.57.4.2  nathanw 	if (ccp->cc_rev >= 2 || (ccp->cc_flags & CCF_ISPYXIS) != 0)
    212  1.57.4.2  nathanw 		ccp->cc_cnfg = REGVAL(CIA_CSR_CNFG);
    213  1.57.4.2  nathanw 	else
    214  1.57.4.2  nathanw 		ccp->cc_cnfg = 0;
    215  1.57.4.2  nathanw 
    216  1.57.4.2  nathanw 	/*
    217  1.57.4.2  nathanw 	 * Use BWX iff:
    218  1.57.4.2  nathanw 	 *
    219  1.57.4.2  nathanw 	 *	- It hasn't been disbled by the user,
    220  1.57.4.2  nathanw 	 *	- it's enabled in CNFG,
    221  1.57.4.2  nathanw 	 *	- we're implementation version ev5,
    222  1.57.4.2  nathanw 	 *	- BWX is enabled in the CPU's capabilities mask
    223  1.57.4.2  nathanw 	 */
    224  1.57.4.2  nathanw 	if ((pci_use_bwx || bus_use_bwx) &&
    225  1.57.4.2  nathanw 	    (ccp->cc_cnfg & CNFG_BWEN) != 0 &&
    226  1.57.4.2  nathanw 	    (cpu_amask & ALPHA_AMASK_BWX) != 0) {
    227  1.57.4.2  nathanw 		u_int32_t ctrl;
    228  1.57.4.2  nathanw 
    229  1.57.4.2  nathanw 		if (pci_use_bwx)
    230  1.57.4.2  nathanw 			ccp->cc_flags |= CCF_PCI_USE_BWX;
    231  1.57.4.2  nathanw 		if (bus_use_bwx)
    232  1.57.4.2  nathanw 			ccp->cc_flags |= CCF_BUS_USE_BWX;
    233  1.57.4.2  nathanw 
    234  1.57.4.2  nathanw 		/*
    235  1.57.4.2  nathanw 		 * For whatever reason, the firmware seems to enable PCI
    236  1.57.4.2  nathanw 		 * loopback mode if it also enables BWX.  Make sure it's
    237  1.57.4.2  nathanw 		 * enabled if we have an old, buggy firmware rev.
    238  1.57.4.2  nathanw 		 */
    239  1.57.4.2  nathanw 		alpha_mb();
    240  1.57.4.2  nathanw 		ctrl = REGVAL(CIA_CSR_CTRL);
    241  1.57.4.2  nathanw 		if ((ctrl & CTRL_PCI_LOOP_EN) == 0) {
    242  1.57.4.2  nathanw 			REGVAL(CIA_CSR_CTRL) = ctrl | CTRL_PCI_LOOP_EN;
    243  1.57.4.2  nathanw 			alpha_mb();
    244  1.57.4.2  nathanw 		}
    245  1.57.4.2  nathanw 	}
    246  1.57.4.2  nathanw 
    247  1.57.4.2  nathanw 	if (!ccp->cc_initted) {
    248  1.57.4.2  nathanw 		/* don't do these twice since they set up extents */
    249  1.57.4.2  nathanw 		if (ccp->cc_flags & CCF_BUS_USE_BWX) {
    250  1.57.4.2  nathanw 			cia_bwx_bus_io_init(&ccp->cc_iot, ccp);
    251  1.57.4.2  nathanw 			cia_bwx_bus_mem_init(&ccp->cc_memt, ccp);
    252  1.57.4.2  nathanw 
    253  1.57.4.2  nathanw 			/*
    254  1.57.4.2  nathanw 			 * We have one window for both PCI I/O and MEM
    255  1.57.4.2  nathanw 			 * in BWX mode.
    256  1.57.4.2  nathanw 			 */
    257  1.57.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
    258  1.57.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
    259  1.57.4.2  nathanw 		} else {
    260  1.57.4.2  nathanw 			cia_swiz_bus_io_init(&ccp->cc_iot, ccp);
    261  1.57.4.2  nathanw 			cia_swiz_bus_mem_init(&ccp->cc_memt, ccp);
    262  1.57.4.2  nathanw 
    263  1.57.4.2  nathanw 			/*
    264  1.57.4.2  nathanw 			 * We have two I/O windows and 4 MEM windows in
    265  1.57.4.2  nathanw 			 * SWIZ mode.
    266  1.57.4.2  nathanw 			 */
    267  1.57.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 2;
    268  1.57.4.2  nathanw 			alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 4;
    269  1.57.4.2  nathanw 		}
    270  1.57.4.2  nathanw 		alpha_bus_get_window = cia_bus_get_window;
    271  1.57.4.2  nathanw 	}
    272  1.57.4.2  nathanw 	ccp->cc_mallocsafe = mallocsafe;
    273  1.57.4.2  nathanw 
    274  1.57.4.2  nathanw 	cia_pci_init(&ccp->cc_pc, ccp);
    275  1.57.4.2  nathanw 	alpha_pci_chipset = &ccp->cc_pc;
    276  1.57.4.2  nathanw 
    277  1.57.4.2  nathanw 	ccp->cc_initted = 1;
    278  1.57.4.2  nathanw }
    279  1.57.4.2  nathanw 
    280  1.57.4.2  nathanw void
    281  1.57.4.2  nathanw ciaattach(parent, self, aux)
    282  1.57.4.2  nathanw 	struct device *parent, *self;
    283  1.57.4.2  nathanw 	void *aux;
    284  1.57.4.2  nathanw {
    285  1.57.4.2  nathanw 	struct cia_softc *sc = (struct cia_softc *)self;
    286  1.57.4.2  nathanw 	struct cia_config *ccp;
    287  1.57.4.2  nathanw 	struct pcibus_attach_args pba;
    288  1.57.4.2  nathanw 	char bits[64];
    289  1.57.4.2  nathanw 	const char *name;
    290  1.57.4.2  nathanw 	int pass;
    291  1.57.4.2  nathanw 
    292  1.57.4.2  nathanw 	/* note that we've attached the chipset; can't have 2 CIAs. */
    293  1.57.4.2  nathanw 	ciafound = 1;
    294  1.57.4.2  nathanw 
    295  1.57.4.2  nathanw 	/*
    296  1.57.4.2  nathanw 	 * set up the chipset's info; done once at console init time
    297  1.57.4.2  nathanw 	 * (maybe), but we must do it here as well to take care of things
    298  1.57.4.2  nathanw 	 * that need to use memory allocation.
    299  1.57.4.2  nathanw 	 */
    300  1.57.4.2  nathanw 	ccp = sc->sc_ccp = &cia_configuration;
    301  1.57.4.2  nathanw 	cia_init(ccp, 1);
    302  1.57.4.2  nathanw 
    303  1.57.4.2  nathanw 	if (ccp->cc_flags & CCF_ISPYXIS) {
    304  1.57.4.2  nathanw 		name = "Pyxis";
    305  1.57.4.2  nathanw 		pass = ccp->cc_rev;
    306  1.57.4.2  nathanw 	} else {
    307  1.57.4.2  nathanw 		name = "ALCOR/ALCOR2";
    308  1.57.4.2  nathanw 		pass = ccp->cc_rev + 1;
    309  1.57.4.2  nathanw 	}
    310  1.57.4.2  nathanw 
    311  1.57.4.2  nathanw 	printf(": DECchip 2117x Core Logic Chipset (%s), pass %d\n",
    312  1.57.4.2  nathanw 	    name, pass);
    313  1.57.4.2  nathanw 	if (ccp->cc_cnfg)
    314  1.57.4.2  nathanw 		printf("%s: extended capabilities: %s\n", self->dv_xname,
    315  1.57.4.2  nathanw 		    bitmask_snprintf(ccp->cc_cnfg, CIA_CSR_CNFG_BITS,
    316  1.57.4.2  nathanw 		    bits, sizeof(bits)));
    317  1.57.4.2  nathanw 
    318  1.57.4.2  nathanw 	switch (ccp->cc_flags & (CCF_PCI_USE_BWX|CCF_BUS_USE_BWX)) {
    319  1.57.4.2  nathanw 	case CCF_PCI_USE_BWX|CCF_BUS_USE_BWX:
    320  1.57.4.2  nathanw 		name = "PCI config and bus";
    321  1.57.4.2  nathanw 		break;
    322  1.57.4.2  nathanw 	case CCF_PCI_USE_BWX:
    323  1.57.4.2  nathanw 		name = "PCI config";
    324  1.57.4.2  nathanw 		break;
    325  1.57.4.2  nathanw 	case CCF_BUS_USE_BWX:
    326  1.57.4.2  nathanw 		name = "bus";
    327  1.57.4.2  nathanw 		break;
    328  1.57.4.2  nathanw 	default:
    329  1.57.4.2  nathanw 		name = NULL;
    330  1.57.4.2  nathanw 		break;
    331  1.57.4.2  nathanw 	}
    332  1.57.4.2  nathanw 	if (name != NULL)
    333  1.57.4.2  nathanw 		printf("%s: using BWX for %s access\n", self->dv_xname, name);
    334  1.57.4.2  nathanw 
    335  1.57.4.2  nathanw #ifdef DEC_550
    336  1.57.4.2  nathanw 	if (cputype == ST_DEC_550 &&
    337  1.57.4.2  nathanw 	    (hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
    338  1.57.4.2  nathanw 		/*
    339  1.57.4.2  nathanw 		 * Miata 1 systems have a bug: DMA cannot cross
    340  1.57.4.2  nathanw 		 * an 8k boundary!  Make sure PCI read prefetching
    341  1.57.4.2  nathanw 		 * is disabled on these chips.  Note that secondary
    342  1.57.4.2  nathanw 		 * PCI busses don't have this problem, because of
    343  1.57.4.2  nathanw 		 * the way PPBs handle PCI read requests.
    344  1.57.4.2  nathanw 		 *
    345  1.57.4.2  nathanw 		 * In the 21174 Technical Reference Manual, this is
    346  1.57.4.2  nathanw 		 * actually documented as "Pyxis Pass 1", but apparently
    347  1.57.4.2  nathanw 		 * there are chips that report themselves as "Pass 1"
    348  1.57.4.2  nathanw 		 * which do not have the bug!  Miatas with the Cypress
    349  1.57.4.2  nathanw 		 * PCI-ISA bridge (i.e. Miata 1.5 and Miata 2) do not
    350  1.57.4.2  nathanw 		 * have the bug, so we use this check.
    351  1.57.4.2  nathanw 		 *
    352  1.57.4.2  nathanw 		 * NOTE: This bug is actually worked around in cia_dma.c,
    353  1.57.4.2  nathanw 		 * when direct-mapped DMA maps are created.
    354  1.57.4.2  nathanw 		 *
    355  1.57.4.2  nathanw 		 * XXX WE NEED TO THINK ABOUT HOW TO HANDLE THIS FOR
    356  1.57.4.2  nathanw 		 * XXX SGMAP DMA MAPPINGS!
    357  1.57.4.2  nathanw 		 */
    358  1.57.4.2  nathanw 		u_int32_t ctrl;
    359  1.57.4.2  nathanw 
    360  1.57.4.2  nathanw 		/* XXX no bets... */
    361  1.57.4.2  nathanw 		printf("%s: WARNING: Pyxis pass 1 DMA bug; no bets...\n",
    362  1.57.4.2  nathanw 		    self->dv_xname);
    363  1.57.4.2  nathanw 
    364  1.57.4.2  nathanw 		ccp->cc_flags |= CCF_PYXISBUG;
    365  1.57.4.2  nathanw 
    366  1.57.4.2  nathanw 		alpha_mb();
    367  1.57.4.2  nathanw 		ctrl = REGVAL(CIA_CSR_CTRL);
    368  1.57.4.2  nathanw 		ctrl &= ~(CTRL_RD_TYPE|CTRL_RL_TYPE|CTRL_RM_TYPE);
    369  1.57.4.2  nathanw 		REGVAL(CIA_CSR_CTRL) = ctrl;
    370  1.57.4.2  nathanw 		alpha_mb();
    371  1.57.4.2  nathanw 	}
    372  1.57.4.2  nathanw #endif /* DEC_550 */
    373  1.57.4.2  nathanw 
    374  1.57.4.2  nathanw 	cia_dma_init(ccp);
    375  1.57.4.2  nathanw 
    376  1.57.4.2  nathanw 	switch (cputype) {
    377  1.57.4.2  nathanw #ifdef DEC_KN20AA
    378  1.57.4.2  nathanw 	case ST_DEC_KN20AA:
    379  1.57.4.2  nathanw 		pci_kn20aa_pickintr(ccp);
    380  1.57.4.2  nathanw 		break;
    381  1.57.4.2  nathanw #endif
    382  1.57.4.2  nathanw 
    383  1.57.4.2  nathanw #ifdef DEC_EB164
    384  1.57.4.2  nathanw 	case ST_EB164:
    385  1.57.4.2  nathanw 		pci_eb164_pickintr(ccp);
    386  1.57.4.2  nathanw 		break;
    387  1.57.4.2  nathanw #endif
    388  1.57.4.2  nathanw 
    389  1.57.4.2  nathanw #ifdef DEC_550
    390  1.57.4.2  nathanw 	case ST_DEC_550:
    391  1.57.4.2  nathanw 		pci_550_pickintr(ccp);
    392  1.57.4.2  nathanw 		break;
    393  1.57.4.2  nathanw #endif
    394  1.57.4.2  nathanw 
    395  1.57.4.2  nathanw #ifdef DEC_1000A
    396  1.57.4.2  nathanw 	case ST_DEC_1000A:
    397  1.57.4.2  nathanw 		pci_1000a_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
    398  1.57.4.2  nathanw 			&ccp->cc_pc);
    399  1.57.4.2  nathanw 		break;
    400  1.57.4.2  nathanw #endif
    401  1.57.4.2  nathanw 
    402  1.57.4.2  nathanw #ifdef DEC_1000
    403  1.57.4.2  nathanw 	case ST_DEC_1000:
    404  1.57.4.2  nathanw 		pci_1000_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
    405  1.57.4.2  nathanw 			&ccp->cc_pc);
    406  1.57.4.2  nathanw 		break;
    407  1.57.4.2  nathanw #endif
    408  1.57.4.2  nathanw 
    409  1.57.4.2  nathanw 	default:
    410  1.57.4.2  nathanw 		panic("ciaattach: shouldn't be here, really...");
    411  1.57.4.2  nathanw 	}
    412  1.57.4.2  nathanw 
    413  1.57.4.2  nathanw 	pba.pba_busname = "pci";
    414  1.57.4.2  nathanw 	pba.pba_iot = &ccp->cc_iot;
    415  1.57.4.2  nathanw 	pba.pba_memt = &ccp->cc_memt;
    416  1.57.4.2  nathanw 	pba.pba_dmat =
    417  1.57.4.2  nathanw 	    alphabus_dma_get_tag(&ccp->cc_dmat_direct, ALPHA_BUS_PCI);
    418  1.57.4.2  nathanw 	pba.pba_pc = &ccp->cc_pc;
    419  1.57.4.2  nathanw 	pba.pba_bus = 0;
    420  1.57.4.2  nathanw 	pba.pba_bridgetag = NULL;
    421  1.57.4.2  nathanw 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
    422  1.57.4.2  nathanw 	if ((ccp->cc_flags & CCF_PYXISBUG) == 0)
    423  1.57.4.2  nathanw 		pba.pba_flags |= PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
    424  1.57.4.2  nathanw 		    PCI_FLAGS_MWI_OKAY;
    425  1.57.4.2  nathanw 	config_found(self, &pba, ciaprint);
    426  1.57.4.2  nathanw }
    427  1.57.4.2  nathanw 
    428  1.57.4.2  nathanw static int
    429  1.57.4.2  nathanw ciaprint(aux, pnp)
    430  1.57.4.2  nathanw 	void *aux;
    431  1.57.4.2  nathanw 	const char *pnp;
    432  1.57.4.2  nathanw {
    433  1.57.4.2  nathanw 	register struct pcibus_attach_args *pba = aux;
    434  1.57.4.2  nathanw 
    435  1.57.4.2  nathanw 	/* only PCIs can attach to CIAs; easy. */
    436  1.57.4.2  nathanw 	if (pnp)
    437  1.57.4.2  nathanw 		printf("%s at %s", pba->pba_busname, pnp);
    438  1.57.4.2  nathanw 	printf(" bus %d", pba->pba_bus);
    439  1.57.4.2  nathanw 	return (UNCONF);
    440  1.57.4.2  nathanw }
    441  1.57.4.2  nathanw 
    442  1.57.4.2  nathanw int
    443  1.57.4.2  nathanw cia_bus_get_window(type, window, abst)
    444  1.57.4.2  nathanw 	int type, window;
    445  1.57.4.2  nathanw 	struct alpha_bus_space_translation *abst;
    446  1.57.4.2  nathanw {
    447  1.57.4.2  nathanw 	struct cia_config *ccp = &cia_configuration;
    448  1.57.4.2  nathanw 	bus_space_tag_t st;
    449  1.57.4.2  nathanw 
    450  1.57.4.2  nathanw 	switch (type) {
    451  1.57.4.2  nathanw 	case ALPHA_BUS_TYPE_PCI_IO:
    452  1.57.4.2  nathanw 		st = &ccp->cc_iot;
    453  1.57.4.2  nathanw 		break;
    454  1.57.4.2  nathanw 
    455  1.57.4.2  nathanw 	case ALPHA_BUS_TYPE_PCI_MEM:
    456  1.57.4.2  nathanw 		st = &ccp->cc_memt;
    457  1.57.4.2  nathanw 		break;
    458  1.57.4.2  nathanw 
    459  1.57.4.2  nathanw 	default:
    460  1.57.4.2  nathanw 		panic("cia_bus_get_window");
    461  1.57.4.2  nathanw 	}
    462  1.57.4.2  nathanw 
    463  1.57.4.2  nathanw 	return (alpha_bus_space_get_window(st, window, abst));
    464  1.57.4.2  nathanw }
    465  1.57.4.2  nathanw 
    466  1.57.4.2  nathanw void
    467  1.57.4.2  nathanw cia_pyxis_intr_enable(irq, onoff)
    468  1.57.4.2  nathanw 	int irq, onoff;
    469  1.57.4.2  nathanw {
    470  1.57.4.2  nathanw 	u_int64_t imask;
    471  1.57.4.2  nathanw 	int s;
    472  1.57.4.2  nathanw 
    473  1.57.4.2  nathanw #if 0
    474  1.57.4.2  nathanw 	printf("cia_pyxis_intr_enable: %s %d\n",
    475  1.57.4.2  nathanw 	    onoff ? "enabling" : "disabling", irq);
    476  1.57.4.2  nathanw #endif
    477  1.57.4.2  nathanw 
    478  1.57.4.2  nathanw 	s = splhigh();
    479  1.57.4.2  nathanw 	alpha_mb();
    480  1.57.4.2  nathanw 	imask = REGVAL64(PYXIS_INT_MASK);
    481  1.57.4.2  nathanw 	if (onoff)
    482  1.57.4.2  nathanw 		imask |= (1UL << irq);
    483  1.57.4.2  nathanw 	else
    484  1.57.4.2  nathanw 		imask &= ~(1UL << irq);
    485  1.57.4.2  nathanw 	REGVAL64(PYXIS_INT_MASK) = imask;
    486  1.57.4.2  nathanw 	alpha_mb();
    487  1.57.4.2  nathanw 	splx(s);
    488  1.57.4.2  nathanw }
    489