puc_pci.c (227843) | puc_pci.c (263109) |
---|---|
1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> | 1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> |
61__FBSDID("$FreeBSD: head/sys/dev/puc/puc_pci.c 227843 2011-11-22 21:28:20Z marius $"); | 61__FBSDID("$FreeBSD: head/sys/dev/puc/puc_pci.c 263109 2014-03-13 15:57:25Z rstone $"); |
62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/kernel.h> 66#include <sys/module.h> 67#include <sys/bus.h> 68#include <sys/conf.h> 69#include <sys/malloc.h> | 62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/kernel.h> 66#include <sys/module.h> 67#include <sys/bus.h> 68#include <sys/conf.h> 69#include <sys/malloc.h> |
70#include <sys/sysctl.h> |
|
70 71#include <machine/bus.h> 72#include <machine/resource.h> 73#include <sys/rman.h> 74 75#include <dev/pci/pcireg.h> 76#include <dev/pci/pcivar.h> 77 78#include <dev/puc/puc_cfg.h> 79#include <dev/puc/puc_bfe.h> 80 | 71 72#include <machine/bus.h> 73#include <machine/resource.h> 74#include <sys/rman.h> 75 76#include <dev/pci/pcireg.h> 77#include <dev/pci/pcivar.h> 78 79#include <dev/puc/puc_cfg.h> 80#include <dev/puc/puc_bfe.h> 81 |
82static int puc_msi_disable; 83TUNABLE_INT("hw.puc.msi_disable", &puc_msi_disable); 84SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RD | CTLFLAG_TUN, 85 &puc_msi_disable, 0, "Disable use of MSI interrupts by puc(9)"); 86 |
|
81static const struct puc_cfg * 82puc_pci_match(device_t dev, const struct puc_cfg *desc) 83{ 84 uint16_t vendor, device; 85 uint16_t subvendor, subdevice; 86 87 vendor = pci_get_vendor(dev); 88 device = pci_get_device(dev); --- 26 unchanged lines hidden (view full) --- 115 return (ENXIO); 116 117 desc = puc_pci_match(dev, puc_pci_devices); 118 if (desc == NULL) 119 return (ENXIO); 120 return (puc_bfe_probe(dev, desc)); 121} 122 | 87static const struct puc_cfg * 88puc_pci_match(device_t dev, const struct puc_cfg *desc) 89{ 90 uint16_t vendor, device; 91 uint16_t subvendor, subdevice; 92 93 vendor = pci_get_vendor(dev); 94 device = pci_get_device(dev); --- 26 unchanged lines hidden (view full) --- 121 return (ENXIO); 122 123 desc = puc_pci_match(dev, puc_pci_devices); 124 if (desc == NULL) 125 return (ENXIO); 126 return (puc_bfe_probe(dev, desc)); 127} 128 |
129static int 130puc_pci_attach(device_t dev) 131{ 132 struct puc_softc *sc; 133 int error, count; 134 135 sc = device_get_softc(dev); 136 137 if (!puc_msi_disable) { 138 count = 1; 139 140 if (pci_alloc_msi(dev, &count) == 0) { 141 sc->sc_msi = 1; 142 sc->sc_irid = 1; 143 } 144 } 145 146 error = puc_bfe_attach(dev); 147 148 if (error != 0 && sc->sc_msi) 149 pci_release_msi(dev); 150 151 return (error); 152} 153 154static int 155puc_pci_detach(device_t dev) 156{ 157 struct puc_softc *sc; 158 int error; 159 160 sc = device_get_softc(dev); 161 162 error = puc_bfe_detach(dev); 163 164 if (error != 0) 165 return (error); 166 167 if (sc->sc_msi) 168 error = pci_release_msi(dev); 169 170 return (error); 171} 172 173 |
|
123static device_method_t puc_pci_methods[] = { 124 /* Device interface */ 125 DEVMETHOD(device_probe, puc_pci_probe), | 174static device_method_t puc_pci_methods[] = { 175 /* Device interface */ 176 DEVMETHOD(device_probe, puc_pci_probe), |
126 DEVMETHOD(device_attach, puc_bfe_attach), 127 DEVMETHOD(device_detach, puc_bfe_detach), | 177 DEVMETHOD(device_attach, puc_pci_attach), 178 DEVMETHOD(device_detach, puc_pci_detach), |
128 129 DEVMETHOD(bus_alloc_resource, puc_bus_alloc_resource), 130 DEVMETHOD(bus_release_resource, puc_bus_release_resource), 131 DEVMETHOD(bus_get_resource, puc_bus_get_resource), 132 DEVMETHOD(bus_read_ivar, puc_bus_read_ivar), 133 DEVMETHOD(bus_setup_intr, puc_bus_setup_intr), 134 DEVMETHOD(bus_teardown_intr, puc_bus_teardown_intr), 135 DEVMETHOD(bus_print_child, puc_bus_print_child), --- 13 unchanged lines hidden --- | 179 180 DEVMETHOD(bus_alloc_resource, puc_bus_alloc_resource), 181 DEVMETHOD(bus_release_resource, puc_bus_release_resource), 182 DEVMETHOD(bus_get_resource, puc_bus_get_resource), 183 DEVMETHOD(bus_read_ivar, puc_bus_read_ivar), 184 DEVMETHOD(bus_setup_intr, puc_bus_setup_intr), 185 DEVMETHOD(bus_teardown_intr, puc_bus_teardown_intr), 186 DEVMETHOD(bus_print_child, puc_bus_print_child), --- 13 unchanged lines hidden --- |