if_ed_pci.c revision 31347
115813Sse/* 215813Sse * 315813Sse * Copyright (c) 1996 Stefan Esser <se@freebsd.org> 415813Sse * All rights reserved. 515813Sse * 615813Sse * Redistribution and use in source and binary forms, with or without 715813Sse * modification, are permitted provided that the following conditions 815813Sse * are met: 915813Sse * 1. Redistributions of source code must retain the above copyright 1015813Sse * notice immediately at the beginning of the file, without modification, 1115813Sse * this list of conditions, and the following disclaimer. 1215813Sse * 2. Redistributions in binary form must reproduce the above copyright 1315813Sse * notice, this list of conditions and the following disclaimer in the 1415813Sse * documentation and/or other materials provided with the distribution. 1515813Sse * 3. Absolutely no warranty of function or purpose is made by the author 1615813Sse * Stefan Esser. 1715813Sse * 4. Modifications may be freely made to this file if the above conditions 1815813Sse * are met. 1915813Sse * 2031347Smsmith * $Id: if_ed_p.c,v 1.10 1997/08/14 07:53:07 danny Exp $ 2115813Sse */ 2215813Sse 2317877Sbde#include "pci.h" 2415813Sse#if NPCI > 0 2515813Sse 2615813Sse#include <sys/param.h> 2715813Sse#include <sys/systm.h> 2815813Sse#include <sys/malloc.h> 2915813Sse#include <sys/kernel.h> 3015813Sse#include <pci/pcireg.h> 3115813Sse#include <pci/pcivar.h> 3215813Sse 3318946Sbde#include "ed.h" 3415813Sse 3524995Sdavidnstatic struct _pcsid 3624995Sdavidn{ 3724995Sdavidn pcidi_t type; 3824995Sdavidn char *desc; 3924995Sdavidn} pci_ids[] = 4024995Sdavidn{ 4124995Sdavidn { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" }, 4228210Sdanny { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" }, 4324995Sdavidn { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" }, 4424995Sdavidn { 0x140111f6, "NE2000 PCI Ethernet (Compex)" }, 4524995Sdavidn { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" }, 4631347Smsmith { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" }, 4724995Sdavidn { 0x00000000, NULL } 4824995Sdavidn}; 4915813Sse 5016289Salexextern void *ed_attach_NE2000_pci __P((int, int)); 5116289Salex 5215813Ssestatic char* ed_pci_probe __P((pcici_t tag, pcidi_t type)); 5315813Ssestatic void ed_pci_attach __P((pcici_t config_id, int unit)); 5415813Sse 5515813Ssestatic u_long ed_pci_count = NED; 5615813Sse 5715813Ssestatic struct pci_device ed_pci_driver = { 5815813Sse "ed", 5915813Sse ed_pci_probe, 6015813Sse ed_pci_attach, 6115813Sse &ed_pci_count, 6216289Salex NULL 6315813Sse}; 6415813Sse 6515813SseDATA_SET (pcidevice_set, ed_pci_driver); 6615813Sse 6715813Ssestatic char* 6815813Sseed_pci_probe (pcici_t tag, pcidi_t type) 6915813Sse{ 7024995Sdavidn struct _pcsid *ep =pci_ids; 7124995Sdavidn 7224995Sdavidn while (ep->type && ep->type != type) 7324995Sdavidn ++ep; 7424995Sdavidn return (ep->desc); 7515813Sse} 7615813Sse 7715813Ssevoid edintr_sc (void*); 7815813Sse 7915813Ssestatic void 8015813Sseed_pci_attach(config_id, unit) 8115813Sse pcici_t config_id; 8215813Sse int unit; 8315813Sse{ 8420723Sse int io_port; 8515813Sse void *ed; /* device specific data ... */ 8615813Sse 8715813Sse io_port = pci_conf_read(config_id, PCI_MAP_REG_START) & ~PCI_MAP_IO; 8815813Sse 8915813Sse ed = ed_attach_NE2000_pci(unit, io_port); 9015813Sse if (!ed) 9115813Sse return; 9215813Sse 9315813Sse if(!(pci_map_int(config_id, edintr_sc, (void *)ed, &net_imask))) { 9415813Sse free (ed, M_DEVBUF); 9515813Sse return; 9615813Sse } 9715813Sse 9815813Sse return; 9915813Sse} 10015813Sse 10115813Sse#endif /* NPCI > 0 */ 10215813Sse 103