iPXE
Data Structures | Macros | Enumerations | Functions | Variables
3c515.c File Reference
#include "etherboot.h"
#include "nic.h"
#include <ipxe/isapnp.h>
#include <ipxe/isa.h>
#include <ipxe/ethernet.h>

Go to the source code of this file.

Data Structures

union  wn3_config
 
struct  wn3_config::w3_config_fields
 
struct  boom_rx_desc
 
struct  boom_tx_desc
 
struct  corkscrew_private
 
struct  media_table
 

Macros

#define HZ   100
 
#define CORKSCREW   1
 
#define AUTOMEDIA   1
 
#define VORTEX_BUS_MASTER
 
#define TX_RING_SIZE   16
 
#define RX_RING_SIZE   16
 
#define PKT_BUF_SZ   1536 /* Size of each temporary Rx buffer. */
 
#define DRIVER_DEBUG   1
 
#define CORKSCREW_ID   10
 
#define EL3WINDOW(win_num)   outw(SelectWindow + (win_num), nic->ioaddr + EL3_CMD)
 
#define EL3_CMD   0x0e
 
#define EL3_STATUS   0x0e
 
#define RX_BYTES_MASK   (unsigned short) (0x07ff)
 

Enumerations

enum  corkscrew_cmd {
  TotalReset = 0 << 11, SelectWindow = 1 << 11, StartCoax = 2 << 11, RxDisable = 3 << 11,
  RxEnable = 4 << 11, RxReset = 5 << 11, UpStall = 6 << 11, UpUnstall = (6 << 11) + 1,
  DownStall = (6 << 11) + 2, DownUnstall = (6 << 11) + 3, RxDiscard = 8 << 11, TxEnable = 9 << 11,
  TxDisable, TxReset = 11 << 11, FakeIntr = 12 << 11, AckIntr = 13 << 11,
  SetIntrEnb = 14 << 11, SetStatusEnb = 15 << 11, SetRxFilter = 16 << 11, SetRxThreshold,
  SetTxThreshold = 18 << 11, SetTxStart = 19 << 11, StartDMAUp = 20 << 11, StartDMADown = (20 << 11) + 1,
  StatsEnable, StatsDisable = 22 << 11, StopCoax = 23 << 11
}
 
enum  RxFilter { RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8 }
 
enum  corkscrew_status {
  IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004, TxAvailable = 0x0008,
  RxComplete = 0x0010, RxEarly = 0x0020, IntReq = 0x0040, StatsFull = 0x0080,
  DMADone = 1 << 8, DownComplete = 1 << 9, UpComplete = 1 << 10, DMAInProgress = 1 << 11,
  CmdInProgress = 1 << 12
}
 
enum  Window1 {
  TX_FIFO = 0x10, RX_FIFO = 0x10, RxErrors = 0x14, RxStatus = 0x18,
  Timer = 0x1A, TxStatus = 0x1B, TxFree = 0x1C
}
 
enum  Window0 { Wn0IRQ = 0x08, Wn0EepromCmd = 0x200A, Wn0EepromData = 0x200C }
 
enum  Win0_EEPROM_bits {
  EEPROM_Read = 0x80, EEPROM_WRITE = 0x40, EEPROM_ERASE = 0xC0, EEPROM_EWENB = 0x30,
  EEPROM_EWDIS = 0x00
}
 
enum  Window3 { Wn3_Config = 0, Wn3_MAC_Ctrl = 6, Wn3_Options = 8 }
 
enum  Window4 { Wn4_NetDiag = 6, Wn4_Media = 10 }
 
enum  Win4_Media_bits { Media_SQE = 0x0008, Media_10TP = 0x00C0, Media_Lnk = 0x0080, Media_LnkBeat = 0x0800 }
 
enum  Window7 { Wn7_MasterAddr = 0, Wn7_MasterLen = 6, Wn7_MasterStatus = 12 }
 
enum  MasterCtrl {
  PktStatus = 0x400, DownListPtr = 0x404, FragAddr = 0x408, FragLen,
  TxFreeThreshold = 0x40f, UpPktStatus = 0x410, UpListPtr = 0x418
}
 
enum  rx_desc_status { RxDComplete = 0x00008000, RxDError = 0x4000 }
 
enum  xcvr_types {
  XCVR_10baseT, XCVR_AUI, XCVR_10baseTOnly, XCVR_10base2,
  XCVR_100baseTx, XCVR_100baseFx, XCVR_MII = 6, XCVR_Default = 8
}
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static void t3c515_wait (unsigned int nticks)
 
static int corkscrew_found_device (int ioaddr, int irq, int product_index, int options, struct nic *nic)
 
static int corkscrew_probe1 (int ioaddr, int irq, int product_index, struct nic *nic)
 
static void t515_reset (struct nic *nic)
 
static int t515_poll (struct nic *nic, int retrieve)
 
