Home | History | Annotate | Line # | Download | only in pci
pceb.c revision 1.6.2.2
      1  1.6.2.2  lukem /*	$NetBSD: pceb.c,v 1.6.2.2 2001/11/15 07:03:34 lukem Exp $	*/
      2  1.6.2.2  lukem 
      3  1.6.2.2  lukem /*-
      4  1.6.2.2  lukem  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
      5  1.6.2.2  lukem  * All rights reserved.
      6  1.6.2.2  lukem  *
      7  1.6.2.2  lukem  * This code is derived from software contributed to The NetBSD Foundation
      8  1.6.2.2  lukem  * by Jason R. Thorpe.
      9  1.6.2.2  lukem  *
     10  1.6.2.2  lukem  * Redistribution and use in source and binary forms, with or without
     11  1.6.2.2  lukem  * modification, are permitted provided that the following conditions
     12  1.6.2.2  lukem  * are met:
     13  1.6.2.2  lukem  * 1. Redistributions of source code must retain the above copyright
     14  1.6.2.2  lukem  *    notice, this list of conditions and the following disclaimer.
     15  1.6.2.2  lukem  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.6.2.2  lukem  *    notice, this list of conditions and the following disclaimer in the
     17  1.6.2.2  lukem  *    documentation and/or other materials provided with the distribution.
     18  1.6.2.2  lukem  * 3. All advertising materials mentioning features or use of this software
     19  1.6.2.2  lukem  *    must display the following acknowledgement:
     20  1.6.2.2  lukem  *        This product includes software developed by the NetBSD
     21  1.6.2.2  lukem  *        Foundation, Inc. and its contributors.
     22  1.6.2.2  lukem  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.6.2.2  lukem  *    contributors may be used to endorse or promote products derived
     24  1.6.2.2  lukem  *    from this software without specific prior written permission.
     25  1.6.2.2  lukem  *
     26  1.6.2.2  lukem  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.6.2.2  lukem  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.6.2.2  lukem  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.6.2.2  lukem  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.6.2.2  lukem  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.6.2.2  lukem  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.6.2.2  lukem  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.6.2.2  lukem  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.6.2.2  lukem  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.6.2.2  lukem  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.6.2.2  lukem  * POSSIBILITY OF SUCH DAMAGE.
     37  1.6.2.2  lukem  */
     38  1.6.2.2  lukem 
     39  1.6.2.2  lukem #include <sys/cdefs.h>
     40  1.6.2.2  lukem __KERNEL_RCSID(0, "$NetBSD: pceb.c,v 1.6.2.2 2001/11/15 07:03:34 lukem Exp $");
     41  1.6.2.2  lukem 
     42  1.6.2.2  lukem #include <sys/types.h>
     43  1.6.2.2  lukem #include <sys/param.h>
     44  1.6.2.2  lukem #include <sys/systm.h>
     45  1.6.2.2  lukem #include <sys/device.h>
     46  1.6.2.2  lukem 
     47  1.6.2.2  lukem #include <machine/bus.h>
     48  1.6.2.2  lukem 
     49  1.6.2.2  lukem #include <dev/isa/isavar.h>
     50  1.6.2.2  lukem #include <dev/eisa/eisavar.h>
     51  1.6.2.2  lukem 
     52  1.6.2.2  lukem #include <dev/pci/pcivar.h>
     53  1.6.2.2  lukem #include <dev/pci/pcireg.h>
     54  1.6.2.2  lukem 
     55  1.6.2.2  lukem #include <dev/pci/pcidevs.h>
     56  1.6.2.2  lukem 
     57  1.6.2.2  lukem #include "eisa.h"
     58  1.6.2.2  lukem #include "isa.h"
     59  1.6.2.2  lukem 
     60  1.6.2.2  lukem int	pcebmatch __P((struct device *, struct cfdata *, void *));
     61  1.6.2.2  lukem void	pcebattach __P((struct device *, struct device *, void *));
     62  1.6.2.2  lukem 
     63  1.6.2.2  lukem struct cfattach pceb_ca = {
     64  1.6.2.2  lukem 	sizeof(struct device), pcebmatch, pcebattach
     65  1.6.2.2  lukem };
     66  1.6.2.2  lukem 
     67  1.6.2.2  lukem void	pceb_callback __P((struct device *));
     68  1.6.2.2  lukem int	pceb_print __P((void *, const char *));
     69  1.6.2.2  lukem 
     70  1.6.2.2  lukem union pceb_attach_args {
     71  1.6.2.2  lukem 	const char *ea_name;			/* XXX should be common */
     72  1.6.2.2  lukem 	struct isabus_attach_args ea_iba;
     73  1.6.2.2  lukem 	struct eisabus_attach_args ea_eba;
     74  1.6.2.2  lukem };
     75  1.6.2.2  lukem 
     76  1.6.2.2  lukem int
     77  1.6.2.2  lukem pcebmatch(parent, match, aux)
     78  1.6.2.2  lukem 	struct device *parent;
     79  1.6.2.2  lukem 	struct cfdata *match;
     80  1.6.2.2  lukem 	void *aux;
     81  1.6.2.2  lukem {
     82  1.6.2.2  lukem 	struct pci_attach_args *pa = aux;
     83  1.6.2.2  lukem 
     84  1.6.2.2  lukem 	/*
     85  1.6.2.2  lukem 	 * Match all known PCI-EISA bridges.
     86  1.6.2.2  lukem 	 */
     87  1.6.2.2  lukem 	switch (PCI_VENDOR(pa->pa_id)) {
     88  1.6.2.2  lukem 	case PCI_VENDOR_INTEL:
     89  1.6.2.2  lukem 		switch (PCI_PRODUCT(pa->pa_id)) {
     90  1.6.2.2  lukem 		case PCI_PRODUCT_INTEL_PCEB:
     91  1.6.2.2  lukem 			return (1);
     92  1.6.2.2  lukem 		}
     93  1.6.2.2  lukem 		break;
     94  1.6.2.2  lukem 	}
     95  1.6.2.2  lukem 
     96  1.6.2.2  lukem 	return (0);
     97  1.6.2.2  lukem }
     98  1.6.2.2  lukem 
     99  1.6.2.2  lukem void
    100  1.6.2.2  lukem pcebattach(parent, self, aux)
    101  1.6.2.2  lukem 	struct device *parent, *self;
    102  1.6.2.2  lukem 	void *aux;
    103  1.6.2.2  lukem {
    104  1.6.2.2  lukem 	struct pci_attach_args *pa = aux;
    105  1.6.2.2  lukem 	char devinfo[256];
    106  1.6.2.2  lukem 
    107  1.6.2.2  lukem 	printf("\n");
    108  1.6.2.2  lukem 
    109  1.6.2.2  lukem 	/*
    110  1.6.2.2  lukem 	 * Just print out a description and defer configuration
    111  1.6.2.2  lukem 	 * until all PCI devices have been attached.
    112  1.6.2.2  lukem 	 */
    113  1.6.2.2  lukem 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
    114  1.6.2.2  lukem 	printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
    115  1.6.2.2  lukem 	    PCI_REVISION(pa->pa_class));
    116  1.6.2.2  lukem 
    117  1.6.2.2  lukem 	config_defer(self, pceb_callback);
    118  1.6.2.2  lukem }
    119  1.6.2.2  lukem 
    120  1.6.2.2  lukem void
    121  1.6.2.2  lukem pceb_callback(self)
    122  1.6.2.2  lukem 	struct device *self;
    123  1.6.2.2  lukem {
    124  1.6.2.2  lukem 	union pceb_attach_args ea;
    125  1.6.2.2  lukem 
    126  1.6.2.2  lukem 	/*
    127  1.6.2.2  lukem 	 * Attach the EISA bus behind this bridge.
    128  1.6.2.2  lukem 	 */
    129  1.6.2.2  lukem 	memset(&ea, 0, sizeof(ea));
    130  1.6.2.2  lukem 	ea.ea_eba.eba_busname = "eisa";
    131  1.6.2.2  lukem 	ea.ea_eba.eba_iot = I386_BUS_SPACE_IO;
    132  1.6.2.2  lukem 	ea.ea_eba.eba_memt = I386_BUS_SPACE_MEM;
    133  1.6.2.2  lukem #if NEISA > 0
    134  1.6.2.2  lukem 	ea.ea_eba.eba_dmat = &eisa_bus_dma_tag;
    135  1.6.2.2  lukem #endif
    136  1.6.2.2  lukem 	config_found(self, &ea.ea_eba, pceb_print);
    137  1.6.2.2  lukem 
    138  1.6.2.2  lukem 	/*
    139  1.6.2.2  lukem 	 * Attach the ISA bus behind this bridge.
    140  1.6.2.2  lukem 	 */
    141  1.6.2.2  lukem 	memset(&ea, 0, sizeof(ea));
    142  1.6.2.2  lukem 	ea.ea_iba.iba_busname = "isa";
    143  1.6.2.2  lukem 	ea.ea_iba.iba_iot = I386_BUS_SPACE_IO;
    144  1.6.2.2  lukem 	ea.ea_iba.iba_memt = I386_BUS_SPACE_MEM;
    145  1.6.2.2  lukem #if NISA > 0
    146  1.6.2.2  lukem 	ea.ea_iba.iba_dmat = &isa_bus_dma_tag;
    147  1.6.2.2  lukem #endif
    148  1.6.2.2  lukem 	config_found(self, &ea.ea_iba, pceb_print);
    149  1.6.2.2  lukem }
    150  1.6.2.2  lukem 
    151  1.6.2.2  lukem int
    152  1.6.2.2  lukem pceb_print(aux, pnp)
    153  1.6.2.2  lukem 	void *aux;
    154  1.6.2.2  lukem 	const char *pnp;
    155  1.6.2.2  lukem {
    156  1.6.2.2  lukem 	union pceb_attach_args *ea = aux;
    157  1.6.2.2  lukem 
    158  1.6.2.2  lukem 	if (pnp)
    159  1.6.2.2  lukem 		printf("%s at %s", ea->ea_name, pnp);
    160  1.6.2.2  lukem 	return (UNCONF);
    161  1.6.2.2  lukem }
    162