1 /* $OpenBSD: if_vrreg.h,v 1.28 2011/03/13 15:38:50 stsp Exp $ */ 2 3 /* 4 * Copyright (c) 1997, 1998 5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Bill Paul. 18 * 4. Neither the name of the author nor the names of any co-contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * $FreeBSD: src/sys/pci/if_vrreg.h,v 1.17 2003/02/01 01:27:05 silby Exp $ 35 */ 36 37 /* 38 * Rhine register definitions. 39 */ 40 41 #define VR_PAR0 0x00 /* node address 0 to 4 */ 42 #define VR_PAR1 0x04 /* node address 2 to 6 */ 43 #define VR_RXCFG 0x06 /* receiver config register */ 44 #define VR_TXCFG 0x07 /* transmit config register */ 45 #define VR_COMMAND 0x08 /* command register */ 46 #define VR_TQWK 0x0A /* transmit queue wake */ 47 #define VR_ISR 0x0C /* interrupt/status register */ 48 #define VR_IMR 0x0E /* interrupt mask register */ 49 #define VR_MAR0 0x10 /* multicast hash 0 */ 50 #define VR_MAR1 0x14 /* multicast hash 1 */ 51 #define VR_RXADDR 0x18 /* rx descriptor list start addr */ 52 #define VR_TXADDR 0x1C /* tx descriptor list start addr */ 53 #define VR_CURRXDESC0 0x20 54 #define VR_CURRXDESC1 0x24 55 #define VR_CURRXDESC2 0x28 56 #define VR_CURRXDESC3 0x2C 57 #define VR_NEXTRXDESC0 0x30 58 #define VR_NEXTRXDESC1 0x34 59 #define VR_NEXTRXDESC2 0x38 60 #define VR_NEXTRXDESC3 0x3C 61 #define VR_CURTXDESC0 0x40 62 #define VR_CURTXDESC1 0x44 63 #define VR_CURTXDESC2 0x48 64 #define VR_CURTXDESC3 0x4C 65 #define VR_NEXTTXDESC0 0x50 66 #define VR_NEXTTXDESC1 0x54 67 #define VR_NEXTTXDESC2 0x58 68 #define VR_NEXTTXDESC3 0x5C 69 #define VR_CURRXDMA 0x60 /* current RX DMA address */ 70 #define VR_CURTXDMA 0x64 /* current TX DMA address */ 71 #define VR_TALLYCNT 0x68 /* tally counter test register */ 72 #define VR_PHYADDR 0x6C 73 #define VR_MIISTAT 0x6D 74 #define VR_BCR0 0x6E 75 #define VR_BCR1 0x6F 76 #define VR_MIICMD 0x70 77 #define VR_MIIADDR 0x71 78 #define VR_MIIDATA 0x72 79 #define VR_EECSR 0x74 80 #define VR_TEST 0x75 81 #define VR_GPIO 0x76 82 #define VR_CONFIG 0x78 83 #define VR_MPA_CNT 0x7C 84 #define VR_CRC_CNT 0x7E 85 #define VR_STICKHW 0x83 86 87 /* Misc Registers */ 88 #define VR_MISC_CR1 0x81 89 #define VR_MISCCR1_FORSRST 0x40 90 91 /* 92 * RX config bits. 93 */ 94 #define VR_RXCFG_RX_ERRPKTS 0x01 95 #define VR_RXCFG_RX_RUNT 0x02 96 #define VR_RXCFG_RX_MULTI 0x04 97 #define VR_RXCFG_RX_BROAD 0x08 98 #define VR_RXCFG_RX_PROMISC 0x10 99 #define VR_RXCFG_RX_THRESH 0xE0 100 101 #define VR_RXTHRESH_32BYTES 0x00 102 #define VR_RXTHRESH_64BYTES 0x20 103 #define VR_RXTHRESH_128BYTES 0x40 104 #define VR_RXTHRESH_256BYTES 0x60 105 #define VR_RXTHRESH_512BYTES 0x80 106 #define VR_RXTHRESH_768BYTES 0xA0 107 #define VR_RXTHRESH_1024BYTES 0xC0 108 #define VR_RXTHRESH_STORENFWD 0xE0 109 110 /* 111 * TX config bits. 112 */ 113 #define VR_TXCFG_TXTAGEN 0x01 /* 6105M */ 114 #define VR_TXCFG_LOOPBKMODE 0x06 115 #define VR_TXCFG_BACKOFF 0x08 116 #define VR_TXCFG_TX_THRESH 0xE0 117 118 #define VR_TXTHRESH_32BYTES 0x00 119 #define VR_TXTHRESH_64BYTES 0x20 120 #define VR_TXTHRESH_128BYTES 0x40 121 #define VR_TXTHRESH_256BYTES 0x60 122 #define VR_TXTHRESH_512BYTES 0x80 123 #define VR_TXTHRESH_768BYTES 0xA0 124 #define VR_TXTHRESH_1024BYTES 0xC0 125 #define VR_TXTHRESH_STORENFWD 0xE0 126 127 /* 128 * Command register bits. 129 */ 130 #define VR_CMD_INIT 0x0001 131 #define VR_CMD_START 0x0002 132 #define VR_CMD_STOP 0x0004 133 #define VR_CMD_RX_ON 0x0008 134 #define VR_CMD_TX_ON 0x0010 135 #define VR_CMD_TX_GO 0x0020 136 #define VR_CMD_RX_GO 0x0040 137 #define VR_CMD_RSVD 0x0080 138 #define VR_CMD_RX_EARLY 0x0100 139 #define VR_CMD_TX_EARLY 0x0200 140 #define VR_CMD_FULLDUPLEX 0x0400 141 #define VR_CMD_TX_NOPOLL 0x0800 142 143 #define VR_CMD_RESET 0x8000 144 145 /* 146 * Interrupt status bits. 147 */ 148 #define VR_ISR_RX_OK 0x0001 /* packet rx ok */ 149 #define VR_ISR_TX_OK 0x0002 /* packet tx ok */ 150 #define VR_ISR_RX_ERR 0x0004 /* packet rx with err */ 151 #define VR_ISR_TX_ABRT 0x0008 /* tx aborted due to excess colls */ 152 #define VR_ISR_TX_UNDERRUN 0x0010 /* tx buffer underflow */ 153 #define VR_ISR_RX_NOBUF 0x0020 /* no rx buffer available */ 154 #define VR_ISR_BUSERR 0x0040 /* PCI bus error */ 155 #define VR_ISR_STATSOFLOW 0x0080 /* stats counter oflow */ 156 #define VR_ISR_RX_EARLY 0x0100 /* rx early */ 157 #define VR_ISR_LINKSTAT 0x0200 /* MII status change */ 158 #define VR_ISR_ETI 0x0200 /* Tx early (3043/3071) */ 159 #define VR_ISR_UDFI 0x0200 /* Tx FIFO underflow (3065) */ 160 #define VR_ISR_RX_OFLOW 0x0400 /* rx FIFO overflow */ 161 #define VR_ISR_RX_DROPPED 0x0800 162 #define VR_ISR_RX_NOBUF2 0x1000 163 #define VR_ISR_TX_ABRT2 0x2000 164 #define VR_ISR_LINKSTAT2 0x4000 165 #define VR_ISR_MAGICPACKET 0x8000 166 167 /* 168 * Interrupt mask bits. 169 */ 170 #define VR_IMR_RX_OK 0x0001 /* packet rx ok */ 171 #define VR_IMR_TX_OK 0x0002 /* packet tx ok */ 172 #define VR_IMR_RX_ERR 0x0004 /* packet rx with err */ 173 #define VR_IMR_TX_ABRT 0x0008 /* tx aborted due to excess colls */ 174 #define VR_IMR_TX_UNDERRUN 0x0010 /* tx buffer underflow */ 175 #define VR_IMR_RX_NOBUF 0x0020 /* no rx buffer available */ 176 #define VR_IMR_BUSERR 0x0040 /* PCI bus error */ 177 #define VR_IMR_STATSOFLOW 0x0080 /* stats counter oflow */ 178 #define VR_IMR_RX_EARLY 0x0100 /* rx early */ 179 #define VR_IMR_LINKSTAT 0x0200 /* MII status change */ 180 #define VR_IMR_RX_OFLOW 0x0400 /* rx FIFO overflow */ 181 #define VR_IMR_RX_DROPPED 0x0800 182 #define VR_IMR_RX_NOBUF2 0x1000 183 #define VR_IMR_TX_ABRT2 0x2000 184 #define VR_IMR_LINKSTAT2 0x4000 185 #define VR_IMR_MAGICPACKET 0x8000 186 187 #define VR_INTRS \ 188 (VR_IMR_RX_OK|VR_IMR_TX_OK|VR_IMR_RX_NOBUF| \ 189 VR_IMR_TX_ABRT|VR_IMR_TX_UNDERRUN|VR_IMR_BUSERR| \ 190 VR_IMR_RX_ERR|VR_ISR_RX_DROPPED) 191 192 /* 193 * MII status register. 194 */ 195 196 #define VR_MIISTAT_SPEED 0x01 197 #define VR_MIISTAT_LINKFAULT 0x02 198 #define VR_MIISTAT_MGTREADERR 0x04 199 #define VR_MIISTAT_MIIERR 0x08 200 #define VR_MIISTAT_PHYOPT 0x10 201 #define VR_MIISTAT_MDC_SPEED 0x20 202 #define VR_MIISTAT_RSVD 0x40 203 #define VR_MIISTAT_GPIO1POLL 0x80 204 205 /* 206 * MII command register bits. 207 */ 208 #define VR_MIICMD_CLK 0x01 209 #define VR_MIICMD_DATAOUT 0x02 210 #define VR_MIICMD_DATAIN 0x04 211 #define VR_MIICMD_DIR 0x08 212 #define VR_MIICMD_DIRECTPGM 0x10 213 #define VR_MIICMD_WRITE_ENB 0x20 214 #define VR_MIICMD_READ_ENB 0x40 215 #define VR_MIICMD_AUTOPOLL 0x80 216 217 /* 218 * EEPROM control bits. 219 */ 220 #define VR_EECSR_DATAIN 0x01 /* data out */ 221 #define VR_EECSR_DATAOUT 0x02 /* data in */ 222 #define VR_EECSR_CLK 0x04 /* clock */ 223 #define VR_EECSR_CS 0x08 /* chip select */ 224 #define VR_EECSR_DPM 0x10 225 #define VR_EECSR_LOAD 0x20 226 #define VR_EECSR_EMBP 0x40 227 #define VR_EECSR_EEPR 0x80 228 229 #define VR_EECMD_WRITE 0x140 230 #define VR_EECMD_READ 0x180 231 #define VR_EECMD_ERASE 0x1c0 232 233 /* 234 * Test register bits. 235 */ 236 #define VR_TEST_TEST0 0x01 237 #define VR_TEST_TEST1 0x02 238 #define VR_TEST_TEST2 0x04 239 #define VR_TEST_TSTUD 0x08 240 #define VR_TEST_TSTOV 0x10 241 #define VR_TEST_BKOFF 0x20 242 #define VR_TEST_FCOL 0x40 243 #define VR_TEST_HBDES 0x80 244 245 /* 246 * Config register bits. 247 */ 248 #define VR_CFG_PREACPIWAKE 0x00000001 /* pre-acpi wake */ 249 #define VR_CFG_ABNORMALWAKE 0x00000002 /* abnormal shut down wake */ 250 #define VR_CFG_RSVD0 0x00000004 251 #define VR_CFG_LED0 0x00000008 252 #define VR_CFG_LED1 0x00000010 253 #define VR_CFG_TAGCRC 0x00000020 /* 6105M tag in CRC */ 254 #define VR_CFG_MIIOPT 0x00000040 /* MII extension clock */ 255 #define VR_CFG_EELOAD 0x00000080 /* enable EEPROM programming */ 256 #define VR_CFG_LATMENB 0x00000100 /* larency timer effect enb. */ 257 #define VR_CFG_MRREADWAIT 0x00000200 258 #define VR_CFG_MRWRITEWAIT 0x00000400 259 #define VR_CFG_RX_ARB 0x00000800 260 #define VR_CFG_TX_ARB 0x00001000 261 #define VR_CFG_READMULTI 0x00002000 262 #define VR_CFG_TX_PACE 0x00004000 263 #define VR_CFG_TX_QDIS 0x00008000 264 #define VR_CFG_ROMSEL0 0x00010000 265 #define VR_CFG_ROMSEL1 0x00020000 266 #define VR_CFG_ROMSEL2 0x00040000 267 #define VR_CFG_ROMTIMESEL 0x00080000 268 #define VR_CFG_RSVD1 0x00100000 269 #define VR_CFG_ROMDLY 0x00200000 270 #define VR_CFG_ROMOPT 0x00400000 271 #define VR_CFG_RSVD2 0x00800000 272 #define VR_CFG_BACKOFFOPT 0x01000000 273 #define VR_CFG_BACKOFFMOD 0x02000000 274 #define VR_CFG_CAPEFFECT 0x04000000 275 #define VR_CFG_BACKOFFRAND 0x08000000 276 #define VR_CFG_MAGICKPACKET 0x10000000 277 #define VR_CFG_PCIREADLINE 0x20000000 278 #define VR_CFG_DIAG 0x40000000 279 #define VR_CFG_GPIOEN 0x80000000 280 281 /* Sticky HW bits */ 282 #define VR_STICKHW_DS0 0x01 283 #define VR_STICKHW_DS1 0x02 284 #define VR_STICKHW_WOL_ENB 0x04 285 #define VR_STICKHW_WOL_STS 0x08 286 #define VR_STICKHW_LEGWOL_ENB 0x80 287 288 /* Wake on Lan */ 289 #define VR_WOLCRSET 0xA0 290 #define VR_PWRCFGSET 0xA1 291 #define VR_WOLCFGSET 0xA3 292 #define VR_WOLCRCLR 0xA4 293 #define VR_PWRCFGCLR 0xA5 294 #define VR_WOLCFGCLR 0xA7 295 #define VR_PWRCSRSET 0xA8 296 #define VR_PWRCSRCLR 0xAC 297 #define VR_WOLCR_UCAST 0x10 298 #define VR_WOLCR_MAGIC 0x20 299 #define VR_WOLCR_LINKON 0x40 300 #define VR_WOLCR_LINKOFF 0x80 301 #define VR_WOLCFG_PMEOVR 0x80 302 303 /* 304 * BCR0 register bits. (At least for the VT6102 chip.) 305 */ 306 #define VR_BCR0_DMA_LENGTH 0x07 307 308 #define VR_BCR0_DMA_32BYTES 0x00 309 #define VR_BCR0_DMA_64BYTES 0x01 310 #define VR_BCR0_DMA_128BYTES 0x02 311 #define VR_BCR0_DMA_256BYTES 0x03 312 #define VR_BCR0_DMA_512BYTES 0x04 313 #define VR_BCR0_DMA_1024BYTES 0x05 314 #define VR_BCR0_DMA_STORENFWD 0x07 315 316 #define VR_BCR0_RX_THRESH 0x38 317 318 #define VR_BCR0_RXTHRESHCFG 0x00 319 #define VR_BCR0_RXTHRESH64BYTES 0x08 320 #define VR_BCR0_RXTHRESH128BYTES 0x10 321 #define VR_BCR0_RXTHRESH256BYTES 0x18 322 #define VR_BCR0_RXTHRESH512BYTES 0x20 323 #define VR_BCR0_RXTHRESH1024BYTES 0x28 324 #define VR_BCR0_RXTHRESHSTORENFWD 0x38 325 #define VR_BCR0_EXTLED 0x40 326 #define VR_BCR0_MED2 0x80 327 328 /* 329 * BCR1 register bits. (At least for the VT6102 chip.) 330 */ 331 #define VR_BCR1_POT0 0x01 332 #define VR_BCR1_POT1 0x02 333 #define VR_BCR1_POT2 0x04 334 #define VR_BCR1_TX_THRESH 0x38 335 #define VR_BCR1_TXTHRESHCFG 0x00 336 #define VR_BCR1_TXTHRESH64BYTES 0x08 337 #define VR_BCR1_TXTHRESH128BYTES 0x10 338 #define VR_BCR1_TXTHRESH256BYTES 0x18 339 #define VR_BCR1_TXTHRESH512BYTES 0x20 340 #define VR_BCR1_TXTHRESH1024BYTES 0x28 341 #define VR_BCR1_TXTHRESHSTORENFWD 0x38 342 #define VR_BCR1_VLANFILT_ENB 0x80 /* 6105M */ 343 344 /* 345 * Rhine TX/RX list structure. 346 */ 347 348 struct vr_desc { 349 u_int32_t vr_status; 350 u_int32_t vr_ctl; 351 u_int32_t vr_data; 352 u_int32_t vr_next; 353 }; 354 355 #define VR_RXSTAT_RXERR 0x00000001 356 #define VR_RXSTAT_CRCERR 0x00000002 357 #define VR_RXSTAT_FRAMEALIGNERR 0x00000004 358 #define VR_RXSTAT_FIFOOFLOW 0x00000008 359 #define VR_RXSTAT_GIANT 0x00000010 360 #define VR_RXSTAT_RUNT 0x00000020 361 #define VR_RXSTAT_BUSERR 0x00000040 362 #define VR_RXSTAT_FRAG 0x00000040 /* 6105M */ 363 #define VR_RXSTAT_BUFFERR 0x00000080 364 #define VR_RXSTAT_LASTFRAG 0x00000100 365 #define VR_RXSTAT_FIRSTFRAG 0x00000200 366 #define VR_RXSTAT_RLINK 0x00000400 367 #define VR_RXSTAT_RX_PHYS 0x00000800 368 #define VR_RXSTAT_RX_BROAD 0x00001000 369 #define VR_RXSTAT_RX_MULTI 0x00002000 370 #define VR_RXSTAT_RX_VIDHIT 0x00004000 /* 6105M */ 371 #define VR_RXSTAT_RX_OK 0x00008000 372 #define VR_RXSTAT_RXLEN 0x07FF0000 373 #define VR_RXSTAT_RXLEN_EXT 0x78000000 374 #define VR_RXSTAT_OWN 0x80000000 375 376 #define VR_RXBYTES(x) ((x & VR_RXSTAT_RXLEN) >> 16) 377 #define VR_RXSTAT (VR_RXSTAT_FIRSTFRAG|VR_RXSTAT_LASTFRAG|VR_RXSTAT_OWN) 378 379 #define VR_RXCTL_BUFLEN 0x000007FF 380 #define VR_RXCTL_BUFLEN_EXT 0x00007800 381 #define VR_RXCTL_CHAIN 0x00008000 382 #define VR_RXCTL_TAG 0x00010000 383 #define VR_RXCTL_UDP 0x00020000 384 #define VR_RXCTL_TCP 0x00040000 385 #define VR_RXCTL_IP 0x00080000 386 #define VR_RXCTL_TCPUDPOK 0x00100000 387 #define VR_RXCTL_IPOK 0x00200000 388 #define VR_RXCTL_SNAPTAG 0x00400000 389 #define VR_RXCTL_RXLERR 0x00800000 /* 6105M */ 390 #define VR_RXCTL_RX_INTR 0x00800000 391 392 #define VR_RXCTL (VR_RXCTL_CHAIN|VR_RXCTL_RX_INTR) 393 394 #define VR_TXSTAT_DEFER 0x00000001 395 #define VR_TXSTAT_UNDERRUN 0x00000002 396 #define VR_TXSTAT_COLLCNT 0x00000078 397 #define VR_TXSTAT_SQE 0x00000080 398 #define VR_TXSTAT_ABRT 0x00000100 399 #define VR_TXSTAT_LATECOLL 0x00000200 400 #define VR_TXSTAT_CARRLOST 0x00000400 401 #define VR_TXSTAT_UDF 0x00000800 402 #define VR_TXSTAT_BUSERR 0x00002000 403 #define VR_TXSTAT_JABTIMEO 0x00004000 404 #define VR_TXSTAT_ERRSUM 0x00008000 405 #define VR_TXSTAT_PQMASK 0x7FFF0000 406 #define VR_TXSTAT_OWN 0x80000000 407 408 #define VR_TXCTL_BUFLEN 0x000007FF 409 #define VR_TXCTL_BUFLEN_EXT 0x00007800 410 #define VR_TXCTL_TLINK 0x00008000 411 #define VR_TXCTL_NOCRC 0x00010000 412 #define VR_TXCTL_INSERTTAG 0x00020000 413 #define VR_TXCTL_IPCSUM 0x00040000 414 #define VR_TXCTL_UDPCSUM 0x00080000 415 #define VR_TXCTL_TCPCSUM 0x00100000 416 #define VR_TXCTL_FIRSTFRAG 0x00200000 417 #define VR_TXCTL_LASTFRAG 0x00400000 418 #define VR_TXCTL_FINT 0x00800000 419 420 #define VR_MAXFRAGS 16 421 #define VR_RX_LIST_CNT 64 422 #define VR_TX_LIST_CNT 128 423 #define VR_MIN_FRAMELEN 60 424 #define VR_RXLEN 1524 425 426 #define VR_TXOWN(x) x->vr_ptr->vr_status 427 428 struct vr_list_data { 429 struct vr_desc vr_rx_list[VR_RX_LIST_CNT]; 430 struct vr_desc vr_tx_list[VR_TX_LIST_CNT]; 431 }; 432 433 struct vr_chain { 434 struct vr_desc *vr_ptr; 435 struct mbuf *vr_mbuf; 436 struct vr_chain *vr_nextdesc; 437 bus_addr_t vr_paddr; 438 bus_dmamap_t vr_map; 439 }; 440 441 struct vr_chain_onefrag { 442 struct vr_desc *vr_ptr; 443 struct vr_chain_onefrag *vr_nextdesc; 444 struct mbuf *vr_mbuf; 445 bus_addr_t vr_paddr; 446 bus_dmamap_t vr_map; 447 }; 448 449 struct vr_chain_data { 450 struct vr_chain_onefrag vr_rx_chain[VR_RX_LIST_CNT]; 451 struct vr_chain vr_tx_chain[VR_TX_LIST_CNT]; 452 453 struct vr_chain_onefrag *vr_rx_cons; 454 struct vr_chain_onefrag *vr_rx_prod; 455 int vr_rx_cnt; 456 457 struct vr_chain *vr_tx_cons; 458 struct vr_chain *vr_tx_prod; 459 }; 460 461 struct vr_mii_frame { 462 u_int8_t mii_stdelim; 463 u_int8_t mii_opcode; 464 u_int8_t mii_phyaddr; 465 u_int8_t mii_regaddr; 466 u_int8_t mii_turnaround; 467 u_int16_t mii_data; 468 }; 469 470 /* 471 * MII constants 472 */ 473 #define VR_MII_STARTDELIM 0x01 474 #define VR_MII_READOP 0x02 475 #define VR_MII_WRITEOP 0x01 476 #define VR_MII_TURNAROUND 0x02 477 478 #define VR_FLAG_FORCEDELAY 1 479 #define VR_FLAG_SCHEDDELAY 2 480 #define VR_FLAG_DELAYTIMEO 3 481 482 struct vr_softc { 483 struct device sc_dev; /* generic device structure */ 484 void * sc_ih; /* interrupt handler cookie */ 485 struct arpcom arpcom; /* interface info */ 486 bus_space_handle_t vr_bhandle; /* bus space handle */ 487 bus_space_tag_t vr_btag; /* bus space tag */ 488 bus_dma_tag_t sc_dmat; 489 struct vr_type *vr_info; /* Rhine adapter info */ 490 u_int8_t vr_revid; /* Rhine chip revision */ 491 u_int8_t vr_flags; /* See VR_F_* below */ 492 struct vr_list_data *vr_ldata; 493 struct vr_chain_data vr_cdata; 494 struct mii_data sc_mii; 495 struct timeout sc_to; 496 bus_dmamap_t sc_listmap; /* descriptor list map */ 497 bus_dma_segment_t sc_listseg; 498 int sc_rxbufs; 499 int vr_link; 500 int vr_quirks; 501 }; 502 503 #define VR_F_RESTART 0x01 /* Restart unit on next tick */ 504 505 /* 506 * register space access macros 507 */ 508 #define CSR_WRITE_4(sc, reg, val) \ 509 bus_space_write_4(sc->vr_btag, sc->vr_bhandle, reg, val) 510 #define CSR_WRITE_2(sc, reg, val) \ 511 bus_space_write_2(sc->vr_btag, sc->vr_bhandle, reg, val) 512 #define CSR_WRITE_1(sc, reg, val) \ 513 bus_space_write_1(sc->vr_btag, sc->vr_bhandle, reg, val) 514 515 #define CSR_READ_4(sc, reg) \ 516 bus_space_read_4(sc->vr_btag, sc->vr_bhandle, reg) 517 #define CSR_READ_2(sc, reg) \ 518 bus_space_read_2(sc->vr_btag, sc->vr_bhandle, reg) 519 #define CSR_READ_1(sc, reg) \ 520 bus_space_read_1(sc->vr_btag, sc->vr_bhandle, reg) 521 522 #define VR_TIMEOUT 1000 523 524 /* 525 * VIA Rhine revision IDs 526 */ 527 528 #define REV_ID_VT3043_E 0x04 529 #define REV_ID_VT3071_A 0x20 530 #define REV_ID_VT3071_B 0x21 531 #define REV_ID_VT3065_A 0x40 532 #define REV_ID_VT3065_B 0x41 533 #define REV_ID_VT3065_C 0x42 534 #define REV_ID_VT6102_APOLLO 0x74 535 #define REV_ID_VT6103 0x78 536 #define REV_ID_VT3106 0x80 537 #define REV_ID_VT3106_J 0x80 /* 0x80-0x8F */ 538 #define REV_ID_VT3106_S 0x90 /* 0x90-0xA0 */ 539 #define REV_ID_VT6105M_A0 0x90 540 #define REV_ID_VT6105M_B1 0x94 541 542 /* 543 * PCI low memory base and low I/O base register, and 544 * other PCI registers. 545 */ 546 547 #define VR_PCI_VENDOR_ID 0x00 548 #define VR_PCI_DEVICE_ID 0x02 549 #define VR_PCI_COMMAND 0x04 550 #define VR_PCI_STATUS 0x06 551 #define VR_PCI_REVID 0x08 552 #define VR_PCI_CLASSCODE 0x09 553 #define VR_PCI_LATENCY_TIMER 0x0D 554 #define VR_PCI_HEADER_TYPE 0x0E 555 #define VR_PCI_LOIO 0x10 556 #define VR_PCI_LOMEM 0x14 557 #define VR_PCI_BIOSROM 0x30 558 #define VR_PCI_INTLINE 0x3C 559 #define VR_PCI_INTPIN 0x3D 560 #define VR_PCI_MINGNT 0x3E 561 #define VR_PCI_MINLAT 0x0F 562 #define VR_PCI_RESETOPT 0x48 563 #define VR_PCI_EEPROM_DATA 0x4C 564 #define VR_PCI_MODE 0x50 565 566 #define VR_MODE3_MIION 0x04 567 568 /* power management registers */ 569 #define VR_PCI_CAPID 0xDC /* 8 bits */ 570 #define VR_PCI_NEXTPTR 0xDD /* 8 bits */ 571 #define VR_PCI_PWRMGMTCAP 0xDE /* 16 bits */ 572 #define VR_PCI_PWRMGMTCTRL 0xE0 /* 16 bits */ 573 574 #define VR_PSTATE_MASK 0x0003 575 #define VR_PSTATE_D0 0x0000 576 #define VR_PSTATE_D1 0x0002 577 #define VR_PSTATE_D2 0x0002 578 #define VR_PSTATE_D3 0x0003 579 #define VR_PME_EN 0x0010 580 #define VR_PME_STATUS 0x8000 581