static void t515_transmit (struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
 
static void t515_disable (struct nic *nic, struct isapnp_device *isapnp)
 
static void t515_irq (struct nic *nic __unused, irq_action_t action __unused)
 
static int t515_probe (struct nic *nic, struct isapnp_device *isapnp)
 
 ISAPNP_DRIVER (t515_driver, t515_adapters)
 
 DRIVER ("3c515", nic_driver, isapnp_driver, t515_driver, t515_probe, t515_disable)
 
 ISA_ROM ("3c515", "3c515 Fast EtherLink ISAPnP")
 

Variables

static int if_port
 
static struct corkscrew_privatevp
 
static struct media_table media_tbl []
 
static int options = -1
 
static char padmap []
 
static struct nic_operations t515_operations
 
static struct isapnp_device_id t515_adapters []
 

Macro Definition Documentation

◆ HZ

#define HZ   100

Definition at line 65 of file 3c515.c.

◆ CORKSCREW

#define CORKSCREW   1

Definition at line 69 of file 3c515.c.

◆ AUTOMEDIA

#define AUTOMEDIA   1

Definition at line 76 of file 3c515.c.

◆ VORTEX_BUS_MASTER

#define VORTEX_BUS_MASTER

Definition at line 82 of file 3c515.c.

◆ TX_RING_SIZE

#define TX_RING_SIZE   16

Definition at line 86 of file 3c515.c.

◆ RX_RING_SIZE

#define RX_RING_SIZE   16

Definition at line 87 of file 3c515.c.

◆ PKT_BUF_SZ

#define PKT_BUF_SZ   1536 /* Size of each temporary Rx buffer. */

Definition at line 88 of file 3c515.c.

◆ DRIVER_DEBUG

#define DRIVER_DEBUG   1

Definition at line 92 of file 3c515.c.

◆ CORKSCREW_ID

#define CORKSCREW_ID   10

Definition at line 98 of file 3c515.c.

◆ EL3WINDOW

#define EL3WINDOW (   win_num)    outw(SelectWindow + (win_num), nic->ioaddr + EL3_CMD)

Definition at line 100 of file 3c515.c.

◆ EL3_CMD

#define EL3_CMD   0x0e

Definition at line 102 of file 3c515.c.

◆ EL3_STATUS

#define EL3_STATUS   0x0e

Definition at line 103 of file 3c515.c.

◆ RX_BYTES_MASK

#define RX_BYTES_MASK   (unsigned short) (0x07ff)

Definition at line 104 of file 3c515.c.

Enumeration Type Documentation

◆ corkscrew_cmd

Enumerator
TotalReset 
SelectWindow 
StartCoax 
RxDisable 
RxEnable 
RxReset 
UpStall 
UpUnstall 
DownStall 
DownUnstall 
RxDiscard 
TxEnable 
TxDisable 
TxReset 
FakeIntr 
AckIntr 
SetIntrEnb 
SetStatusEnb 
SetRxFilter 
SetRxThreshold 
SetTxThreshold 
SetTxStart 
StartDMAUp 
StartDMADown 
StatsEnable 
StatsDisable 
StopCoax 

Definition at line 106 of file 3c515.c.

106  {
107  TotalReset = 0 << 11, SelectWindow = 1 << 11, StartCoax = 2 << 11,
108  RxDisable = 3 << 11, RxEnable = 4 << 11, RxReset = 5 << 11,
109  UpStall = 6 << 11, UpUnstall = (6 << 11) + 1,
110  DownStall = (6 << 11) + 2, DownUnstall = (6 << 11) + 3,
111  RxDiscard = 8 << 11, TxEnable = 9 << 11, TxDisable =
112  10 << 11, TxReset = 11 << 11,
113  FakeIntr = 12 << 11, AckIntr = 13 << 11, SetIntrEnb = 14 << 11,
114  SetStatusEnb = 15 << 11, SetRxFilter = 16 << 11, SetRxThreshold =
115  17 << 11,
116  SetTxThreshold = 18 << 11, SetTxStart = 19 << 11,
117  StartDMAUp = 20 << 11, StartDMADown = (20 << 11) + 1, StatsEnable =
118  21 << 11,
119  StatsDisable = 22 << 11, StopCoax = 23 << 11,
120 };
Definition: 3c515.c:109
Definition: 3c515.c:112
Definition: 3c515.c:108
Definition: 3c515.c:113

◆ RxFilter

enum RxFilter
Enumerator
RxStation 
RxMulticast 
RxBroadcast 
RxProm 

Definition at line 123 of file 3c515.c.

123  {
124  RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8
125 };
Definition: 3c515.c:124

◆ corkscrew_status

Enumerator
IntLatch 
AdapterFailure 
TxComplete 
TxAvailable 
RxComplete 
RxEarly 
IntReq 
StatsFull 
DMADone 
DownComplete 
UpComplete 
DMAInProgress 
CmdInProgress 

Definition at line 128 of file 3c515.c.

128  {
129  IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004,
130  TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
131  IntReq = 0x0040, StatsFull = 0x0080,
132  DMADone = 1 << 8, DownComplete = 1 << 9, UpComplete = 1 << 10,
133  DMAInProgress = 1 << 11, /* DMA controller is still busy. */
134  CmdInProgress = 1 << 12, /* EL3_CMD is still busy. */
135 };
Definition: 3c515.c:130
Definition: 3c515.c:132
Definition: 3c515.c:131

◆ Window1

enum Window1
Enumerator
TX_FIFO 
RX_FIFO 
RxErrors 
RxStatus 
Timer 
TxStatus 
TxFree 

Definition at line 139 of file 3c515.c.

139  {
140  TX_FIFO = 0x10, RX_FIFO = 0x10, RxErrors = 0x14,
141  RxStatus = 0x18, Timer = 0x1A, TxStatus = 0x1B,
142  TxFree = 0x1C, /* Remaining free bytes in Tx buffer. */
143 };
Definition: 3c515.c:140
Definition: 3c515.c:142
Definition: 3c515.c:141
Definition: 3c515.c:140

◆ Window0

enum Window0
Enumerator
Wn0IRQ 
Wn0EepromCmd 
Wn0EepromData 

Definition at line 144 of file 3c515.c.

144  {
145  Wn0IRQ = 0x08,
146 #if defined(CORKSCREW)
147  Wn0EepromCmd = 0x200A, /* Corkscrew EEPROM command register. */
148  Wn0EepromData = 0x200C, /* Corkscrew EEPROM results register. */
149 #else
150  Wn0EepromCmd = 10, /* Window 0: EEPROM command register. */
151  Wn0EepromData = 12, /* Window 0: EEPROM results register. */
152 #endif
153 };
Definition: 3c515.c:145

◆ Win0_EEPROM_bits

Enumerator
EEPROM_Read 
EEPROM_WRITE 
EEPROM_ERASE 
EEPROM_EWENB 
EEPROM_EWDIS 

Definition at line 154 of file 3c515.c.

154  {
155  EEPROM_Read = 0x80, EEPROM_WRITE = 0x40, EEPROM_ERASE = 0xC0,
156  EEPROM_EWENB = 0x30, /* Enable erasing/writing for 10 msec. */
157  EEPROM_EWDIS = 0x00, /* Disable EWENB before 10 msec timeout. */
158 };

◆ Window3

enum Window3
Enumerator
Wn3_Config 
Wn3_MAC_Ctrl 
Wn3_Options 

Definition at line 160 of file 3c515.c.

160  { /* Window 3: MAC/config bits. */
161  Wn3_Config = 0, Wn3_MAC_Ctrl = 6, Wn3_Options = 8,
162 };

◆ Window4

enum Window4
Enumerator
Wn4_NetDiag 
Wn4_Media 

Definition at line 175 of file 3c515.c.

175  {
176  Wn4_NetDiag = 6, Wn4_Media = 10, /* Window 4: Xcvr/media bits. */
177 };

◆ Win4_Media_bits

Enumerator
Media_SQE 
Media_10TP 
Media_Lnk 
Media_LnkBeat 

Definition at line 178 of file 3c515.c.

178  {
179  Media_SQE = 0x0008, /* Enable SQE error counting for AUI. */
180  Media_10TP = 0x00C0, /* Enable link beat and jabber for 10baseT. */
181  Media_Lnk = 0x0080, /* Enable just link beat for 100TX/100FX. */
182  Media_LnkBeat = 0x0800,
183 };

◆ Window7

enum Window7
Enumerator
Wn7_MasterAddr 
Wn7_MasterLen 
Wn7_MasterStatus 

Definition at line 184 of file 3c515.c.

184  { /* Window 7: Bus Master control. */
186 };

◆ MasterCtrl

enum MasterCtrl
Enumerator
PktStatus 
DownListPtr 
FragAddr 
FragLen 
TxFreeThreshold 
UpPktStatus 
UpListPtr 

Definition at line 189 of file 3c515.c.

189  {
190  PktStatus = 0x400, DownListPtr = 0x404, FragAddr = 0x408, FragLen =
191  0x40c,
192  TxFreeThreshold = 0x40f, UpPktStatus = 0x410, UpListPtr = 0x418,
193 };
UpPktStatus
Definition: 3c90x.h:213
Definition: 3c515.c:190

◆ rx_desc_status

Enumerator
RxDComplete 
RxDError 

Definition at line 206 of file 3c515.c.

206  {
207  RxDComplete = 0x00008000, RxDError = 0x4000,
208  /* See boomerang_rx() for actual error bits */
209 };

◆ xcvr_types

enum xcvr_types
Enumerator
XCVR_10baseT 
XCVR_AUI 
XCVR_10baseTOnly 
XCVR_10base2 
XCVR_100baseTx 
XCVR_100baseFx 
XCVR_MII 
XCVR_Default 

Definition at line 244 of file 3c515.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ t3c515_wait()

static void t3c515_wait ( unsigned int  nticks)
static

Definition at line 57 of file 3c515.c.

58 {
59  unsigned int to = currticks() + nticks;
60  while (currticks() < to)
61  /* wait */ ;
62 }
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42

References currticks().

Referenced by corkscrew_probe1(), and t515_probe().

◆ corkscrew_found_device()

static int corkscrew_found_device ( int  ioaddr,
int  irq,
int  product_index,
int  options,
struct nic nic 
)
static

Definition at line 656 of file 3c515.c.

658 {
659  /* Direct copy from Becker 3c515.c with unnecessary parts removed */
660  vp->product_name = "3c515";
661  vp->options = options;
662  if (options >= 0) {
663  vp->media_override =
664  ((options & 7) == 2) ? 0 : options & 7;
665  vp->full_duplex = (options & 8) ? 1 : 0;
666  vp->bus_master = (options & 16) ? 1 : 0;
667  } else {
668  vp->media_override = 7;
669  vp->full_duplex = 0;
670  vp->bus_master = 0;
671  }
672 
673  corkscrew_probe1(ioaddr, irq, product_index, nic);
674  return 0;
675 }
const char * product_name
Definition: 3c515.c:219
unsigned int bus_master
Definition: 3c515.c:233
static int corkscrew_probe1(int ioaddr, int irq, int product_index, struct nic *nic)
Definition: 3c515.c:678
static unsigned long ioaddr
Definition: davicom.c:129
static int options
Definition: 3c515.c:286
unsigned int full_duplex
Definition: 3c515.c:233
Definition: nic.h:49
static struct corkscrew_private * vp
Definition: 3c515.c:67
unsigned int media_override
Definition: 3c515.c:233

References corkscrew_private::bus_master, corkscrew_probe1(), corkscrew_private::full_duplex, ioaddr, nic_operations::irq, corkscrew_private::media_override, corkscrew_private::options, options, corkscrew_private::product_name, and vp.

Referenced by t515_probe().

◆ corkscrew_probe1()

static int corkscrew_probe1 ( int  ioaddr,
int  irq,
int product_index  __unused,
struct nic nic 
)
static

Definition at line 678 of file 3c515.c.

680 {
681  unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
682  int i;
683 
684  printf("3Com %s at 0x%hX, ", vp->product_name, ioaddr);
685 
686  /* Read the station address from the EEPROM. */
687  EL3WINDOW(0);
688  for (i = 0; i < 0x18; i++) {
689  short *phys_addr = (short *) nic->node_addr;
690  int timer;
692  /* Pause for at least 162 us. for the read to take place. */
693  for (timer = 4; timer >= 0; timer--) {
694  t3c515_wait(1);
695  if ((inw(ioaddr + Wn0EepromCmd) & 0x0200) == 0)
696  break;
697  }
698  eeprom[i] = inw(ioaddr + Wn0EepromData);
699  DBG ( "Value %d: %hX ", i, eeprom[i] );
700  checksum ^= eeprom[i];
701  if (i < 3)
702  phys_addr[i] = htons(eeprom[i]);
703  }
704  checksum = (checksum ^ (checksum >> 8)) & 0xff;
705  if (checksum != 0x00)
706  printf(" ***INVALID CHECKSUM 0x%hX*** ", checksum);
707 
708  DBG ( "%s", eth_ntoa ( nic->node_addr ) );
709 
710  if (eeprom[16] == 0x11c7) { /* Corkscrew */
711 
712  }
713  printf(", IRQ %d\n", irq);
714  /* Tell them about an invalid IRQ. */
715  if ( (irq <= 0 || irq > 15) ) {
716  DBG (" *** Warning: this IRQ is unlikely to work! ***\n" );
717  }
718 
719  {
720  char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" };
721  union wn3_config config;
722  EL3WINDOW(3);
724  config.i = inl(ioaddr + Wn3_Config);
725  DBG ( " Internal config register is %4.4x, "
726  "transceivers 0x%hX.\n",
727  config.i, inw(ioaddr + Wn3_Options) );
728  printf
729  (" %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
730  8 << config.u.ram_size,
731  config.u.ram_width ? "word" : "byte",
732  ram_split[config.u.ram_split],
733  config.u.autoselect ? "autoselect/" : "",
734  media_tbl[config.u.xcvr].name);
735  if_port = config.u.xcvr;
736  vp->default_media = config.u.xcvr;
737  vp->autoselect = config.u.autoselect;
738  }
739  if (vp->media_override != 7) {
740  printf(" Media override to transceiver type %d (%s).\n",
744  }
745 
746  vp->capabilities = eeprom[16];
747  vp->full_bus_master_tx = (vp->capabilities & 0x20) ? 1 : 0;
748  /* Rx is broken at 10mbps, so we always disable it. */
749  /* vp->full_bus_master_rx = 0; */
750  vp->full_bus_master_rx = (vp->capabilities & 0x20) ? 1 : 0;
751 
752  return 0;
753 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
const char * product_name
Definition: 3c515.c:219
unsigned int autoselect
Definition: 3c515.c:233
#define outw(data, io_addr)
Definition: io.h:319
unsigned int full_bus_master_rx
Definition: 3c515.c:233
int capabilities
Definition: 3c515.c:230
uint8_t checksum
Checksum.
Definition: pnpbios.c:37
A timer.
Definition: timer.h:28
eeprom
Definition: 3c90x.h:232
unsigned int available_media
Definition: 3c515.c:233
static unsigned long ioaddr
Definition: davicom.c:129
#define EL3WINDOW(win_num)
Definition: 3c515.c:100
unsigned int default_media
Definition: 3c515.c:233
static void t3c515_wait(unsigned int nticks)
Definition: 3c515.c:57
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
char * name
Definition: 3c515.c:251
Definition: nic.h:49
static struct corkscrew_private * vp
Definition: 3c515.c:67
unsigned char * node_addr
Definition: nic.h:52
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
unsigned int full_bus_master_tx
Definition: 3c515.c:233
static int if_port
Definition: 3c515.c:66
unsigned int media_override
Definition: 3c515.c:233
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static struct media_table media_tbl[]
#define htons(value)
Definition: byteswap.h:135

References wn3_config::w3_config_fields::autoselect, corkscrew_private::autoselect, corkscrew_private::available_media, corkscrew_private::capabilities, checksum, DBG, corkscrew_private::default_media, EEPROM_Read, EL3WINDOW, eth_ntoa(), corkscrew_private::full_bus_master_rx, corkscrew_private::full_bus_master_tx, htons, wn3_config::i, if_port, inl(), inw(), ioaddr, nic_operations::irq, corkscrew_private::media_override, media_tbl, media_table::name, nic::node_addr, outw, printf(), corkscrew_private::product_name, wn3_config::w3_config_fields::ram_size, wn3_config::w3_config_fields::ram_split, wn3_config::w3_config_fields::ram_width, t3c515_wait(), wn3_config::u, vp, Wn0EepromCmd, Wn0EepromData, Wn3_Config, Wn3_Options, and wn3_config::w3_config_fields::xcvr.

Referenced by corkscrew_found_device().

◆ t515_reset()

static void t515_reset ( struct nic nic)
static

Definition at line 293 of file 3c515.c.

294 {
295  union wn3_config config;
296  int i;
297 
298  /* Before initializing select the active media port. */
299  EL3WINDOW(3);
300  if (vp->full_duplex)
301  outb(0x20, nic->ioaddr + Wn3_MAC_Ctrl); /* Set the full-duplex bit. */
302  config.i = inl(nic->ioaddr + Wn3_Config);
303 
304  if (vp->media_override != 7) {
305  DBG ( "Media override to transceiver %d (%s).\n",
309  } else if (vp->autoselect) {
310  /* Find first available media type, starting with 100baseTx. */
311  if_port = 4;
312  while (!(vp->available_media & media_tbl[if_port].mask))
314 
315  DBG ( "Initial media type %s.\n",
317  } else
319 
320  config.u.xcvr = if_port;
321  outl(config.i, nic->ioaddr + Wn3_Config);
322 
323  DBG ( "corkscrew_open() InternalConfig 0x%hX.\n",
324  config.i);
325 
327  for (i = 20; i >= 0; i--)
328  if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
329  break;
330 
332  /* Wait a few ticks for the RxReset command to complete. */
333  for (i = 20; i >= 0; i--)
334  if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
335  break;
336 
337  outw(SetStatusEnb | 0x00, nic->ioaddr + EL3_CMD);
338 
339 #ifdef debug_3c515
340  EL3WINDOW(4);
341  DBG ( "FIXME: fix print for irq, not 9" );
342  DBG ( "corkscrew_open() irq %d media status 0x%hX.\n",
343  9, inw(nic->ioaddr + Wn4_Media) );
344 #endif
345 
346  /* Set the station address and mask in window 2 each time opened. */
347  EL3WINDOW(2);
348  for (i = 0; i < 6; i++)
349  outb(nic->node_addr[i], nic->ioaddr + i);
350  for (; i < 12; i += 2)
351  outw(0, nic->ioaddr + i);
352 
353  if (if_port == 3)
354  /* Start the thinnet transceiver. We should really wait 50ms... */
356  EL3WINDOW(4);
359 
360  /* Switch to the stats window, and clear all stats by reading. */
361 /* outw(StatsDisable, nic->ioaddr + EL3_CMD);*/
362  EL3WINDOW(6);
363  for (i = 0; i < 10; i++)
364  inb(nic->ioaddr + i);
365  inw(nic->ioaddr + 10);
366  inw(nic->ioaddr + 12);
367  /* New: On the Vortex we must also clear the BadSSD counter. */
368  EL3WINDOW(4);
369  inb(nic->ioaddr + 12);
370  /* ..and on the Boomerang we enable the extra statistics bits. */
371  outw(0x0040, nic->ioaddr + Wn4_NetDiag);
372 
373  /* Switch to register set 7 for normal use. */
374  EL3WINDOW(7);
375 
376  /* Temporarily left in place. If these FIXMEs are printed
377  it meand that special logic for that card may need to be added
378  see Becker's 3c515.c driver */
379  if (vp->full_bus_master_rx) { /* Boomerang bus master. */
380  printf("FIXME: Is this if necessary");
381  vp->cur_rx = vp->dirty_rx = 0;
382  DBG ( " Filling in the Rx ring.\n" );
383  for (i = 0; i < RX_RING_SIZE; i++) {
384  printf("FIXME: Is this if necessary");
385  }
386  }
387  if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */
388  vp->cur_tx = vp->dirty_tx = 0;
389  outb(PKT_BUF_SZ >> 8, nic->ioaddr + TxFreeThreshold); /* Room for a packet. */
390  /* Clear the Tx ring. */
391  for (i = 0; i < TX_RING_SIZE; i++)
392  vp->tx_skbuff[i] = NULL;
393  outl(0, nic->ioaddr + DownListPtr);
394  }
395  /* Set receiver mode: presumably accept b-case and phys addr only. */
397  nic->ioaddr + EL3_CMD);
398 
399  outw(RxEnable, nic->ioaddr + EL3_CMD); /* Enable the receiver. */
400  outw(TxEnable, nic->ioaddr + EL3_CMD); /* Enable transmitter. */
401  /* Allow status bits to be seen. */
405  (vp->bus_master ? DMADone : 0), nic->ioaddr + EL3_CMD);
406  /* Ack all pending events, and set active indicator mask. */
408  nic->ioaddr + EL3_CMD);
411  nic->ioaddr + EL3_CMD);
412 
413 }
struct sk_buff * tx_skbuff[TX_RING_SIZE]
Definition: 3c515.c:226
const char * name
Definition: ath9k_hw.c:1984
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
unsigned int autoselect
Definition: 3c515.c:233
#define outw(data, io_addr)
Definition: io.h:319
unsigned int full_bus_master_rx
Definition: 3c515.c:233
unsigned int bus_master
Definition: 3c515.c:233
#define PKT_BUF_SZ
Definition: 3c515.c:88
unsigned int available_media
Definition: 3c515.c:233
unsigned int ioaddr
Definition: nic.h:55
#define EL3_CMD
Definition: 3c515.c:102
Definition: 3c515.c:130
Definition: 3c515.c:112
unsigned int full_duplex
Definition: 3c515.c:233
unsigned int dirty_rx
Definition: 3c515.c:228
unsigned int mask
Definition: 3c515.c:252
#define EL3WINDOW(win_num)
Definition: 3c515.c:100
unsigned int next
Definition: 3c515.c:252
unsigned int default_media
Definition: 3c515.c:233
Definition: 3c515.c:132
#define outl(data, io_addr)
Definition: io.h:329
char * name
Definition: 3c515.c:251
int i
Definition: 3c515.c:164
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
Definition: nic.h:49
Definition: 3c515.c:108
#define RX_RING_SIZE
Definition: 3c515.c:87
Definition: 3c515.c:113
static struct corkscrew_private * vp
Definition: 3c515.c:67
unsigned char * node_addr
Definition: nic.h:52
#define outb(data, io_addr)
Definition: io.h:309
Definition: 3c515.c:131
unsigned int dirty_tx
Definition: 3c515.c:228
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
unsigned int full_bus_master_tx
Definition: 3c515.c:233
static int if_port
Definition: 3c515.c:66
unsigned int media_override
Definition: 3c515.c:233
unsigned int cur_tx
Definition: 3c515.c:227
unsigned int cur_rx
Definition: 3c515.c:227
Definition: 3c515.c:124
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static struct media_table media_tbl[]
#define EL3_STATUS
Definition: 3c515.c:103
#define TX_RING_SIZE
Definition: 3c515.c:86
unsigned int media_bits
Definition: 3c515.c:252

