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