if_ed_pci.c revision 33893
1222509Snp/*
2237263Snp *
3222509Snp * Copyright (c) 1996 Stefan Esser <se@freebsd.org>
4222509Snp * All rights reserved.
5222509Snp *
6222509Snp * Redistribution and use in source and binary forms, with or without
7222509Snp * modification, are permitted provided that the following conditions
8222509Snp * are met:
9222509Snp * 1. Redistributions of source code must retain the above copyright
10222509Snp *    notice immediately at the beginning of the file, without modification,
11222509Snp *    this list of conditions, and the following disclaimer.
12222509Snp * 2. Redistributions in binary form must reproduce the above copyright
13222509Snp *    notice, this list of conditions and the following disclaimer in the
14222509Snp *    documentation and/or other materials provided with the distribution.
15222509Snp * 3. Absolutely no warranty of function or purpose is made by the author
16222509Snp *    Stefan Esser.
17222509Snp * 4. Modifications may be freely made to this file if the above conditions
18222509Snp *    are met.
19222509Snp *
20222509Snp *	$Id: if_ed_p.c,v 1.11 1997/11/22 06:19:59 msmith Exp $
21222509Snp */
22222509Snp
23222509Snp#include "pci.h"
24222509Snp#if NPCI > 0
25222509Snp
26222509Snp#include <sys/param.h>
27222509Snp#include <sys/systm.h>
28222509Snp#include <sys/malloc.h>
29222509Snp#include <sys/kernel.h>
30222509Snp#include <pci/pcireg.h>
31222509Snp#include <pci/pcivar.h>
32222509Snp
33222509Snp#include "ed.h"
34222509Snp
35222509Snpstatic struct _pcsid
36222509Snp{
37222509Snp	pcidi_t		type;
38222509Snp	char	*desc;
39222509Snp} pci_ids[] =
40228561Snp{
41222509Snp	{ 0x802910ec,	"NE2000 PCI Ethernet (RealTek 8029)"	},
42222509Snp	{ 0x50004a14,	"NE2000 PCI Ethernet (NetVin 5000)"	},
43222509Snp	{ 0x09401050,	"NE2000 PCI Ethernet (ProLAN)"		},
44222509Snp	{ 0x140111f6,	"NE2000 PCI Ethernet (Compex)"		},
45222509Snp	{ 0x30008e2e,	"NE2000 PCI Ethernet (KTI)"		},
46222509Snp	{ 0x19808c4a,	"NE2000 PCI Ethernet (Winbond W89C940)" },
47222509Snp	{ 0x0e3410bd,	"NE2000 PCI Ethernet (Surecom NE-34)"	},
48228561Snp	{ 0x00000000,	NULL					}
49228561Snp};
50228561Snp
51228561Snpextern void *ed_attach_NE2000_pci __P((int, int));
52228561Snp
53228561Snpstatic char* ed_pci_probe __P((pcici_t tag, pcidi_t type));
54228561Snpstatic void ed_pci_attach __P((pcici_t config_id, int unit));
55228561Snp
56228561Snpstatic u_long ed_pci_count = NED;
57228561Snp
58228561Snpstatic struct pci_device ed_pci_driver = {
59228561Snp	"ed",
60228561Snp	ed_pci_probe,
61228561Snp	ed_pci_attach,
62228561Snp	&ed_pci_count,
63228561Snp	NULL
64228561Snp};
65228561Snp
66222509SnpDATA_SET (pcidevice_set, ed_pci_driver);
67228561Snp
68222509Snpstatic char*
69237263Snped_pci_probe (pcici_t tag, pcidi_t type)
70237263Snp{
71228561Snp	struct _pcsid	*ep =pci_ids;
72228561Snp
73228561Snp	while (ep->type && ep->type != type)
74228561Snp		++ep;
75228561Snp	return (ep->desc);
76228561Snp}
77228561Snp
78228561Snpvoid edintr_sc (void*);
79228561Snp
80228561Snpstatic void
81228561Snped_pci_attach(config_id, unit)
82228561Snp	pcici_t config_id;
83228561Snp	int	unit;
84237263Snp{
85237263Snp	int io_port;
86228561Snp	void *ed; /* device specific data ... */
87228561Snp
88228561Snp	io_port = pci_conf_read(config_id, PCI_MAP_REG_START) & ~PCI_MAP_IO;
89228561Snp
90228561Snp	ed = ed_attach_NE2000_pci(unit, io_port);
91228561Snp	if (!ed)
92228561Snp		return;
93228561Snp
94228561Snp	if(!(pci_map_int(config_id, edintr_sc, (void *)ed, &net_imask))) {
95228561Snp		free (ed, M_DEVBUF);
96228561Snp		return;
97228561Snp	}
98228561Snp
99228561Snp	return;
100228561Snp}
101228561Snp
102228561Snp#endif /* NPCI > 0 */
103228561Snp
104228561Snp