1433d6423SLionel Sambuc /* 2433d6423SLionel Sambuc ibm/rtl8139.h 3433d6423SLionel Sambuc 4433d6423SLionel Sambuc Created: Aug 2003 by Philip Homburg <philip@cs.vu.nl> 5433d6423SLionel Sambuc */ 6433d6423SLionel Sambuc 7433d6423SLionel Sambuc #include <minix/drivers.h> 8433d6423SLionel Sambuc #include <minix/netdriver.h> 9433d6423SLionel Sambuc #include <machine/pci.h> 10*4081bff6SDavid van Moolenbroek #include <minix/ds.h> 11433d6423SLionel Sambuc #include <assert.h> 12433d6423SLionel Sambuc 13433d6423SLionel Sambuc #define RL_IDR 0x00 /* Ethernet address 14433d6423SLionel Sambuc * Note: RL_9346CR_EEM_CONFIG mode is 15433d6423SLionel Sambuc * required the change the ethernet 16433d6423SLionel Sambuc * address. 17433d6423SLionel Sambuc * Note: 4-byte write access only. 18433d6423SLionel Sambuc */ 19433d6423SLionel Sambuc #define RL_N_TX 4 /* Number of transmit buffers */ 20433d6423SLionel Sambuc #define RL_TSD0 0x010 /* Transmit Status of Descriptor 0 */ 21433d6423SLionel Sambuc #define RL_TSD_CRS 0x80000000 /* Carrier Sense Lost */ 22433d6423SLionel Sambuc #define RL_TSD_TABT 0x40000000 /* Transmit Abort */ 23433d6423SLionel Sambuc #define RL_TSD_OWC 0x20000000 /* Out of Window Collision */ 24433d6423SLionel Sambuc #define RL_TSD_CDH 0x10000000 /* CD Heart Beat */ 25433d6423SLionel Sambuc #define RL_TSD_NCC_M 0x0F000000 /* Number of Collision Count */ 26433d6423SLionel Sambuc #define RL_TSD_RES 0x00C00000 /* Reserved */ 27433d6423SLionel Sambuc #define RL_TSD_ERTXTH_M 0x003F0000 /* Early Tx Threshold */ 28433d6423SLionel Sambuc #define RL_TSD_ERTXTH_S 16 /* shift */ 29433d6423SLionel Sambuc #define RL_TSD_ERTXTH_8 0x00000000 /* 8 bytes */ 30433d6423SLionel Sambuc #define RL_TSD_TOK 0x00008000 /* Transmit OK */ 31433d6423SLionel Sambuc #define RL_TSD_TUN 0x00004000 /* Transmit FIFO Underrun */ 32433d6423SLionel Sambuc #define RL_TSD_OWN 0x00002000 /* Controller (does not) Own Buf. */ 33433d6423SLionel Sambuc #define RL_TSD_SIZE 0x00001FFF /* Descriptor Size */ 34433d6423SLionel Sambuc #define RL_TSAD0 0x20 /* Transmit Start Address of Descriptor 0 */ 35433d6423SLionel Sambuc #define RL_RBSTART 0x30 /* Receive Buffer Start Address */ 36433d6423SLionel Sambuc #define RL_CR 0x37 /* Command Register */ 37433d6423SLionel Sambuc #define RL_CR_RES0 0xE0 /* Reserved */ 38433d6423SLionel Sambuc #define RL_CR_RST 0x10 /* Reset */ 39433d6423SLionel Sambuc #define RL_CR_RE 0x08 /* Receiver Enable */ 40433d6423SLionel Sambuc #define RL_CR_TE 0x04 /* Transmitter Enable * 41433d6423SLionel Sambuc * Note: start with transmit buffer 42433d6423SLionel Sambuc * 0 after RL_CR_TE has been reset. 43433d6423SLionel Sambuc */ 44433d6423SLionel Sambuc #define RL_CR_RES1 0x02 /* Reserved */ 45433d6423SLionel Sambuc #define RL_CR_BUFE 0x01 /* Receive Buffer Empty */ 46433d6423SLionel Sambuc #define RL_CAPR 0x38 /* Current Address of Packet Read */ 47433d6423SLionel Sambuc #define RL_CAPR_DATA_OFF 0x10 /* Packet Starts at Offset */ 48433d6423SLionel Sambuc #define RL_CBR 0x3A /* Current Buffer Address */ 49433d6423SLionel Sambuc #define RL_IMR 0x3C /* Interrupt Mask Register */ 50433d6423SLionel Sambuc #define RL_IMR_SERR 0x8000 /* System Error */ 51433d6423SLionel Sambuc #define RL_IMR_TIMEOUT 0x4000 /* Time Out */ 52433d6423SLionel Sambuc #define RL_IMR_LENCHG 0x2000 /* Cable Length Change */ 53433d6423SLionel Sambuc #define RL_IMR_RES 0x1F80 /* Reserved */ 54433d6423SLionel Sambuc #define RL_IMR_FOVW 0x0040 /* Rx FIFO Overflow */ 55433d6423SLionel Sambuc #define RL_IMR_PUN 0x0020 /* Packet Underrun / Link Change */ 56433d6423SLionel Sambuc #define RL_IMR_RXOVW 0x0010 /* Rx Buffer Overflow */ 57433d6423SLionel Sambuc #define RL_IMR_TER 0x0008 /* Transmit Error */ 58433d6423SLionel Sambuc #define RL_IMR_TOK 0x0004 /* Transmit OK */ 59433d6423SLionel Sambuc #define RL_IMR_RER 0x0002 /* Receive Error */ 60433d6423SLionel Sambuc #define RL_IMR_ROK 0x0001 /* Receive OK */ 61433d6423SLionel Sambuc #define RL_ISR 0x3E /* Interrupt Status Register */ 62433d6423SLionel Sambuc #define RL_ISR_SERR 0x8000 /* System Error */ 63433d6423SLionel Sambuc #define RL_ISR_TIMEOUT 0x4000 /* Time Out */ 64433d6423SLionel Sambuc #define RL_ISR_LENCHG 0x2000 /* Cable Length Change */ 65433d6423SLionel Sambuc #define RL_ISR_RES 0x1F80 /* Reserved */ 66433d6423SLionel Sambuc #define RL_ISR_FOVW 0x0040 /* Rx FIFO Overflow */ 67433d6423SLionel Sambuc #define RL_ISR_PUN 0x0020 /* Packet Underrun / Link Change */ 68433d6423SLionel Sambuc #define RL_ISR_RXOVW 0x0010 /* Rx Buffer Overflow */ 69433d6423SLionel Sambuc #define RL_ISR_TER 0x0008 /* Transmit Error */ 70433d6423SLionel Sambuc #define RL_ISR_TOK 0x0004 /* Transmit OK */ 71433d6423SLionel Sambuc #define RL_ISR_RER 0x0002 /* Receive Error */ 72433d6423SLionel Sambuc #define RL_ISR_ROK 0x0001 /* Receive OK */ 73433d6423SLionel Sambuc #define RL_TCR 0x40 /* Transmit Configuration Register 74433d6423SLionel Sambuc * Note: RL_CR_TE has to be set to 75433d6423SLionel Sambuc * set/change RL_TCR. 76433d6423SLionel Sambuc */ 77433d6423SLionel Sambuc #define RL_TCR_RES0 0x80000000 /* Reserved */ 78433d6423SLionel Sambuc #define RL_TCR_HWVER_AM 0x7C000000 /* Hardware Version ID A */ 79433d6423SLionel Sambuc #define RL_TCR_IFG_M 0x03000000 /* Interframe Gap Time */ 80433d6423SLionel Sambuc #define RL_TCR_IFG_STD 0x03000000 /* IEEE 802.3 std */ 81433d6423SLionel Sambuc #if 0 82433d6423SLionel Sambuc #undef RL_TCR_IFG_STD 83433d6423SLionel Sambuc #define RL_TCR_IFG_STD 0x00000000 84433d6423SLionel Sambuc #endif 85433d6423SLionel Sambuc #define RL_TCR_HWVER_BM 0x00C00000 /* Hardware Version ID B */ 86433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139 0x60000000 /* RTL8139 */ 87433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139A 0x70000000 /* RTL8139A */ 88433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139AG 0x74000000 /* RTL8139A-G */ 89433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139B 0x78000000 /* RTL8139B */ 90433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8130 0x78000000 /* RTL8130 (dup) */ 91433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139C 0x74000000 /* RTL8139C (dup) */ 92433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8100 0x78800000 /* RTL8100 */ 93433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8100B 0x74400000 /* RTL8100B / 94433d6423SLionel Sambuc RTL8139D */ 95433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8139CP 0x74800000 /* RTL8139C+ */ 96433d6423SLionel Sambuc #define RL_TCR_HWVER_RTL8101 0x74C00000 /* RTL8101 */ 97433d6423SLionel Sambuc #define RL_TCR_RES1 0x00380000 /* Reserved */ 98433d6423SLionel Sambuc #define RL_TCR_LBK_M 0x00060000 /* Loopback Test */ 99433d6423SLionel Sambuc #define RL_TCR_LBK_NORMAL 0x00000000 /* Normal */ 100433d6423SLionel Sambuc #define RL_TCR_LBK_LOOKBOCK 0x00060000 /* Loopback Mode */ 101433d6423SLionel Sambuc #define RL_TCR_CRC 0x00010000 /* (Do not) Append CRC */ 102433d6423SLionel Sambuc #define RL_TCR_RES2 0x0000F800 /* Reserved */ 103433d6423SLionel Sambuc #define RL_TCR_MXDMA_M 0x00000700 /* Max DMA Burst Size Tx */ 104433d6423SLionel Sambuc #define RL_TCR_MXDMA_16 0x00000000 /* 16 bytes */ 105433d6423SLionel Sambuc #define RL_TCR_MXDMA_32 0x00000100 /* 32 bytes */ 106433d6423SLionel Sambuc #define RL_TCR_MXDMA_64 0x00000200 /* 64 bytes */ 107433d6423SLionel Sambuc #define RL_TCR_MXDMA_128 0x00000300 /* 128 bytes */ 108433d6423SLionel Sambuc #define RL_TCR_MXDMA_128 0x00000300 /* 128 bytes */ 109433d6423SLionel Sambuc #define RL_TCR_MXDMA_256 0x00000400 /* 256 bytes */ 110433d6423SLionel Sambuc #define RL_TCR_MXDMA_512 0x00000500 /* 512 bytes */ 111433d6423SLionel Sambuc #define RL_TCR_MXDMA_1024 0x00000600 /* 1024 bytes */ 112433d6423SLionel Sambuc #define RL_TCR_MXDMA_2048 0x00000700 /* 2048 bytes */ 113433d6423SLionel Sambuc #define RL_TCR_TXRR_M 0x000000F0 /* Tx Retry Count */ 114433d6423SLionel Sambuc #define RL_TCR_RES3 0x0000000E /* Reserved */ 115433d6423SLionel Sambuc #define RL_TCR_CLRABT 0x00000001 /* Clear Abort */ 116433d6423SLionel Sambuc #define RL_RCR 0x44 /* Receive Configuration Register 117433d6423SLionel Sambuc * Note: RL_CR_RE has to be set to 118433d6423SLionel Sambuc * set/change RL_RCR. 119433d6423SLionel Sambuc */ 120433d6423SLionel Sambuc #define RL_RCR_RES0 0xF0000000 /* Reserved */ 121433d6423SLionel Sambuc #define RL_RCR_ERTH_M 0x0F000000 /* Early Rx Threshold */ 122433d6423SLionel Sambuc #define RL_RCR_ERTH_0 0x00000000 /* No threshold */ 123433d6423SLionel Sambuc #define RL_RCR_ERTH_1 0x01000000 /* 1/16 */ 124433d6423SLionel Sambuc #define RL_RCR_ERTH_2 0x02000000 /* 2/16 */ 125433d6423SLionel Sambuc #define RL_RCR_ERTH_3 0x03000000 /* 3/16 */ 126433d6423SLionel Sambuc #define RL_RCR_ERTH_4 0x04000000 /* 4/16 */ 127433d6423SLionel Sambuc #define RL_RCR_ERTH_5 0x05000000 /* 5/16 */ 128433d6423SLionel Sambuc #define RL_RCR_ERTH_6 0x06000000 /* 6/16 */ 129433d6423SLionel Sambuc #define RL_RCR_ERTH_7 0x07000000 /* 7/16 */ 130433d6423SLionel Sambuc #define RL_RCR_ERTH_8 0x08000000 /* 8/16 */ 131433d6423SLionel Sambuc #define RL_RCR_ERTH_9 0x09000000 /* 9/16 */ 132433d6423SLionel Sambuc #define RL_RCR_ERTH_10 0x0A000000 /* 10/16 */ 133433d6423SLionel Sambuc #define RL_RCR_ERTH_11 0x0B000000 /* 11/16 */ 134433d6423SLionel Sambuc #define RL_RCR_ERTH_12 0x0C000000 /* 12/16 */ 135433d6423SLionel Sambuc #define RL_RCR_ERTH_13 0x0D000000 /* 13/16 */ 136433d6423SLionel Sambuc #define RL_RCR_ERTH_14 0x0E000000 /* 14/16 */ 137433d6423SLionel Sambuc #define RL_RCR_ERTH_15 0x0F000000 /* 15/16 */ 138433d6423SLionel Sambuc #define RL_RCR_RES1 0x00FC0000 /* Reserved */ 139433d6423SLionel Sambuc #define RL_RCR_MULERINT 0x00020000 /* Multiple Early Int Select */ 140433d6423SLionel Sambuc #define RL_RCR_RER8 0x00010000 /* Receive small error packet */ 141433d6423SLionel Sambuc #define RL_RCR_RXFTH_M 0x0000E000 /* Rx FIFO Threshold */ 142433d6423SLionel Sambuc #define RL_RCR_RXFTH_16 0x00000000 /* 16 bytes */ 143433d6423SLionel Sambuc #define RL_RCR_RXFTH_32 0x00002000 /* 32 bytes */ 144433d6423SLionel Sambuc #define RL_RCR_RXFTH_64 0x00004000 /* 64 bytes */ 145433d6423SLionel Sambuc #define RL_RCR_RXFTH_128 0x00006000 /* 128 bytes */ 146433d6423SLionel Sambuc #define RL_RCR_RXFTH_256 0x00008000 /* 256 bytes */ 147433d6423SLionel Sambuc #define RL_RCR_RXFTH_512 0x0000A000 /* 512 bytes */ 148433d6423SLionel Sambuc #define RL_RCR_RXFTH_1024 0x0000C000 /* 1024 bytes */ 149433d6423SLionel Sambuc #define RL_RCR_RXFTH_UNLIM 0x0000E000 /* unlimited */ 150433d6423SLionel Sambuc #define RL_RCR_RBLEM_M 0x00001800 /* Rx Buffer Length */ 151433d6423SLionel Sambuc #define RL_RCR_RBLEN_8K 0x00000000 /* 8KB + 16 bytes */ 152433d6423SLionel Sambuc #define RL_RCR_RBLEN_8K_SIZE (8*1024) 153433d6423SLionel Sambuc #define RL_RCR_RBLEN_16K 0x00000800 /* 16KB + 16 bytes */ 154433d6423SLionel Sambuc #define RL_RCR_RBLEN_16K_SIZE (16*1024) 155433d6423SLionel Sambuc #define RL_RCR_RBLEN_32K 0x00001000 /* 32KB + 16 bytes */ 156433d6423SLionel Sambuc #define RL_RCR_RBLEN_32K_SIZE (32*1024) 157433d6423SLionel Sambuc #define RL_RCR_RBLEN_64K 0x00001800 /* 64KB + 16 bytes */ 158433d6423SLionel Sambuc #define RL_RCR_RBLEN_64K_SIZE (64*1024) 159433d6423SLionel Sambuc /* Note: the documentation for the RTL8139C(L) or 160433d6423SLionel Sambuc * for the RTL8139D(L) claims that the buffer should 161433d6423SLionel Sambuc * be 16 bytes larger. Multiples of 8KB are the 162433d6423SLionel Sambuc * correct values. 163433d6423SLionel Sambuc */ 164433d6423SLionel Sambuc #define RL_RCR_MXDMA_M 0x00000700 /* Rx DMA burst size */ 165433d6423SLionel Sambuc #define RL_RCR_MXDMA_16 0x00000000 /* 16 bytes */ 166433d6423SLionel Sambuc #define RL_RCR_MXDMA_32 0x00000100 /* 32 bytes */ 167433d6423SLionel Sambuc #define RL_RCR_MXDMA_64 0x00000200 /* 64 bytes */ 168433d6423SLionel Sambuc #define RL_RCR_MXDMA_128 0x00000300 /* 128 bytes */ 169433d6423SLionel Sambuc #define RL_RCR_MXDMA_256 0x00000400 /* 256 bytes */ 170433d6423SLionel Sambuc #define RL_RCR_MXDMA_512 0x00000500 /* 512 bytes */ 171433d6423SLionel Sambuc #define RL_RCR_MXDMA_1024 0x00000600 /* 1024 bytes */ 172433d6423SLionel Sambuc #define RL_RCR_MXDMA_UNLIM 0x00000700 /* unlimited */ 173433d6423SLionel Sambuc #define RL_RCR_WRAP 0x00000080 /* (Do not) Wrap on receive */ 174433d6423SLionel Sambuc #define RL_RCR_RES2 0x00000040 /* EEPROM type? */ 175433d6423SLionel Sambuc #define RL_RCR_AER 0x00000020 /* Accept Error Packets */ 176433d6423SLionel Sambuc #define RL_RCR_AR 0x00000010 /* Accept Runt Packets */ 177433d6423SLionel Sambuc #define RL_RCR_AB 0x00000008 /* Accept Broadcast Packets */ 178433d6423SLionel Sambuc #define RL_RCR_AM 0x00000004 /* Accept Multicast Packets */ 179433d6423SLionel Sambuc #define RL_RCR_APM 0x00000002 /* Accept Physical Match Packets */ 180433d6423SLionel Sambuc #define RL_RCR_AAP 0x00000001 /* Accept All Packets */ 181433d6423SLionel Sambuc #define RL_MPC 0x4c /* Missed Packet Counter */ 182433d6423SLionel Sambuc #define RL_9346CR 0x50 /* 93C46 Command Register */ 183433d6423SLionel Sambuc #define RL_9346CR_EEM_M 0xC0 /* Operating Mode */ 184433d6423SLionel Sambuc #define RL_9346CR_EEM_NORMAL 0x00 /* Normal Mode */ 185433d6423SLionel Sambuc #define RL_9346CR_EEM_AUTOLOAD 0x40 /* Load from 93C46 */ 186433d6423SLionel Sambuc #define RL_9346CR_EEM_PROG 0x80 /* 93C46 Programming */ 187433d6423SLionel Sambuc #define RL_9346CR_EEM_CONFIG 0xC0 /* Config Write Enable */ 188433d6423SLionel Sambuc #define RL_9346CR_RES 0x30 /* Reserved */ 189433d6423SLionel Sambuc #define RL_9346CR_EECS 0x08 /* EECS Pin */ 190433d6423SLionel Sambuc #define RL_9346CR_EESK 0x04 /* EESK Pin */ 191433d6423SLionel Sambuc #define RL_9346CR_EEDI 0x02 /* EEDI Pin */ 192433d6423SLionel Sambuc #define RL_9346CR_EEDO 0x01 /* EEDO Pin */ 193433d6423SLionel Sambuc #define RL_CONFIG0 0x51 /* Configuration Register 0 */ 194433d6423SLionel Sambuc #define RL_CONFIG1 0x52 /* Configuration Register 1 */ 195433d6423SLionel Sambuc #define RL_MSR 0x58 /* Media Status Register */ 196433d6423SLionel Sambuc #define RL_MSR_TXFCE 0x80 /* Tx Flow Control Enable */ 197433d6423SLionel Sambuc #define RL_MSR_RXFCE 0x40 /* Rx Flow Control Enable */ 198433d6423SLionel Sambuc #define RL_MSR_RES 0x20 /* Reserved */ 199433d6423SLionel Sambuc #define RL_MSR_AUXSTAT 0x10 /* Aux. Power Present */ 200433d6423SLionel Sambuc #define RL_MSR_SPEED_10 0x08 /* In 10 Mbps mode */ 201433d6423SLionel Sambuc #define RL_MSR_LINKB 0x04 /* link Failed */ 202433d6423SLionel Sambuc #define RL_MSR_TXPF 0x02 /* Sent Pause Packet */ 203433d6423SLionel Sambuc #define RL_MSR_RXPF 0x01 /* Received Pause Packet */ 204433d6423SLionel Sambuc #define RL_CONFIG3 0x59 /* Configuration Register 3 */ 205433d6423SLionel Sambuc #define RL_CONFIG4 0x5A /* Configuration Register 4 */ 206433d6423SLionel Sambuc /* 0x5B */ /* Reserved */ 207433d6423SLionel Sambuc #define RL_REVID 0x5E /* PCI Revision ID */ 208433d6423SLionel Sambuc /* 0x5F */ /* Reserved */ 209433d6423SLionel Sambuc #define RL_TSAD 0x60 /* Transmit Status of All Descriptors */ 210433d6423SLionel Sambuc #define RL_TSAD_TOK3 0x8000 /* TOK bit of Descriptor 3 */ 211433d6423SLionel Sambuc #define RL_TSAD_TOK2 0x4000 /* TOK bit of Descriptor 2 */ 212433d6423SLionel Sambuc #define RL_TSAD_TOK1 0x2000 /* TOK bit of Descriptor 1 */ 213433d6423SLionel Sambuc #define RL_TSAD_TOK0 0x1000 /* TOK bit of Descriptor 0 */ 214433d6423SLionel Sambuc #define RL_TSAD_TUN3 0x0800 /* TUN bit of Descriptor 3 */ 215433d6423SLionel Sambuc #define RL_TSAD_TUN2 0x0400 /* TUN bit of Descriptor 2 */ 216433d6423SLionel Sambuc #define RL_TSAD_TUN1 0x0200 /* TUN bit of Descriptor 1 */ 217433d6423SLionel Sambuc #define RL_TSAD_TUN0 0x0100 /* TUN bit of Descriptor 0 */ 218433d6423SLionel Sambuc #define RL_TSAD_TABT3 0x0080 /* TABT bit of Descriptor 3 */ 219433d6423SLionel Sambuc #define RL_TSAD_TABT2 0x0040 /* TABT bit of Descriptor 2 */ 220433d6423SLionel Sambuc #define RL_TSAD_TABT1 0x0020 /* TABT bit of Descriptor 1 */ 221433d6423SLionel Sambuc #define RL_TSAD_TABT0 0x0010 /* TABT bit of Descriptor 0 */ 222433d6423SLionel Sambuc #define RL_TSAD_OWN3 0x0008 /* OWN bit of Descriptor 3 */ 223433d6423SLionel Sambuc #define RL_TSAD_OWN2 0x0004 /* OWN bit of Descriptor 2 */ 224433d6423SLionel Sambuc #define RL_TSAD_OWN1 0x0002 /* OWN bit of Descriptor 1 */ 225433d6423SLionel Sambuc #define RL_TSAD_OWN0 0x0001 /* OWN bit of Descriptor 0 */ 226433d6423SLionel Sambuc #define RL_BMCR 0x62 /* Basic Mode Control Register (MII_CTRL) */ 227433d6423SLionel Sambuc #define RL_BMSR 0x64 /* Basic Mode Status Register (MII_STATUS) */ 228433d6423SLionel Sambuc #define RL_ANAR 0x66 /* Auto-Neg Advertisement Register (MII_ANA) */ 229433d6423SLionel Sambuc #define RL_ANLPAR 0x68 /* Auto-Neg Link Partner Register (MII_ANLPA) */ 230433d6423SLionel Sambuc #define RL_ANER 0x6a /* Auto-Neg Expansion Register (MII_ANE) */ 231433d6423SLionel Sambuc #define RL_NWAYTR 0x70 /* N-way Test Register */ 232433d6423SLionel Sambuc #define RL_CSCR 0x74 /* CS Configuration Register */ 233433d6423SLionel Sambuc #define RL_CONFIG5 0xD8 /* Configuration Register 5 */ 234433d6423SLionel Sambuc 235433d6423SLionel Sambuc /* Status word in receive buffer */ 236433d6423SLionel Sambuc #define RL_RXS_LEN_M 0xFFFF0000 /* Length Field, Excl. Status word */ 237433d6423SLionel Sambuc #define RL_RXS_LEN_S 16 /* Shift For Length */ 238433d6423SLionel Sambuc #define RL_RXS_MAR 0x00008000 /* Multicast Address Received */ 239433d6423SLionel Sambuc #define RL_RXS_PAR 0x00004000 /* Physical Address Matched */ 240433d6423SLionel Sambuc #define RL_RXS_BAR 0x00002000 /* Broadcast Address Received */ 241433d6423SLionel Sambuc #define RL_RXS_RES_M 0x00001FC0 /* Reserved */ 242433d6423SLionel Sambuc #define RL_RXS_ISE 0x00000020 /* Invalid Symbol Error */ 243433d6423SLionel Sambuc #define RL_RXS_RUNT 0x00000010 /* Runt Packet Received */ 244433d6423SLionel Sambuc #define RL_RXS_LONG 0x00000008 /* Long (>4KB) Packet */ 245433d6423SLionel Sambuc #define RL_RXS_CRC 0x00000004 /* CRC Error */ 246433d6423SLionel Sambuc #define RL_RXS_FAE 0x00000002 /* Frame Alignment Error */ 247433d6423SLionel Sambuc #define RL_RXS_ROK 0x00000001 /* Receive OK */ 248433d6423SLionel Sambuc 249433d6423SLionel Sambuc /* Registers in the Machine Independent Interface (MII) to the PHY. 250433d6423SLionel Sambuc * IEEE 802.3 (2000 Edition) Clause 22. 251433d6423SLionel Sambuc */ 252433d6423SLionel Sambuc #define MII_CTRL 0x0 /* Control Register (basic) */ 253433d6423SLionel Sambuc #define MII_CTRL_RST 0x8000 /* Reset PHY */ 254433d6423SLionel Sambuc #define MII_CTRL_LB 0x4000 /* Enable Loopback Mode */ 255433d6423SLionel Sambuc #define MII_CTRL_SP_LSB 0x2000 /* Speed Selection (LSB) */ 256433d6423SLionel Sambuc #define MII_CTRL_ANE 0x1000 /* Auto Negotiation Enable */ 257433d6423SLionel Sambuc #define MII_CTRL_PD 0x0800 /* Power Down */ 258433d6423SLionel Sambuc #define MII_CTRL_ISO 0x0400 /* Isolate */ 259433d6423SLionel Sambuc #define MII_CTRL_RAN 0x0200 /* Restart Auto-Negotiation Process */ 260433d6423SLionel Sambuc #define MII_CTRL_DM 0x0100 /* Full Duplex */ 261433d6423SLionel Sambuc #define MII_CTRL_CT 0x0080 /* Enable COL Signal Test */ 262433d6423SLionel Sambuc #define MII_CTRL_SP_MSB 0x0040 /* Speed Selection (MSB) */ 263433d6423SLionel Sambuc #define MII_CTRL_SP_10 0x0000 /* 10 Mb/s */ 264433d6423SLionel Sambuc #define MII_CTRL_SP_100 0x2000 /* 100 Mb/s */ 265433d6423SLionel Sambuc #define MII_CTRL_SP_1000 0x0040 /* 1000 Mb/s */ 266433d6423SLionel Sambuc #define MII_CTRL_SP_RES 0x2040 /* Reserved */ 267433d6423SLionel Sambuc #define MII_CTRL_RES 0x003F /* Reserved */ 268433d6423SLionel Sambuc #define MII_STATUS 0x1 /* Status Register (basic) */ 269433d6423SLionel Sambuc #define MII_STATUS_100T4 0x8000 /* 100Base-T4 support */ 270433d6423SLionel Sambuc #define MII_STATUS_100XFD 0x4000 /* 100Base-X FD support */ 271433d6423SLionel Sambuc #define MII_STATUS_100XHD 0x2000 /* 100Base-X HD support */ 272433d6423SLionel Sambuc #define MII_STATUS_10FD 0x1000 /* 10 Mb/s FD support */ 273433d6423SLionel Sambuc #define MII_STATUS_10HD 0x0800 /* 10 Mb/s HD support */ 274433d6423SLionel Sambuc #define MII_STATUS_100T2FD 0x0400 /* 100Base-T2 FD support */ 275433d6423SLionel Sambuc #define MII_STATUS_100T2HD 0x0200 /* 100Base-T2 HD support */ 276433d6423SLionel Sambuc #define MII_STATUS_EXT_STAT 0x0100 /* Supports MII_EXT_STATUS */ 277433d6423SLionel Sambuc #define MII_STATUS_RES 0x0080 /* Reserved */ 278433d6423SLionel Sambuc #define MII_STATUS_MFPS 0x0040 /* MF Preamble Suppression */ 279433d6423SLionel Sambuc #define MII_STATUS_ANC 0x0020 /* Auto-Negotiation Completed */ 280433d6423SLionel Sambuc #define MII_STATUS_RF 0x0010 /* Remote Fault Detected */ 281433d6423SLionel Sambuc #define MII_STATUS_ANA 0x0008 /* Auto-Negotiation Ability */ 282433d6423SLionel Sambuc #define MII_STATUS_LS 0x0004 /* Link Up */ 283433d6423SLionel Sambuc #define MII_STATUS_JD 0x0002 /* Jabber Condition Detected */ 284433d6423SLionel Sambuc #define MII_STATUS_EC 0x0001 /* Ext Register Capabilities */ 285433d6423SLionel Sambuc #define MII_PHYID_H 0x2 /* PHY ID (high) */ 286433d6423SLionel Sambuc #define MII_PHYID_L 0x3 /* PHY ID (low) */ 287433d6423SLionel Sambuc #define MII_ANA 0x4 /* Auto-Negotiation Advertisement */ 288433d6423SLionel Sambuc #define MII_ANA_NP 0x8000 /* Next PAge */ 289433d6423SLionel Sambuc #define MII_ANA_RES 0x4000 /* Reserved */ 290433d6423SLionel Sambuc #define MII_ANA_RF 0x2000 /* Remote Fault */ 291433d6423SLionel Sambuc #define MII_ANA_TAF_M 0x1FE0 /* Technology Ability Field */ 292433d6423SLionel Sambuc #define MII_ANA_TAF_S 5 /* Shift */ 293433d6423SLionel Sambuc #define MII_ANA_TAF_RES 0x1000 /* Reserved */ 294433d6423SLionel Sambuc #define MII_ANA_PAUSE_ASYM 0x0800 /* Asym. Pause */ 295433d6423SLionel Sambuc #define MII_ANA_PAUSE_SYM 0x0400 /* Sym. Pause */ 296433d6423SLionel Sambuc #define MII_ANA_100T4 0x0200 /* 100Base-T4 */ 297433d6423SLionel Sambuc #define MII_ANA_100TXFD 0x0100 /* 100Base-TX FD */ 298433d6423SLionel Sambuc #define MII_ANA_100TXHD 0x0080 /* 100Base-TX HD */ 299433d6423SLionel Sambuc #define MII_ANA_10TFD 0x0040 /* 10Base-T FD */ 300433d6423SLionel Sambuc #define MII_ANA_10THD 0x0020 /* 10Base-T HD */ 301433d6423SLionel Sambuc #define MII_ANA_SEL_M 0x001F /* Selector Field */ 302433d6423SLionel Sambuc #define MII_ANA_SEL_802_3 0x0001 /* 802.3 */ 303433d6423SLionel Sambuc #define MII_ANLPA 0x5 /* Auto-Neg Link Partner Ability Register */ 304433d6423SLionel Sambuc #define MII_ANLPA_NP 0x8000 /* Next Page */ 305433d6423SLionel Sambuc #define MII_ANLPA_ACK 0x4000 /* Acknowledge */ 306433d6423SLionel Sambuc #define MII_ANLPA_RF 0x2000 /* Remote Fault */ 307433d6423SLionel Sambuc #define MII_ANLPA_TAF_M 0x1FC0 /* Technology Ability Field */ 308433d6423SLionel Sambuc #define MII_ANLPA_SEL_M 0x001F /* Selector Field */ 309433d6423SLionel Sambuc #define MII_ANE 0x6 /* Auto-Negotiation Expansion */ 310433d6423SLionel Sambuc #define MII_ANE_RES 0xFFE0 /* Reserved */ 311433d6423SLionel Sambuc #define MII_ANE_PDF 0x0010 /* Parallel Detection Fault */ 312433d6423SLionel Sambuc #define MII_ANE_LPNPA 0x0008 /* Link Partner is Next Page Able */ 313433d6423SLionel Sambuc #define MII_ANE_NPA 0x0002 /* Local Device is Next Page Able */ 314433d6423SLionel Sambuc #define MII_ANE_PR 0x0002 /* New Page has been received */ 315433d6423SLionel Sambuc #define MII_ANE_LPANA 0x0001 /* Link Partner is Auto-Neg.able */ 316433d6423SLionel Sambuc #define MII_ANNPT 0x7 /* Auto-Negotiation Next Page Transmit */ 317433d6423SLionel Sambuc #define MII_ANLPRNP 0x8 /* Auto-Neg Link Partner Received Next Page */ 318433d6423SLionel Sambuc #define MII_MS_CTRL 0x9 /* MASTER-SLAVE Control Register */ 319433d6423SLionel Sambuc #define MII_MS_STATUS 0xA /* MASTER-SLAVE Status Register */ 320433d6423SLionel Sambuc /* 0xB ... 0xE */ /* Reserved */ 321433d6423SLionel Sambuc #define MII_EXT_STATUS 0xF /* Extended Status */ 322433d6423SLionel Sambuc #define MII_ESTAT_1000XFD 0x8000 /* 1000Base-X Full Duplex */ 323433d6423SLionel Sambuc #define MII_ESTAT_1000XHD 0x4000 /* 1000Base-X Half Duplex */ 324433d6423SLionel Sambuc #define MII_ESTAT_1000TFD 0x2000 /* 1000Base-T Full Duplex */ 325433d6423SLionel Sambuc #define MII_ESTAT_1000THD 0x1000 /* 1000Base-T Half Duplex */ 326433d6423SLionel Sambuc #define MII_ESTAT_RES 0x0FFF /* Reserved */ 327433d6423SLionel Sambuc /* 0x10 ... 0x1F */ /* Vendor Specific */ 328433d6423SLionel Sambuc 329433d6423SLionel Sambuc #if 0 330433d6423SLionel Sambuc 34-35 R ERBCR Early Receive (Rx) Byte Count Register 331433d6423SLionel Sambuc 36 R ERSR Early Rx Status Register 332433d6423SLionel Sambuc 7-4 reserved 333433d6423SLionel Sambuc 3 R ERGood Early Rx Good packet 334433d6423SLionel Sambuc 2 R ERBad Early Rx Bad packet 335433d6423SLionel Sambuc 1 R EROVW Early Rx OverWrite 336433d6423SLionel Sambuc 0 R EROK Early Rx OK 337433d6423SLionel Sambuc 51 R/W CONFIG0 Configuration Register 0 338433d6423SLionel Sambuc 7 R SCR Scrambler Mode 339433d6423SLionel Sambuc 6 R PCS PCS Mode 340433d6423SLionel Sambuc 5 R T10 10 Mbps Mode 341433d6423SLionel Sambuc 4-3 R PL[1-0] Select 10 Mbps medium type 342433d6423SLionel Sambuc 2-0 R BS[2-0] Select Boot ROM size 343433d6423SLionel Sambuc 52 R/W CONFIG1 Configuration Register 1 344433d6423SLionel Sambuc 7-6 R/W LEDS[1-0] LED PIN 345433d6423SLionel Sambuc 5 R/W DVRLOAD Driver Load 346433d6423SLionel Sambuc 4 R/W LWACT LWAKE active mode 347433d6423SLionel Sambuc 3 R MEMMAP Memory Mapping 348433d6423SLionel Sambuc 2 R IOMAP I/O Mapping 349433d6423SLionel Sambuc 1 R/W VPD Set to enable Vital Product Data 350433d6423SLionel Sambuc 0 R/W PMEn Power Management Enable 351433d6423SLionel Sambuc 59 R/W CONFIG3 Configuration Register 3 352433d6423SLionel Sambuc 7 R GNTSel Gnt Select 353433d6423SLionel Sambuc 6 R/W PARM_En Parameter Enable 354433d6423SLionel Sambuc 5 R/W Magic Magic Packet 355433d6423SLionel Sambuc 4 R/W LinkUp Link Up 356433d6423SLionel Sambuc 3 reserved 357433d6423SLionel Sambuc 2 R CLKRUN_En CLKRUN Enable 358433d6423SLionel Sambuc 1 reserved 359433d6423SLionel Sambuc 0 R FBtBEn Fast Back to Back Enable 360433d6423SLionel Sambuc 5a R/W CONFIG4 Configuration Register 4 361433d6423SLionel Sambuc 7 R/W RxFIFOAutoClr Auto Clear the Rx FIFO on overflow 362433d6423SLionel Sambuc 6 R/W AnaOff Analog Power Off 363433d6423SLionel Sambuc 5 R/W LongWF Long Wake-up Frame 364433d6423SLionel Sambuc 4 R/W LWPME LANWAKE vs PMEB 365433d6423SLionel Sambuc 3 reserved 366433d6423SLionel Sambuc 2 R/W LWPTN LWAKE pattern 367433d6423SLionel Sambuc 1 reserved 368433d6423SLionel Sambuc 0 R/W PBWakeup Pre-Boot Wakeup 369433d6423SLionel Sambuc 5c-5d R/W MULINT Multiple Interrupt Select 370433d6423SLionel Sambuc 15-12 reserved 371433d6423SLionel Sambuc 11-0 R/W MISR[11-0] Multiple Interrupt Select 372433d6423SLionel Sambuc 68-69 R ANLPAR Auto-Negotiation Link Partnet Register 373433d6423SLionel Sambuc 15 R NP Next Page bit 374433d6423SLionel Sambuc 14 R ACK acknowledge received from link partner 375433d6423SLionel Sambuc 13 R/W RF received remote fault detection capability 376433d6423SLionel Sambuc 12-11 reserved 377433d6423SLionel Sambuc 10 R Pause Flow control is supported 378433d6423SLionel Sambuc 9 R T4 100Base-T4 is supported 379433d6423SLionel Sambuc 8 R/W TXFD 100Base-TX full duplex is supported 380433d6423SLionel Sambuc 7 R/W TX 100Base-TX is supported 381433d6423SLionel Sambuc 6 R/W 10FD 10Base-T full duplex is supported 382433d6423SLionel Sambuc 5 R/W 10 10Base-T is supported 383433d6423SLionel Sambuc 4-0 R/W Selector Binary encoded selector 384433d6423SLionel Sambuc 6a-6b R ANER Auto-Negotiation Expansion Register 385433d6423SLionel Sambuc 15-5 reserved 386433d6423SLionel Sambuc 4 R MLF Multiple link fault occured 387433d6423SLionel Sambuc 3 R LP_NP_ABLE Link partner supports Next Page 388433d6423SLionel Sambuc 2 R NP_ABLE Local node is able to send add. Next Pages 389433d6423SLionel Sambuc 1 R PAGE_RX Link Code Word Page received 390433d6423SLionel Sambuc 0 R LP_NW_ABLE Link partner supports NWay auto-negotiation 391433d6423SLionel Sambuc 70-71 R/W NWAYTR N-way Test Register 392433d6423SLionel Sambuc 15-8 reserved 393433d6423SLionel Sambuc 7 R/W NWLPBK NWay loopback mode 394433d6423SLionel Sambuc 6-4 reserved 395433d6423SLionel Sambuc 3 R ENNWLE LED0 pin indicates linkpulse 396433d6423SLionel Sambuc 2 R FLAGABD Auto-neg experienced ability detect state 397433d6423SLionel Sambuc 1 R FLAGPDF Auto-neg exp. par. detection fault state 398433d6423SLionel Sambuc 0 R FLAGLSC Auto-neg experienced link status check state 399433d6423SLionel Sambuc 74-75 R/W CSCR CS Configuration Register 400433d6423SLionel Sambuc 15 W Testfun Auto-neg speeds up internal timer 401433d6423SLionel Sambuc 14-10 reserved 402433d6423SLionel Sambuc 9 R/W LD Active low TPI link disable signal 403433d6423SLionel Sambuc 8 R/W HEARTBEAT HEART BEAT enable 404433d6423SLionel Sambuc 7 R/W JBEN Enable jabber function 405433d6423SLionel Sambuc 6 R/W F_LINK_100 Force 100 Mbps 406433d6423SLionel Sambuc 5 R/W F_Conect Bypass disconnect function 407433d6423SLionel Sambuc 4 reserved 408433d6423SLionel Sambuc 3 R Con_status Connected link detected 409433d6423SLionel Sambuc 2 R/W Con_status_En Configures LED1 to indicate conn. stat. 410433d6423SLionel Sambuc 1 reserved 411433d6423SLionel Sambuc 0 R/W PASS_SCR Bypass scramble 412433d6423SLionel Sambuc 76-77 reserved 413433d6423SLionel Sambuc 78-7b R/W PHY1_PARM PHY parameter 1 414433d6423SLionel Sambuc 7c-7f R/W TW_PARM Twister parameter 415433d6423SLionel Sambuc 80 R/W PHY2_PARM PHY parameter 2 416433d6423SLionel Sambuc 81-83 reserved 417433d6423SLionel Sambuc 84-8b R/W CRC[0-7] Power Management CRC reg.[0-7] for frame[0-7] 418433d6423SLionel Sambuc 8c-cb R/W Wakeup[0-7] Power Management wakeup frame[0-7] (64 bit) 419433d6423SLionel Sambuc cc-d3 R/W LSBCRC[0-7] LSB of the mask byte of makeup frame[0-7] 420433d6423SLionel Sambuc d4-d7 reserved 421433d6423SLionel Sambuc d8 R/W Config5 Configuration register 5 422433d6423SLionel Sambuc 7 reserved 423433d6423SLionel Sambuc 6 R/W BWF Broadcast Wakeup Frame 424433d6423SLionel Sambuc 5 R/W MWF Multicast Wakeup Frame 425433d6423SLionel Sambuc 4 R/W UWF Unicast Wakeup Frame 426433d6423SLionel Sambuc 3 R/W FifoAddrPtr FIFO Address Pointer 427433d6423SLionel Sambuc 2 R/W LDPS Link Down Power Saving mode 428433d6423SLionel Sambuc 1 R/W LANWake LANWake Signal 429433d6423SLionel Sambuc 0 R/W PME_STS PME_Status bit 430433d6423SLionel Sambuc d9-ff reserved 431433d6423SLionel Sambuc #endif 432433d6423SLionel Sambuc 433433d6423SLionel Sambuc #define vm_1phys2bus(p) (p) 434433d6423SLionel Sambuc 435433d6423SLionel Sambuc #define RX_BUFSIZE RL_RCR_RBLEN_64K_SIZE 436433d6423SLionel Sambuc #define RX_BUFBITS RL_RCR_RBLEN_64K 437433d6423SLionel Sambuc #define N_TX_BUF RL_N_TX 438433d6423SLionel Sambuc 439433d6423SLionel Sambuc /* Configuration */ 440433d6423SLionel Sambuc #define RL_ENVVAR "RTLETH" 441433d6423SLionel Sambuc 442433d6423SLionel Sambuc typedef struct re 443433d6423SLionel Sambuc { 444433d6423SLionel Sambuc port_t re_base_port; 445433d6423SLionel Sambuc int re_irq; 446433d6423SLionel Sambuc int re_mode; 447433d6423SLionel Sambuc int re_link_up; 448433d6423SLionel Sambuc int re_got_int; 449433d6423SLionel Sambuc int re_send_int; 450433d6423SLionel Sambuc int re_report_link; 451433d6423SLionel Sambuc int re_clear_rx; 452433d6423SLionel Sambuc int re_need_reset; 453433d6423SLionel Sambuc int re_tx_alive; 454*4081bff6SDavid van Moolenbroek int re_tx_busy; 455*4081bff6SDavid van Moolenbroek const char *re_model; 456433d6423SLionel Sambuc 457433d6423SLionel Sambuc /* Rx */ 458433d6423SLionel Sambuc phys_bytes re_rx_buf; 459433d6423SLionel Sambuc char *v_re_rx_buf; 460433d6423SLionel Sambuc 461433d6423SLionel Sambuc /* Tx */ 462433d6423SLionel Sambuc int re_tx_head; 463433d6423SLionel Sambuc int re_tx_tail; 464433d6423SLionel Sambuc struct 465433d6423SLionel Sambuc { 466433d6423SLionel Sambuc int ret_busy; 467433d6423SLionel Sambuc phys_bytes ret_buf; 468433d6423SLionel Sambuc char * v_ret_buf; 469433d6423SLionel Sambuc } re_tx[N_TX_BUF]; 470433d6423SLionel Sambuc u32_t re_ertxth; /* Early Tx Threshold */ 471433d6423SLionel Sambuc 472433d6423SLionel Sambuc int re_hook_id; /* IRQ hook id at kernel */ 473*4081bff6SDavid van Moolenbroek } re_t; 474433d6423SLionel Sambuc 475433d6423SLionel Sambuc /* 476433d6423SLionel Sambuc * $PchId: rtl8139.h,v 1.1 2003/09/05 10:58:50 philip Exp $ 477433d6423SLionel Sambuc */ 478