if_ed_pci.c revision 16289
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 *
2016289Salex *	$Id: if_ed_p.c,v 1.1 1996/05/18 17:56:40 se Exp $
2115813Sse */
2215813Sse
2315813Sse#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#include <i386/isa/isa_device.h>
3315813Sse
3415813Sse#include <ed.h>
3515813Sse
3615813Sse#define PCI_DEVICE_ID_NE2000	0x802910ec
3715813Sse
3816289Salexextern void *ed_attach_NE2000_pci __P((int, int));
3916289Salex
4015813Ssestatic char* ed_pci_probe __P((pcici_t tag, pcidi_t type));
4115813Ssestatic void ed_pci_attach __P((pcici_t config_id, int unit));
4215813Sse
4315813Ssestatic u_long ed_pci_count = NED;
4415813Sse
4515813Ssestatic struct pci_device ed_pci_driver = {
4615813Sse	"ed",
4715813Sse	ed_pci_probe,
4815813Sse	ed_pci_attach,
4915813Sse	&ed_pci_count,
5016289Salex	NULL
5115813Sse};
5215813Sse
5315813SseDATA_SET (pcidevice_set, ed_pci_driver);
5415813Sse
5515813Ssestatic char*
5615813Sseed_pci_probe (pcici_t tag, pcidi_t type)
5715813Sse{
5815813Sse	switch(type) {
5915813Sse	case PCI_DEVICE_ID_NE2000:
6015813Sse		return ("NE2000 compatible PCI Ethernet adapter");
6115813Sse		break;
6215813Sse	default:
6315813Sse		break;
6415813Sse	}
6515813Sse	return (0);
6615813Sse}
6715813Sse
6815813Ssevoid edintr_sc (void*);
6915813Sse
7015813Ssestatic void
7115813Sseed_pci_attach(config_id, unit)
7215813Sse	pcici_t config_id;
7315813Sse	int	unit;
7415813Sse{
7515813Sse	u_long io_port;
7615813Sse	void *ed; /* device specific data ... */
7715813Sse
7815813Sse	io_port = pci_conf_read(config_id, PCI_MAP_REG_START) & ~PCI_MAP_IO;
7915813Sse
8015813Sse	ed = ed_attach_NE2000_pci(unit, io_port);
8115813Sse	if (!ed)
8215813Sse		return;
8315813Sse
8415813Sse	if(!(pci_map_int(config_id, edintr_sc, (void *)ed, &net_imask))) {
8515813Sse		free (ed, M_DEVBUF);
8615813Sse		return;
8715813Sse	}
8815813Sse
8915813Sse	return;
9015813Sse}
9115813Sse
9215813Sse#endif /* NPCI > 0 */
9315813Sse
94