if_ed_pci.c revision 51442
1/* 2 * 3 * Copyright (c) 1996 Stefan Esser <se@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice immediately at the beginning of the file, without modification, 11 * this list of conditions, and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Absolutely no warranty of function or purpose is made by the author 16 * Stefan Esser. 17 * 4. Modifications may be freely made to this file if the above conditions 18 * are met. 19 * 20 * $FreeBSD: head/sys/dev/ed/if_ed_pci.c 51442 1999-09-20 05:48:16Z peter $ 21 */ 22 23#include "card.h" 24#if NCARD == 0 25 26#include <sys/param.h> 27#include <sys/systm.h> 28#include <sys/socket.h> 29#include <sys/kernel.h> 30#include <sys/module.h> 31#include <sys/bus.h> 32#include <machine/bus.h> 33 34#include <pci/pcireg.h> 35#include <pci/pcivar.h> 36 37#include <net/if.h> 38#include <net/if_arp.h> 39#include <net/if_mib.h> 40 41#include <dev/ed/if_edvar.h> 42 43static struct _pcsid 44{ 45 u_int32_t type; 46 const char *desc; 47} pci_ids[] = 48{ 49 { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" }, 50 { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" }, 51 { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" }, 52 { 0x140111f6, "NE2000 PCI Ethernet (Compex)" }, 53 { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" }, 54 { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" }, 55 { 0x0e3410bd, "NE2000 PCI Ethernet (Surecom NE-34)" }, 56 { 0x09261106, "NE2000 PCI Ethernet (VIA VT86C926)" }, 57 { 0x00000000, NULL } 58}; 59 60extern int ed_attach_NE2000_pci __P((device_t dev, int)); 61 62static int ed_pci_probe __P((device_t)); 63static int ed_pci_attach __P((device_t)); 64 65static int 66ed_pci_probe (device_t dev) 67{ 68 u_int32_t type = pci_get_devid(dev); 69 struct _pcsid *ep =pci_ids; 70 71 while (ep->type && ep->type != type) 72 ++ep; 73 if (ep->desc) { 74 device_set_desc(dev, ep->desc); 75 return 0; 76 } else { 77 return ENXIO; 78 } 79} 80 81static int 82ed_pci_attach(device_t dev) 83{ 84 return ed_attach_NE2000_pci(dev, PCIR_MAPS); 85} 86 87static device_method_t ed_pci_methods[] = { 88 /* Device interface */ 89 DEVMETHOD(device_probe, ed_pci_probe), 90 DEVMETHOD(device_attach, ed_pci_attach), 91 92 { 0, 0 } 93}; 94 95static driver_t ed_pci_driver = { 96 "ed", 97 ed_pci_methods, 98 sizeof(struct ed_softc), 99}; 100 101static devclass_t ed_devclass; 102 103DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); 104#endif 105