References AckIntr, AdapterFailure, corkscrew_private::autoselect, corkscrew_private::available_media, corkscrew_private::bus_master, CmdInProgress, corkscrew_private::cur_rx, corkscrew_private::cur_tx, DBG, corkscrew_private::default_media, corkscrew_private::dirty_rx, corkscrew_private::dirty_tx, DMADone, DownComplete, DownListPtr, EL3_CMD, EL3_STATUS, EL3WINDOW, corkscrew_private::full_bus_master_rx, corkscrew_private::full_bus_master_tx, corkscrew_private::full_duplex, wn3_config::i, if_port, inb(), inl(), IntLatch, IntReq, inw(), nic::ioaddr, media_table::mask, Media_10TP, media_table::media_bits, corkscrew_private::media_override, Media_SQE, media_tbl, media_table::name, name, media_table::next, nic::node_addr, NULL, outb, outl, outw, PKT_BUF_SZ, printf(), RX_RING_SIZE, RxBroadcast, RxComplete, RxEarly, RxEnable, RxMulticast, RxProm, RxReset, RxStation, SetIntrEnb, SetRxFilter, SetStatusEnb, StartCoax, StatsFull, TX_RING_SIZE, corkscrew_private::tx_skbuff, TxAvailable, TxEnable, TxFreeThreshold, TxReset, wn3_config::u, UpComplete, vp, Wn3_Config, Wn3_MAC_Ctrl, Wn4_Media, Wn4_NetDiag, and wn3_config::w3_config_fields::xcvr.

