Lines Matching +full:pci +full:- +full:dev
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
35 * PCI bindings for Apple GMAC and Sun GEM Ethernet controllers
54 #include <dev/ofw/ofw_bus.h>
55 #include <dev/ofw/openfirm.h>
60 #include <dev/gem/if_gemreg.h>
61 #include <dev/gem/if_gemvar.h>
63 #include <dev/pci/pcireg.h>
64 #include <dev/pci/pcivar.h>
68 static int gem_pci_attach(device_t dev);
69 static int gem_pci_detach(device_t dev);
70 static int gem_pci_probe(device_t dev);
71 static int gem_pci_resume(device_t dev);
72 static int gem_pci_suspend(device_t dev);
113 DRIVER_MODULE(gem, pci, gem_pci_driver, 0, 0);
114 MODULE_PNP_INFO("W32:vendor/device", pci, gem, gem_pci_devlist,
115 nitems(gem_pci_devlist) - 1);
116 MODULE_DEPEND(gem, pci, 1, 1, 1);
120 gem_pci_probe(device_t dev) in gem_pci_probe() argument
125 if (pci_get_devid(dev) == gem_pci_devlist[i].gpd_devid) { in gem_pci_probe()
126 device_set_desc(dev, gem_pci_devlist[i].gpd_desc); in gem_pci_probe()
137 { -1, 0 }
140 #define GEM_SHARED_PINS "shared-pins"
144 gem_pci_attach(device_t dev) in gem_pci_attach() argument
154 sc = device_get_softc(dev); in gem_pci_attach()
155 sc->sc_variant = GEM_UNKNOWN; in gem_pci_attach()
157 if (pci_get_devid(dev) == gem_pci_devlist[i].gpd_devid) { in gem_pci_attach()
158 sc->sc_variant = gem_pci_devlist[i].gpd_variant; in gem_pci_attach()
162 if (sc->sc_variant == GEM_UNKNOWN) { in gem_pci_attach()
163 device_printf(dev, "unknown adaptor\n"); in gem_pci_attach()
167 pci_enable_busmaster(dev); in gem_pci_attach()
169 sc->sc_dev = dev; in gem_pci_attach()
171 if (bus_alloc_resources(dev, gem_pci_res_spec, sc->sc_res)) { in gem_pci_attach()
172 device_printf(dev, "failed to allocate resources\n"); in gem_pci_attach()
173 bus_release_resources(dev, gem_pci_res_spec, sc->sc_res); in gem_pci_attach()
177 GEM_LOCK_INIT(sc, device_get_nameunit(dev)); in gem_pci_attach()
181 sc->sc_flags |= GEM_PCI66; in gem_pci_attach()
184 OF_getetheraddr(dev, sc->sc_enaddr); in gem_pci_attach()
185 if (OF_getprop(ofw_bus_get_node(dev), GEM_SHARED_PINS, buf, in gem_pci_attach()
187 buf[sizeof(buf) - 1] = '\0'; in gem_pci_attach()
189 sc->sc_flags |= GEM_SERDES; in gem_pci_attach()
194 * The VPD resides in the PCI Expansion ROM (PCI FCode) and can't in gem_pci_attach()
195 * be accessed via the PCI capability pointer. in gem_pci_attach()
230 /* Read PCI Expansion ROM header. */ in gem_pci_attach()
234 device_printf(dev, "unexpected PCI Expansion ROM header\n"); in gem_pci_attach()
238 /* Read PCI Expansion ROM data. */ in gem_pci_attach()
240 GEM_ROM_READ_2(sc, i + PCI_ROM_VENDOR) != pci_get_vendor(dev) || in gem_pci_attach()
241 GEM_ROM_READ_2(sc, i + PCI_ROM_DEVICE) != pci_get_device(dev) || in gem_pci_attach()
244 device_printf(dev, "unexpected PCI Expansion ROM data\n"); in gem_pci_attach()
249 * Read PCI VPD. in gem_pci_attach()
250 * SUNW,pci-gem cards have a single large resource VPD-R tag in gem_pci_attach()
251 * containing one NA. The VPD used is not in PCI 2.2 standard in gem_pci_attach()
253 * endian and the end tag is non-standard (0x79) and followed in gem_pci_attach()
254 * by an all-zero "checksum" byte. Sun calls this a "Fresh in gem_pci_attach()
272 device_printf(dev, "unexpected PCI VPD\n"); in gem_pci_attach()
275 bus_read_region_1(sc->sc_res[GEM_RES_MEM], in gem_pci_attach()
277 sc->sc_enaddr, ETHER_ADDR_LEN); in gem_pci_attach()
280 * The Xserve G5 has a fake GMAC with an all-zero MAC address. in gem_pci_attach()
284 for (i = 0; i < ETHER_ADDR_LEN && sc->sc_enaddr[i] == 0; i++) {} in gem_pci_attach()
286 device_printf(dev, "invalid MAC address\n"); in gem_pci_attach()
291 device_printf(dev, "could not be attached\n"); in gem_pci_attach()
295 if (bus_setup_intr(dev, sc->sc_res[GEM_RES_INTR], INTR_TYPE_NET | in gem_pci_attach()
296 INTR_MPSAFE, NULL, gem_intr, sc, &sc->sc_ih) != 0) { in gem_pci_attach()
297 device_printf(dev, "failed to set up interrupt\n"); in gem_pci_attach()
305 bus_release_resources(dev, gem_pci_res_spec, sc->sc_res); in gem_pci_attach()
310 gem_pci_detach(device_t dev) in gem_pci_detach() argument
314 sc = device_get_softc(dev); in gem_pci_detach()
315 bus_teardown_intr(dev, sc->sc_res[GEM_RES_INTR], sc->sc_ih); in gem_pci_detach()
318 bus_release_resources(dev, gem_pci_res_spec, sc->sc_res); in gem_pci_detach()
323 gem_pci_suspend(device_t dev) in gem_pci_suspend() argument
326 gem_suspend(device_get_softc(dev)); in gem_pci_suspend()
331 gem_pci_resume(device_t dev) in gem_pci_resume() argument
334 gem_resume(device_get_softc(dev)); in gem_pci_resume()