1 /*- 2 * Copyright (c) 2015 Landon Fuller <landon@landonf.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13 * redistribution must be conditioned upon including a substantially 14 * similar Disclaimer requirement for further binary redistribution. 15 * 16 * NO WARRANTY 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30 #include <sys/cdefs.h> 31 __FBSDID("$FreeBSD$"); 32 33 /* 34 * Broadcom PCI-BHND Host Bridge. 35 * 36 * This driver is used to "eat" PCI(e) cores operating in endpoint mode when 37 * they're attached to a bhndb_pci driver on the host side. 38 */ 39 40 #include <sys/param.h> 41 #include <sys/kernel.h> 42 #include <sys/bus.h> 43 #include <sys/module.h> 44 45 #include <machine/bus.h> 46 #include <sys/rman.h> 47 #include <machine/resource.h> 48 49 #include <dev/bhnd/bhnd.h> 50 51 #include "bhnd_pcireg.h" 52 53 #include "bhnd_pcibvar.h" 54 55 static const struct bhnd_pcib_device { 56 uint16_t vendor; 57 uint16_t device; 58 const char *desc; 59 } bhnd_pcib_devs[] = { 60 { BHND_MFGID_BCM, BHND_COREID_PCI, "BHND Host-PCI bridge" }, 61 { BHND_MFGID_BCM, BHND_COREID_PCIE, "BHND Host-PCI bridge (PCIe Gen1)" }, 62 { BHND_MFGID_INVALID, BHND_COREID_INVALID, NULL } 63 }; 64 65 static int 66 bhnd_pcib_probe(device_t dev) 67 { 68 const struct bhnd_pcib_device *id; 69 70 /* Ignore PCI cores configured in host bridge mode */ 71 if (bhnd_is_hostb_device(dev)) 72 return (ENXIO); 73 74 for (id = bhnd_pcib_devs; id->device != BHND_COREID_INVALID; id++) { 75 if (bhnd_get_vendor(dev) != id->vendor) 76 continue; 77 78 if (bhnd_get_device(dev) != id->device) 79 continue; 80 81 device_set_desc(dev, id->desc); 82 return (BUS_PROBE_SPECIFIC); 83 } 84 85 return (ENXIO); 86 } 87 88 static int 89 bhnd_pcib_attach(device_t dev) 90 { 91 return (ENXIO); 92 } 93 94 static int 95 bhnd_pcib_detach(device_t dev) 96 { 97 return (ENXIO); 98 } 99 100 static int 101 bhnd_pcib_suspend(device_t dev) 102 { 103 return (ENXIO); 104 } 105 106 static int 107 bhnd_pcib_resume(device_t dev) 108 { 109 return (ENXIO); 110 } 111 112 static device_method_t bhnd_pcib_methods[] = { 113 /* Device interface */ 114 DEVMETHOD(device_probe, bhnd_pcib_probe), 115 DEVMETHOD(device_attach, bhnd_pcib_attach), 116 DEVMETHOD(device_detach, bhnd_pcib_detach), 117 DEVMETHOD(device_suspend, bhnd_pcib_suspend), 118 DEVMETHOD(device_resume, bhnd_pcib_resume), 119 DEVMETHOD_END 120 }; 121 122 DEFINE_CLASS_0(bhnd_pcib, bhnd_pcib_driver, bhnd_pcib_methods, sizeof(struct bhnd_pcib_softc)); 123 DRIVER_MODULE(bhnd_pcib, bhnd, bhnd_pcib_driver, bhnd_hostb_devclass, 0, 0); 124 125 MODULE_VERSION(bhnd_pcib, 1); 126 MODULE_DEPEND(bhnd_pcib, pci, 1, 1, 1); 127 MODULE_DEPEND(bhnd_pcib, bhnd_pci_mdio, 1, 1, 1); 128