1 /* $NetBSD: pcib.c,v 1.1 2007/10/26 22:17:14 xtraeme 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 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.1 2007/10/26 22:17:14 xtraeme Exp $"); 41 42 #include <sys/types.h> 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/device.h> 46 47 #include <machine/bus.h> 48 49 #include <dev/isa/isavar.h> 50 51 #include <dev/pci/pcivar.h> 52 #include <dev/pci/pcireg.h> 53 54 #include <dev/pci/pcidevs.h> 55 56 #include "isa.h" 57 58 int pcibmatch(struct device *, struct cfdata *, void *); 59 void pcibattach(struct device *, struct device *, void *); 60 61 CFATTACH_DECL(pcib, sizeof(struct device), 62 pcibmatch, pcibattach, NULL, NULL); 63 64 void pcib_callback(struct device *); 65 66 int 67 pcibmatch(struct device *parent, struct cfdata *match, void *aux) 68 { 69 struct pci_attach_args *pa = aux; 70 71 #if 0 72 /* 73 * PCI-ISA bridges are matched on class/subclass. 74 * This list contains only the bridges where correct 75 * (or incorrect) behaviour is not yet confirmed. 76 */ 77 switch (PCI_VENDOR(pa->pa_id)) { 78 case PCI_VENDOR_INTEL: 79 switch (PCI_PRODUCT(pa->pa_id)) { 80 case PCI_PRODUCT_INTEL_82426EX: 81 case PCI_PRODUCT_INTEL_82380AB: 82 return (1); 83 } 84 break; 85 86 case PCI_VENDOR_UMC: 87 switch (PCI_PRODUCT(pa->pa_id)) { 88 case PCI_PRODUCT_UMC_UM8886F: 89 case PCI_PRODUCT_UMC_UM82C886: 90 return (1); 91 } 92 break; 93 case PCI_VENDOR_ALI: 94 switch (PCI_PRODUCT(pa->pa_id)) { 95 case PCI_PRODUCT_ALI_M1449: 96 case PCI_PRODUCT_ALI_M1543: 97 return (1); 98 } 99 break; 100 case PCI_VENDOR_COMPAQ: 101 switch (PCI_PRODUCT(pa->pa_id)) { 102 case PCI_PRODUCT_COMPAQ_PCI_ISA_BRIDGE: 103 return (1); 104 } 105 break; 106 case PCI_VENDOR_VIATECH: 107 switch (PCI_PRODUCT(pa->pa_id)) { 108 case PCI_PRODUCT_VIATECH_VT82C570MV: 109 case PCI_PRODUCT_VIATECH_VT82C586_ISA: 110 return (1); 111 } 112 break; 113 } 114 #endif 115 116 /* 117 * some special cases: 118 */ 119 switch (PCI_VENDOR(pa->pa_id)) { 120 case PCI_VENDOR_INTEL: 121 switch (PCI_PRODUCT(pa->pa_id)) { 122 case PCI_PRODUCT_INTEL_SIO: 123 /* 124 * The Intel SIO identifies itself as a 125 * miscellaneous prehistoric. 126 */ 127 case PCI_PRODUCT_INTEL_82371MX: 128 /* 129 * The Intel 82371MX identifies itself erroneously as a 130 * miscellaneous bridge. 131 */ 132 case PCI_PRODUCT_INTEL_82371AB_ISA: 133 /* 134 * Some Intel 82371AB PCI-ISA bridge identifies 135 * itself as miscellaneous bridge. 136 */ 137 return (1); 138 } 139 break; 140 case PCI_VENDOR_SIS: 141 switch (PCI_PRODUCT(pa->pa_id)) { 142 case PCI_PRODUCT_SIS_85C503: 143 /* 144 * The SIS 85C503 identifies itself as a 145 * miscellaneous prehistoric. 146 */ 147 return (1); 148 } 149 break; 150 case PCI_VENDOR_VIATECH: 151 switch (PCI_PRODUCT(pa->pa_id)) { 152 case PCI_PRODUCT_VIATECH_VT82C686A_SMB: 153 /* 154 * The VIA VT82C686A SMBus Controller itself as 155 * ISA bridge, but it's wrong ! 156 */ 157 return (0); 158 } 159 /* 160 * The Cyrix cs5530 PCI host bridge does not have a broken 161 * latch on the i8254 clock core, unlike its predecessors 162 * the cs5510 and cs5520. This reverses the setting from 163 * i386/i386/identcpu.c where it arguably should not have 164 * been set in the first place. XXX 165 */ 166 case PCI_VENDOR_CYRIX: 167 switch (PCI_PRODUCT(pa->pa_id)) { 168 case PCI_PRODUCT_CYRIX_CX5530_PCIB: 169 { 170 extern int clock_broken_latch; 171 172 clock_broken_latch = 0; 173 } 174 return(1); 175 } 176 break; 177 } 178 179 if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE && 180 PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA) { 181 return (1); 182 } 183 184 return (0); 185 } 186 187 void 188 pcibattach(struct device *parent, struct device *self, void *aux) 189 { 190 struct pci_attach_args *pa = aux; 191 char devinfo[256]; 192 193 aprint_naive("\n"); 194 aprint_normal("\n"); 195 196 /* 197 * Just print out a description and defer configuration 198 * until all PCI devices have been attached. 199 */ 200 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); 201 aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo, 202 PCI_REVISION(pa->pa_class)); 203 204 config_defer(self, pcib_callback); 205 } 206 207 void 208 pcib_callback(struct device *self) 209 { 210 struct isabus_attach_args iba; 211 212 /* 213 * Attach the ISA bus behind this bridge. 214 */ 215 memset(&iba, 0, sizeof(iba)); 216 iba.iba_iot = X86_BUS_SPACE_IO; 217 iba.iba_memt = X86_BUS_SPACE_MEM; 218 #if NISA > 0 219 iba.iba_dmat = &isa_bus_dma_tag; 220 #endif 221 config_found_ia(self, "isabus", &iba, isabusprint); 222 } 223