Fix conflicts from import, clean up a few printfs, and use the
generic PCI vendor/product definitions, rather than home-grown versions.
This commit is contained in:
parent
1a614aed0c
commit
fee0e539c4
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: if_fpa.c,v 1.9 1996/05/13 00:03:18 mycroft Exp $ */
|
||||
/* $NetBSD: if_fpa.c,v 1.10 1996/05/20 00:30:49 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com)
|
||||
* Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -23,70 +23,18 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Id: if_fpa.c,v 1.2 1995/08/20 18:56:11 thomas Exp
|
||||
*
|
||||
* Log: if_fpa.c,v
|
||||
* Revision 1.2 1995/08/20 18:56:11 thomas
|
||||
* Misc. changes for NetBSD
|
||||
*
|
||||
* Revision 1.1 1995/08/16 22:57:28 thomas
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.13 1995/08/04 21:54:56 thomas
|
||||
* Clean IRQ processing under BSD/OS.
|
||||
* A receive tweaks. (print source of MAC CRC errors, etc.)
|
||||
*
|
||||
* Revision 1.12 1995/06/02 16:04:22 thomas
|
||||
* Use correct PCI defs for BSDI now that they have fixed them.
|
||||
* Increment the slot number 0x1000, not one! (*duh*)
|
||||
*
|
||||
* Revision 1.11 1995/04/21 13:23:55 thomas
|
||||
* Fix a few pub in the DEFPA BSDI support
|
||||
*
|
||||
* Revision 1.10 1995/04/20 21:46:42 thomas
|
||||
* Why???
|
||||
* ,
|
||||
*
|
||||
* Revision 1.9 1995/04/20 20:17:33 thomas
|
||||
* Add PCI support for BSD/OS.
|
||||
* Fix BSD/OS EISA support.
|
||||
* Set latency timer for DEFPA to recommended value if 0.
|
||||
*
|
||||
* Revision 1.8 1995/04/04 22:54:29 thomas
|
||||
* Fix DEFEA support
|
||||
*
|
||||
* Revision 1.7 1995/03/14 01:52:52 thomas
|
||||
* Update for new FreeBSD PCI Interrupt interface
|
||||
*
|
||||
* Revision 1.6 1995/03/10 17:06:59 thomas
|
||||
* Update for latest version of FreeBSD.
|
||||
* Compensate for the fast that the ifp will not be first thing
|
||||
* in softc on BSDI.
|
||||
*
|
||||
* Revision 1.5 1995/03/07 19:59:42 thomas
|
||||
* First pass at BSDI EISA support
|
||||
*
|
||||
* Revision 1.4 1995/03/06 17:06:03 thomas
|
||||
* Add transmit timeout support.
|
||||
* Add support DEFEA (untested).
|
||||
*
|
||||
* Revision 1.3 1995/03/03 13:48:35 thomas
|
||||
* more fixes
|
||||
*
|
||||
* Id: if_fpa.c,v 1.8 1996/05/17 01:15:18 thomas Exp
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEC PDQ FDDI Controller; code for BSD derived operating systems
|
||||
*
|
||||
* Written by Matt Thomas
|
||||
*
|
||||
* This module supports the DEC DEFPA PCI FDDI Controller
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/protosw.h>
|
||||
@ -129,19 +77,23 @@
|
||||
#include "fpa.h"
|
||||
#include <pci/pcivar.h>
|
||||
#include <i386/isa/icu.h>
|
||||
#include <pci/pdqvar.h>
|
||||
#include <pci/pdqreg.h>
|
||||
#include <pci/pdq_os.h>
|
||||
#elif defined(__bsdi__)
|
||||
#if BSDI_VERSION < 199401
|
||||
#include <i386/isa/isavar.h>
|
||||
#include <i386/isa/icu.h>
|
||||
#define DRQNONE 0
|
||||
#define IRQSHARE 0
|
||||
#endif
|
||||
#include <i386/pci/pci.h>
|
||||
#include <i386/pci/pdqvar.h>
|
||||
#include <i386/pci/pdqreg.h>
|
||||
#include <i386/pci/pdq_os.h>
|
||||
#elif defined(__NetBSD__)
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/ic/pdqreg.h>
|
||||
#include <dev/ic/pdqvar.h>
|
||||
#include <dev/ic/pdqreg.h>
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
|
||||
@ -154,71 +106,32 @@
|
||||
|
||||
#define PCI_CFLT 0x0C /* Configuration Latency */
|
||||
#define PCI_CBMA 0x10 /* Configuration Base Memory Address */
|
||||
#define PCI_CBIO 0x14 /* Configuration Base I/O Address */
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
/*
|
||||
* This is the PCI configuration support. Since the PDQ is available
|
||||
* on both EISA and PCI boards, one must be careful in how defines the
|
||||
* PDQ in the config file.
|
||||
*/
|
||||
static char *pdq_pci_probe (pcici_t config_id, pcidi_t device_id);
|
||||
static void pdq_pci_attach(pcici_t config_id, int unit);
|
||||
static int pdq_pci_shutdown(struct kern_devconf *, int);
|
||||
static u_long pdq_pci_count;
|
||||
|
||||
struct pci_device fpadevice = {
|
||||
"fpa",
|
||||
pdq_pci_probe,
|
||||
pdq_pci_attach,
|
||||
&pdq_pci_count,
|
||||
pdq_pci_shutdown,
|
||||
};
|
||||
|
||||
#ifdef DATA_SET
|
||||
DATA_SET (pcidevice_set, fpadevice);
|
||||
#endif
|
||||
static pdq_softc_t *pdqs_pci[NFPA];
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) (pdqs_pci[unit])
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#if defined(__bsdi__)
|
||||
extern struct cfdriver fpacd;
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpacd.cd_devs[unit])
|
||||
#if BSD >= 199506
|
||||
#define pdq_pci_ifwatchdog NULL
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#elif defined(__bsdi__)
|
||||
extern struct cfdriver fpacd;
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpacd.cd_devs[unit])
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
extern struct cfattach fpa_ca;
|
||||
extern struct cfdriver fpa_cd;
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpa_cd.cd_devs[unit])
|
||||
#define pdq_pci_ifwatchdog NULL
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
static ifnet_ret_t
|
||||
pdq_pci_ifinit(
|
||||
struct ifnet *ifp)
|
||||
{
|
||||
pdq_ifinit((pdq_softc_t *)(ifp->if_softc));
|
||||
}
|
||||
|
||||
static ifnet_ret_t
|
||||
pdq_pci_ifwatchdog(
|
||||
struct ifnet *ifp)
|
||||
{
|
||||
pdq_ifwatchdog((pdq_softc_t *)(ifp->if_softc));
|
||||
}
|
||||
#else
|
||||
static ifnet_ret_t
|
||||
pdq_pci_ifinit(
|
||||
int unit)
|
||||
{
|
||||
pdq_ifinit(PDQ_PCI_UNIT_TO_SOFTC(unit));
|
||||
}
|
||||
|
||||
#ifndef pdq_pci_ifwatchdog
|
||||
static ifnet_ret_t
|
||||
pdq_pci_ifwatchdog(
|
||||
int unit)
|
||||
{
|
||||
pdq_ifwatchdog(PDQ_PCI_UNIT_TO_SOFTC(unit));
|
||||
pdq_ifwatchdog(&PDQ_PCI_UNIT_TO_SOFTC(unit)->sc_if);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -236,6 +149,11 @@ pdq_pci_ifintr(
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
/*
|
||||
* This is the PCI configuration support. Since the PDQ is available
|
||||
* on both EISA and PCI boards, one must be careful in how defines the
|
||||
* PDQ in the config file.
|
||||
*/
|
||||
static char *
|
||||
pdq_pci_probe(
|
||||
pcici_t config_id,
|
||||
@ -263,7 +181,7 @@ pdq_pci_attach(
|
||||
}
|
||||
|
||||
data = pci_conf_read(config_id, PCI_CFLT);
|
||||
if ((data & 0xFF00) == 0) {
|
||||
if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) {
|
||||
data &= ~0xFF00;
|
||||
data |= DEFPA_LATENCY << 8;
|
||||
pci_conf_write(config_id, PCI_CFLT, data);
|
||||
@ -281,7 +199,9 @@ pdq_pci_attach(
|
||||
|
||||
sc->sc_if.if_name = "fpa";
|
||||
sc->sc_if.if_unit = unit;
|
||||
sc->sc_pdq = pdq_initialize((void *) va_csrs, "fpa", unit,
|
||||
sc->sc_membase = (pdq_bus_memaddr_t) va_csrs;
|
||||
sc->sc_pdq = pdq_initialize(PDQ_BUS_PCI, sc->sc_membase,
|
||||
sc->sc_if.if_name, sc->sc_if.if_unit,
|
||||
(void *) sc, PDQ_DEFPA);
|
||||
if (sc->sc_pdq == NULL) {
|
||||
free((void *) sc, M_DEVBUF);
|
||||
@ -289,7 +209,7 @@ pdq_pci_attach(
|
||||
}
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6);
|
||||
pdqs_pci[unit] = sc;
|
||||
pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog);
|
||||
pdq_ifattach(sc, pdq_pci_ifwatchdog);
|
||||
pci_map_int(config_id, pdq_pci_ifintr, (void*) sc, &net_imask);
|
||||
}
|
||||
|
||||
@ -303,6 +223,20 @@ pdq_pci_shutdown(
|
||||
(void) dev_detach(kdc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u_long pdq_pci_count;
|
||||
|
||||
struct pci_device fpadevice = {
|
||||
"fpa",
|
||||
pdq_pci_probe,
|
||||
pdq_pci_attach,
|
||||
&pdq_pci_count,
|
||||
pdq_pci_shutdown,
|
||||
};
|
||||
|
||||
#ifdef DATA_SET
|
||||
DATA_SET (pcidevice_set, fpadevice);
|
||||
#endif
|
||||
#elif defined(__bsdi__)
|
||||
|
||||
static int
|
||||
@ -345,10 +279,9 @@ pdq_pci_probe(
|
||||
ffs(ia->ia_irq) - 1, ffs(irq) - 1);
|
||||
return 0;
|
||||
}
|
||||
if (ia->ia_irq == IRQUNK && (ia->ia_irq = isa_irqalloc(irq)) == 0) {
|
||||
printf("fpa%d: error: IRQ %d is already in use\n", cf->cf_unit,
|
||||
ffs(irq) - 1);
|
||||
return 0;
|
||||
if (ia->ia_irq == IRQUNK) {
|
||||
(void) isa_irqalloc(irq);
|
||||
ia->ia_irq = irq;
|
||||
}
|
||||
|
||||
/* PCI bus masters don't use host DMA channels */
|
||||
@ -367,11 +300,12 @@ pdq_pci_probe(
|
||||
|
||||
/* Make sure the latency timer is what the DEFPA likes */
|
||||
data = pci_inl(pa, PCI_CFLT);
|
||||
if ((data & 0xFF00) == 0) {
|
||||
if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) {
|
||||
data &= ~0xFF00;
|
||||
data |= DEFPA_LATENCY << 8;
|
||||
pci_outl(pa, PCI_CFLT, data);
|
||||
}
|
||||
ia->ia_irq |= IRQSHARE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -390,9 +324,11 @@ pdq_pci_attach(
|
||||
sc->sc_if.if_unit = sc->sc_dev.dv_unit;
|
||||
sc->sc_if.if_name = "fpa";
|
||||
sc->sc_if.if_flags = 0;
|
||||
sc->sc_membase = (pdq_bus_memaddr_t) mapphys((vm_offset_t)ia->ia_maddr, ia->ia_msize);
|
||||
|
||||
sc->sc_pdq = pdq_initialize((void *) mapphys((vm_offset_t)ia->ia_maddr, ia->ia_msize), "fpa",
|
||||
sc->sc_if.if_unit, (void *) sc, PDQ_DEFPA);
|
||||
sc->sc_pdq = pdq_initialize(PDQ_BUS_PCI, sc->sc_membase,
|
||||
sc->sc_if.if_nme, sc->sc_if.if_unit,
|
||||
(void *) sc, PDQ_DEFPA);
|
||||
if (sc->sc_pdq == NULL) {
|
||||
printf("fpa%d: initialization failed\n", sc->sc_if.if_unit);
|
||||
return;
|
||||
@ -400,7 +336,7 @@ pdq_pci_attach(
|
||||
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6);
|
||||
|
||||
pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog);
|
||||
pdq_ifattach(sc, pdq_pci_ifwatchdog);
|
||||
|
||||
isa_establish(&sc->sc_id, &sc->sc_dev);
|
||||
|
||||
@ -414,23 +350,27 @@ pdq_pci_attach(
|
||||
}
|
||||
|
||||
struct cfdriver fpacd = {
|
||||
0, "fpa", pdq_pci_probe, pdq_pci_attach, DV_IFNET, sizeof(pdq_softc_t)
|
||||
0, "fpa", pdq_pci_probe, pdq_pci_attach,
|
||||
#if _BSDI_VERSION >= 199401
|
||||
DV_IFNET,
|
||||
#endif
|
||||
sizeof(pdq_softc_t)
|
||||
};
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
static int
|
||||
pdq_pci_probe(
|
||||
pdq_pci_match(
|
||||
struct device *parent,
|
||||
void *match,
|
||||
void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
|
||||
|
||||
if (PCI_VENDORID(pa->pa_id) != DEC_VENDORID)
|
||||
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_DEC)
|
||||
return 0;
|
||||
if (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_DEC_DEFPA)
|
||||
return 0;
|
||||
if (PCI_CHIPID(pa->pa_id) == DEFPA_CHIPID)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -441,51 +381,92 @@ pdq_pci_attach(
|
||||
struct device * const self,
|
||||
void * const aux)
|
||||
{
|
||||
vm_offset_t va_csrs, pa_csrs;
|
||||
pdq_uint32_t data;
|
||||
pdq_softc_t * const sc = (pdq_softc_t *) self;
|
||||
struct pci_attach_args * const pa = (struct pci_attach_args *) aux;
|
||||
pci_chipset_tag_t pc = pa->pa_pc;
|
||||
pdq_uint32_t data;
|
||||
pci_intr_handle_t intrhandle;
|
||||
const char *intrstr;
|
||||
const char *model;
|
||||
#ifdef PDQ_IOMAPPED
|
||||
bus_io_addr_t iobase;
|
||||
bus_io_size_t iosize;
|
||||
#else
|
||||
bus_mem_addr_t membase;
|
||||
bus_mem_size_t memsize;
|
||||
#endif
|
||||
|
||||
data = pci_conf_read(pc, pa->pa_tag, PCI_CFLT);
|
||||
if ((data & 0xFF00) == 0) {
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_DEC_DEFPA:
|
||||
model = "Digital Equipment DEFPA FDDI Controller";
|
||||
break;
|
||||
|
||||
default:
|
||||
model = "unknown model!";
|
||||
break;
|
||||
}
|
||||
printf(": %s\n", model);
|
||||
|
||||
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFLT);
|
||||
if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) {
|
||||
data &= ~0xFF00;
|
||||
data |= DEFPA_LATENCY << 8;
|
||||
pci_conf_write(pc, pa->pa_tag, PCI_CFLT, data);
|
||||
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CFLT, data);
|
||||
}
|
||||
|
||||
if (pci_map_mem(pa->pa_tag, PCI_CBMA, &va_csrs, &pa_csrs))
|
||||
return;
|
||||
|
||||
sc->sc_bc = pa->pa_bc;
|
||||
bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ);
|
||||
sc->sc_if.if_softc = sc;
|
||||
sc->sc_if.if_flags = 0;
|
||||
sc->sc_pdq = pdq_initialize((void *) va_csrs,
|
||||
sc->sc_dev.dv_cfdata->cf_driver->cd_name, sc->sc_dev.dv_unit,
|
||||
(void *) sc, PDQ_DEFPA);
|
||||
if (sc->sc_pdq == NULL)
|
||||
return;
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6);
|
||||
pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog);
|
||||
sc->sc_if.if_softc = sc;
|
||||
|
||||
sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, pdq_pci_ifintr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: error: couldn't map interrupt\n", sc->sc_dev.dv_xname);
|
||||
#ifdef PDQ_IOMAPPED
|
||||
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)
|
||||
|| bus_io_map(pa->pa_bc, iobase, iosize, &sc->sc_iobase))
|
||||
return;
|
||||
#else
|
||||
if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_CBMA, &membase, &memsize, NULL)
|
||||
|| bus_mem_map(pa->pa_bc, membase, memsize, 0, &sc->sc_membase))
|
||||
return;
|
||||
#endif
|
||||
|
||||
sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase,
|
||||
sc->sc_if.if_xname, 0,
|
||||
(void *) sc, PDQ_DEFPA);
|
||||
if (sc->sc_pdq == NULL) {
|
||||
printf("%s: initialization failed\n", sc->sc_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
sc->sc_ats = shutdownhook_establish(pdq_hwreset, sc);
|
||||
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6);
|
||||
pdq_ifattach(sc, pdq_pci_ifwatchdog);
|
||||
|
||||
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
|
||||
pa->pa_intrline, &intrhandle)) {
|
||||
printf("%s: couldn't map interrupt\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
intrstr = pci_intr_string(pa->pa_pc, intrhandle);
|
||||
sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_NET, pdq_pci_ifintr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt", self->dv_xname);
|
||||
if (intrstr != NULL)
|
||||
printf(" at %s", intrstr);
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq);
|
||||
if (sc->sc_ats == NULL)
|
||||
printf("%s: warning: couldn't establish shutdown hook\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
#endif
|
||||
printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname);
|
||||
if (intrstr != NULL)
|
||||
printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
|
||||
}
|
||||
|
||||
struct cfattach fpa_ca = {
|
||||
sizeof(pdq_softc_t), pdq_pci_probe, pdq_pci_attach
|
||||
sizeof(pdq_softc_t), pdq_pci_match, pdq_pci_attach
|
||||
};
|
||||
|
||||
struct cfdriver fpa_cd = {
|
||||
0, "fpa", DV_IFNET
|
||||
};
|
||||
|
||||
#endif /* __NetBSD__ */
|
||||
|
Loading…
Reference in New Issue
Block a user