ofw_pcib.c (200874) | ofw_pcib.c (200987) |
---|---|
1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 - 2003 Thomas Moestl <tmm@FreeBSD.org> | 1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 - 2003 Thomas Moestl <tmm@FreeBSD.org> |
6 * Copyright (c) 2009 by Marius Strobl <marius@FreeBSD.org> |
|
6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright --- 13 unchanged lines hidden (view full) --- 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 32 */ 33 34#include <sys/cdefs.h> | 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright --- 13 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 33 */ 34 35#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/sparc64/pci/ofw_pcib.c 200874 2009-12-22 21:02:46Z marius $"); | 36__FBSDID("$FreeBSD: head/sys/sparc64/pci/ofw_pcib.c 200987 2009-12-25 15:03:05Z marius $"); |
36 37#include "opt_ofw_pci.h" 38 39#include <sys/param.h> | 37 38#include "opt_ofw_pci.h" 39 40#include <sys/param.h> |
40#include <sys/kernel.h> | |
41#include <sys/bus.h> | 41#include <sys/bus.h> |
42#include <sys/kernel.h> 43#include <sys/libkern.h> |
|
42#include <sys/module.h> 43 44#include <dev/ofw/ofw_bus.h> 45#include <dev/ofw/openfirm.h> 46 47#include <machine/bus.h> 48 49#include <dev/pci/pcireg.h> --- 27 unchanged lines hidden (view full) --- 77 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 78 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 79 80 /* pcib interface */ 81 DEVMETHOD(pcib_maxslots, pcib_maxslots), 82 DEVMETHOD(pcib_read_config, pcib_read_config), 83 DEVMETHOD(pcib_write_config, pcib_write_config), 84 DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt), | 44#include <sys/module.h> 45 46#include <dev/ofw/ofw_bus.h> 47#include <dev/ofw/openfirm.h> 48 49#include <machine/bus.h> 50 51#include <dev/pci/pcireg.h> --- 27 unchanged lines hidden (view full) --- 79 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 80 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 81 82 /* pcib interface */ 83 DEVMETHOD(pcib_maxslots, pcib_maxslots), 84 DEVMETHOD(pcib_read_config, pcib_read_config), 85 DEVMETHOD(pcib_write_config, pcib_write_config), 86 DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt), |
87 DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), 88 DEVMETHOD(pcib_release_msi, pcib_release_msi), 89 DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), 90 DEVMETHOD(pcib_release_msix, pcib_release_msix), 91 DEVMETHOD(pcib_map_msi, pcib_map_msi), |
|
85 86 /* ofw_bus interface */ 87 DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node), 88 89 KOBJMETHOD_END 90}; 91 92static devclass_t pcib_devclass; 93 94DEFINE_CLASS_0(pcib, ofw_pcib_driver, ofw_pcib_methods, 95 sizeof(struct ofw_pcib_gen_softc)); 96EARLY_DRIVER_MODULE(ofw_pcib, pci, ofw_pcib_driver, pcib_devclass, 0, 0, 97 BUS_PASS_BUS); 98MODULE_DEPEND(ofw_pcib, pci, 1, 1, 1); 99 100static int 101ofw_pcib_probe(device_t dev) 102{ | 92 93 /* ofw_bus interface */ 94 DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node), 95 96 KOBJMETHOD_END 97}; 98 99static devclass_t pcib_devclass; 100 101DEFINE_CLASS_0(pcib, ofw_pcib_driver, ofw_pcib_methods, 102 sizeof(struct ofw_pcib_gen_softc)); 103EARLY_DRIVER_MODULE(ofw_pcib, pci, ofw_pcib_driver, pcib_devclass, 0, 0, 104 BUS_PASS_BUS); 105MODULE_DEPEND(ofw_pcib, pci, 1, 1, 1); 106 107static int 108ofw_pcib_probe(device_t dev) 109{ |
110 char desc[sizeof("OFW PCIe-PCIe bridge")]; 111 const char *dtype, *pbdtype; |
|
103 | 112 |
113#define ISDTYPE(dtype, type) \ 114 (((dtype) != NULL) && strcmp((dtype), (type)) == 0) 115 |
|
104 if ((pci_get_class(dev) == PCIC_BRIDGE) && 105 (pci_get_subclass(dev) == PCIS_BRIDGE_PCI) && 106 ofw_bus_get_node(dev) != 0) { | 116 if ((pci_get_class(dev) == PCIC_BRIDGE) && 117 (pci_get_subclass(dev) == PCIS_BRIDGE_PCI) && 118 ofw_bus_get_node(dev) != 0) { |
107 device_set_desc(dev, "OFW PCI-PCI bridge"); | 119 dtype = ofw_bus_get_type(dev); 120 pbdtype = ofw_bus_get_type(device_get_parent( 121 device_get_parent(dev))); 122 snprintf(desc, sizeof(desc), "OFW PCI%s-PCI%s bridge", 123 ISDTYPE(pbdtype, OFW_TYPE_PCIE) ? "e" : "", 124 ISDTYPE(dtype, OFW_TYPE_PCIE) ? "e" : ""); 125 device_set_desc_copy(dev, desc); |
108 return (0); 109 } | 126 return (0); 127 } |
128 129#undef ISDTYPE 130 |
|
110 return (ENXIO); 111} 112 113static int 114ofw_pcib_attach(device_t dev) 115{ | 131 return (ENXIO); 132} 133 134static int 135ofw_pcib_attach(device_t dev) 136{ |
137 struct ofw_pcib_gen_softc *sc; |
|
116 | 138 |
139 sc = device_get_softc(dev); 140 141 /* Quirk handling */ 142 switch (pci_get_devid(dev)) { 143 /* 144 * The ALi M5249 found in Fire-based machines by definition must me 145 * subtractive as they have a ISA bridge on their secondary side but 146 * don't indicate this in the class code although the ISA I/O range 147 * isn't included in their bridge decode. 148 */ 149 case 0x524910b9: 150 sc->ops_pcib_sc.flags |= PCIB_SUBTRACTIVE; 151 break; 152 } 153 |
|
117 ofw_pcib_gen_setup(dev); 118 pcib_attach_common(dev); 119 device_add_child(dev, "pci", -1); 120 return (bus_generic_attach(dev)); 121} | 154 ofw_pcib_gen_setup(dev); 155 pcib_attach_common(dev); 156 device_add_child(dev, "pci", -1); 157 return (bus_generic_attach(dev)); 158} |