160727d8bSWarner Losh /*- 2df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3df57947fSPedro F. Giffuni * 4726ff6a1SBill Paul * Copyright (c) 1997, 1998 5726ff6a1SBill Paul * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 6726ff6a1SBill Paul * 7726ff6a1SBill Paul * Redistribution and use in source and binary forms, with or without 8726ff6a1SBill Paul * modification, are permitted provided that the following conditions 9726ff6a1SBill Paul * are met: 10726ff6a1SBill Paul * 1. Redistributions of source code must retain the above copyright 11726ff6a1SBill Paul * notice, this list of conditions and the following disclaimer. 12726ff6a1SBill Paul * 2. Redistributions in binary form must reproduce the above copyright 13726ff6a1SBill Paul * notice, this list of conditions and the following disclaimer in the 14726ff6a1SBill Paul * documentation and/or other materials provided with the distribution. 15726ff6a1SBill Paul * 3. All advertising materials mentioning features or use of this software 16726ff6a1SBill Paul * must display the following acknowledgement: 17726ff6a1SBill Paul * This product includes software developed by Bill Paul. 18726ff6a1SBill Paul * 4. Neither the name of the author nor the names of any co-contributors 19726ff6a1SBill Paul * may be used to endorse or promote products derived from this software 20726ff6a1SBill Paul * without specific prior written permission. 21726ff6a1SBill Paul * 22726ff6a1SBill Paul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23726ff6a1SBill Paul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24726ff6a1SBill Paul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25726ff6a1SBill Paul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26726ff6a1SBill Paul * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27726ff6a1SBill Paul * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28726ff6a1SBill Paul * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29726ff6a1SBill Paul * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30726ff6a1SBill Paul * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31726ff6a1SBill Paul * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32726ff6a1SBill Paul * THE POSSIBILITY OF SUCH DAMAGE. 33726ff6a1SBill Paul */ 34726ff6a1SBill Paul 35726ff6a1SBill Paul /* 36726ff6a1SBill Paul * Rhine register definitions. 37726ff6a1SBill Paul */ 38726ff6a1SBill Paul 39726ff6a1SBill Paul #define VR_PAR0 0x00 /* node address 0 to 4 */ 40726ff6a1SBill Paul #define VR_PAR1 0x04 /* node address 2 to 6 */ 41726ff6a1SBill Paul #define VR_RXCFG 0x06 /* receiver config register */ 42726ff6a1SBill Paul #define VR_TXCFG 0x07 /* transmit config register */ 43de126af3SPyun YongHyeon #define VR_CR0 0x08 /* command register 0 */ 44de126af3SPyun YongHyeon #define VR_CR1 0x09 /* command register 1 */ 45de126af3SPyun YongHyeon #define VR_TQW 0x0A /* tx queue wake 6105M, 8bits */ 46726ff6a1SBill Paul #define VR_ISR 0x0C /* interrupt/status register */ 47726ff6a1SBill Paul #define VR_IMR 0x0E /* interrupt mask register */ 48726ff6a1SBill Paul #define VR_MAR0 0x10 /* multicast hash 0 */ 49726ff6a1SBill Paul #define VR_MAR1 0x14 /* multicast hash 1 */ 506b284b78SPyun YongHyeon #define VR_MCAM0 0x10 516b284b78SPyun YongHyeon #define VR_MCAM1 0x11 526b284b78SPyun YongHyeon #define VR_MCAM2 0x12 536b284b78SPyun YongHyeon #define VR_MCAM3 0x13 546b284b78SPyun YongHyeon #define VR_MCAM4 0x14 556b284b78SPyun YongHyeon #define VR_MCAM5 0x15 566b284b78SPyun YongHyeon #define VR_VCAM0 0x16 576b284b78SPyun YongHyeon #define VR_VCAM1 0x17 58726ff6a1SBill Paul #define VR_RXADDR 0x18 /* rx descriptor list start addr */ 59726ff6a1SBill Paul #define VR_TXADDR 0x1C /* tx descriptor list start addr */ 60726ff6a1SBill Paul #define VR_CURRXDESC0 0x20 61726ff6a1SBill Paul #define VR_CURRXDESC1 0x24 62726ff6a1SBill Paul #define VR_CURRXDESC2 0x28 63726ff6a1SBill Paul #define VR_CURRXDESC3 0x2C 64726ff6a1SBill Paul #define VR_NEXTRXDESC0 0x30 65726ff6a1SBill Paul #define VR_NEXTRXDESC1 0x34 66726ff6a1SBill Paul #define VR_NEXTRXDESC2 0x38 67726ff6a1SBill Paul #define VR_NEXTRXDESC3 0x3C 68726ff6a1SBill Paul #define VR_CURTXDESC0 0x40 69726ff6a1SBill Paul #define VR_CURTXDESC1 0x44 70726ff6a1SBill Paul #define VR_CURTXDESC2 0x48 71726ff6a1SBill Paul #define VR_CURTXDESC3 0x4C 72726ff6a1SBill Paul #define VR_NEXTTXDESC0 0x50 73726ff6a1SBill Paul #define VR_NEXTTXDESC1 0x54 74726ff6a1SBill Paul #define VR_NEXTTXDESC2 0x58 75726ff6a1SBill Paul #define VR_NEXTTXDESC3 0x5C 76726ff6a1SBill Paul #define VR_CURRXDMA 0x60 /* current RX DMA address */ 77726ff6a1SBill Paul #define VR_CURTXDMA 0x64 /* current TX DMA address */ 78726ff6a1SBill Paul #define VR_TALLYCNT 0x68 /* tally counter test register */ 79726ff6a1SBill Paul #define VR_PHYADDR 0x6C 80726ff6a1SBill Paul #define VR_MIISTAT 0x6D 81726ff6a1SBill Paul #define VR_BCR0 0x6E 82726ff6a1SBill Paul #define VR_BCR1 0x6F 83726ff6a1SBill Paul #define VR_MIICMD 0x70 84726ff6a1SBill Paul #define VR_MIIADDR 0x71 85726ff6a1SBill Paul #define VR_MIIDATA 0x72 86726ff6a1SBill Paul #define VR_EECSR 0x74 87726ff6a1SBill Paul #define VR_TEST 0x75 88726ff6a1SBill Paul #define VR_GPIO 0x76 89de126af3SPyun YongHyeon #define VR_CFGA 0x78 90de126af3SPyun YongHyeon #define VR_CFGB 0x79 91de126af3SPyun YongHyeon #define VR_CFGC 0x7A 92de126af3SPyun YongHyeon #define VR_CFGD 0x7B 93726ff6a1SBill Paul #define VR_MPA_CNT 0x7C 94726ff6a1SBill Paul #define VR_CRC_CNT 0x7E 95de126af3SPyun YongHyeon #define VR_MISC_CR0 0x80 /* VT6102, 8bits */ 96de126af3SPyun YongHyeon #define VR_MISC_CR1 0x81 9711c2ec41SBill Paul #define VR_STICKHW 0x83 98de126af3SPyun YongHyeon #define VR_MII_ISR 0x84 99de126af3SPyun YongHyeon #define VR_MII_IMR 0x86 100de126af3SPyun YongHyeon #define VR_CAMMASK 0x88 /* VT6105M, 32bits */ 101de126af3SPyun YongHyeon #define VR_CAMCTL 0x92 /* VT6105M, 8bits */ 102de126af3SPyun YongHyeon #define VR_CAMADDR 0x93 /* VT6105M, 8bits */ 103de126af3SPyun YongHyeon #define VR_FLOWCR0 0x98 104de126af3SPyun YongHyeon #define VR_FLOWCR1 0x99 105de126af3SPyun YongHyeon #define VR_PAUSETIMER 0x9A /* 16bit */ 106de126af3SPyun YongHyeon #define VR_WOLCR_SET 0xA0 107de126af3SPyun YongHyeon #define VR_PWRCFG_SET 0xA1 108de126af3SPyun YongHyeon #define VR_TESTREG_SET 0xA2 109de126af3SPyun YongHyeon #define VR_WOLCFG_SET 0xA3 110de126af3SPyun YongHyeon #define VR_WOLCR_CLR 0xA4 111de126af3SPyun YongHyeon #define VR_PWRCFG_CLR 0xA5 112de126af3SPyun YongHyeon #define VR_TESTREG_CLR 0xA6 113de126af3SPyun YongHyeon #define VR_WOLCFG_CLR 0xA7 114de126af3SPyun YongHyeon #define VR_PWRCSR_SET 0xA8 115de126af3SPyun YongHyeon #define VR_PWRCSR1_SET 0xA9 116de126af3SPyun YongHyeon #define VR_PWRCSR_CLR 0xAC 117de126af3SPyun YongHyeon #define VR_PWRCSR1_CLR 0xAD 118726ff6a1SBill Paul 119c7c3f58eSMike Silbersack /* Misc Registers */ 120de126af3SPyun YongHyeon #define VR_MISCCR0_RXPAUSE 0x08 121c7c3f58eSMike Silbersack #define VR_MISCCR1_FORSRST 0x40 122c7c3f58eSMike Silbersack 123726ff6a1SBill Paul /* 124726ff6a1SBill Paul * RX config bits. 125726ff6a1SBill Paul */ 126726ff6a1SBill Paul #define VR_RXCFG_RX_ERRPKTS 0x01 127726ff6a1SBill Paul #define VR_RXCFG_RX_RUNT 0x02 128726ff6a1SBill Paul #define VR_RXCFG_RX_MULTI 0x04 129726ff6a1SBill Paul #define VR_RXCFG_RX_BROAD 0x08 130726ff6a1SBill Paul #define VR_RXCFG_RX_PROMISC 0x10 131726ff6a1SBill Paul #define VR_RXCFG_RX_THRESH 0xE0 132726ff6a1SBill Paul 133726ff6a1SBill Paul #define VR_RXTHRESH_32BYTES 0x00 134726ff6a1SBill Paul #define VR_RXTHRESH_64BYTES 0x20 135726ff6a1SBill Paul #define VR_RXTHRESH_128BYTES 0x40 136726ff6a1SBill Paul #define VR_RXTHRESH_256BYTES 0x60 137726ff6a1SBill Paul #define VR_RXTHRESH_512BYTES 0x80 138726ff6a1SBill Paul #define VR_RXTHRESH_768BYTES 0xA0 139726ff6a1SBill Paul #define VR_RXTHRESH_1024BYTES 0xC0 140726ff6a1SBill Paul #define VR_RXTHRESH_STORENFWD 0xE0 141726ff6a1SBill Paul 142726ff6a1SBill Paul /* 143726ff6a1SBill Paul * TX config bits. 144726ff6a1SBill Paul */ 145de126af3SPyun YongHyeon #define VR_TXCFG_TXTAGEN 0x01 /* 6105M */ 146726ff6a1SBill Paul #define VR_TXCFG_LOOPBKMODE 0x06 147726ff6a1SBill Paul #define VR_TXCFG_BACKOFF 0x08 148de126af3SPyun YongHyeon #define VR_TXCFG_RXTAGCTL 0x10 /* 6105M */ 149726ff6a1SBill Paul #define VR_TXCFG_TX_THRESH 0xE0 150726ff6a1SBill Paul 151726ff6a1SBill Paul #define VR_TXTHRESH_32BYTES 0x00 152726ff6a1SBill Paul #define VR_TXTHRESH_64BYTES 0x20 153726ff6a1SBill Paul #define VR_TXTHRESH_128BYTES 0x40 154726ff6a1SBill Paul #define VR_TXTHRESH_256BYTES 0x60 155726ff6a1SBill Paul #define VR_TXTHRESH_512BYTES 0x80 156726ff6a1SBill Paul #define VR_TXTHRESH_768BYTES 0xA0 157726ff6a1SBill Paul #define VR_TXTHRESH_1024BYTES 0xC0 158726ff6a1SBill Paul #define VR_TXTHRESH_STORENFWD 0xE0 159de126af3SPyun YongHyeon #define VR_TXTHRESH_MIN 1 /* 64 bytes */ 160de126af3SPyun YongHyeon #define VR_TXTHRESH_MAX 5 /* store and forward */ 161726ff6a1SBill Paul 162726ff6a1SBill Paul /* 163726ff6a1SBill Paul * Command register bits. 164726ff6a1SBill Paul */ 165de126af3SPyun YongHyeon #define VR_CR0_INIT 0x01 166de126af3SPyun YongHyeon #define VR_CR0_START 0x02 167de126af3SPyun YongHyeon #define VR_CR0_STOP 0x04 168de126af3SPyun YongHyeon #define VR_CR0_RX_ON 0x08 169de126af3SPyun YongHyeon #define VR_CR0_TX_ON 0x10 170de126af3SPyun YongHyeon #define VR_CR0_TX_GO 0x20 171de126af3SPyun YongHyeon #define VR_CR0_RX_GO 0x40 172de126af3SPyun YongHyeon #define VR_CR0_RSVD 0x80 173de126af3SPyun YongHyeon #define VR_CR1_RX_EARLY 0x01 174de126af3SPyun YongHyeon #define VR_CR1_TX_EARLY 0x02 175de126af3SPyun YongHyeon #define VR_CR1_FULLDUPLEX 0x04 176de126af3SPyun YongHyeon #define VR_CR1_TX_NOPOLL 0x08 177726ff6a1SBill Paul 178de126af3SPyun YongHyeon #define VR_CR1_RESET 0x80 179726ff6a1SBill Paul 180726ff6a1SBill Paul /* 181726ff6a1SBill Paul * Interrupt status bits. 182726ff6a1SBill Paul */ 183726ff6a1SBill Paul #define VR_ISR_RX_OK 0x0001 /* packet rx ok */ 184726ff6a1SBill Paul #define VR_ISR_TX_OK 0x0002 /* packet tx ok */ 185726ff6a1SBill Paul #define VR_ISR_RX_ERR 0x0004 /* packet rx with err */ 186726ff6a1SBill Paul #define VR_ISR_TX_ABRT 0x0008 /* tx aborted due to excess colls */ 187726ff6a1SBill Paul #define VR_ISR_TX_UNDERRUN 0x0010 /* tx buffer underflow */ 188726ff6a1SBill Paul #define VR_ISR_RX_NOBUF 0x0020 /* no rx buffer available */ 189726ff6a1SBill Paul #define VR_ISR_BUSERR 0x0040 /* PCI bus error */ 190726ff6a1SBill Paul #define VR_ISR_STATSOFLOW 0x0080 /* stats counter oflow */ 191726ff6a1SBill Paul #define VR_ISR_RX_EARLY 0x0100 /* rx early */ 192726ff6a1SBill Paul #define VR_ISR_LINKSTAT 0x0200 /* MII status change */ 193f3b2d59eSMike Silbersack #define VR_ISR_ETI 0x0200 /* Tx early (3043/3071) */ 194de126af3SPyun YongHyeon #define VR_ISR_UDFI 0x0200 /* Tx FIFO underflow (6102) */ 195726ff6a1SBill Paul #define VR_ISR_RX_OFLOW 0x0400 /* rx FIFO overflow */ 196726ff6a1SBill Paul #define VR_ISR_RX_DROPPED 0x0800 197de126af3SPyun YongHyeon #define VR_ISR_RX_NOBUF2 0x1000 /* Rx descriptor running up */ 198726ff6a1SBill Paul #define VR_ISR_TX_ABRT2 0x2000 199726ff6a1SBill Paul #define VR_ISR_LINKSTAT2 0x4000 200726ff6a1SBill Paul #define VR_ISR_MAGICPACKET 0x8000 201726ff6a1SBill Paul 202de126af3SPyun YongHyeon #define VR_ISR_ERR_BITS "\20" \ 203de126af3SPyun YongHyeon "\3RXERR\4TXABRT\5TXUNDERRUN" \ 204de126af3SPyun YongHyeon "\6RXNOBUF\7BUSERR\10STATSOFLOW" \ 205de126af3SPyun YongHyeon "\12TXUDF\13RXOFLOW\14RXDROPPED" \ 206de126af3SPyun YongHyeon "\15RXNOBUF2\16TXABRT2" 207726ff6a1SBill Paul /* 208726ff6a1SBill Paul * Interrupt mask bits. 209726ff6a1SBill Paul */ 210726ff6a1SBill Paul #define VR_IMR_RX_OK 0x0001 /* packet rx ok */ 211726ff6a1SBill Paul #define VR_IMR_TX_OK 0x0002 /* packet tx ok */ 212726ff6a1SBill Paul #define VR_IMR_RX_ERR 0x0004 /* packet rx with err */ 213726ff6a1SBill Paul #define VR_IMR_TX_ABRT 0x0008 /* tx aborted due to excess colls */ 214726ff6a1SBill Paul #define VR_IMR_TX_UNDERRUN 0x0010 /* tx buffer underflow */ 215726ff6a1SBill Paul #define VR_IMR_RX_NOBUF 0x0020 /* no rx buffer available */ 216726ff6a1SBill Paul #define VR_IMR_BUSERR 0x0040 /* PCI bus error */ 217726ff6a1SBill Paul #define VR_IMR_STATSOFLOW 0x0080 /* stats counter oflow */ 218726ff6a1SBill Paul #define VR_IMR_RX_EARLY 0x0100 /* rx early */ 219726ff6a1SBill Paul #define VR_IMR_LINKSTAT 0x0200 /* MII status change */ 220726ff6a1SBill Paul #define VR_IMR_RX_OFLOW 0x0400 /* rx FIFO overflow */ 221726ff6a1SBill Paul #define VR_IMR_RX_DROPPED 0x0800 222726ff6a1SBill Paul #define VR_IMR_RX_NOBUF2 0x1000 223726ff6a1SBill Paul #define VR_IMR_TX_ABRT2 0x2000 224726ff6a1SBill Paul #define VR_IMR_LINKSTAT2 0x4000 225726ff6a1SBill Paul #define VR_IMR_MAGICPACKET 0x8000 226726ff6a1SBill Paul 227726ff6a1SBill Paul #define VR_INTRS \ 228726ff6a1SBill Paul (VR_IMR_RX_OK|VR_IMR_TX_OK|VR_IMR_RX_NOBUF| \ 229726ff6a1SBill Paul VR_IMR_TX_ABRT|VR_IMR_TX_UNDERRUN|VR_IMR_BUSERR| \ 230726ff6a1SBill Paul VR_IMR_RX_ERR|VR_ISR_RX_DROPPED) 231726ff6a1SBill Paul 232726ff6a1SBill Paul /* 233726ff6a1SBill Paul * MII status register. 234726ff6a1SBill Paul */ 235726ff6a1SBill Paul 236726ff6a1SBill Paul #define VR_MIISTAT_SPEED 0x01 237726ff6a1SBill Paul #define VR_MIISTAT_LINKFAULT 0x02 238726ff6a1SBill Paul #define VR_MIISTAT_MGTREADERR 0x04 239726ff6a1SBill Paul #define VR_MIISTAT_MIIERR 0x08 240726ff6a1SBill Paul #define VR_MIISTAT_PHYOPT 0x10 241726ff6a1SBill Paul #define VR_MIISTAT_MDC_SPEED 0x20 242726ff6a1SBill Paul #define VR_MIISTAT_RSVD 0x40 243726ff6a1SBill Paul #define VR_MIISTAT_GPIO1POLL 0x80 244726ff6a1SBill Paul 245726ff6a1SBill Paul /* 246726ff6a1SBill Paul * MII command register bits. 247726ff6a1SBill Paul */ 248726ff6a1SBill Paul #define VR_MIICMD_CLK 0x01 249726ff6a1SBill Paul #define VR_MIICMD_DATAOUT 0x02 250726ff6a1SBill Paul #define VR_MIICMD_DATAIN 0x04 251726ff6a1SBill Paul #define VR_MIICMD_DIR 0x08 252726ff6a1SBill Paul #define VR_MIICMD_DIRECTPGM 0x10 253726ff6a1SBill Paul #define VR_MIICMD_WRITE_ENB 0x20 254726ff6a1SBill Paul #define VR_MIICMD_READ_ENB 0x40 255726ff6a1SBill Paul #define VR_MIICMD_AUTOPOLL 0x80 256726ff6a1SBill Paul 257726ff6a1SBill Paul /* 258726ff6a1SBill Paul * EEPROM control bits. 259726ff6a1SBill Paul */ 260726ff6a1SBill Paul #define VR_EECSR_DATAIN 0x01 /* data out */ 261726ff6a1SBill Paul #define VR_EECSR_DATAOUT 0x02 /* data in */ 262726ff6a1SBill Paul #define VR_EECSR_CLK 0x04 /* clock */ 263726ff6a1SBill Paul #define VR_EECSR_CS 0x08 /* chip select */ 264726ff6a1SBill Paul #define VR_EECSR_DPM 0x10 265726ff6a1SBill Paul #define VR_EECSR_LOAD 0x20 266726ff6a1SBill Paul #define VR_EECSR_EMBP 0x40 267726ff6a1SBill Paul #define VR_EECSR_EEPR 0x80 268726ff6a1SBill Paul 269726ff6a1SBill Paul #define VR_EECMD_WRITE 0x140 270726ff6a1SBill Paul #define VR_EECMD_READ 0x180 271726ff6a1SBill Paul #define VR_EECMD_ERASE 0x1c0 272726ff6a1SBill Paul 273726ff6a1SBill Paul /* 274726ff6a1SBill Paul * Test register bits. 275726ff6a1SBill Paul */ 276726ff6a1SBill Paul #define VR_TEST_TEST0 0x01 277726ff6a1SBill Paul #define VR_TEST_TEST1 0x02 278726ff6a1SBill Paul #define VR_TEST_TEST2 0x04 279726ff6a1SBill Paul #define VR_TEST_TSTUD 0x08 280726ff6a1SBill Paul #define VR_TEST_TSTOV 0x10 281726ff6a1SBill Paul #define VR_TEST_BKOFF 0x20 282726ff6a1SBill Paul #define VR_TEST_FCOL 0x40 283726ff6a1SBill Paul #define VR_TEST_HBDES 0x80 284726ff6a1SBill Paul 285726ff6a1SBill Paul /* 286de126af3SPyun YongHyeon * Config A register bits. 287726ff6a1SBill Paul */ 288de126af3SPyun YongHyeon #define VR_CFG_GPIO2OUTENB 0x01 289de126af3SPyun YongHyeon #define VR_CFG_GPIO2OUT 0x02 /* gen. purp. pin */ 290de126af3SPyun YongHyeon #define VR_CFG_GPIO2IN 0x04 /* gen. purp. pin */ 291de126af3SPyun YongHyeon #define VR_CFG_AUTOOPT 0x08 /* enable rx/tx autopoll */ 292de126af3SPyun YongHyeon #define VR_CFG_MIIOPT 0x10 293de126af3SPyun YongHyeon #define VR_CFG_MMIENB 0x20 /* memory mapped mode enb */ 294de126af3SPyun YongHyeon #define VR_CFG_JUMPER 0x40 /* PHY and oper. mode select */ 295de126af3SPyun YongHyeon #define VR_CFG_EELOAD 0x80 /* enable EEPROM programming */ 296de126af3SPyun YongHyeon 297de126af3SPyun YongHyeon /* 298de126af3SPyun YongHyeon * Config B register bits. 299de126af3SPyun YongHyeon */ 300de126af3SPyun YongHyeon #define VR_CFG_LATMENB 0x01 /* larency timer effect enb. */ 301de126af3SPyun YongHyeon #define VR_CFG_MRREADWAIT 0x02 302de126af3SPyun YongHyeon #define VR_CFG_MRWRITEWAIT 0x04 303de126af3SPyun YongHyeon #define VR_CFG_RX_ARB 0x08 304de126af3SPyun YongHyeon #define VR_CFG_TX_ARB 0x10 305de126af3SPyun YongHyeon #define VR_CFG_READMULTI 0x20 306de126af3SPyun YongHyeon #define VR_CFG_TX_PACE 0x40 307de126af3SPyun YongHyeon #define VR_CFG_TX_QDIS 0x80 308de126af3SPyun YongHyeon 309de126af3SPyun YongHyeon /* 310de126af3SPyun YongHyeon * Config C register bits. 311de126af3SPyun YongHyeon */ 312de126af3SPyun YongHyeon #define VR_CFG_ROMSEL0 0x01 313de126af3SPyun YongHyeon #define VR_CFG_ROMSEL1 0x02 314de126af3SPyun YongHyeon #define VR_CFG_ROMSEL2 0x04 315de126af3SPyun YongHyeon #define VR_CFG_ROMTIMESEL 0x08 316de126af3SPyun YongHyeon #define VR_CFG_RSVD0 0x10 317de126af3SPyun YongHyeon #define VR_CFG_ROMDLY 0x20 318de126af3SPyun YongHyeon #define VR_CFG_ROMOPT 0x40 319de126af3SPyun YongHyeon #define VR_CFG_RSVD1 0x80 320de126af3SPyun YongHyeon 321de126af3SPyun YongHyeon /* 322de126af3SPyun YongHyeon * Config D register bits. 323de126af3SPyun YongHyeon */ 324de126af3SPyun YongHyeon #define VR_CFG_BACKOFFOPT 0x01 325de126af3SPyun YongHyeon #define VR_CFG_BACKOFFMOD 0x02 326de126af3SPyun YongHyeon #define VR_CFG_CAPEFFECT 0x04 327de126af3SPyun YongHyeon #define VR_CFG_BACKOFFRAND 0x08 328de126af3SPyun YongHyeon #define VR_CFG_MAGICKPACKET 0x10 329de126af3SPyun YongHyeon #define VR_CFG_PCIREADLINE 0x20 330de126af3SPyun YongHyeon #define VR_CFG_DIAG 0x40 331de126af3SPyun YongHyeon #define VR_CFG_GPIOEN 0x80 332726ff6a1SBill Paul 33311c2ec41SBill Paul /* Sticky HW bits */ 33411c2ec41SBill Paul #define VR_STICKHW_DS0 0x01 33511c2ec41SBill Paul #define VR_STICKHW_DS1 0x02 33611c2ec41SBill Paul #define VR_STICKHW_WOL_ENB 0x04 33711c2ec41SBill Paul #define VR_STICKHW_WOL_STS 0x08 33811c2ec41SBill Paul #define VR_STICKHW_LEGWOL_ENB 0x80 33911c2ec41SBill Paul 340726ff6a1SBill Paul /* 34116afddabSMike Silbersack * BCR0 register bits. (At least for the VT6102 chip.) 34216afddabSMike Silbersack */ 34316afddabSMike Silbersack #define VR_BCR0_DMA_LENGTH 0x07 34416afddabSMike Silbersack 34516afddabSMike Silbersack #define VR_BCR0_DMA_32BYTES 0x00 34616afddabSMike Silbersack #define VR_BCR0_DMA_64BYTES 0x01 34716afddabSMike Silbersack #define VR_BCR0_DMA_128BYTES 0x02 34816afddabSMike Silbersack #define VR_BCR0_DMA_256BYTES 0x03 34916afddabSMike Silbersack #define VR_BCR0_DMA_512BYTES 0x04 35016afddabSMike Silbersack #define VR_BCR0_DMA_1024BYTES 0x05 35116afddabSMike Silbersack #define VR_BCR0_DMA_STORENFWD 0x07 35216afddabSMike Silbersack 35316afddabSMike Silbersack #define VR_BCR0_RX_THRESH 0x38 35416afddabSMike Silbersack 35516afddabSMike Silbersack #define VR_BCR0_RXTHRESHCFG 0x00 35616afddabSMike Silbersack #define VR_BCR0_RXTHRESH64BYTES 0x08 35716afddabSMike Silbersack #define VR_BCR0_RXTHRESH128BYTES 0x10 35816afddabSMike Silbersack #define VR_BCR0_RXTHRESH256BYTES 0x18 35916afddabSMike Silbersack #define VR_BCR0_RXTHRESH512BYTES 0x20 36016afddabSMike Silbersack #define VR_BCR0_RXTHRESH1024BYTES 0x28 36116afddabSMike Silbersack #define VR_BCR0_RXTHRESHSTORENFWD 0x38 36216afddabSMike Silbersack #define VR_BCR0_EXTLED 0x40 36316afddabSMike Silbersack #define VR_BCR0_MED2 0x80 36416afddabSMike Silbersack 36516afddabSMike Silbersack /* 36616afddabSMike Silbersack * BCR1 register bits. (At least for the VT6102 chip.) 36716afddabSMike Silbersack */ 36816afddabSMike Silbersack #define VR_BCR1_POT0 0x01 36916afddabSMike Silbersack #define VR_BCR1_POT1 0x02 37016afddabSMike Silbersack #define VR_BCR1_POT2 0x04 37116afddabSMike Silbersack #define VR_BCR1_TX_THRESH 0x38 37216afddabSMike Silbersack #define VR_BCR1_TXTHRESHCFG 0x00 37316afddabSMike Silbersack #define VR_BCR1_TXTHRESH64BYTES 0x08 37416afddabSMike Silbersack #define VR_BCR1_TXTHRESH128BYTES 0x10 37516afddabSMike Silbersack #define VR_BCR1_TXTHRESH256BYTES 0x18 37616afddabSMike Silbersack #define VR_BCR1_TXTHRESH512BYTES 0x20 37716afddabSMike Silbersack #define VR_BCR1_TXTHRESH1024BYTES 0x28 37816afddabSMike Silbersack #define VR_BCR1_TXTHRESHSTORENFWD 0x38 3796b284b78SPyun YongHyeon #define VR_BCR1_VLANFILT_ENB 0x80 /* VT6105M */ 38016afddabSMike Silbersack 38116afddabSMike Silbersack /* 382de126af3SPyun YongHyeon * CAMCTL register bits. (VT6105M only) 383de126af3SPyun YongHyeon */ 384de126af3SPyun YongHyeon #define VR_CAMCTL_ENA 0x01 385de126af3SPyun YongHyeon #define VR_CAMCTL_VLAN 0x02 386de126af3SPyun YongHyeon #define VR_CAMCTL_MCAST 0x00 387de126af3SPyun YongHyeon #define VR_CAMCTL_WRITE 0x04 388de126af3SPyun YongHyeon #define VR_CAMCTL_READ 0x08 389de126af3SPyun YongHyeon 390de126af3SPyun YongHyeon #define VR_CAM_MCAST_CNT 32 391de126af3SPyun YongHyeon #define VR_CAM_VLAN_CNT 32 392de126af3SPyun YongHyeon 393de126af3SPyun YongHyeon /* 394de126af3SPyun YongHyeon * FLOWCR1 register bits. (VT6105LOM, VT6105M only) 395de126af3SPyun YongHyeon */ 396de126af3SPyun YongHyeon #define VR_FLOWCR1_TXLO4 0x00 397de126af3SPyun YongHyeon #define VR_FLOWCR1_TXLO8 0x40 398de126af3SPyun YongHyeon #define VR_FLOWCR1_TXLO16 0x80 399de126af3SPyun YongHyeon #define VR_FLOWCR1_TXLO24 0xC0 400de126af3SPyun YongHyeon #define VR_FLOWCR1_TXHI24 0x00 401de126af3SPyun YongHyeon #define VR_FLOWCR1_TXHI32 0x10 402de126af3SPyun YongHyeon #define VR_FLOWCR1_TXHI48 0x20 403de126af3SPyun YongHyeon #define VR_FLOWCR1_TXHI64 0x30 404de126af3SPyun YongHyeon #define VR_FLOWCR1_XONXOFF 0x08 405de126af3SPyun YongHyeon #define VR_FLOWCR1_TXPAUSE 0x04 406de126af3SPyun YongHyeon #define VR_FLOWCR1_RXPAUSE 0x02 407de126af3SPyun YongHyeon #define VR_FLOWCR1_HDX 0x01 408de126af3SPyun YongHyeon 409de126af3SPyun YongHyeon /* 410de126af3SPyun YongHyeon * WOLCR register bits. (VT6102 or higher only) 411de126af3SPyun YongHyeon */ 412de126af3SPyun YongHyeon #define VR_WOLCR_PATTERN0 0x01 413de126af3SPyun YongHyeon #define VR_WOLCR_PATTERN1 0x02 414de126af3SPyun YongHyeon #define VR_WOLCR_PATTERN2 0x04 415de126af3SPyun YongHyeon #define VR_WOLCR_PATTERN3 0x08 416de126af3SPyun YongHyeon #define VR_WOLCR_UCAST 0x10 417de126af3SPyun YongHyeon #define VR_WOLCR_MAGIC 0x20 418de126af3SPyun YongHyeon #define VR_WOLCR_LINKON 0x40 419de126af3SPyun YongHyeon #define VR_WOLCR_LINKOFF 0x80 420de126af3SPyun YongHyeon 421de126af3SPyun YongHyeon /* 422de126af3SPyun YongHyeon * PWRCFG register bits. (VT6102 or higher only) 423de126af3SPyun YongHyeon */ 424de126af3SPyun YongHyeon #define VR_PWRCFG_WOLEN 0x01 425de126af3SPyun YongHyeon #define VR_PWRCFG_WOLSR 0x02 426de126af3SPyun YongHyeon #define VR_PWRCFG_LEGACY_WOL 0x10 427de126af3SPyun YongHyeon #define VR_PWRCFG_WOLTYPE_PULSE 0x20 428de126af3SPyun YongHyeon #define VR_PWRCFG_SMIITIME 0x80 429de126af3SPyun YongHyeon 430de126af3SPyun YongHyeon /* 431de126af3SPyun YongHyeon * WOLCFG register bits. (VT6102 or higher only) 432de126af3SPyun YongHyeon */ 433de126af3SPyun YongHyeon #define VR_WOLCFG_PATTERN_PAGE 0x04 /* VT6505 B0 */ 434de126af3SPyun YongHyeon #define VR_WOLCFG_SMIIOPT 0x04 435de126af3SPyun YongHyeon #define VR_WOLCFG_SMIIACC 0x08 436de126af3SPyun YongHyeon #define VR_WOLCFG_SAB 0x10 437de126af3SPyun YongHyeon #define VR_WOLCFG_SAM 0x20 438de126af3SPyun YongHyeon #define VR_WOLCFG_SFDX 0x40 439de126af3SPyun YongHyeon #define VR_WOLCFG_PMEOVR 0x80 440de126af3SPyun YongHyeon 441de126af3SPyun YongHyeon /* 442726ff6a1SBill Paul * Rhine TX/RX list structure. 443726ff6a1SBill Paul */ 444726ff6a1SBill Paul 445726ff6a1SBill Paul struct vr_desc { 446de126af3SPyun YongHyeon uint32_t vr_status; 447de126af3SPyun YongHyeon uint32_t vr_ctl; 448de126af3SPyun YongHyeon uint32_t vr_data; 449de126af3SPyun YongHyeon uint32_t vr_nextphys; 450726ff6a1SBill Paul }; 451726ff6a1SBill Paul 452726ff6a1SBill Paul #define VR_RXSTAT_RXERR 0x00000001 453726ff6a1SBill Paul #define VR_RXSTAT_CRCERR 0x00000002 454726ff6a1SBill Paul #define VR_RXSTAT_FRAMEALIGNERR 0x00000004 455726ff6a1SBill Paul #define VR_RXSTAT_FIFOOFLOW 0x00000008 456726ff6a1SBill Paul #define VR_RXSTAT_GIANT 0x00000010 457726ff6a1SBill Paul #define VR_RXSTAT_RUNT 0x00000020 458726ff6a1SBill Paul #define VR_RXSTAT_BUSERR 0x00000040 459de126af3SPyun YongHyeon #define VR_RXSTAT_FRAG 0x00000040 /* 6105M */ 460726ff6a1SBill Paul #define VR_RXSTAT_BUFFERR 0x00000080 461726ff6a1SBill Paul #define VR_RXSTAT_LASTFRAG 0x00000100 462726ff6a1SBill Paul #define VR_RXSTAT_FIRSTFRAG 0x00000200 463726ff6a1SBill Paul #define VR_RXSTAT_RLINK 0x00000400 464726ff6a1SBill Paul #define VR_RXSTAT_RX_PHYS 0x00000800 465726ff6a1SBill Paul #define VR_RXSTAT_RX_BROAD 0x00001000 466726ff6a1SBill Paul #define VR_RXSTAT_RX_MULTI 0x00002000 4670a76b259SPyun YongHyeon #define VR_RXSTAT_RX_VIDHIT 0x00004000 /* 6105M */ 4680a76b259SPyun YongHyeon #define VR_RXSTAT_RX_OK 0x00008000 469726ff6a1SBill Paul #define VR_RXSTAT_RXLEN 0x07FF0000 470726ff6a1SBill Paul #define VR_RXSTAT_RXLEN_EXT 0x78000000 471726ff6a1SBill Paul #define VR_RXSTAT_OWN 0x80000000 472726ff6a1SBill Paul 473726ff6a1SBill Paul #define VR_RXBYTES(x) ((x & VR_RXSTAT_RXLEN) >> 16) 474de126af3SPyun YongHyeon #define VR_RXSTAT_ERR_BITS "\20" \ 475de126af3SPyun YongHyeon "\1RXERR\2CRCERR\3FRAMEALIGN" \ 476de126af3SPyun YongHyeon "\4FIFOOFLOW\5GIANT\6RUNT" \ 477de126af3SPyun YongHyeon "\10BUFERR" 478726ff6a1SBill Paul 479726ff6a1SBill Paul #define VR_RXCTL_BUFLEN 0x000007FF 480726ff6a1SBill Paul #define VR_RXCTL_BUFLEN_EXT 0x00007800 481726ff6a1SBill Paul #define VR_RXCTL_CHAIN 0x00008000 482de126af3SPyun YongHyeon #define VR_RXCTL_TAG 0x00010000 483de126af3SPyun YongHyeon #define VR_RXCTL_UDP 0x00020000 484de126af3SPyun YongHyeon #define VR_RXCTL_TCP 0x00040000 485de126af3SPyun YongHyeon #define VR_RXCTL_IP 0x00080000 486de126af3SPyun YongHyeon #define VR_RXCTL_TCPUDPOK 0x00100000 487de126af3SPyun YongHyeon #define VR_RXCTL_IPOK 0x00200000 488de126af3SPyun YongHyeon #define VR_RXCTL_SNAPTAG 0x00400000 489de126af3SPyun YongHyeon #define VR_RXCTL_RXLERR 0x00800000 /* 6105M */ 490726ff6a1SBill Paul #define VR_RXCTL_RX_INTR 0x00800000 491de126af3SPyun YongHyeon 4926c70e5b4SBill Paul #define VR_RXCTL (VR_RXCTL_CHAIN|VR_RXCTL_RX_INTR) 493726ff6a1SBill Paul 494726ff6a1SBill Paul #define VR_TXSTAT_DEFER 0x00000001 495726ff6a1SBill Paul #define VR_TXSTAT_UNDERRUN 0x00000002 496726ff6a1SBill Paul #define VR_TXSTAT_COLLCNT 0x00000078 497726ff6a1SBill Paul #define VR_TXSTAT_SQE 0x00000080 498726ff6a1SBill Paul #define VR_TXSTAT_ABRT 0x00000100 499726ff6a1SBill Paul #define VR_TXSTAT_LATECOLL 0x00000200 500726ff6a1SBill Paul #define VR_TXSTAT_CARRLOST 0x00000400 501f3b2d59eSMike Silbersack #define VR_TXSTAT_UDF 0x00000800 502de126af3SPyun YongHyeon #define VR_TXSTAT_TBUFF 0x00001000 503726ff6a1SBill Paul #define VR_TXSTAT_BUSERR 0x00002000 504726ff6a1SBill Paul #define VR_TXSTAT_JABTIMEO 0x00004000 505726ff6a1SBill Paul #define VR_TXSTAT_ERRSUM 0x00008000 506726ff6a1SBill Paul #define VR_TXSTAT_OWN 0x80000000 507726ff6a1SBill Paul 508726ff6a1SBill Paul #define VR_TXCTL_BUFLEN 0x000007FF 509726ff6a1SBill Paul #define VR_TXCTL_BUFLEN_EXT 0x00007800 510726ff6a1SBill Paul #define VR_TXCTL_TLINK 0x00008000 5114898b3a5SPoul-Henning Kamp #define VR_TXCTL_NOCRC 0x00010000 5124898b3a5SPoul-Henning Kamp #define VR_TXCTL_INSERTTAG 0x00020000 5134898b3a5SPoul-Henning Kamp #define VR_TXCTL_IPCSUM 0x00040000 5144898b3a5SPoul-Henning Kamp #define VR_TXCTL_UDPCSUM 0x00080000 5154898b3a5SPoul-Henning Kamp #define VR_TXCTL_TCPCSUM 0x00100000 516726ff6a1SBill Paul #define VR_TXCTL_FIRSTFRAG 0x00200000 517726ff6a1SBill Paul #define VR_TXCTL_LASTFRAG 0x00400000 518726ff6a1SBill Paul #define VR_TXCTL_FINT 0x00800000 519726ff6a1SBill Paul 520726ff6a1SBill Paul #define VR_MIN_FRAMELEN 60 521726ff6a1SBill Paul 522726ff6a1SBill Paul #define VR_FLAG_FORCEDELAY 1 523726ff6a1SBill Paul #define VR_FLAG_SCHEDDELAY 2 524726ff6a1SBill Paul #define VR_FLAG_DELAYTIMEO 3 525726ff6a1SBill Paul 526726ff6a1SBill Paul #define VR_TIMEOUT 1000 527de126af3SPyun YongHyeon #define VR_MII_TIMEOUT 10000 528de126af3SPyun YongHyeon 529de126af3SPyun YongHyeon #define VR_PHYADDR_MASK 0x1f 530726ff6a1SBill Paul 531726ff6a1SBill Paul /* 532726ff6a1SBill Paul * General constants that are fun to know. 533726ff6a1SBill Paul * 534726ff6a1SBill Paul * VIA vendor ID 535726ff6a1SBill Paul */ 536726ff6a1SBill Paul #define VIA_VENDORID 0x1106 537726ff6a1SBill Paul 538726ff6a1SBill Paul /* 539726ff6a1SBill Paul * VIA Rhine device IDs. 540726ff6a1SBill Paul */ 541726ff6a1SBill Paul #define VIA_DEVICEID_RHINE 0x3043 542726ff6a1SBill Paul #define VIA_DEVICEID_RHINE_II 0x6100 5431be1972cSBill Paul #define VIA_DEVICEID_RHINE_II_2 0x3065 5441a984aadSMike Silbersack #define VIA_DEVICEID_RHINE_III 0x3106 5451a984aadSMike Silbersack #define VIA_DEVICEID_RHINE_III_M 0x3053 546726ff6a1SBill Paul 547141ae166SBill Paul /* 548141ae166SBill Paul * Delta Electronics device ID. 549141ae166SBill Paul */ 550141ae166SBill Paul #define DELTA_VENDORID 0x1500 551141ae166SBill Paul 552141ae166SBill Paul /* 553141ae166SBill Paul * Delta device IDs. 554141ae166SBill Paul */ 555141ae166SBill Paul #define DELTA_DEVICEID_RHINE_II 0x1320 556141ae166SBill Paul 557141ae166SBill Paul /* 558141ae166SBill Paul * Addtron vendor ID. 559141ae166SBill Paul */ 560141ae166SBill Paul #define ADDTRON_VENDORID 0x4033 561141ae166SBill Paul 562141ae166SBill Paul /* 563141ae166SBill Paul * Addtron device IDs. 564141ae166SBill Paul */ 565141ae166SBill Paul #define ADDTRON_DEVICEID_RHINE_II 0x1320 566141ae166SBill Paul 567c7c3f58eSMike Silbersack /* 568c7c3f58eSMike Silbersack * VIA Rhine revision IDs 569c7c3f58eSMike Silbersack */ 570c7c3f58eSMike Silbersack 571c7c3f58eSMike Silbersack #define REV_ID_VT3043_E 0x04 572c7c3f58eSMike Silbersack #define REV_ID_VT3071_A 0x20 573c7c3f58eSMike Silbersack #define REV_ID_VT3071_B 0x21 574de126af3SPyun YongHyeon #define REV_ID_VT6102_A 0x40 575de126af3SPyun YongHyeon #define REV_ID_VT6102_B 0x41 576de126af3SPyun YongHyeon #define REV_ID_VT6102_C 0x42 57797e6eca5SMike Silbersack #define REV_ID_VT6102_APOLLO 0x74 578de126af3SPyun YongHyeon #define REV_ID_VT6105_A0 0x80 579de126af3SPyun YongHyeon #define REV_ID_VT6105_B0 0x83 580de126af3SPyun YongHyeon #define REV_ID_VT6105_LOM 0x8A 581de126af3SPyun YongHyeon #define REV_ID_VT6107_A0 0x8C 582de126af3SPyun YongHyeon #define REV_ID_VT6107_A1 0x8D 583de126af3SPyun YongHyeon #define REV_ID_VT6105M_A0 0x90 584de126af3SPyun YongHyeon #define REV_ID_VT6105M_B1 0x94 585726ff6a1SBill Paul 586726ff6a1SBill Paul /* 587726ff6a1SBill Paul * PCI low memory base and low I/O base register, and 588726ff6a1SBill Paul * other PCI registers. 589726ff6a1SBill Paul */ 590726ff6a1SBill Paul 591726ff6a1SBill Paul #define VR_PCI_VENDOR_ID 0x00 592726ff6a1SBill Paul #define VR_PCI_DEVICE_ID 0x02 593726ff6a1SBill Paul #define VR_PCI_COMMAND 0x04 594726ff6a1SBill Paul #define VR_PCI_STATUS 0x06 595c7c3f58eSMike Silbersack #define VR_PCI_REVID 0x08 596726ff6a1SBill Paul #define VR_PCI_CLASSCODE 0x09 597726ff6a1SBill Paul #define VR_PCI_LATENCY_TIMER 0x0D 598726ff6a1SBill Paul #define VR_PCI_HEADER_TYPE 0x0E 599726ff6a1SBill Paul #define VR_PCI_LOIO 0x10 600726ff6a1SBill Paul #define VR_PCI_LOMEM 0x14 601726ff6a1SBill Paul #define VR_PCI_BIOSROM 0x30 602726ff6a1SBill Paul #define VR_PCI_INTLINE 0x3C 603726ff6a1SBill Paul #define VR_PCI_INTPIN 0x3D 604726ff6a1SBill Paul #define VR_PCI_MINGNT 0x3E 605726ff6a1SBill Paul #define VR_PCI_MINLAT 0x0F 606726ff6a1SBill Paul #define VR_PCI_RESETOPT 0x48 607726ff6a1SBill Paul #define VR_PCI_EEPROM_DATA 0x4C 608de126af3SPyun YongHyeon #define VR_PCI_MODE0 0x50 609de126af3SPyun YongHyeon #define VR_PCI_MODE2 0x52 610de126af3SPyun YongHyeon #define VR_PCI_MODE3 0x53 61197e6eca5SMike Silbersack 612de126af3SPyun YongHyeon #define VR_MODE2_PCEROPT 0x80 /* VT6102 only */ 613de126af3SPyun YongHyeon #define VR_MODE2_DISABT 0x40 614de126af3SPyun YongHyeon #define VR_MODE2_MRDPL 0x08 /* VT6107A1 and above */ 615de126af3SPyun YongHyeon #define VR_MODE2_MODE10T 0x02 616de126af3SPyun YongHyeon 617de126af3SPyun YongHyeon #define VR_MODE3_XONOPT 0x80 618de126af3SPyun YongHyeon #define VR_MODE3_TPACEN 0x40 619de126af3SPyun YongHyeon #define VR_MODE3_BACKOPT 0x20 620de126af3SPyun YongHyeon #define VR_MODE3_DLTSEL 0x10 621de126af3SPyun YongHyeon #define VR_MODE3_MIIDMY 0x08 62297e6eca5SMike Silbersack #define VR_MODE3_MIION 0x04 623726ff6a1SBill Paul 624726ff6a1SBill Paul /* power management registers */ 625726ff6a1SBill Paul #define VR_PCI_CAPID 0xDC /* 8 bits */ 626726ff6a1SBill Paul #define VR_PCI_NEXTPTR 0xDD /* 8 bits */ 627726ff6a1SBill Paul #define VR_PCI_PWRMGMTCAP 0xDE /* 16 bits */ 628726ff6a1SBill Paul #define VR_PCI_PWRMGMTCTRL 0xE0 /* 16 bits */ 629726ff6a1SBill Paul 630726ff6a1SBill Paul #define VR_PSTATE_MASK 0x0003 631726ff6a1SBill Paul #define VR_PSTATE_D0 0x0000 632726ff6a1SBill Paul #define VR_PSTATE_D1 0x0002 633726ff6a1SBill Paul #define VR_PSTATE_D2 0x0002 634726ff6a1SBill Paul #define VR_PSTATE_D3 0x0003 635726ff6a1SBill Paul #define VR_PME_EN 0x0010 636726ff6a1SBill Paul #define VR_PME_STATUS 0x8000 637de126af3SPyun YongHyeon 638de126af3SPyun YongHyeon #define VR_RX_RING_CNT 128 639de126af3SPyun YongHyeon #define VR_TX_RING_CNT 128 640de126af3SPyun YongHyeon #define VR_TX_RING_SIZE sizeof(struct vr_desc) * VR_TX_RING_CNT 641de126af3SPyun YongHyeon #define VR_RX_RING_SIZE sizeof(struct vr_desc) * VR_RX_RING_CNT 642de126af3SPyun YongHyeon #define VR_RING_ALIGN sizeof(struct vr_desc) 643de126af3SPyun YongHyeon #define VR_RX_ALIGN sizeof(uint32_t) 644de126af3SPyun YongHyeon #define VR_MAXFRAGS 8 645de126af3SPyun YongHyeon #define VR_TX_INTR_THRESH 8 646de126af3SPyun YongHyeon 647de126af3SPyun YongHyeon #define VR_ADDR_LO(x) ((uint64_t)(x) & 0xffffffff) 648de126af3SPyun YongHyeon #define VR_ADDR_HI(x) ((uint64_t)(x) >> 32) 649de126af3SPyun YongHyeon #define VR_TX_RING_ADDR(sc, i) \ 650de126af3SPyun YongHyeon ((sc)->vr_rdata.vr_tx_ring_paddr + sizeof(struct vr_desc) * (i)) 651de126af3SPyun YongHyeon #define VR_RX_RING_ADDR(sc, i) \ 652de126af3SPyun YongHyeon ((sc)->vr_rdata.vr_rx_ring_paddr + sizeof(struct vr_desc) * (i)) 653de126af3SPyun YongHyeon #define VR_INC(x,y) (x) = (((x) + 1) % y) 654de126af3SPyun YongHyeon 655de126af3SPyun YongHyeon struct vr_txdesc { 656de126af3SPyun YongHyeon struct mbuf *tx_m; 657de126af3SPyun YongHyeon bus_dmamap_t tx_dmamap; 658de126af3SPyun YongHyeon }; 659de126af3SPyun YongHyeon 660de126af3SPyun YongHyeon struct vr_rxdesc { 661de126af3SPyun YongHyeon struct mbuf *rx_m; 662de126af3SPyun YongHyeon bus_dmamap_t rx_dmamap; 663de126af3SPyun YongHyeon struct vr_desc *desc; 664de126af3SPyun YongHyeon }; 665de126af3SPyun YongHyeon 666de126af3SPyun YongHyeon struct vr_chain_data { 667de126af3SPyun YongHyeon bus_dma_tag_t vr_parent_tag; 668de126af3SPyun YongHyeon bus_dma_tag_t vr_tx_tag; 669de126af3SPyun YongHyeon struct vr_txdesc vr_txdesc[VR_TX_RING_CNT]; 670de126af3SPyun YongHyeon bus_dma_tag_t vr_rx_tag; 671de126af3SPyun YongHyeon struct vr_rxdesc vr_rxdesc[VR_RX_RING_CNT]; 672de126af3SPyun YongHyeon bus_dma_tag_t vr_tx_ring_tag; 673de126af3SPyun YongHyeon bus_dma_tag_t vr_rx_ring_tag; 674de126af3SPyun YongHyeon bus_dmamap_t vr_tx_ring_map; 675de126af3SPyun YongHyeon bus_dmamap_t vr_rx_ring_map; 676de126af3SPyun YongHyeon bus_dmamap_t vr_rx_sparemap; 677de126af3SPyun YongHyeon int vr_tx_pkts; 678de126af3SPyun YongHyeon int vr_tx_prod; 679de126af3SPyun YongHyeon int vr_tx_cons; 680de126af3SPyun YongHyeon int vr_tx_cnt; 681de126af3SPyun YongHyeon int vr_rx_cons; 682de126af3SPyun YongHyeon }; 683de126af3SPyun YongHyeon 684de126af3SPyun YongHyeon struct vr_ring_data { 685de126af3SPyun YongHyeon struct vr_desc *vr_rx_ring; 686de126af3SPyun YongHyeon struct vr_desc *vr_tx_ring; 687de126af3SPyun YongHyeon bus_addr_t vr_rx_ring_paddr; 688de126af3SPyun YongHyeon bus_addr_t vr_tx_ring_paddr; 689de126af3SPyun YongHyeon }; 690de126af3SPyun YongHyeon 691de126af3SPyun YongHyeon struct vr_statistics { 692de126af3SPyun YongHyeon uint64_t tx_ok; 693de126af3SPyun YongHyeon uint64_t rx_ok; 694de126af3SPyun YongHyeon uint32_t tx_errors; 695de126af3SPyun YongHyeon uint32_t rx_errors; 696de126af3SPyun YongHyeon uint32_t rx_no_buffers; 697de126af3SPyun YongHyeon uint32_t rx_no_mbufs; 698de126af3SPyun YongHyeon uint32_t rx_crc_errors; 699de126af3SPyun YongHyeon uint32_t rx_alignment; 700de126af3SPyun YongHyeon uint32_t rx_fifo_overflows; 701de126af3SPyun YongHyeon uint32_t rx_giants; 702de126af3SPyun YongHyeon uint32_t rx_runts; 703de126af3SPyun YongHyeon uint32_t tx_abort; 704de126af3SPyun YongHyeon uint32_t tx_collisions; 705de126af3SPyun YongHyeon uint32_t tx_late_collisions; 706de126af3SPyun YongHyeon uint32_t tx_underrun; 707de126af3SPyun YongHyeon uint32_t bus_errors; 708de126af3SPyun YongHyeon uint32_t num_restart; 709de126af3SPyun YongHyeon }; 710de126af3SPyun YongHyeon 711de126af3SPyun YongHyeon struct vr_softc { 712*0d102534SJustin Hibbits if_t vr_ifp; /* interface info */ 713de126af3SPyun YongHyeon device_t vr_dev; 714de126af3SPyun YongHyeon struct resource *vr_res; 715de126af3SPyun YongHyeon int vr_res_id; 716de126af3SPyun YongHyeon int vr_res_type; 717de126af3SPyun YongHyeon struct resource *vr_irq; 718de126af3SPyun YongHyeon void *vr_intrhand; 719de126af3SPyun YongHyeon device_t vr_miibus; 720de126af3SPyun YongHyeon uint8_t vr_revid; /* Rhine chip revision */ 7217d45b35cSPyun YongHyeon int vr_flags; /* See VR_F_* below */ 7227d45b35cSPyun YongHyeon #define VR_F_RESTART 0x0001 /* Restart unit on next tick */ 723649ab165SPyun YongHyeon #define VR_F_TXPAUSE 0x0010 7247d45b35cSPyun YongHyeon #define VR_F_SUSPENDED 0x2000 7257d45b35cSPyun YongHyeon #define VR_F_DETACHED 0x4000 7267d45b35cSPyun YongHyeon #define VR_F_LINK 0x8000 727de126af3SPyun YongHyeon int vr_if_flags; 728de126af3SPyun YongHyeon struct vr_chain_data vr_cdata; 729de126af3SPyun YongHyeon struct vr_ring_data vr_rdata; 730de126af3SPyun YongHyeon struct vr_statistics vr_stat; 731de126af3SPyun YongHyeon struct callout vr_stat_callout; 732de126af3SPyun YongHyeon struct mtx vr_mtx; 733de126af3SPyun YongHyeon int vr_quirks; 734de126af3SPyun YongHyeon int vr_watchdog_timer; 735de126af3SPyun YongHyeon int vr_txthresh; 736de126af3SPyun YongHyeon #ifdef DEVICE_POLLING 737de126af3SPyun YongHyeon int rxcycles; 738de126af3SPyun YongHyeon #endif 73982f98de5SRui Paulo struct task vr_inttask; 740de126af3SPyun YongHyeon }; 741de126af3SPyun YongHyeon 742de126af3SPyun YongHyeon #define VR_LOCK(_sc) mtx_lock(&(_sc)->vr_mtx) 743de126af3SPyun YongHyeon #define VR_UNLOCK(_sc) mtx_unlock(&(_sc)->vr_mtx) 744de126af3SPyun YongHyeon #define VR_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->vr_mtx, MA_OWNED) 745de126af3SPyun YongHyeon 746de126af3SPyun YongHyeon /* 747de126af3SPyun YongHyeon * register space access macros 748de126af3SPyun YongHyeon */ 749de126af3SPyun YongHyeon #define CSR_WRITE_4(sc, reg, val) bus_write_4(sc->vr_res, reg, val) 750de126af3SPyun YongHyeon #define CSR_WRITE_2(sc, reg, val) bus_write_2(sc->vr_res, reg, val) 751de126af3SPyun YongHyeon #define CSR_WRITE_1(sc, reg, val) bus_write_1(sc->vr_res, reg, val) 752de126af3SPyun YongHyeon 753de126af3SPyun YongHyeon #define CSR_READ_2(sc, reg) bus_read_2(sc->vr_res, reg) 754de126af3SPyun YongHyeon #define CSR_READ_1(sc, reg) bus_read_1(sc->vr_res, reg) 755de126af3SPyun YongHyeon 756de126af3SPyun YongHyeon #define VR_SETBIT(sc, reg, x) CSR_WRITE_1(sc, reg, CSR_READ_1(sc, reg) | (x)) 757de126af3SPyun YongHyeon #define VR_CLRBIT(sc, reg, x) CSR_WRITE_1(sc, reg, CSR_READ_1(sc, reg) & ~(x)) 758de126af3SPyun YongHyeon 759de126af3SPyun YongHyeon #define VR_SETBIT16(sc, reg, x) CSR_WRITE_2(sc, reg, CSR_READ_2(sc, reg) | (x)) 760de126af3SPyun YongHyeon #define VR_CLRBIT16(sc, reg, x) CSR_WRITE_2(sc, reg, CSR_READ_2(sc, reg) & ~(x)) 7616b284b78SPyun YongHyeon 7626b284b78SPyun YongHyeon #define VR_MCAST_CAM 0 7636b284b78SPyun YongHyeon #define VR_VLAN_CAM 1 764