1*4882a593Smuzhiyun /*------------------------------------------------------------------------ 2*4882a593Smuzhiyun . smc9194.h 3*4882a593Smuzhiyun . Copyright (C) 1996 by Erik Stahlman 4*4882a593Smuzhiyun . 5*4882a593Smuzhiyun . This software may be used and distributed according to the terms 6*4882a593Smuzhiyun . of the GNU General Public License, incorporated herein by reference. 7*4882a593Smuzhiyun . 8*4882a593Smuzhiyun . This file contains register information and access macros for 9*4882a593Smuzhiyun . the SMC91xxx chipset. 10*4882a593Smuzhiyun . 11*4882a593Smuzhiyun . Information contained in this file was obtained from the SMC91C94 12*4882a593Smuzhiyun . manual from SMC. To get a copy, if you really want one, you can find 13*4882a593Smuzhiyun . information under www.smc.com in the components division. 14*4882a593Smuzhiyun . ( this thanks to advice from Donald Becker ). 15*4882a593Smuzhiyun . 16*4882a593Smuzhiyun . Authors 17*4882a593Smuzhiyun . Erik Stahlman ( erik@vt.edu ) 18*4882a593Smuzhiyun . 19*4882a593Smuzhiyun . History 20*4882a593Smuzhiyun . 01/06/96 Erik Stahlman moved definitions here from main .c file 21*4882a593Smuzhiyun . 01/19/96 Erik Stahlman polished this up some, and added better 22*4882a593Smuzhiyun . error handling 23*4882a593Smuzhiyun . 24*4882a593Smuzhiyun ---------------------------------------------------------------------------*/ 25*4882a593Smuzhiyun #ifndef _SMC9194_H_ 26*4882a593Smuzhiyun #define _SMC9194_H_ 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /* I want some simple types */ 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun typedef unsigned char byte; 31*4882a593Smuzhiyun typedef unsigned short word; 32*4882a593Smuzhiyun typedef unsigned long int dword; 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* Because of bank switching, the SMC91xxx uses only 16 I/O ports */ 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun #define SMC_IO_EXTENT 16 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /*--------------------------------------------------------------- 41*4882a593Smuzhiyun . 42*4882a593Smuzhiyun . A description of the SMC registers is probably in order here, 43*4882a593Smuzhiyun . although for details, the SMC datasheet is invaluable. 44*4882a593Smuzhiyun . 45*4882a593Smuzhiyun . Basically, the chip has 4 banks of registers ( 0 to 3 ), which 46*4882a593Smuzhiyun . are accessed by writing a number into the BANK_SELECT register 47*4882a593Smuzhiyun . ( I also use a SMC_SELECT_BANK macro for this ). 48*4882a593Smuzhiyun . 49*4882a593Smuzhiyun . The banks are configured so that for most purposes, bank 2 is all 50*4882a593Smuzhiyun . that is needed for simple run time tasks. 51*4882a593Smuzhiyun -----------------------------------------------------------------------*/ 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* 54*4882a593Smuzhiyun . Bank Select Register: 55*4882a593Smuzhiyun . 56*4882a593Smuzhiyun . yyyy yyyy 0000 00xx 57*4882a593Smuzhiyun . xx = bank number 58*4882a593Smuzhiyun . yyyy yyyy = 0x33, for identification purposes. 59*4882a593Smuzhiyun */ 60*4882a593Smuzhiyun #define BANK_SELECT 14 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun /* BANK 0 */ 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun #define TCR 0 /* transmit control register */ 65*4882a593Smuzhiyun #define TCR_ENABLE 0x0001 /* if this is 1, we can transmit */ 66*4882a593Smuzhiyun #define TCR_FDUPLX 0x0800 /* receive packets sent out */ 67*4882a593Smuzhiyun #define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */ 68*4882a593Smuzhiyun #define TCR_MON_CNS 0x0400 /* monitors the carrier status */ 69*4882a593Smuzhiyun #define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */ 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun #define TCR_CLEAR 0 /* do NOTHING */ 72*4882a593Smuzhiyun /* the normal settings for the TCR register : */ 73*4882a593Smuzhiyun /* QUESTION: do I want to enable padding of short packets ? */ 74*4882a593Smuzhiyun #define TCR_NORMAL TCR_ENABLE 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun #define EPH_STATUS 2 78*4882a593Smuzhiyun #define ES_LINK_OK 0x4000 /* is the link integrity ok ? */ 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun #define RCR 4 81*4882a593Smuzhiyun #define RCR_SOFTRESET 0x8000 /* resets the chip */ 82*4882a593Smuzhiyun #define RCR_STRIP_CRC 0x200 /* strips CRC */ 83*4882a593Smuzhiyun #define RCR_ENABLE 0x100 /* IFF this is set, we can receive packets */ 84*4882a593Smuzhiyun #define RCR_ALMUL 0x4 /* receive all multicast packets */ 85*4882a593Smuzhiyun #define RCR_PROMISC 0x2 /* enable promiscuous mode */ 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun /* the normal settings for the RCR register : */ 88*4882a593Smuzhiyun #define RCR_NORMAL (RCR_STRIP_CRC | RCR_ENABLE) 89*4882a593Smuzhiyun #define RCR_CLEAR 0x0 /* set it to a base state */ 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun #define COUNTER 6 92*4882a593Smuzhiyun #define MIR 8 93*4882a593Smuzhiyun #define MCR 10 94*4882a593Smuzhiyun /* 12 is reserved */ 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /* BANK 1 */ 97*4882a593Smuzhiyun #define CONFIG 0 98*4882a593Smuzhiyun #define CFG_AUI_SELECT 0x100 99*4882a593Smuzhiyun #define BASE 2 100*4882a593Smuzhiyun #define ADDR0 4 101*4882a593Smuzhiyun #define ADDR1 6 102*4882a593Smuzhiyun #define ADDR2 8 103*4882a593Smuzhiyun #define GENERAL 10 104*4882a593Smuzhiyun #define CONTROL 12 105*4882a593Smuzhiyun #define CTL_POWERDOWN 0x2000 106*4882a593Smuzhiyun #define CTL_LE_ENABLE 0x80 107*4882a593Smuzhiyun #define CTL_CR_ENABLE 0x40 108*4882a593Smuzhiyun #define CTL_TE_ENABLE 0x0020 109*4882a593Smuzhiyun #define CTL_AUTO_RELEASE 0x0800 110*4882a593Smuzhiyun #define CTL_EPROM_ACCESS 0x0003 /* high if Eprom is being read */ 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* BANK 2 */ 113*4882a593Smuzhiyun #define MMU_CMD 0 114*4882a593Smuzhiyun #define MC_BUSY 1 /* only readable bit in the register */ 115*4882a593Smuzhiyun #define MC_NOP 0 116*4882a593Smuzhiyun #define MC_ALLOC 0x20 /* or with number of 256 byte packets */ 117*4882a593Smuzhiyun #define MC_RESET 0x40 118*4882a593Smuzhiyun #define MC_REMOVE 0x60 /* remove the current rx packet */ 119*4882a593Smuzhiyun #define MC_RELEASE 0x80 /* remove and release the current rx packet */ 120*4882a593Smuzhiyun #define MC_FREEPKT 0xA0 /* Release packet in PNR register */ 121*4882a593Smuzhiyun #define MC_ENQUEUE 0xC0 /* Enqueue the packet for transmit */ 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun #define PNR_ARR 2 124*4882a593Smuzhiyun #define FIFO_PORTS 4 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun #define FP_RXEMPTY 0x8000 127*4882a593Smuzhiyun #define FP_TXEMPTY 0x80 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun #define POINTER 6 130*4882a593Smuzhiyun #define PTR_READ 0x2000 131*4882a593Smuzhiyun #define PTR_RCV 0x8000 132*4882a593Smuzhiyun #define PTR_AUTOINC 0x4000 133*4882a593Smuzhiyun #define PTR_AUTO_INC 0x0040 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun #define DATA_1 8 136*4882a593Smuzhiyun #define DATA_2 10 137*4882a593Smuzhiyun #define INTERRUPT 12 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun #define INT_MASK 13 140*4882a593Smuzhiyun #define IM_RCV_INT 0x1 141*4882a593Smuzhiyun #define IM_TX_INT 0x2 142*4882a593Smuzhiyun #define IM_TX_EMPTY_INT 0x4 143*4882a593Smuzhiyun #define IM_ALLOC_INT 0x8 144*4882a593Smuzhiyun #define IM_RX_OVRN_INT 0x10 145*4882a593Smuzhiyun #define IM_EPH_INT 0x20 146*4882a593Smuzhiyun #define IM_ERCV_INT 0x40 /* not on SMC9192 */ 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun /* BANK 3 */ 149*4882a593Smuzhiyun #define MULTICAST1 0 150*4882a593Smuzhiyun #define MULTICAST2 2 151*4882a593Smuzhiyun #define MULTICAST3 4 152*4882a593Smuzhiyun #define MULTICAST4 6 153*4882a593Smuzhiyun #define MGMT 8 154*4882a593Smuzhiyun #define REVISION 10 /* ( hi: chip id low: rev # ) */ 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun /* this is NOT on SMC9192 */ 158*4882a593Smuzhiyun #define ERCV 12 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun #define CHIP_9190 3 161*4882a593Smuzhiyun #define CHIP_9194 4 162*4882a593Smuzhiyun #define CHIP_9195 5 163*4882a593Smuzhiyun #define CHIP_91100 7 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun static const char * chip_ids[ 15 ] = { 166*4882a593Smuzhiyun NULL, NULL, NULL, 167*4882a593Smuzhiyun /* 3 */ "SMC91C90/91C92", 168*4882a593Smuzhiyun /* 4 */ "SMC91C94", 169*4882a593Smuzhiyun /* 5 */ "SMC91C95", 170*4882a593Smuzhiyun NULL, 171*4882a593Smuzhiyun /* 7 */ "SMC91C100", 172*4882a593Smuzhiyun /* 8 */ "SMC91C100FD", 173*4882a593Smuzhiyun NULL, NULL, NULL, 174*4882a593Smuzhiyun NULL, NULL, NULL}; 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun /* 177*4882a593Smuzhiyun . Transmit status bits 178*4882a593Smuzhiyun */ 179*4882a593Smuzhiyun #define TS_SUCCESS 0x0001 180*4882a593Smuzhiyun #define TS_LOSTCAR 0x0400 181*4882a593Smuzhiyun #define TS_LATCOL 0x0200 182*4882a593Smuzhiyun #define TS_16COL 0x0010 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun /* 185*4882a593Smuzhiyun . Receive status bits 186*4882a593Smuzhiyun */ 187*4882a593Smuzhiyun #define RS_ALGNERR 0x8000 188*4882a593Smuzhiyun #define RS_BADCRC 0x2000 189*4882a593Smuzhiyun #define RS_ODDFRAME 0x1000 190*4882a593Smuzhiyun #define RS_TOOLONG 0x0800 191*4882a593Smuzhiyun #define RS_TOOSHORT 0x0400 192*4882a593Smuzhiyun #define RS_MULTICAST 0x0001 193*4882a593Smuzhiyun #define RS_ERRORS (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT) 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun static const char * interfaces[ 2 ] = { "TP", "AUI" }; 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun /*------------------------------------------------------------------------- 198*4882a593Smuzhiyun . I define some macros to make it easier to do somewhat common 199*4882a593Smuzhiyun . or slightly complicated, repeated tasks. 200*4882a593Smuzhiyun --------------------------------------------------------------------------*/ 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun /* select a register bank, 0 to 3 */ 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun #define SMC_SELECT_BANK(x) { outw( x, ioaddr + BANK_SELECT ); } 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun /* define a small delay for the reset */ 207*4882a593Smuzhiyun #define SMC_DELAY() { inw( ioaddr + RCR );\ 208*4882a593Smuzhiyun inw( ioaddr + RCR );\ 209*4882a593Smuzhiyun inw( ioaddr + RCR ); } 210*4882a593Smuzhiyun 211*4882a593Smuzhiyun /* this enables an interrupt in the interrupt mask register */ 212*4882a593Smuzhiyun #define SMC_ENABLE_INT(x) {\ 213*4882a593Smuzhiyun unsigned char mask;\ 214*4882a593Smuzhiyun SMC_SELECT_BANK(2);\ 215*4882a593Smuzhiyun mask = inb( ioaddr + INT_MASK );\ 216*4882a593Smuzhiyun mask |= (x);\ 217*4882a593Smuzhiyun outb( mask, ioaddr + INT_MASK ); \ 218*4882a593Smuzhiyun } 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun /* this disables an interrupt from the interrupt mask register */ 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun #define SMC_DISABLE_INT(x) {\ 223*4882a593Smuzhiyun unsigned char mask;\ 224*4882a593Smuzhiyun SMC_SELECT_BANK(2);\ 225*4882a593Smuzhiyun mask = inb( ioaddr + INT_MASK );\ 226*4882a593Smuzhiyun mask &= ~(x);\ 227*4882a593Smuzhiyun outb( mask, ioaddr + INT_MASK ); \ 228*4882a593Smuzhiyun } 229*4882a593Smuzhiyun 230*4882a593Smuzhiyun /*---------------------------------------------------------------------- 231*4882a593Smuzhiyun . Define the interrupts that I want to receive from the card 232*4882a593Smuzhiyun . 233*4882a593Smuzhiyun . I want: 234*4882a593Smuzhiyun . IM_EPH_INT, for nasty errors 235*4882a593Smuzhiyun . IM_RCV_INT, for happy received packets 236*4882a593Smuzhiyun . IM_RX_OVRN_INT, because I have to kick the receiver 237*4882a593Smuzhiyun --------------------------------------------------------------------------*/ 238*4882a593Smuzhiyun #define SMC_INTERRUPT_MASK (IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT) 239*4882a593Smuzhiyun 240*4882a593Smuzhiyun #endif /* _SMC_9194_H_ */ 241*4882a593Smuzhiyun 242