3c509.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/**************************************************************************
Author: Martin Renters.
Date: Mar 22 1995
This code is based heavily on David Greenman's if_ed.c driver and
Andres Vega Garcia's if_ep.c driver.
Copyright (C) 1993-1994, David Greenman, Martin Renters.
Copyright (C) 1993-1995, Andres Vega Garcia.
Copyright (C) 1995, Serge Babkin.
This software may be used, modified, copied, distributed, and sold, in
both source and binary form provided that the above copyright and these
terms are retained. Under no circumstances are the authors responsible for
the proper functioning of this software, nor do the authors assume any
responsibility for damages incurred with its use.
3c509 support added by Serge Babkin (babkin@hq.icb.chel.su)
$Id$
***************************************************************************/
/* #define EDEBUG */
#include "etherboot.h"
#include "nic.h"
#include "isa.h"
#include "timer.h"
#include "3c509.h"
static unsigned short eth_nic_base;
#ifdef INCLUDE_3C529
/*
* This table and several other pieces of the MCA support
* code were shamelessly borrowed from the Linux kernel source.
*
* MCA support added by Adam Fritzler (mid@auk.cx)
*
*/
struct el3_mca_adapters_struct {
const char *name;
int id;
};
static struct el3_mca_adapters_struct el3_mca_adapters[] = {
{ "3Com 3c529 EtherLink III (10base2)", 0x627c },
{ "3Com 3c529 EtherLink III (10baseT)", 0x627d },
{ "3Com 3c529 EtherLink III (test mode)", 0x62db },
{ "3Com 3c529 EtherLink III (TP or coax)", 0x62f6 },
{ "3Com 3c529 EtherLink III (TP)", 0x62f7 },
{ NULL, 0 },
};
#endif
/**************************************************************************
ETH_RESET - Reset adapter
***************************************************************************/
{
int i;
/***********************************************************
Reset 3Com 509 card
*************************************************************/
/* stop card */
;
udelay(1000);
/*
* initialize card
*/
;
GO_WINDOW(0);
/* Disable the card */
/* Configure IRQ to none */
/* Enable the card */
GO_WINDOW(2);
/* Reload the ether_addr. */
for (i = 0; i < ETH_ALEN; i++)
/* Window 1 is operating window */
GO_WINDOW(1);
for (i = 0; i < 31; i++)
/* get rid of stray intr's */
/* configure BNC */
udelay(1000);
}
/* configure UTP */
GO_WINDOW(4);
GO_WINDOW(1);
}
/* start transceiver and receiver */
/* set early threshold for minimal packet length */
}
/**************************************************************************
ETH_TRANSMIT - Transmit a frame
***************************************************************************/
static char padmap[] = {
0, 3, 2, 1};
static void t509_transmit(
const char *d, /* Destination */
unsigned int t, /* Type */
unsigned int s, /* size */
const char *p) /* Packet */
{
register unsigned int len;
int pad;
int status;
#ifdef EDEBUG
#endif
/* swap bytes of type */
t= htons(t);
/*
* The 3c509 automatically pads short packets to minimum ethernet length,
* but we drop packets that are too large. Perhaps we should truncate
* them instead?
*/
return;
}
/* drop acknowledgements */
}
}
; /* no room in FIFO */
/* write packet */
if (s & 1)
while (pad--)
/* wait for Tx complete */
;
}
/**************************************************************************
ETH_POLL - Wait for a frame
***************************************************************************/
{
/* common variables */
/* variables for 3C509 */
register short rx_fifo;
#ifdef EDEBUG
if(cst & 0x1FFF)
#endif
if( (cst & S_RX_COMPLETE)==0 ) {
/* acknowledge everything */
return 0;
}
#ifdef EDEBUG
#endif
return 0;
}
if (rx_fifo==0)
return 0;
if ( ! retrieve ) return 1;
/* read packet */
#ifdef EDEBUG
#endif
if(rx_fifo & 1)
while(1) {
#ifdef EDEBUG
#endif
if(rx_fifo>0) {
if(rx_fifo & 1)
#ifdef EDEBUG
#endif
}
if(( status & RX_INCOMPLETE )==0) {
#ifdef EDEBUG
#endif
break;
}
}
/* acknowledge reception of packet */
;
#ifdef EDEBUG
{
unsigned short type = 0; /* used by EDEBUG */
else
}
#endif
return (1);
}
/*************************************************************************
3Com 509 - specific routines
**************************************************************************/
static int
eeprom_rdy(void)
{
int i;
if (i >= MAX_EEPROMBUSY) {
/* printf("3c509: eeprom failed to come ready.\n"); */
/* memory in EPROM is tight */
/* printf("3c509: eeprom busy.\n"); */
return (0);
}
return (1);
}
/*
* get_e: gets a 16 bits word from the EEPROM. we must have set the window
* before
*/
static int
{
if (!eeprom_rdy())
return (0xffff);
if (!eeprom_rdy())
return (0xffff);
}
static int
send_ID_sequence(int port)
{
al <<= 1;
if (al & 0x100)
al ^= 0xcf;
}
return (1);
}
/*
* We get eeprom data from the id_port given an offset into the eeprom.
* Basically; after the ID_sequence is sent to all of the cards; they enter
* the ID_CMD state where they will accept command requests. 0x80-0xbf loads
* the eeprom data. We then read the port 16 times and with every read; the
* cards check for contention (ie: if one card writes a 0 bit and another
* writes a 1 bit then the host sees a 0. At the end of the cycle; each card
* compares the data on the bus; if there is a difference then that card goes
* into ID_WAIT state again). In the meantime; one bit of data is returned in
* the AX register which is conveniently returned to us by inb(). Hence; we
* read 16 times getting one bit of data with each read.
*/
static int
{
int i, data = 0;
/* Do we really need this wait? Won't be noticeable anyway */
udelay(10000);
for (i = 0; i < 16; i++)
return (data);
}
static void __t509_disable(void)
{
}
{
/* reset and disable merge */
}
{
switch ( action ) {
case DISABLE :
break;
case ENABLE :
break;
case FORCE :
break;
}
}
/**************************************************************************
ETH_PROBE - Look for an adapter
***************************************************************************/
#ifdef INCLUDE_3C529
#else
#endif
{
/* common variables */
int i;
int failcount;
#ifdef INCLUDE_3C529
#endif
__t509_disable(); /* in case board was active */
unsigned short k;
int ep_current_tag;
short *p;
#ifdef INCLUDE_3C529
int curboard;
#endif
/*********************************************************
Search for 3Com 509 card
***********************************************************/
#ifdef INCLUDE_3C529
/*
* XXX: We should really check to make sure we have an MCA
* bus controller before going ahead with this...
*
* For now, we avoid any hassle by making it a compile
* time option.
*
*/
/* printf("\nWarning: Assuming presence of MCA bus\n"); */
/* Make sure motherboard setup is off */
/* Cycle through slots */
int boardid;
int curcard;
curcard = 0;
goto donewithdetect;
}
else
curcard++;
}
}
/* Kill all setup modes */
if (mcafound) {
}
else
/*printf("MCA Card not found\n")*/;
#endif
/* Look for the EISA boards, leave them activated */
/* search for the first card, ignore all others */
for(j = 1; j < 16; j++) {
continue;
/* we must have found 0x1f if the board is EISA configurated */
continue;
/* Reset and Enable the card */
/*
* Once activated, all the registers are mapped in the range
* x000 - x00F, where x is the slot number.
*/
eth_nic_base = j * EP_EISA_START;
break;
}
/* Look for the ISA boards. Init and leave them actived */
/* search for the first card, ignore all others */
for (i = 0; i < EP_MAX_BOARDS; i++) {
break;
/* resolve contention using the Ethernet address */
for (j = 0; j < 3; j++)
break;
}
if (i >= EP_MAX_BOARDS)
goto no3c509;
/*
* The iobase was found and MFG_ID was 0x6d50. PROD_ID should be
* 0x9[0-f]50
*/
GO_WINDOW(0);
k = get_e(EEPROM_PROD_ID);
#ifdef INCLUDE_3C529
/*
* On MCA, the PROD_ID matches the MCA card ID (POS0+POS1)
*/
if (mcafound) {
goto no3c509;
}
goto no3c509;
}
#else
goto no3c509;
#endif
#ifdef INCLUDE_3C529
if (mcafound) {
printf("%s board found on MCA at %#hx IRQ %d -",
} else {
#endif
if(eth_nic_base >= EP_EISA_START)
else
#ifdef INCLUDE_3C529
}
#endif
/* test for presence of connectors */
switch(j) {
case 0:
if (i & IS_UTP) {
printf("10baseT\n");
}
else {
printf("10baseT not present\n");
goto no3c509;
}
break;
case 1:
if (i & IS_AUI)
printf("10base5\n");
else {
printf("10base5 not present\n");
goto no3c509;
}
break;
case 3:
if (i & IS_BNC) {
printf("10base2\n");
}
else {
printf("10base2 not present\n");
goto no3c509;
}
break;
default:
printf("unknown connector\n");
goto no3c509;
}
/*
* Read the station address from the eeprom
*/
for (i = 0; i < ETH_ALEN / 2; i++) {
GO_WINDOW(0);
GO_WINDOW(2);
}
/* Based on PnP ISA map */
return 1;
continue;
/* printf("(probe fail)"); */
}
return 0;
}
#ifdef INCLUDE_3C509
.type = NIC_DRIVER,
.name = "3C509",
.probe = t509_probe,
.ioaddrs = 0,
};
#endif
#ifdef INCLUDE_3C529
.type = NIC_DRIVER,
.name = "3C529",
.probe = t529_probe,
.ioaddrs = 0,
};
#endif
/*
* Local variables:
* c-basic-offset: 8
* End:
*/