Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/de/if_de.c
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | |||||
static void tulip_txput_setup(tulip_softc_t * const sc); | static void tulip_txput_setup(tulip_softc_t * const sc); | ||||
static void tulip_watchdog(void *arg); | static void tulip_watchdog(void *arg); | ||||
struct mbuf * tulip_dequeue_mbuf(tulip_ringinfo_t *ri, tulip_descinfo_t *di, | struct mbuf * tulip_dequeue_mbuf(tulip_ringinfo_t *ri, tulip_descinfo_t *di, | ||||
int sync); | int sync); | ||||
static void tulip_dma_map_addr(void *, bus_dma_segment_t *, int, int); | static void tulip_dma_map_addr(void *, bus_dma_segment_t *, int, int); | ||||
static void tulip_dma_map_rxbuf(void *, bus_dma_segment_t *, int, | static void tulip_dma_map_rxbuf(void *, bus_dma_segment_t *, int, | ||||
bus_size_t, int); | bus_size_t, int); | ||||
static struct de_dev { | struct pci_device_table de_devs[] = { | ||||
uint16_t vendorid; | {PCI_DEV(DEC_VENDORID, CHIPID_21040), PCI_REVID(0), | ||||
uint16_t deviceid; | PCI_DESCR("Digital 21040 Ethernet")}, | ||||
uint8_t revid; | {PCI_DEV(DEC_VENDORID, CHIPID_21041), PCI_REVID(0), | ||||
const char *description; | PCI_DESCR("Digital 21041 Ethernet")}, | ||||
} de_devs[] = { | {PCI_DEV(DEC_VENDORID, CHIPID_21140), PCI_REVID(0), | ||||
{DEC_VENDORID, CHIPID_21040, 0, "Digital 21040 Ethernet"}, | PCI_DESCR("Digital 21140 Fast Ethernet")}, | ||||
{DEC_VENDORID, CHIPID_21041, 0, "Digital 21041 Ethernet"}, | {PCI_DEV(DEC_VENDORID, CHIPID_21140), PCI_REVID(0x20), | ||||
{DEC_VENDORID, CHIPID_21140, 0, "Digital 21140 Fast Ethernet"}, | PCI_DESCR("Digital 21140A Fast Ethernet")}, | ||||
{DEC_VENDORID, CHIPID_21140, 0x20, "Digital 21140A Fast Ethernet"}, | {PCI_DEV(DEC_VENDORID, CHIPID_21142), PCI_REVID(0), | ||||
{DEC_VENDORID, CHIPID_21142, 0, "Digital 21142 Fast Ethernet"}, | PCI_DESCR("Digital 21142 Fast Ethernet")}, | ||||
{DEC_VENDORID, CHIPID_21142, 0x20, "Digital 21143 Fast Ethernet"}, | {PCI_DEV(DEC_VENDORID, CHIPID_21142), PCI_REVID(0x20), | ||||
{0, 0, 0, 0}, | PCI_DESCR("Digital 21143 Fast Ethernet")} | ||||
}; | }; | ||||
static void | static void | ||||
tulip_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) | tulip_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) | ||||
{ | { | ||||
bus_addr_t *paddr; | bus_addr_t *paddr; | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 4,495 Lines • ▼ Show 20 Lines | |||||
#define PCI_CBIO PCIR_BAR(0) /* Configuration Base IO Address */ | #define PCI_CBIO PCIR_BAR(0) /* Configuration Base IO Address */ | ||||
#define PCI_CBMA PCIR_BAR(1) /* Configuration Base Memory Address */ | #define PCI_CBMA PCIR_BAR(1) /* Configuration Base Memory Address */ | ||||
#define PCI_CFDA 0x40 /* Configuration Driver Area */ | #define PCI_CFDA 0x40 /* Configuration Driver Area */ | ||||
static int | static int | ||||
tulip_pci_probe(device_t dev) | tulip_pci_probe(device_t dev) | ||||
{ | { | ||||
const char *name = NULL; | const struct pci_device_table *ded; | ||||
const struct de_dev *ded; | |||||
uint16_t vid; | uint16_t vid; | ||||
uint16_t did; | |||||
uint8_t revid; | |||||
size_t i; | |||||
vid = pci_get_vendor(dev); | vid = pci_get_vendor(dev); | ||||
did = pci_get_device(dev); | |||||
revid = pci_get_revid(dev); | |||||
if (vid != DEC_VENDORID) | if (vid != DEC_VENDORID) | ||||
return ENXIO; | return ENXIO; | ||||
/* | /* | ||||
* Some LanMedia WAN cards use the Tulip chip, but they have | * Some LanMedia WAN cards use the Tulip chip, but they have | ||||
* their own driver, and we should not recognize them | * their own driver, and we should not recognize them | ||||
*/ | */ | ||||
if (pci_get_subvendor(dev) == 0x1376) | if (pci_get_subvendor(dev) == 0x1376) | ||||
return ENXIO; | return ENXIO; | ||||
for (i = 0; i < nitems(de_devs); i++) { | ded = PCI_MATCH(dev, de_devs); | ||||
ded = &de_devs[i]; | if (ded == NULL) | ||||
if ((ded->deviceid == did) && | return (ENXIO); | ||||
((revid >= ded->revid) || (ded->revid == 0))) { | device_set_desc(dev, ded->descr); | ||||
name = ded->description; | return (BUS_PROBE_LOW_PRIORITY); | ||||
} | } | ||||
} | |||||
if (name) { | |||||
device_set_desc(dev, name); | |||||
return BUS_PROBE_LOW_PRIORITY; | |||||
} | |||||
return ENXIO; | |||||
} | |||||
static int | static int | ||||
tulip_shutdown(device_t dev) | tulip_shutdown(device_t dev) | ||||
{ | { | ||||
tulip_softc_t * const sc = device_get_softc(dev); | tulip_softc_t * const sc = device_get_softc(dev); | ||||
TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET); | TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET); | ||||
DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at | DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at | ||||
33MHz that comes to two microseconds but wait a | 33MHz that comes to two microseconds but wait a | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | static driver_t tulip_pci_driver = { | ||||
"de", | "de", | ||||
tulip_pci_methods, | tulip_pci_methods, | ||||
sizeof(tulip_softc_t), | sizeof(tulip_softc_t), | ||||
}; | }; | ||||
static devclass_t tulip_devclass; | static devclass_t tulip_devclass; | ||||
DRIVER_MODULE(de, pci, tulip_pci_driver, tulip_devclass, 0, 0); | DRIVER_MODULE(de, pci, tulip_pci_driver, tulip_devclass, 0, 0); | ||||
MODULE_PNP_INFO("U16:vendor;U16:device", pci, de, de_devs, | PCI_PNP_INFO(de_devs); | ||||
sizeof(de_devs[0]), nitems(de_devs) - 1); | |||||
#ifdef DDB | #ifdef DDB | ||||
void tulip_dumpring(int unit, int ring); | void tulip_dumpring(int unit, int ring); | ||||
void tulip_dumpdesc(int unit, int ring, int desc); | void tulip_dumpdesc(int unit, int ring, int desc); | ||||
void tulip_status(int unit); | void tulip_status(int unit); | ||||
void | void | ||||
tulip_dumpring(int unit, int ring) | tulip_dumpring(int unit, int ring) | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |