xref: /dflybsd-src/sys/dev/netif/sn/if_snreg.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*
286d7f5d3SJohn Marino  * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
386d7f5d3SJohn Marino  * All rights reserved.
486d7f5d3SJohn Marino  *
586d7f5d3SJohn Marino  * Redistribution and use in source and binary forms, with or without
686d7f5d3SJohn Marino  * modification, are permitted provided that the following conditions
786d7f5d3SJohn Marino  * are met:
886d7f5d3SJohn Marino  * 1. Redistributions of source code must retain the above copyright
986d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer.
1086d7f5d3SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
1186d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
1286d7f5d3SJohn Marino  *    documentation and/or other materials provided with the distribution.
1386d7f5d3SJohn Marino  * 3. All advertising materials mentioning features or use of this software
1486d7f5d3SJohn Marino  *    must display the following acknowledgement:
1586d7f5d3SJohn Marino  *      This product includes software developed by Gardner Buchanan.
1686d7f5d3SJohn Marino  * 4. The name of Gardner Buchanan may not be used to endorse or promote
1786d7f5d3SJohn Marino  *    products derived from this software without specific prior written
1886d7f5d3SJohn Marino  *    permission.
1986d7f5d3SJohn Marino  *
2086d7f5d3SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2186d7f5d3SJohn Marino  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2286d7f5d3SJohn Marino  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2386d7f5d3SJohn Marino  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2486d7f5d3SJohn Marino  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2586d7f5d3SJohn Marino  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2686d7f5d3SJohn Marino  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2786d7f5d3SJohn Marino  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2886d7f5d3SJohn Marino  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2986d7f5d3SJohn Marino  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3086d7f5d3SJohn Marino  *
3186d7f5d3SJohn Marino  *   $FreeBSD: src/sys/dev/sn/if_snreg.h,v 1.2.2.1 2001/02/04 04:38:38 toshi Exp $
3286d7f5d3SJohn Marino  *   $DragonFly: src/sys/dev/netif/sn/if_snreg.h,v 1.2 2003/06/17 04:28:29 dillon Exp $
3386d7f5d3SJohn Marino  */
3486d7f5d3SJohn Marino 
3586d7f5d3SJohn Marino /*
3686d7f5d3SJohn Marino  * This file contains register information and access macros for
3786d7f5d3SJohn Marino  * the SMC91xxx chipset.
3886d7f5d3SJohn Marino  *
3986d7f5d3SJohn Marino  * Information contained in this file was obtained from the SMC91C92
4086d7f5d3SJohn Marino  * and SMC91C94 manuals from SMC.  You will need one of these in order
4186d7f5d3SJohn Marino  * to make any meaningful changes to this driver.  Information about
4286d7f5d3SJohn Marino  * obtaining one can be found at http://www.smc.com in the components
4386d7f5d3SJohn Marino  * division.
4486d7f5d3SJohn Marino  *
4586d7f5d3SJohn Marino  * This FreeBSD driver is derived in part from the smc9194 Linux driver
4686d7f5d3SJohn Marino  * by Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
4786d7f5d3SJohn Marino  * It is also derived in part from the FreeBSD ep (3C509) driver which
4886d7f5d3SJohn Marino  * is Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights
4986d7f5d3SJohn Marino  * reserved.
5086d7f5d3SJohn Marino  *
5186d7f5d3SJohn Marino  */
5286d7f5d3SJohn Marino #ifndef _IF_SNREG_H_
5386d7f5d3SJohn Marino #define _IF_SNREG_H_
5486d7f5d3SJohn Marino 
5586d7f5d3SJohn Marino /*
5686d7f5d3SJohn Marino  * Wait time for memory to be free.  This probably shouldn't be
5786d7f5d3SJohn Marino  * tuned that much, as waiting for this means nothing else happens
5886d7f5d3SJohn Marino  * in the system
5986d7f5d3SJohn Marino  */
6086d7f5d3SJohn Marino #define	MEMORY_WAIT_TIME	1000
6186d7f5d3SJohn Marino 
6286d7f5d3SJohn Marino 
6386d7f5d3SJohn Marino /* The SMC91xxx uses 16 I/O ports
6486d7f5d3SJohn Marino  */
6586d7f5d3SJohn Marino #define SMC_IO_EXTENT   16
6686d7f5d3SJohn Marino 
6786d7f5d3SJohn Marino 
6886d7f5d3SJohn Marino /*
6986d7f5d3SJohn Marino  * A description of the SMC registers is probably in order here,
7086d7f5d3SJohn Marino  * although for details, the SMC datasheet is invaluable.
7186d7f5d3SJohn Marino  * The data sheet I (GB) am using is "SMC91C92 Single Chip Ethernet
7286d7f5d3SJohn Marino  * Controller With RAM", Rev. 12/0/94.  Constant definitions I give
7386d7f5d3SJohn Marino  * here are loosely based on the mnemonic names given to them in the
7486d7f5d3SJohn Marino  * data sheet, but there are many exceptions.
7586d7f5d3SJohn Marino  *
7686d7f5d3SJohn Marino  * Basically, the chip has 4 banks of registers (0 to 3), which
7786d7f5d3SJohn Marino  * are accessed by writing a number into the BANK_SELECT register
7886d7f5d3SJohn Marino  * (I also use a SMC_SELECT_BANK macro for this).  Registers are
7986d7f5d3SJohn Marino  * either Byte or Word sized.  My constant definitions end in _B
8086d7f5d3SJohn Marino  * or _W as appropriate.
8186d7f5d3SJohn Marino  *
8286d7f5d3SJohn Marino  * The banks are arranged so that for most purposes, bank 2 is all
8386d7f5d3SJohn Marino  * that is needed for normal run time tasks.
8486d7f5d3SJohn Marino  */
8586d7f5d3SJohn Marino 
8686d7f5d3SJohn Marino /*
8786d7f5d3SJohn Marino  * Bank Select Register.  This also doubles as
8886d7f5d3SJohn Marino  * a chip identification register.  This register
8986d7f5d3SJohn Marino  * is mapped at the same position in all banks.
9086d7f5d3SJohn Marino  */
9186d7f5d3SJohn Marino #define BANK_SELECT_REG_W       0x0e
9286d7f5d3SJohn Marino #define BSR_DETECT_MASK         0xff00
9386d7f5d3SJohn Marino #define BSR_DETECT_VALUE        0x3300
9486d7f5d3SJohn Marino 
9586d7f5d3SJohn Marino 
9686d7f5d3SJohn Marino /* BANK 0
9786d7f5d3SJohn Marino  */
9886d7f5d3SJohn Marino 
9986d7f5d3SJohn Marino /* Transmit Control Register controls some aspects of the transmit
10086d7f5d3SJohn Marino  * behavior of the Ethernet Protocol Handler.
10186d7f5d3SJohn Marino  */
10286d7f5d3SJohn Marino #define TXMIT_CONTROL_REG_W  0x00
10386d7f5d3SJohn Marino 
10486d7f5d3SJohn Marino #define TCR_ENABLE      0x0001	/* if this is 1, we can transmit */
10586d7f5d3SJohn Marino #define TCR_LOOP        0x0002	/* Enable internal analogue loopback */
10686d7f5d3SJohn Marino #define TCR_FORCOL      0x0004	/* Force Collision on next TX */
10786d7f5d3SJohn Marino #define TCR_PAD_ENABLE  0x0080	/* Pad short packets to 64 bytes */
10886d7f5d3SJohn Marino #define TCR_NOCRC       0x0100	/* Do not append CRC */
10986d7f5d3SJohn Marino #define TCR_MON_CSN     0x0400	/* monitors the carrier status */
11086d7f5d3SJohn Marino #define TCR_FDUPLX      0x0800	/* receive packets sent out */
11186d7f5d3SJohn Marino #define TCR_STP_SQET    0x1000	/* stop transmitting if Signal quality error */
11286d7f5d3SJohn Marino #define TCR_EPH_LOOP    0x2000	/* Enable internal digital loopback */
11386d7f5d3SJohn Marino 
11486d7f5d3SJohn Marino 
11586d7f5d3SJohn Marino /* Status of the last transmitted frame and instantaneous status of
11686d7f5d3SJohn Marino  * the Ethernet Protocol Handler jumbled together.  In auto-release
11786d7f5d3SJohn Marino  * mode this information is simply discarded after each TX.  This info
11886d7f5d3SJohn Marino  * is copied to the status word of in-memory packets after transmit
11986d7f5d3SJohn Marino  * where relevent statuses can be checked.
12086d7f5d3SJohn Marino  */
12186d7f5d3SJohn Marino #define EPH_STATUS_REG_W 0x02
12286d7f5d3SJohn Marino 
12386d7f5d3SJohn Marino #define EPHSR_TX_SUC    0x0001	/* Transmit was successful */
12486d7f5d3SJohn Marino #define EPHSR_SNGLCOL   0x0002	/* Single collision occurred */
12586d7f5d3SJohn Marino #define EPHSR_MULCOL    0x0004	/* Multiple Collisions occurred */
12686d7f5d3SJohn Marino #define EPHSR_LTX_MULT  0x0008	/* Transmit was a multicast */
12786d7f5d3SJohn Marino #define EPHSR_16COL     0x0010	/* 16 Collisions occurred, TX disabled */
12886d7f5d3SJohn Marino #define EPHSR_SQET      0x0020	/* SQE Test failed, TX disabled */
12986d7f5d3SJohn Marino #define EPHSR_LTX_BRD   0x0040	/* Transmit was a broadcast */
13086d7f5d3SJohn Marino #define EPHSR_DEFR      0x0080	/* TX deferred due to carrier det. */
13186d7f5d3SJohn Marino #define EPHSR_LATCOL    0x0200	/* Late collision detected, TX disabled */
13286d7f5d3SJohn Marino #define EPHSR_LOST_CAR  0x0400	/* Lost carrier sense, TX disabled */
13386d7f5d3SJohn Marino #define EPHSR_EXC_DEF   0x0800	/* Excessive deferrals in TX >2 MAXETHER
13486d7f5d3SJohn Marino 				 * times */
13586d7f5d3SJohn Marino #define EPHSR_CTR_ROL   0x1000	/* Some ECR Counter(s) rolled over */
13686d7f5d3SJohn Marino #define EPHSR_RX_OVRN   0x2000	/* Receiver overrun, packets dropped */
13786d7f5d3SJohn Marino #define EPHSR_LINK_OK   0x4000	/* Link integrity is OK */
13886d7f5d3SJohn Marino #define EPHSR_TXUNRN    0x8000	/* Transmit underrun */
13986d7f5d3SJohn Marino 
14086d7f5d3SJohn Marino 
14186d7f5d3SJohn Marino /* Receiver Control Register controls some aspects of the receive
14286d7f5d3SJohn Marino  * behavior of the Ethernet Protocol Handler.
14386d7f5d3SJohn Marino  */
14486d7f5d3SJohn Marino #define RECV_CONTROL_REG_W 0x04
14586d7f5d3SJohn Marino 
14686d7f5d3SJohn Marino #define RCR_RX_ABORT    0x0001	/* Received huge packet */
14786d7f5d3SJohn Marino #define RCR_PROMISC     0x0002	/* enable promiscuous mode */
14886d7f5d3SJohn Marino #define RCR_ALMUL       0x0004	/* receive all multicast packets */
14986d7f5d3SJohn Marino #define RCR_ENABLE      0x0100	/* IFF this is set, we can recieve packets */
15086d7f5d3SJohn Marino #define RCR_STRIP_CRC   0x0200	/* strips CRC */
15186d7f5d3SJohn Marino #define RCR_GAIN_BITS   0x0c00	/* PLL Gain control (for testing) */
15286d7f5d3SJohn Marino #define RCR_FILT_CAR    0x4000	/* Enable 12 bit carrier filter */
15386d7f5d3SJohn Marino #define RCR_SOFTRESET   0x8000	/* Resets the EPH logic */
15486d7f5d3SJohn Marino 
15586d7f5d3SJohn Marino 
15686d7f5d3SJohn Marino /* TX Statistics counters
15786d7f5d3SJohn Marino  */
15886d7f5d3SJohn Marino #define COUNTER_REG_W   0x06
15986d7f5d3SJohn Marino 
16086d7f5d3SJohn Marino #define ECR_COLN_MASK   0x000f	/* Vanilla collisions */
16186d7f5d3SJohn Marino #define ECR_MCOLN_MASK  0x00f0	/* Multiple collisions */
16286d7f5d3SJohn Marino #define ECR_DTX_MASK    0x0f00	/* Deferred transmits */
16386d7f5d3SJohn Marino #define ECR_EXDTX_MASK  0xf000	/* Excessively deferred transmits */
16486d7f5d3SJohn Marino 
16586d7f5d3SJohn Marino /* Memory Information
16686d7f5d3SJohn Marino  */
16786d7f5d3SJohn Marino #define MEM_INFO_REG_W  0x08
16886d7f5d3SJohn Marino 
16986d7f5d3SJohn Marino #define MIR_FREE_MASK   0xff00	/* Free memory pages available */
17086d7f5d3SJohn Marino #define MIR_TOTAL_MASK  0x00ff	/* Total memory pages available */
17186d7f5d3SJohn Marino 
17286d7f5d3SJohn Marino /* Memory Configuration
17386d7f5d3SJohn Marino  */
17486d7f5d3SJohn Marino #define MEM_CFG_REG_W   0x0a
17586d7f5d3SJohn Marino 
17686d7f5d3SJohn Marino #define MCR_TXRSV_MASK  0x001f	/* Count of pages reserved for transmit */
17786d7f5d3SJohn Marino 
17886d7f5d3SJohn Marino 
17986d7f5d3SJohn Marino /* Bank 0, Register 0x0c is unised in the SMC91C92
18086d7f5d3SJohn Marino  */
18186d7f5d3SJohn Marino 
18286d7f5d3SJohn Marino 
18386d7f5d3SJohn Marino /* BANK 1
18486d7f5d3SJohn Marino  */
18586d7f5d3SJohn Marino 
18686d7f5d3SJohn Marino /* Adapter configuration
18786d7f5d3SJohn Marino  */
18886d7f5d3SJohn Marino #define CONFIG_REG_W    0x00
18986d7f5d3SJohn Marino 
19086d7f5d3SJohn Marino #define CR_INT_SEL0     0x0002	/* Interrupt selector */
19186d7f5d3SJohn Marino #define CR_INT_SEL1     0x0004	/* Interrupt selector */
19286d7f5d3SJohn Marino #define CR_DIS_LINK     0x0040	/* Disable 10BaseT Link Test */
19386d7f5d3SJohn Marino #define CR_16BIT        0x0080	/* Bus width */
19486d7f5d3SJohn Marino #define CR_AUI_SELECT   0x0100	/* Use external (AUI) Transceiver */
19586d7f5d3SJohn Marino #define CR_SET_SQLCH    0x0200	/* Squelch level */
19686d7f5d3SJohn Marino #define CR_FULL_STEP    0x0400	/* AUI signalling mode */
19786d7f5d3SJohn Marino #define CR_NOW_WAIT_ST  0x1000	/* Disable bus wait states */
19886d7f5d3SJohn Marino 
19986d7f5d3SJohn Marino /* The contents of this port are used by the adapter
20086d7f5d3SJohn Marino  * to decode its I/O address.  We use it as a varification
20186d7f5d3SJohn Marino  * that the adapter is detected properly when probing.
20286d7f5d3SJohn Marino  */
20386d7f5d3SJohn Marino #define BASE_ADDR_REG_W 0x02	/* The select IO Base addr. */
20486d7f5d3SJohn Marino 
20586d7f5d3SJohn Marino /* These registers hold the Ethernet MAC address.
20686d7f5d3SJohn Marino  */
20786d7f5d3SJohn Marino #define IAR_ADDR0_REG_W 0x04	/* My Ethernet address */
20886d7f5d3SJohn Marino #define IAR_ADDR1_REG_W 0x06	/* My Ethernet address */
20986d7f5d3SJohn Marino #define IAR_ADDR2_REG_W 0x08	/* My Ethernet address */
21086d7f5d3SJohn Marino 
21186d7f5d3SJohn Marino /* General purpose register used for talking to the EEPROM.
21286d7f5d3SJohn Marino  */
21386d7f5d3SJohn Marino #define GENERAL_REG_W   0x0a
21486d7f5d3SJohn Marino 
21586d7f5d3SJohn Marino /* Control register used for talking to the EEPROM and
21686d7f5d3SJohn Marino  * setting some EPH functions.
21786d7f5d3SJohn Marino  */
21886d7f5d3SJohn Marino #define CONTROL_REG_W    0x0c
21986d7f5d3SJohn Marino #define CTR_STORE        0x0001	/* Store something to EEPROM */
22086d7f5d3SJohn Marino #define CTR_RELOAD       0x0002	/* Read EEPROM into registers */
22186d7f5d3SJohn Marino #define CTR_EEPROM_SEL   0x0004	/* Select registers for Reload/Store */
22286d7f5d3SJohn Marino #define CTR_TE_ENABLE    0x0020	/* Enable TX Error detection via EPH_INT */
22386d7f5d3SJohn Marino #define CTR_CR_ENABLE    0x0040	/* Enable Counter Rollover via EPH_INT */
22486d7f5d3SJohn Marino #define CTR_LE_ENABLE    0x0080	/* Enable Link Error detection via EPH_INT */
22586d7f5d3SJohn Marino #define CTR_AUTO_RELEASE 0x0800	/* Enable auto release mode for TX */
22686d7f5d3SJohn Marino #define CTR_POWERDOWN    0x2000	/* Enter powerdown mode */
22786d7f5d3SJohn Marino #define CTR_RCV_BAD      0x4000	/* Enable receipt of frames with bad CRC */
22886d7f5d3SJohn Marino 
22986d7f5d3SJohn Marino 
23086d7f5d3SJohn Marino /* BANK 2
23186d7f5d3SJohn Marino  */
23286d7f5d3SJohn Marino 
23386d7f5d3SJohn Marino /* Memory Management Unit Control Register
23486d7f5d3SJohn Marino  * Controls allocation of memory to receive and
23586d7f5d3SJohn Marino  * transmit functions.
23686d7f5d3SJohn Marino  */
23786d7f5d3SJohn Marino #define MMU_CMD_REG_W   0x00
23886d7f5d3SJohn Marino #define MMUCR_BUSY      0x0001	/* MMU busy performing a release */
23986d7f5d3SJohn Marino 
24086d7f5d3SJohn Marino /* MMU Commands:
24186d7f5d3SJohn Marino  */
24286d7f5d3SJohn Marino #define MMUCR_NOP       0x0000	/* Do nothing */
24386d7f5d3SJohn Marino #define MMUCR_ALLOC     0x0020	/* Or with number of 256 byte packets - 1 */
24486d7f5d3SJohn Marino #define MMUCR_RESET     0x0040	/* Reset MMU State */
24586d7f5d3SJohn Marino #define MMUCR_REMOVE    0x0060	/* Dequeue (but not free) current RX packet */
24686d7f5d3SJohn Marino #define MMUCR_RELEASE   0x0080	/* Dequeue and free the current RX packet */
24786d7f5d3SJohn Marino #define MMUCR_FREEPKT   0x00a0	/* Release packet in PNR register */
24886d7f5d3SJohn Marino #define MMUCR_ENQUEUE   0x00c0	/* Enqueue the packet for transmit */
24986d7f5d3SJohn Marino #define MMUCR_RESETTX   0x00e0	/* Reset transmit queues */
25086d7f5d3SJohn Marino 
25186d7f5d3SJohn Marino /* Packet Number at TX Area
25286d7f5d3SJohn Marino  */
25386d7f5d3SJohn Marino #define PACKET_NUM_REG_B   0x02
25486d7f5d3SJohn Marino 
25586d7f5d3SJohn Marino /* Packet number resulting from MMUCR_ALLOC
25686d7f5d3SJohn Marino  */
25786d7f5d3SJohn Marino #define ALLOC_RESULT_REG_B 0x03
25886d7f5d3SJohn Marino #define ARR_FAILED      0x80
25986d7f5d3SJohn Marino 
26086d7f5d3SJohn Marino /* Transmit and receive queue heads
26186d7f5d3SJohn Marino  */
26286d7f5d3SJohn Marino #define FIFO_PORTS_REG_W 0x04
26386d7f5d3SJohn Marino #define FIFO_REMPTY     0x8000
26486d7f5d3SJohn Marino #define FIFO_TEMPTY     0x0080
26586d7f5d3SJohn Marino #define FIFO_RX_MASK    0x7f00
26686d7f5d3SJohn Marino #define FIFO_TX_MASK    0x007f
26786d7f5d3SJohn Marino 
26886d7f5d3SJohn Marino /* The address within the packet for reading/writing.  The
26986d7f5d3SJohn Marino  * PTR_RCV bit is tricky.  When PTR_RCV==1, the packet number
27086d7f5d3SJohn Marino  * to be read is found in the FIFO_PORTS_REG_W, FIFO_RX_MASK.
27186d7f5d3SJohn Marino  * When PTR_RCV==0, the packet number to be written is found
27286d7f5d3SJohn Marino  * in the PACKET_NUM_REG_B.
27386d7f5d3SJohn Marino  */
27486d7f5d3SJohn Marino #define POINTER_REG_W   0x06
27586d7f5d3SJohn Marino #define PTR_READ        0x2000	/* Intended access mode */
27686d7f5d3SJohn Marino #define PTR_AUTOINC     0x4000	/* Do auto inc after read/write */
27786d7f5d3SJohn Marino #define PTR_RCV         0x8000	/* FIFO_RX is packet, otherwise PNR is packet */
27886d7f5d3SJohn Marino 
27986d7f5d3SJohn Marino /* Data I/O register to be used in conjunction with
28086d7f5d3SJohn Marino  * The pointer register to read and write data from the
28186d7f5d3SJohn Marino  * card.  The same register can be used for byte and word
28286d7f5d3SJohn Marino  * ops.
28386d7f5d3SJohn Marino  */
28486d7f5d3SJohn Marino #define DATA_REG_W      0x08
28586d7f5d3SJohn Marino #define DATA_REG_B      0x08
28686d7f5d3SJohn Marino #define DATA_1_REG_B    0x08
28786d7f5d3SJohn Marino #define DATA_2_REG_B    0x0a
28886d7f5d3SJohn Marino 
28986d7f5d3SJohn Marino /* Sense interrupt status (READ)
29086d7f5d3SJohn Marino  */
29186d7f5d3SJohn Marino #define INTR_STAT_REG_B 0x0c
29286d7f5d3SJohn Marino 
29386d7f5d3SJohn Marino /* Acknowledge interrupt sources (WRITE)
29486d7f5d3SJohn Marino  */
29586d7f5d3SJohn Marino #define INTR_ACK_REG_B  0x0c
29686d7f5d3SJohn Marino 
29786d7f5d3SJohn Marino /* Interrupt mask.  Bit set indicates interrupt allowed.
29886d7f5d3SJohn Marino  */
29986d7f5d3SJohn Marino #define INTR_MASK_REG_B 0x0d
30086d7f5d3SJohn Marino 
30186d7f5d3SJohn Marino /* Interrupts
30286d7f5d3SJohn Marino  */
30386d7f5d3SJohn Marino #define IM_RCV_INT      0x01	/* A packet has been received */
30486d7f5d3SJohn Marino #define IM_TX_INT       0x02	/* Packet TX complete */
30586d7f5d3SJohn Marino #define IM_TX_EMPTY_INT 0x04	/* No packets left to TX  */
30686d7f5d3SJohn Marino #define IM_ALLOC_INT    0x08	/* Memory allocation completed */
30786d7f5d3SJohn Marino #define IM_RX_OVRN_INT  0x10	/* Receiver was overrun */
30886d7f5d3SJohn Marino #define IM_EPH_INT      0x20	/* Misc. EPH conditions (see CONTROL_REG_W) */
30986d7f5d3SJohn Marino #define IM_ERCV_INT     0x40	/* not on SMC9192 */
31086d7f5d3SJohn Marino 
31186d7f5d3SJohn Marino /* BANK 3
31286d7f5d3SJohn Marino  */
31386d7f5d3SJohn Marino 
31486d7f5d3SJohn Marino /* Multicast subscriptions.
31586d7f5d3SJohn Marino  * The multicast handling in the SMC90Cxx is quite complicated.  A table
31686d7f5d3SJohn Marino  * of multicast address subscriptions is provided and a clever way of
31786d7f5d3SJohn Marino  * speeding the search of that table by hashing is implemented in the
31886d7f5d3SJohn Marino  * hardware.  I have ignored this and simply subscribed to all multicasts
31986d7f5d3SJohn Marino  * and let the kernel deal with the results.
32086d7f5d3SJohn Marino  */
32186d7f5d3SJohn Marino #define MULTICAST1_REG_W 0x00
32286d7f5d3SJohn Marino #define MULTICAST2_REG_W 0x02
32386d7f5d3SJohn Marino #define MULTICAST3_REG_W 0x04
32486d7f5d3SJohn Marino #define MULTICAST4_REG_W 0x06
32586d7f5d3SJohn Marino 
32686d7f5d3SJohn Marino /* These registers do not exist on SMC9192, or at least
32786d7f5d3SJohn Marino  * are not documented in the SMC91C92 data sheet.
32886d7f5d3SJohn Marino  * The REVISION_REG_W register does however seem to work.
32986d7f5d3SJohn Marino  */
33086d7f5d3SJohn Marino #define MGMT_REG_W      0x08
33186d7f5d3SJohn Marino #define REVISION_REG_W  0x0a	/* (hi: chip id low: rev #) */
33286d7f5d3SJohn Marino #define ERCV_REG_W      0x0c
33386d7f5d3SJohn Marino 
33486d7f5d3SJohn Marino /* These are constants expected to be found in the
33586d7f5d3SJohn Marino  * chip id register.
33686d7f5d3SJohn Marino  */
33786d7f5d3SJohn Marino #define CHIP_9190       3
33886d7f5d3SJohn Marino #define CHIP_9194       4
33986d7f5d3SJohn Marino #define CHIP_9195       5
34086d7f5d3SJohn Marino #define CHIP_91100      7
34186d7f5d3SJohn Marino #define CHIP_91100FD    8
34286d7f5d3SJohn Marino 
34386d7f5d3SJohn Marino /* When packets are stuffed into the card or sucked out of the card
34486d7f5d3SJohn Marino  * they are set up more or less as follows:
34586d7f5d3SJohn Marino  *
34686d7f5d3SJohn Marino  * Addr msbyte   lsbyte
34786d7f5d3SJohn Marino  * 00   SSSSSSSS SSSSSSSS - STATUS-WORD 16 bit TX or RX status
34886d7f5d3SJohn Marino  * 02   RRRRR             - RESERVED (unused)
34986d7f5d3SJohn Marino  * 02        CCC CCCCCCCC - BYTE COUNT (RX: always even, TX: bit 0 ignored)
35086d7f5d3SJohn Marino  * 04   DDDDDDDD DDDDDDDD - DESTINATION ADDRESS
35186d7f5d3SJohn Marino  * 06   DDDDDDDD DDDDDDDD        (48 bit Ethernet MAC Address)
35286d7f5d3SJohn Marino  * 08   DDDDDDDD DDDDDDDD
35386d7f5d3SJohn Marino  * 0A   SSSSSSSS SSSSSSSS - SOURCE ADDRESS
35486d7f5d3SJohn Marino  * 0C   SSSSSSSS SSSSSSSS        (48 bit Ethernet MAC Address)
35586d7f5d3SJohn Marino  * 0E   SSSSSSSS SSSSSSSS
35686d7f5d3SJohn Marino  * 10   PPPPPPPP PPPPPPPP
35786d7f5d3SJohn Marino  * ..   PPPPPPPP PPPPPPPP
35886d7f5d3SJohn Marino  * C-2  CCCCCCCC          - CONTROL BYTE
35986d7f5d3SJohn Marino  * C-2           PPPPPPPP - Last data byte (If odd length)
36086d7f5d3SJohn Marino  *
36186d7f5d3SJohn Marino  * The STATUS_WORD is derived from the EPH_STATUS_REG_W register
36286d7f5d3SJohn Marino  * during transmit and is composed of another set of bits described
36386d7f5d3SJohn Marino  * below during receive.
36486d7f5d3SJohn Marino  */
36586d7f5d3SJohn Marino 
36686d7f5d3SJohn Marino 
36786d7f5d3SJohn Marino /* Receive status bits.  These values are found in the status word
36886d7f5d3SJohn Marino  * field of a received packet.  For receive packets I use the RS_ODDFRAME
36986d7f5d3SJohn Marino  * to detect whether a frame has an extra byte on it.  The CTLB_ODD
37086d7f5d3SJohn Marino  * bit of the control byte tells the same thing.
37186d7f5d3SJohn Marino  */
37286d7f5d3SJohn Marino #define RS_MULTICAST    0x0001	/* Packet is multicast */
37386d7f5d3SJohn Marino #define RS_HASH_MASK    0x007e	/* Mask of multicast hash value */
37486d7f5d3SJohn Marino #define RS_TOOSHORT     0x0400	/* Frame was a runt, <64 bytes */
37586d7f5d3SJohn Marino #define RS_TOOLONG      0x0800	/* Frame was giant, >1518 */
37686d7f5d3SJohn Marino #define RS_ODDFRAME     0x1000	/* Frame is odd lengthed */
37786d7f5d3SJohn Marino #define RS_BADCRC       0x2000	/* Frame had CRC error */
37886d7f5d3SJohn Marino #define RS_ALGNERR      0x8000	/* Frame had alignment error */
37986d7f5d3SJohn Marino #define RS_ERRORS       (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT)
38086d7f5d3SJohn Marino 
38186d7f5d3SJohn Marino #define RLEN_MASK       0x07ff	/* Significant length bits in RX length */
38286d7f5d3SJohn Marino 
38386d7f5d3SJohn Marino /* The control byte has the following significant bits.
38486d7f5d3SJohn Marino  * For transmit, the CTLB_ODD bit specifies whether an extra byte
38586d7f5d3SJohn Marino  * is present in the frame.  Bit 0 of the byte count field is
38686d7f5d3SJohn Marino  * ignored.  I just pad every frame to even length and forget about
38786d7f5d3SJohn Marino  * it.
38886d7f5d3SJohn Marino  */
38986d7f5d3SJohn Marino #define CTLB_CRC        0x10	/* Add CRC for this packet (TX only) */
39086d7f5d3SJohn Marino #define CTLB_ODD        0x20	/* The packet length is ODD */
39186d7f5d3SJohn Marino 
39286d7f5d3SJohn Marino 
39386d7f5d3SJohn Marino /*
39486d7f5d3SJohn Marino  * I define some macros to make it easier to do somewhat common
39586d7f5d3SJohn Marino  * or slightly complicated, repeated tasks.
39686d7f5d3SJohn Marino  */
39786d7f5d3SJohn Marino 
39886d7f5d3SJohn Marino /* The base I/O address.
39986d7f5d3SJohn Marino  */
40086d7f5d3SJohn Marino #define BASE    (sc->sn_io_addr)
40186d7f5d3SJohn Marino 
40286d7f5d3SJohn Marino /* Select a register bank, 0 to 3
40386d7f5d3SJohn Marino  */
40486d7f5d3SJohn Marino #define SMC_SELECT_BANK(x)  { outw( BASE + BANK_SELECT_REG_W, (x) ); }
40586d7f5d3SJohn Marino 
40686d7f5d3SJohn Marino /* Define a small delay for the reset
40786d7f5d3SJohn Marino  */
40886d7f5d3SJohn Marino #define SMC_DELAY() { inw( BASE + RECV_CONTROL_REG_W );\
40986d7f5d3SJohn Marino                       inw( BASE + RECV_CONTROL_REG_W );\
41086d7f5d3SJohn Marino                       inw( BASE + RECV_CONTROL_REG_W );  }
41186d7f5d3SJohn Marino 
41286d7f5d3SJohn Marino /* Define flags
41386d7f5d3SJohn Marino  */
41486d7f5d3SJohn Marino 
41586d7f5d3SJohn Marino #define SN_FLAGS_PCCARD		0x0001	/* PCMCIA (PC-card) */
41686d7f5d3SJohn Marino #define	SN_FLAGS_XJBT10		0x0002	/* Megahertz XJ-BT10 (PCMCIA) */
41786d7f5d3SJohn Marino 
41886d7f5d3SJohn Marino #endif	/* _IF_SNREG_H_ */
419