Referenced by t515_disable(), and t515_probe().

◆ t515_poll()

static int t515_poll ( struct nic nic,
int  retrieve 
)
static

Definition at line 418 of file 3c515.c.

419 {
420  short status, cst;
421  register short rx_fifo;
422 
423  cst = inw(nic->ioaddr + EL3_STATUS);
424 
425  if ((cst & RxComplete) == 0) {
426  /* Ack all pending events, and set active indicator mask. */
428  nic->ioaddr + EL3_CMD);
430  StatsFull | (vp->
431  bus_master ? DMADone : 0) | UpComplete |
433  return 0;
434  }
435  status = inw(nic->ioaddr + RxStatus);
436 
437  if (status & RxDError) {
438  printf("RxDError\n");
440  return 0;
441  }
442 
443  rx_fifo = status & RX_BYTES_MASK;
444  if (rx_fifo == 0)
445  return 0;
446 
447  if ( ! retrieve ) return 1;
448 
449  DBG ( "[l=%d", rx_fifo );
450  insw(nic->ioaddr + RX_FIFO, nic->packet, rx_fifo / 2);
451  if (rx_fifo & 1)
452  nic->packet[rx_fifo - 1] = inb(nic->ioaddr + RX_FIFO);
453  nic->packetlen = rx_fifo;
454 
455  while (1) {
456  status = inw(nic->ioaddr + RxStatus);
457  DBG ( "0x%hX*", status );
458  rx_fifo = status & RX_BYTES_MASK;
459 
460  if (rx_fifo > 0) {
462  rx_fifo / 2);
463  if (rx_fifo & 1)
464  nic->packet[nic->packetlen + rx_fifo - 1] =
465  inb(nic->ioaddr + RX_FIFO);
466  nic->packetlen += rx_fifo;
467  DBG ( "+%d", rx_fifo );
468  }
469  if ((status & RxComplete) == 0) {
470  DBG ( "=%d", nic->packetlen );
471  break;
472  }
473  udelay(1000);
474  }
475 
476  /* acknowledge reception of packet */
478  while (inw(nic->ioaddr + EL3_STATUS) & CmdInProgress);
479 #ifdef debug_3c515
480  {
481  unsigned short type = 0;
482  type = (nic->packet[12] << 8) | nic->packet[13];
483  if (nic->packet[0] + nic->packet[1] + nic->packet[2] +
484  nic->packet[3] + nic->packet[4] + nic->packet[5] ==
485  0xFF * ETH_ALEN)
486  DBG ( ",t=0x%hX,b]", type );
487  else
488  DBG ( ",t=0x%hX]", type );
489  }
490 #endif
491 
492  return 1;
493 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
uint8_t status
Status.
Definition: ena.h:16
unsigned int ioaddr
Definition: nic.h:55
#define EL3_CMD
Definition: 3c515.c:102
Definition: 3c515.c:130
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
Definition: 3c515.c:132
unsigned int packetlen
Definition: nic.h:54
#define RX_BYTES_MASK
Definition: 3c515.c:104
void insw(volatile uint16_t *io_addr, uint16_t *data, unsigned int count)
Read 16-bit words from I/O-mapped device.
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define ETH_ALEN
Definition: if_ether.h:8
Definition: nic.h:49
Definition: 3c515.c:113
static struct corkscrew_private * vp
Definition: 3c515.c:67
unsigned char * packet
Definition: nic.h:53
Definition: 3c515.c:131
uint32_t type
Operating system type.
Definition: ena.h:12
Definition: 3c515.c:140
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define EL3_STATUS
Definition: 3c515.c:103
if(natsemi->flags &NATSEMI_64BIT) return 1

