1 /* $NetBSD: pcib.c,v 1.18 2021/08/07 16:19:00 thorpej 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 * from: i386/pci/pcib.c,v 1.12 32 */ 33 34 #include <sys/cdefs.h> 35 __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.18 2021/08/07 16:19:00 thorpej Exp $"); 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/device.h> 40 41 #include <sys/bus.h> 42 43 #include <dev/isa/isavar.h> 44 45 #include <dev/pci/pcivar.h> 46 #include <dev/pci/pcireg.h> 47 48 #include <dev/pci/pcidevs.h> 49 50 #include "isadma.h" 51 52 int pcibmatch(device_t, cfdata_t, void *); 53 void pcibattach(device_t, device_t, void *); 54 55 CFATTACH_DECL_NEW(pcib, 0, 56 pcibmatch, pcibattach, NULL, NULL); 57 58 void pcib_callback(device_t); 59 60 int 61 pcibmatch(device_t parent, cfdata_t match, void *aux) 62 { 63 struct pci_attach_args *pa = aux; 64 65 /* 66 * Match tested PCI-ISA bridges. 67 */ 68 switch (PCI_VENDOR(pa->pa_id)) { 69 case PCI_VENDOR_WINBOND: 70 switch (PCI_PRODUCT(pa->pa_id)) { 71 case PCI_PRODUCT_WINBOND_W83C553F_0: 72 return (1); 73 } 74 break; 75 76 case PCI_VENDOR_SYMPHONY: 77 switch (PCI_PRODUCT(pa->pa_id)) { 78 case PCI_PRODUCT_SYMPHONY_83C553: 79 return (1); 80 } 81 break; 82 } 83 84 return (0); 85 } 86 87 void 88 pcibattach(device_t parent, device_t self, void *aux) 89 { 90 struct pci_attach_args *pa = aux; 91 char devinfo[256]; 92 93 printf("\n"); 94 95 /* 96 * Just print out a description and set the ISA bus 97 * callback. 98 */ 99 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); 100 printf("%s: %s (rev. 0x%02x)\n", device_xname(self), devinfo, 101 PCI_REVISION(pa->pa_class)); 102 103 /* Set the ISA bus callback */ 104 config_defer(self, pcib_callback); 105 } 106 107 void 108 pcib_callback(device_t self) 109 { 110 struct isabus_attach_args iba; 111 112 /* 113 * Attach the ISA bus behind this bridge. 114 */ 115 memset(&iba, 0, sizeof(iba)); 116 iba.iba_iot = &isa_io_bs_tag; 117 iba.iba_memt = &isa_mem_bs_tag; 118 #if NISADMA > 0 119 iba.iba_dmat = &isa_bus_dma_tag; 120 #endif 121 config_found(self, &iba, isabusprint, CFARGS_NONE); 122 } 123