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