References AckIntr, CmdInProgress, DBG, DMADone, DownComplete, EL3_CMD, EL3_STATUS, ETH_ALEN, if(), inb(), insw(), IntLatch, IntReq, inw(), nic::ioaddr, outw, nic::packet, nic::packetlen, printf(), RX_BYTES_MASK, RX_FIFO, RxComplete, RxDError, RxDiscard, RxEarly, RxStatus, SetIntrEnb, StatsFull, status, TxAvailable, type, udelay(), UpComplete, and vp.

◆ t515_transmit()

static void t515_transmit ( struct nic nic,
const char *  d,
unsigned int  t,
unsigned int  s,
const char *  p 
)
static

Definition at line 504 of file 3c515.c.

508 { /* Packet */
509  register int len;
510  int pad;
511  int status;
512 
513  DBG ( "{l=%d,t=0x%hX}", s + ETH_HLEN, t );
514 
515  /* swap bytes of type */
516  t = htons(t);
517 
518  len = s + ETH_HLEN; /* actual length of packet */
519  pad = padmap[len & 3];
520 
521  /*
522  * The 3c515 automatically pads short packets to minimum ethernet length,
523  * but we drop packets that are too large. Perhaps we should truncate
524  * them instead?
525  Copied from 3c595. Is this true for the 3c515?
526  */
527  if (len + pad > ETH_FRAME_LEN) {
528  return;
529  }
530  /* drop acknowledgements */
531  while ((status = inb(nic->ioaddr + TxStatus)) & TxComplete) {
532  /*if(status & (TXS_UNDERRUN|0x88|TXS_STATUS_OVERFLOW)) { */
535 /* } */
536 
537  outb(0x0, nic->ioaddr + TxStatus);
538  }
539 
540  while (inw(nic->ioaddr + TxFree) < len + pad + 4) {
541  /* no room in FIFO */
542  }
543 
544  outw(len, nic->ioaddr + TX_FIFO);
545  outw(0x0, nic->ioaddr + TX_FIFO); /* Second dword meaningless */
546 
547  /* write packet */
548  outsw(nic->ioaddr + TX_FIFO, d, ETH_ALEN / 2);
550  outw(t, nic->ioaddr + TX_FIFO);
551  outsw(nic->ioaddr + TX_FIFO, p, s / 2);
552 
553  if (s & 1)
554  outb(*(p + s - 1), nic->ioaddr + TX_FIFO);
555 
556  while (pad--)
557  outb(0, nic->ioaddr + TX_FIFO); /* Padding */
558 
559  /* wait for Tx complete */
560  while ((inw(nic->ioaddr + EL3_STATUS) & CmdInProgress) != 0);
561 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
Definition: 3c515.c:140
void outsw(volatile uint16_t *io_addr, const uint16_t *data, unsigned int count)
Write 16-bit words to I/O-mapped device.
Definition: 3c515.c:142
u32 pad[9]
Padding.
Definition: ar9003_mac.h:90
uint8_t status
Status.
Definition: ena.h:16
unsigned int ioaddr
Definition: nic.h:55
#define EL3_CMD
Definition: 3c515.c:102
#define ETH_HLEN
Definition: if_ether.h:9
Definition: 3c515.c:112
#define ETH_FRAME_LEN
Definition: if_ether.h:11
static char padmap[]
Definition: 3c515.c:498
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define ETH_ALEN
Definition: if_ether.h:8
Definition: nic.h:49
unsigned char * node_addr
Definition: nic.h:52
#define outb(data, io_addr)
Definition: io.h:309
uint32_t len
Length.
Definition: ena.h:14
uint32_t d
Definition: md4.c:31
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define EL3_STATUS
Definition: 3c515.c:103
#define htons(value)
Definition: byteswap.h:135

References CmdInProgress, d, DBG, EL3_CMD, EL3_STATUS, ETH_ALEN, ETH_FRAME_LEN, ETH_HLEN, htons, inb(), inw(), nic::ioaddr, len, nic::node_addr, outb, outsw(), outw, pad, padmap, status, TX_FIFO, TxComplete, TxEnable, TxFree, TxReset, and TxStatus.

◆ t515_disable()

static void t515_disable ( struct nic nic,
struct isapnp_device isapnp 
)
static

Definition at line 566 of file 3c515.c.

567  {
568 
569  t515_reset(nic);
570 
571  /* This is a hack. Since ltsp worked on my
572  system without any disable functionality I
573  have no way to determine if this works */
574 
575  /* Disable the receiver and transmitter. */
578 
579  if (if_port == XCVR_10base2)
580  /* Turn off thinnet power. Green! */
582 
583 
584  outw(SetIntrEnb | 0x0000, nic->ioaddr + EL3_CMD);
585 
586  deactivate_isapnp_device ( isapnp );
587  return;
588 }
static void deactivate_isapnp_device(struct isapnp_device *isapnp)
Deactivate ISAPnP device.
Definition: isapnp.h:256
#define outw(data, io_addr)
Definition: io.h:319
unsigned int ioaddr
Definition: nic.h:55
#define EL3_CMD
Definition: 3c515.c:102
Definition: nic.h:49
static void t515_reset(struct nic *nic)
Definition: 3c515.c:293
static int if_port
Definition: 3c515.c:66

References deactivate_isapnp_device(), EL3_CMD, if_port, nic::ioaddr, outw, RxDisable, SetIntrEnb, StopCoax, t515_reset(), TxDisable, and XCVR_10base2.

◆ t515_irq()

static void t515_irq ( struct nic *nic  __unused,
irq_action_t action  __unused 
)
static

Definition at line 590 of file 3c515.c.

591 {
592  switch ( action ) {
593  case DISABLE :
594  break;
595  case ENABLE :
596  break;
597  case FORCE :
598  break;
599  }
600 }
Definition: nic.h:35
Definition: nic.h:37
Definition: nic.h:36

References DISABLE, ENABLE, and FORCE.

◆ t515_probe()

static int t515_probe ( struct nic nic,
struct isapnp_device isapnp 
)
static

Definition at line 614 of file 3c515.c.

614  {
615 
616  /* Direct copy from Beckers 3c515.c removing any ISAPNP sections */
617 
618  nic->ioaddr = isapnp->ioaddr;
619  nic->irqno = isapnp->irqno;
620  activate_isapnp_device ( isapnp );
621 
622  /* Check the resource configuration for a matching ioaddr. */
623  if ((unsigned)(inw(nic->ioaddr + 0x2002) & 0x1f0)
624  != (nic->ioaddr & 0x1f0)) {
625  DBG ( "3c515 ioaddr mismatch\n" );
626  return 0;
627  }
628 
629  /* Verify by reading the device ID from the EEPROM. */
630  {
631  int timer;
633  /* Pause for at least 162 us. for the read to take place. */
634  for (timer = 4; timer >= 0; timer--) {
635  t3c515_wait(1);
636  if ((inw(nic->ioaddr + Wn0EepromCmd) & 0x0200) == 0)
637  break;
638  }
639  if (inw(nic->ioaddr + Wn0EepromData) != 0x6d50) {
640  DBG ( "3c515 read incorrect vendor ID from EEPROM" );
641  return 0;
642  }
643 
644  }
645  DBG ( "3c515 Resource configuration register 0x%X, DCR 0x%hX.\n",
646  inl(nic->ioaddr + 0x2002), inw(nic->ioaddr + 0x2000) );
648  options, nic);
649 
650  t515_reset(nic);
652  return 1;
653 }
unsigned char irqno
Definition: nic.h:56
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
uint16_t ioaddr
I/O address.
Definition: isapnp.h:191
A timer.
Definition: timer.h:28
unsigned int ioaddr
Definition: nic.h:55
static int options
Definition: 3c515.c:286
static struct nic_operations t515_operations
Definition: 3c515.c:602
static void t3c515_wait(unsigned int nticks)
Definition: 3c515.c:57
Definition: nic.h:49
uint8_t irqno
Interrupt number.
Definition: isapnp.h:193
static void t515_reset(struct nic *nic)
Definition: 3c515.c:293
static void activate_isapnp_device(struct isapnp_device *isapnp)
Activate ISAPnP device.
Definition: isapnp.h:247
static struct timer * timer
Current timer.
Definition: timer.c:35
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
#define CORKSCREW_ID
Definition: 3c515.c:98
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct nic_operations * nic_op
Definition: nic.h:50
static int corkscrew_found_device(int ioaddr, int irq, int product_index, int options, struct nic *nic)
Definition: 3c515.c:656

