1N/A/*
1N/A * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
1N/A *
1N/A * Redistribution and use in source and binary forms, with or without
1N/A * modification, are permitted provided that the following conditions are
1N/A * met: 1. Redistributions of source code must retain the above copyright
1N/A * notice, this list of conditions and the following disclaimer. 2. The name
1N/A * of the author may not be used to endorse or promote products derived from
1N/A * this software without specific prior written permission
1N/A *
1N/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1N/A * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1N/A * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
1N/A * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1N/A *
1N/A October 2, 1994
1N/A
1N/A Modified by: Andres Vega Garcia
1N/A
1N/A INRIA - Sophia Antipolis, France
1N/A e-mail: avega@sophia.inria.fr
1N/A finger: avega@pax.inria.fr
1N/A
1N/A */
1N/A
1N/A/*
1N/A * Created from if_epreg.h by Fred Gray (fgray@rice.edu) to support the
1N/A * 3c590 family.
1N/A */
1N/A
1N/A/*
1N/A * Modified by Shusuke Nisiyama <shu@athena.qe.eng.hokudai.ac.jp>
1N/A * for etherboot
1N/A * Mar. 14, 2000
1N/A*/
1N/A
1N/A/*
1N/A * Ethernet software status per interface.
1N/A */
1N/A
1N/A/*
1N/A * Some global constants
1N/A */
1N/A
1N/A#define TX_INIT_RATE 16
1N/A#define TX_INIT_MAX_RATE 64
1N/A#define RX_INIT_LATENCY 64
1N/A#define RX_INIT_EARLY_THRESH 64
1N/A#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
1N/A#define MIN_RX_EARLY_THRESHL 4
1N/A
1N/A#define EEPROMSIZE 0x40
1N/A#define MAX_EEPROMBUSY 1000
1N/A#define VX_LAST_TAG 0xd7
1N/A#define VX_MAX_BOARDS 16
1N/A#define VX_ID_PORT 0x100
1N/A
1N/A/*
1N/A * some macros to acces long named fields
1N/A */
1N/A#define BASE (eth_nic_base)
1N/A
1N/A/*
1N/A * Commands to read/write EEPROM trough EEPROM command register (Window 0,
1N/A * Offset 0xa)
1N/A */
1N/A#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */
1N/A#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */
1N/A#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
1N/A#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */
1N/A
1N/A#define EEPROM_BUSY (1<<15)
1N/A
1N/A/*
1N/A * Some short functions, worth to let them be a macro
1N/A */
1N/A
1N/A/**************************************************************************
1N/A * *
1N/A * These define the EEPROM data structure. They are used in the probe
1N/A * function to verify the existence of the adapter after having sent
1N/A * the ID_Sequence.
1N/A *
1N/A * There are others but only the ones we use are defined here.
1N/A *
1N/A **************************************************************************/
1N/A
1N/A#define EEPROM_NODE_ADDR_0 0x0 /* Word */
1N/A#define EEPROM_NODE_ADDR_1 0x1 /* Word */
1N/A#define EEPROM_NODE_ADDR_2 0x2 /* Word */
1N/A#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
1N/A#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
1N/A#define EEPROM_ADDR_CFG 0x8 /* Base addr */
1N/A#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
1N/A#define EEPROM_OEM_ADDR_0 0xa /* Word */
1N/A#define EEPROM_OEM_ADDR_1 0xb /* Word */
1N/A#define EEPROM_OEM_ADDR_2 0xc /* Word */
1N/A#define EEPROM_SOFT_INFO_2 0xf /* Software information 2 */
1N/A
1N/A#define NO_RX_OVN_ANOMALY (1<<5)
1N/A
1N/A/**************************************************************************
1N/A * *
1N/A * These are the registers for the 3Com 3c509 and their bit patterns when *
1N/A * applicable. They have been taken out the the "EtherLink III Parallel *
1N/A * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
1N/A * from 3com. *
1N/A * *
1N/A **************************************************************************/
1N/A
1N/A#define VX_COMMAND 0x0e /* Write. BASE+0x0e is always a
1N/A * command reg. */
1N/A#define VX_STATUS 0x0e /* Read. BASE+0x0e is always status
1N/A * reg. */
1N/A#define VX_WINDOW 0x0f /* Read. BASE+0x0f is always window
1N/A * reg. */
1N/A/*
1N/A * Window 0 registers. Setup.
1N/A */
1N/A/* Write */
1N/A#define VX_W0_EEPROM_DATA 0x0c
1N/A#define VX_W0_EEPROM_COMMAND 0x0a
1N/A#define VX_W0_RESOURCE_CFG 0x08
1N/A#define VX_W0_ADDRESS_CFG 0x06
1N/A#define VX_W0_CONFIG_CTRL 0x04
1N/A /* Read */
1N/A#define VX_W0_PRODUCT_ID 0x02
1N/A#define VX_W0_MFG_ID 0x00
1N/A
1N/A
1N/A/*
1N/A * Window 1 registers. Operating Set.
1N/A */
1N/A/* Write */
1N/A#define VX_W1_TX_PIO_WR_2 0x02
1N/A#define VX_W1_TX_PIO_WR_1 0x00
1N/A/* Read */
1N/A#define VX_W1_FREE_TX 0x0c
1N/A#define VX_W1_TX_STATUS 0x0b /* byte */
1N/A#define VX_W1_TIMER 0x0a /* byte */
1N/A#define VX_W1_RX_STATUS 0x08
1N/A#define VX_W1_RX_PIO_RD_2 0x02
1N/A#define VX_W1_RX_PIO_RD_1 0x00
1N/A
1N/A/*
1N/A * Window 2 registers. Station Address Setup/Read
1N/A */
1N/A/* Read/Write */
1N/A#define VX_W2_ADDR_5 0x05
1N/A#define VX_W2_ADDR_4 0x04
1N/A#define VX_W2_ADDR_3 0x03
1N/A#define VX_W2_ADDR_2 0x02
1N/A#define VX_W2_ADDR_1 0x01
1N/A#define VX_W2_ADDR_0 0x00
1N/A
1N/A/*
1N/A * Window 3 registers. FIFO Management.
1N/A */
1N/A/* Read */
1N/A#define VX_W3_INTERNAL_CFG 0x00
1N/A#define VX_W3_RESET_OPT 0x08
1N/A#define VX_W3_FREE_TX 0x0c
1N/A#define VX_W3_FREE_RX 0x0a
1N/A
1N/A/*
1N/A * Window 4 registers. Diagnostics.
1N/A */
1N/A/* Read/Write */
1N/A#define VX_W4_MEDIA_TYPE 0x0a
1N/A#define VX_W4_CTRLR_STATUS 0x08
1N/A#define VX_W4_NET_DIAG 0x06
1N/A#define VX_W4_FIFO_DIAG 0x04
1N/A#define VX_W4_HOST_DIAG 0x02
1N/A#define VX_W4_TX_DIAG 0x00
1N/A
1N/A/*
1N/A * Window 5 Registers. Results and Internal status.
1N/A */
1N/A/* Read */
1N/A#define VX_W5_READ_0_MASK 0x0c
1N/A#define VX_W5_INTR_MASK 0x0a
1N/A#define VX_W5_RX_FILTER 0x08
1N/A#define VX_W5_RX_EARLY_THRESH 0x06
1N/A#define VX_W5_TX_AVAIL_THRESH 0x02
1N/A#define VX_W5_TX_START_THRESH 0x00
1N/A
1N/A/*
1N/A * Window 6 registers. Statistics.
1N/A */
1N/A/* Read/Write */
1N/A#define TX_TOTAL_OK 0x0c
1N/A#define RX_TOTAL_OK 0x0a
1N/A#define TX_DEFERRALS 0x08
1N/A#define RX_FRAMES_OK 0x07
1N/A#define TX_FRAMES_OK 0x06
1N/A#define RX_OVERRUNS 0x05
1N/A#define TX_COLLISIONS 0x04
1N/A#define TX_AFTER_1_COLLISION 0x03
1N/A#define TX_AFTER_X_COLLISIONS 0x02
1N/A#define TX_NO_SQE 0x01
1N/A#define TX_CD_LOST 0x00
1N/A
1N/A/****************************************
1N/A *
1N/A * Register definitions.
1N/A *
1N/A ****************************************/
1N/A
1N/A/*
1N/A * Command register. All windows.
1N/A *
1N/A * 16 bit register.
1N/A * 15-11: 5-bit code for command to be executed.
1N/A * 10-0: 11-bit arg if any. For commands with no args;
1N/A * this can be set to anything.
1N/A */
1N/A#define GLOBAL_RESET (unsigned short) 0x0000 /* Wait at least 1ms
1N/A * after issuing */
1N/A#define WINDOW_SELECT (unsigned short) (0x1<<11)
1N/A#define START_TRANSCEIVER (unsigned short) (0x2<<11) /* Read ADDR_CFG reg to
1N/A * determine whether
1N/A * this is needed. If
1N/A * so; wait 800 uSec
1N/A * before using trans-
1N/A * ceiver. */
1N/A#define RX_DISABLE (unsigned short) (0x3<<11) /* state disabled on
1N/A * power-up */
1N/A#define RX_ENABLE (unsigned short) (0x4<<11)
1N/A#define RX_RESET (unsigned short) (0x5<<11)
1N/A#define RX_DISCARD_TOP_PACK (unsigned short) (0x8<<11)
1N/A#define TX_ENABLE (unsigned short) (0x9<<11)
1N/A#define TX_DISABLE (unsigned short) (0xa<<11)
1N/A#define TX_RESET (unsigned short) (0xb<<11)
1N/A#define REQ_INTR (unsigned short) (0xc<<11)
1N/A/*
1N/A * The following C_* acknowledge the various interrupts. Some of them don't
1N/A * do anything. See the manual.
1N/A */
1N/A#define ACK_INTR (unsigned short) (0x6800)
1N/A# define C_INTR_LATCH (unsigned short) (ACK_INTR|0x1)
1N/A# define C_CARD_FAILURE (unsigned short) (ACK_INTR|0x2)
1N/A# define C_TX_COMPLETE (unsigned short) (ACK_INTR|0x4)
1N/A# define C_TX_AVAIL (unsigned short) (ACK_INTR|0x8)
1N/A# define C_RX_COMPLETE (unsigned short) (ACK_INTR|0x10)
1N/A# define C_RX_EARLY (unsigned short) (ACK_INTR|0x20)
1N/A# define C_INT_RQD (unsigned short) (ACK_INTR|0x40)
1N/A# define C_UPD_STATS (unsigned short) (ACK_INTR|0x80)
1N/A#define SET_INTR_MASK (unsigned short) (0xe<<11)
1N/A#define SET_RD_0_MASK (unsigned short) (0xf<<11)
1N/A#define SET_RX_FILTER (unsigned short) (0x10<<11)
1N/A# define FIL_INDIVIDUAL (unsigned short) (0x1)
1N/A# define FIL_MULTICAST (unsigned short) (0x02)
1N/A# define FIL_BRDCST (unsigned short) (0x04)
1N/A# define FIL_PROMISC (unsigned short) (0x08)
1N/A#define SET_RX_EARLY_THRESH (unsigned short) (0x11<<11)
1N/A#define SET_TX_AVAIL_THRESH (unsigned short) (0x12<<11)
1N/A#define SET_TX_START_THRESH (unsigned short) (0x13<<11)
1N/A#define STATS_ENABLE (unsigned short) (0x15<<11)
1N/A#define STATS_DISABLE (unsigned short) (0x16<<11)
1N/A#define STOP_TRANSCEIVER (unsigned short) (0x17<<11)
1N/A
1N/A/*
1N/A * Status register. All windows.
1N/A *
1N/A * 15-13: Window number(0-7).
1N/A * 12: Command_in_progress.
1N/A * 11: reserved.
1N/A * 10: reserved.
1N/A * 9: reserved.
1N/A * 8: reserved.
1N/A * 7: Update Statistics.
1N/A * 6: Interrupt Requested.
1N/A * 5: RX Early.
1N/A * 4: RX Complete.
1N/A * 3: TX Available.
1N/A * 2: TX Complete.
1N/A * 1: Adapter Failure.
1N/A * 0: Interrupt Latch.
1N/A */
1N/A#define S_INTR_LATCH (unsigned short) (0x1)
1N/A#define S_CARD_FAILURE (unsigned short) (0x2)
1N/A#define S_TX_COMPLETE (unsigned short) (0x4)
1N/A#define S_TX_AVAIL (unsigned short) (0x8)
1N/A#define S_RX_COMPLETE (unsigned short) (0x10)
1N/A#define S_RX_EARLY (unsigned short) (0x20)
1N/A#define S_INT_RQD (unsigned short) (0x40)
1N/A#define S_UPD_STATS (unsigned short) (0x80)
1N/A#define S_COMMAND_IN_PROGRESS (unsigned short) (0x1000)
1N/A
1N/A#define VX_BUSY_WAIT while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS)
1N/A
1N/A/* Address Config. Register.
1N/A * Window 0/Port 06
1N/A */
1N/A
1N/A#define ACF_CONNECTOR_BITS 14
1N/A#define ACF_CONNECTOR_UTP 0
1N/A#define ACF_CONNECTOR_AUI 1
1N/A#define ACF_CONNECTOR_BNC 3
1N/A
1N/A#define INTERNAL_CONNECTOR_BITS 20
1N/A#define INTERNAL_CONNECTOR_MASK 0x01700000
1N/A
1N/A/*
1N/A * FIFO Registers. RX Status.
1N/A *
1N/A * 15: Incomplete or FIFO empty.
1N/A * 14: 1: Error in RX Packet 0: Incomplete or no error.
1N/A * 13-11: Type of error.
1N/A * 1000 = Overrun.
1N/A * 1011 = Run Packet Error.
1N/A * 1100 = Alignment Error.
1N/A * 1101 = CRC Error.
1N/A * 1001 = Oversize Packet Error (>1514 bytes)
1N/A * 0010 = Dribble Bits.
1N/A * (all other error codes, no errors.)
1N/A *
1N/A * 10-0: RX Bytes (0-1514)
1N/A */
1N/A#define ERR_INCOMPLETE (unsigned short) (0x8000)
1N/A#define ERR_RX (unsigned short) (0x4000)
1N/A#define ERR_MASK (unsigned short) (0x7800)
1N/A#define ERR_OVERRUN (unsigned short) (0x4000)
1N/A#define ERR_RUNT (unsigned short) (0x5800)
1N/A#define ERR_ALIGNMENT (unsigned short) (0x6000)
1N/A#define ERR_CRC (unsigned short) (0x6800)
1N/A#define ERR_OVERSIZE (unsigned short) (0x4800)
1N/A#define ERR_DRIBBLE (unsigned short) (0x1000)
1N/A
1N/A/*
1N/A * TX Status.
1N/A *
1N/A * Reports the transmit status of a completed transmission. Writing this
1N/A * register pops the transmit completion stack.
1N/A *
1N/A * Window 1/Port 0x0b.
1N/A *
1N/A * 7: Complete
1N/A * 6: Interrupt on successful transmission requested.
1N/A * 5: Jabber Error (TP Only, TX Reset required. )
1N/A * 4: Underrun (TX Reset required. )
1N/A * 3: Maximum Collisions.
1N/A * 2: TX Status Overflow.
1N/A * 1-0: Undefined.
1N/A *
1N/A */
1N/A#define TXS_COMPLETE 0x80
1N/A#define TXS_INTR_REQ 0x40
1N/A#define TXS_JABBER 0x20
1N/A#define TXS_UNDERRUN 0x10
1N/A#define TXS_MAX_COLLISION 0x8
1N/A#define TXS_STATUS_OVERFLOW 0x4
1N/A
1N/A#define RS_AUI (1<<5)
1N/A#define RS_BNC (1<<4)
1N/A#define RS_UTP (1<<3)
1N/A#define RS_T4 (1<<0)
1N/A#define RS_TX (1<<1)
1N/A#define RS_FX (1<<2)
1N/A#define RS_MII (1<<6)
1N/A
1N/A
1N/A/*
1N/A * FIFO Status (Window 4)
1N/A *
1N/A * Supports FIFO diagnostics
1N/A *
1N/A * Window 4/Port 0x04.1
1N/A *
1N/A * 15: 1=RX receiving (RO). Set when a packet is being received
1N/A * into the RX FIFO.
1N/A * 14: Reserved
1N/A * 13: 1=RX underrun (RO). Generates Adapter Failure interrupt.
1N/A * Requires RX Reset or Global Reset command to recover.
1N/A * It is generated when you read past the end of a packet -
1N/A * reading past what has been received so far will give bad
1N/A * data.
1N/A * 12: 1=RX status overrun (RO). Set when there are already 8
1N/A * packets in the RX FIFO. While this bit is set, no additional
1N/A * packets are received. Requires no action on the part of
1N/A * the host. The condition is cleared once a packet has been
1N/A * read out of the RX FIFO.
1N/A * 11: 1=RX overrun (RO). Set when the RX FIFO is full (there
1N/A * may not be an overrun packet yet). While this bit is set,
1N/A * no additional packets will be received (some additional
1N/A * bytes can still be pending between the wire and the RX
1N/A * FIFO). Requires no action on the part of the host. The
1N/A * condition is cleared once a few bytes have been read out
1N/A * from the RX FIFO.
1N/A * 10: 1=TX overrun (RO). Generates adapter failure interrupt.
1N/A * Requires TX Reset or Global Reset command to recover.
1N/A * Disables Transmitter.
1N/A * 9-8: Unassigned.
1N/A * 7-0: Built in self test bits for the RX and TX FIFO's.
1N/A */
1N/A#define FIFOS_RX_RECEIVING (unsigned short) 0x8000
1N/A#define FIFOS_RX_UNDERRUN (unsigned short) 0x2000
1N/A#define FIFOS_RX_STATUS_OVERRUN (unsigned short) 0x1000
1N/A#define FIFOS_RX_OVERRUN (unsigned short) 0x0800
1N/A#define FIFOS_TX_OVERRUN (unsigned short) 0x0400
1N/A
1N/A/*
1N/A * Misc defines for various things.
1N/A */
1N/A#define TAG_ADAPTER 0xd0
1N/A#define ACTIVATE_ADAPTER_TO_CONFIG 0xff
1N/A#define ENABLE_DRQ_IRQ 0x0001
1N/A#define MFG_ID 0x506d /* `TCM' */
1N/A#define PROD_ID 0x5090
1N/A#define GO_WINDOW(x) outw(WINDOW_SELECT|(x),BASE+VX_COMMAND)
1N/A#define JABBER_GUARD_ENABLE 0x40
1N/A#define LINKBEAT_ENABLE 0x80
1N/A#define ENABLE_UTP (JABBER_GUARD_ENABLE | LINKBEAT_ENABLE)
1N/A#define DISABLE_UTP 0x0
1N/A#define RX_BYTES_MASK (unsigned short) (0x07ff)
1N/A#define RX_ERROR 0x4000
1N/A#define RX_INCOMPLETE 0x8000
1N/A#define TX_INDICATE 1<<15
1N/A#define is_eeprom_busy(b) (inw((b)+VX_W0_EEPROM_COMMAND)&EEPROM_BUSY)
1N/A
1N/A#define VX_IOSIZE 0x20
1N/A
1N/A#define VX_CONNECTORS 8
1N/A
1N/A/*
1N/A * Local variables:
1N/A * c-basic-offset: 8
1N/A * End:
1N/A */