if_ed_pci.c revision 149558
1119418Sobrien/*- 215813Sse * Copyright (c) 1996 Stefan Esser <se@freebsd.org> 315813Sse * All rights reserved. 415813Sse * 515813Sse * Redistribution and use in source and binary forms, with or without 615813Sse * modification, are permitted provided that the following conditions 715813Sse * are met: 815813Sse * 1. Redistributions of source code must retain the above copyright 915813Sse * notice immediately at the beginning of the file, without modification, 1015813Sse * this list of conditions, and the following disclaimer. 1115813Sse * 2. Redistributions in binary form must reproduce the above copyright 1215813Sse * notice, this list of conditions and the following disclaimer in the 1315813Sse * documentation and/or other materials provided with the distribution. 1415813Sse * 3. Absolutely no warranty of function or purpose is made by the author 1515813Sse * Stefan Esser. 1615813Sse * 4. Modifications may be freely made to this file if the above conditions 1715813Sse * are met. 1815813Sse */ 1915813Sse 20119418Sobrien#include <sys/cdefs.h> 21119418Sobrien__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_pci.c 149558 2005-08-28 23:56:25Z imp $"); 22119418Sobrien 2315813Sse#include <sys/param.h> 2473374Simp#include <sys/systm.h> 2550852Speter#include <sys/socket.h> 2615813Sse#include <sys/kernel.h> 2752247Smdodd 2850852Speter#include <sys/module.h> 2950852Speter#include <sys/bus.h> 3052247Smdodd 3150852Speter#include <machine/bus.h> 3252247Smdodd#include <sys/rman.h> 3352247Smdodd#include <machine/resource.h> 3450852Speter 3550852Speter#include <net/if.h> 3650852Speter#include <net/if_arp.h> 37149558Simp#include <net/if_media.h> 3850852Speter#include <net/if_mib.h> 3915813Sse 40119277Simp#include <dev/pci/pcireg.h> 41119277Simp#include <dev/pci/pcivar.h> 4252247Smdodd 4351442Speter#include <dev/ed/if_edvar.h> 4450852Speter 4524995Sdavidnstatic struct _pcsid 4624995Sdavidn{ 47140468Simp uint32_t type; 4850852Speter const char *desc; 4924995Sdavidn} pci_ids[] = 5024995Sdavidn{ 5124995Sdavidn { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" }, 5228210Sdanny { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" }, 5324995Sdavidn { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" }, 5424995Sdavidn { 0x140111f6, "NE2000 PCI Ethernet (Compex)" }, 5524995Sdavidn { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" }, 5631347Smsmith { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" }, 5733893Sse { 0x0e3410bd, "NE2000 PCI Ethernet (Surecom NE-34)" }, 5834645Sdanny { 0x09261106, "NE2000 PCI Ethernet (VIA VT86C926)" }, 5924995Sdavidn { 0x00000000, NULL } 6024995Sdavidn}; 6115813Sse 62130657Simpstatic int ed_pci_probe(device_t); 63130657Simpstatic int ed_pci_attach(device_t); 6416289Salex 6550852Speterstatic int 66130659Simped_pci_probe(device_t dev) 6715813Sse{ 68140468Simp uint32_t type = pci_get_devid(dev); 6924995Sdavidn struct _pcsid *ep =pci_ids; 7024995Sdavidn 7124995Sdavidn while (ep->type && ep->type != type) 7224995Sdavidn ++ep; 73143161Simp if (ep->desc == NULL) 74143161Simp return (ENXIO); 75143161Simp device_set_desc(dev, ep->desc); 76143161Simp return (BUS_PROBE_DEFAULT); 7715813Sse} 7815813Sse 7950852Speterstatic int 8050852Spetered_pci_attach(device_t dev) 8115813Sse{ 82147184Simp struct ed_softc *sc = device_get_softc(dev); 83147184Simp int flags = 0; 84147184Simp int error; 8552247Smdodd 86147184Simp error = ed_probe_Novell(dev, PCIR_BAR(0), flags); 87147184Simp if (error) { 88147184Simp ed_release_resources(dev); 89147184Simp return (error); 90141577Simp } 91147149Simp ed_Novell_read_mac(sc); 9252247Smdodd 93147184Simp error = ed_alloc_irq(dev, 0, RF_SHAREABLE); 94147184Simp if (error) { 95147184Simp ed_release_resources(dev); 96147184Simp return (error); 97147184Simp } 98149558Simp error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, 99142254Simp edintr, sc, &sc->irq_handle); 100147184Simp if (error) { 101147184Simp ed_release_resources(dev); 102147184Simp return (error); 103147184Simp } 10452247Smdodd 105121816Sbrooks error = ed_attach(dev); 106147184Simp if (error) 107147184Simp ed_release_resources(dev); 10852247Smdodd return (error); 10950852Speter} 11015813Sse 11150852Speterstatic device_method_t ed_pci_methods[] = { 11250852Speter /* Device interface */ 11350852Speter DEVMETHOD(device_probe, ed_pci_probe), 11450852Speter DEVMETHOD(device_attach, ed_pci_attach), 115141494Simp DEVMETHOD(device_attach, ed_detach), 11615813Sse 11750852Speter { 0, 0 } 11850852Speter}; 11915813Sse 12050852Speterstatic driver_t ed_pci_driver = { 12150852Speter "ed", 12250852Speter ed_pci_methods, 12350852Speter sizeof(struct ed_softc), 12450852Speter}; 12515813Sse 126113506SmdoddDRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); 127113506SmdoddMODULE_DEPEND(ed, pci, 1, 1, 1); 128113506SmdoddMODULE_DEPEND(ed, ether, 1, 1, 1); 129