References activate_isapnp_device(), corkscrew_found_device(), CORKSCREW_ID, DBG, EEPROM_Read, inl(), inw(), nic::ioaddr, isapnp_device::ioaddr, nic::irqno, isapnp_device::irqno, nic::nic_op, options, outw, t3c515_wait(), t515_operations, t515_reset(), timer, Wn0EepromCmd, and Wn0EepromData.

◆ ISAPNP_DRIVER()

ISAPNP_DRIVER ( t515_driver  ,
t515_adapters   
)

◆ DRIVER()

DRIVER ( "3c515"  ,
nic_driver  ,
isapnp_driver  ,
t515_driver  ,
t515_probe  ,
t515_disable   
)

◆ ISA_ROM()

ISA_ROM ( "3c515"  ,
"3c515 Fast EtherLink ISAPnP"   
)

Variable Documentation

◆ if_port

int if_port
static

Definition at line 66 of file 3c515.c.

Referenced by corkscrew_probe1(), t515_disable(), and t515_reset().

◆ vp

struct corkscrew_private* vp
static

◆ media_tbl

struct media_table media_tbl[]
static
Initial value:
= {
{
"10baseT", Media_10TP, 0x08, XCVR_10base2, (14 * HZ) / 10}
, {
"10Mbs AUI", Media_SQE, 0x20, XCVR_Default, (1 * HZ) / 10}
, {
"undefined", 0, 0x80, XCVR_10baseT, 10000}
, {
"10base2", 0, 0x10, XCVR_AUI, (1 * HZ) / 10}
, {
"100baseTX", Media_Lnk, 0x02, XCVR_100baseFx,
(14 * HZ) / 10}
, {
"100baseFX", Media_Lnk, 0x04, XCVR_MII, (14 * HZ) / 10}
, {
"MII", 0, 0x40, XCVR_10baseT, 3 * HZ}
, {
"undefined", 0, 0x01, XCVR_10baseT, 10000}
, {
"Default", 0, 0xFF, XCVR_10baseT, 10000}
,}
#define HZ
Definition: 3c515.c:65

Referenced by corkscrew_probe1(), and t515_reset().

◆ options

int options = -1
static

◆ padmap

char padmap[]
static
Initial value:
= {
0, 3, 2, 1
}

Definition at line 498 of file 3c515.c.

Referenced by t515_transmit().

◆ t515_operations

struct nic_operations t515_operations
static
Initial value:
= {
.connect = dummy_connect,
.poll = t515_poll,
.transmit = t515_transmit,
.irq = t515_irq,
}
static void t515_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition: 3c515.c:590
int dummy_connect(struct nic *nic __unused)
Definition: legacy.c:151
static void t515_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
Definition: 3c515.c:504
static int t515_poll(struct nic *nic, int retrieve)
Definition: 3c515.c:418

Definition at line 602 of file 3c515.c.

Referenced by t515_probe().

◆ t515_adapters

struct isapnp_device_id t515_adapters[]
static
Initial value:
= {
{ "3c515 (ISAPnP)", ISAPNP_VENDOR('T','C','M'), 0x5051 },
}
#define ISAPNP_VENDOR(a, b, c)
Definition: isa_ids.h:35

Definition at line 755 of file 3c515.c.