1 /* $NetBSD: tulipvar.h,v 1.64 2009/04/17 15:22:35 cegger Exp $ */ 2 3 /*- 4 * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * NASA Ames Research Center. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _DEV_IC_TULIPVAR_H_ 34 #define _DEV_IC_TULIPVAR_H_ 35 36 #include "rnd.h" 37 38 #include <sys/queue.h> 39 #include <sys/callout.h> 40 41 #if NRND > 0 42 #include <sys/rnd.h> 43 #endif 44 45 /* 46 * Misc. definitions for the Digital Semiconductor ``Tulip'' (21x4x) 47 * Ethernet controller family driver. 48 */ 49 50 /* 51 * Transmit descriptor list size. This is arbitrary, but allocate 52 * enough descriptors for 64 pending transmissions and 16 segments 53 * per packet. Since a descriptor holds 2 buffer addresses, that's 54 * 8 descriptors per packet. This MUST work out to a power of 2. 55 */ 56 #define TULIP_NTXSEGS 16 57 58 #define TULIP_TXQUEUELEN 64 59 #define TULIP_NTXDESC (TULIP_TXQUEUELEN * TULIP_NTXSEGS) 60 #define TULIP_NTXDESC_MASK (TULIP_NTXDESC - 1) 61 #define TULIP_NEXTTX(x) ((x + 1) & TULIP_NTXDESC_MASK) 62 63 /* 64 * Receive descriptor list size. We have one Rx buffer per incoming 65 * packet, so this logic is a little simpler. 66 */ 67 #define TULIP_NRXDESC 64 68 #define TULIP_NRXDESC_MASK (TULIP_NRXDESC - 1) 69 #define TULIP_NEXTRX(x) ((x + 1) & TULIP_NRXDESC_MASK) 70 71 /* 72 * Control structures are DMA'd to the TULIP chip. We allocate them in 73 * a single clump that maps to a single DMA segment to make several things 74 * easier. 75 */ 76 struct tulip_control_data { 77 /* 78 * The transmit descriptors. 79 */ 80 struct tulip_desc tcd_txdescs[TULIP_NTXDESC]; 81 82 /* 83 * The receive descriptors. 84 */ 85 struct tulip_desc tcd_rxdescs[TULIP_NRXDESC]; 86 87 /* 88 * The setup packet. 89 */ 90 uint32_t tcd_setup_packet[TULIP_SETUP_PACKET_LEN / sizeof(uint32_t)]; 91 }; 92 93 #define TULIP_CDOFF(x) offsetof(struct tulip_control_data, x) 94 #define TULIP_CDTXOFF(x) TULIP_CDOFF(tcd_txdescs[(x)]) 95 #define TULIP_CDRXOFF(x) TULIP_CDOFF(tcd_rxdescs[(x)]) 96 #define TULIP_CDSPOFF TULIP_CDOFF(tcd_setup_packet) 97 98 /* 99 * Software state for transmit jobs. 100 */ 101 struct tulip_txsoft { 102 struct mbuf *txs_mbuf; /* head of our mbuf chain */ 103 bus_dmamap_t txs_dmamap; /* our DMA map */ 104 int txs_firstdesc; /* first descriptor in packet */ 105 int txs_lastdesc; /* last descriptor in packet */ 106 int txs_ndescs; /* number of descriptors */ 107 SIMPLEQ_ENTRY(tulip_txsoft) txs_q; 108 }; 109 110 SIMPLEQ_HEAD(tulip_txsq, tulip_txsoft); 111 112 /* 113 * Software state for receive jobs. 114 */ 115 struct tulip_rxsoft { 116 struct mbuf *rxs_mbuf; /* head of our mbuf chain */ 117 bus_dmamap_t rxs_dmamap; /* our DMA map */ 118 }; 119 120 /* 121 * Type of Tulip chip we're dealing with. 122 */ 123 typedef enum { 124 TULIP_CHIP_INVALID = 0, /* invalid chip type */ 125 TULIP_CHIP_DE425 = 1, /* DE-425 EISA */ 126 TULIP_CHIP_21040 = 2, /* DECchip 21040 */ 127 TULIP_CHIP_21041 = 3, /* DECchip 21041 */ 128 TULIP_CHIP_21140 = 4, /* DECchip 21140 */ 129 TULIP_CHIP_21140A = 5, /* DECchip 21140A */ 130 TULIP_CHIP_21142 = 6, /* DECchip 21142 */ 131 TULIP_CHIP_21143 = 7, /* DECchip 21143 */ 132 TULIP_CHIP_82C168 = 8, /* Lite-On 82C168 PNIC */ 133 TULIP_CHIP_82C169 = 9, /* Lite-On 82C169 PNIC */ 134 TULIP_CHIP_82C115 = 10, /* Lite-On 82C115 PNIC II */ 135 TULIP_CHIP_MX98713 = 11, /* Macronix 98713 PMAC */ 136 TULIP_CHIP_MX98713A = 12, /* Macronix 98713A PMAC */ 137 TULIP_CHIP_MX98715 = 13, /* Macronix 98715 PMAC */ 138 TULIP_CHIP_MX98715A = 14, /* Macronix 98715A PMAC */ 139 TULIP_CHIP_MX98715AEC_X = 15, /* Macronix 98715AEC-C, -E PMAC */ 140 TULIP_CHIP_MX98725 = 16, /* Macronix 98725 PMAC */ 141 TULIP_CHIP_WB89C840F = 17, /* Winbond 89C840F */ 142 TULIP_CHIP_DM9102 = 18, /* Davicom DM9102 */ 143 TULIP_CHIP_DM9102A = 19, /* Davicom DM9102A */ 144 TULIP_CHIP_AL981 = 20, /* ADMtek AL981 */ 145 TULIP_CHIP_AN983 = 21, /* ADMtek AN983 */ 146 TULIP_CHIP_AN985 = 22, /* ADMtek AN985 */ 147 TULIP_CHIP_AX88140 = 23, /* ASIX AX88140 */ 148 TULIP_CHIP_AX88141 = 24, /* ASIX AX88141 */ 149 TULIP_CHIP_X3201_3 = 25, /* Xircom X3201-3 */ 150 TULIP_CHIP_RS7112 = 26 /* Conexant RS7112 LANfinity */ 151 } tulip_chip_t; 152 153 #define TULIP_CHIP_NAMES \ 154 { \ 155 NULL, \ 156 "DE-425", \ 157 "DECchip 21040", \ 158 "DECchip 21041", \ 159 "DECchip 21140", \ 160 "DECchip 21140A", \ 161 "DECchip 21142", \ 162 "DECchip 21143", \ 163 "Lite-On 82C168", \ 164 "Lite-On 82C169", \ 165 "Lite-On 82C115", \ 166 "Macronix MX98713", \ 167 "Macronix MX98713A", \ 168 "Macronix MX98715", \ 169 "Macronix MX98715A", \ 170 "Macronix MX98715AEC-x", \ 171 "Macronix MX98725", \ 172 "Winbond 89C840F", \ 173 "Davicom DM9102", \ 174 "Davicom DM9102A", \ 175 "ADMtek AL981", \ 176 "ADMtek AN983", \ 177 "ADMtek AN985", \ 178 "ASIX AX88140", \ 179 "ASIX AX88141", \ 180 "Xircom X3201-3", \ 181 "Conexant RS7112", \ 182 } 183 184 struct tulip_softc; 185 186 /* 187 * Media init, change, status function pointers. 188 */ 189 struct tulip_mediasw { 190 void (*tmsw_init)(struct tulip_softc *); 191 void (*tmsw_get)(struct tulip_softc *, struct ifmediareq *); 192 int (*tmsw_set)(struct tulip_softc *); 193 }; 194 195 /* 196 * Table which describes the transmit threshold mode. We generally 197 * start at index 0. Whenever we get a transmit underrun, we increment 198 * our index, falling back if we encounter the NULL terminator. 199 */ 200 struct tulip_txthresh_tab { 201 uint32_t txth_opmode; /* OPMODE bits */ 202 const char *txth_name; /* name of mode */ 203 }; 204 205 #define TLP_TXTHRESH_TAB_10 { \ 206 { OPMODE_TR_72, "72 bytes" }, \ 207 { OPMODE_TR_96, "96 bytes" }, \ 208 { OPMODE_TR_128, "128 bytes" }, \ 209 { OPMODE_TR_160, "160 bytes" }, \ 210 { 0, NULL }, \ 211 } 212 213 #define TLP_TXTHRESH_TAB_10_100 { \ 214 { OPMODE_TR_72, "72/128 bytes" }, \ 215 { OPMODE_TR_96, "96/256 bytes" }, \ 216 { OPMODE_TR_128, "128/512 bytes" }, \ 217 { OPMODE_TR_160, "160/1024 bytes" }, \ 218 { OPMODE_SF, "store and forward mode" }, \ 219 { 0, NULL }, \ 220 } 221 222 #define TXTH_72 0 223 #define TXTH_96 1 224 #define TXTH_128 2 225 #define TXTH_160 3 226 #define TXTH_SF 4 227 228 #define TLP_TXTHRESH_TAB_DM9102 { \ 229 { OPMODE_TR_72, "72/128 bytes" }, \ 230 { OPMODE_TR_96, "96/256 bytes" }, \ 231 { OPMODE_TR_128, "128/512 bytes" }, \ 232 { OPMODE_SF, "store and forward mode" }, \ 233 { 0, NULL }, \ 234 } 235 236 #define TXTH_DM9102_72 0 237 #define TXTH_DM9102_96 1 238 #define TXTH_DM9102_128 2 239 #define TXTH_DM9102_SF 3 240 241 /* 242 * The Winbond 89C840F does transmit threshold control totally 243 * differently. It simply has a 7-bit field which indicates 244 * the threshold: 245 * 246 * txth = ((OPMODE & OPMODE_WINB_TTH) >> OPMODE_WINB_TTH_SHIFT) * 16; 247 * 248 * However, we just do Store-and-Forward mode on these chips, since 249 * the DMA engines seem to be flaky. 250 */ 251 #define TLP_TXTHRESH_TAB_WINB { \ 252 { 0, "store and forward mode" }, \ 253 { 0, NULL }, \ 254 } 255 256 #define TXTH_WINB_SF 0 257 258 /* 259 * Settings for Tulip SIA media. 260 */ 261 struct tulip_sia_media { 262 uint32_t tsm_siaconn; /* CSR13 value */ 263 uint32_t tsm_siatxrx; /* CSR14 value */ 264 uint32_t tsm_siagen; /* CSR15 value */ 265 }; 266 267 /* 268 * Description of 2x14x media. 269 */ 270 struct tulip_21x4x_media { 271 int tm_type; /* type of media; see tulipreg.h */ 272 const char *tm_name; /* name of media */ 273 274 void (*tm_get)(struct tulip_softc *, struct ifmediareq *); 275 int (*tm_set)(struct tulip_softc *); 276 277 int tm_phyno; /* PHY # on MII */ 278 279 int tm_gp_length; /* MII select sequence length */ 280 int tm_gp_offset; /* MII select sequence offset */ 281 282 int tm_reset_length;/* MII reset sequence length */ 283 int tm_reset_offset;/* MII reset sequence offset */ 284 285 uint32_t tm_opmode; /* OPMODE bits for this media */ 286 uint32_t tm_gpctl; /* GPIO control bits for this media */ 287 uint32_t tm_gpdata; /* GPIO bits for this media */ 288 uint32_t tm_actmask; /* `active' bits for this data */ 289 uint32_t tm_actdata; /* active high/low info */ 290 291 struct tulip_sia_media tm_sia; /* SIA settings */ 292 #define tm_siaconn tm_sia.tsm_siaconn 293 #define tm_siatxrx tm_sia.tsm_siatxrx 294 #define tm_siagen tm_sia.tsm_siagen 295 }; 296 297 /* 298 * Table for converting Tulip SROM media info into ifmedia data. 299 */ 300 struct tulip_srom_to_ifmedia { 301 uint8_t tsti_srom; /* SROM media type */ 302 int tsti_subtype; /* ifmedia subtype */ 303 int tsti_options; /* ifmedia options */ 304 const char *tsti_name; /* media name */ 305 306 uint32_t tsti_opmode; /* OPMODE bits for this media */ 307 uint32_t tsti_sia_cap; /* "MII" capabilities for this media */ 308 309 /* 310 * Settings for 21040, 21041, and 21142/21143 SIA, in the event 311 * the SROM doesn't have them. 312 */ 313 struct tulip_sia_media tsti_21040; 314 struct tulip_sia_media tsti_21041; 315 struct tulip_sia_media tsti_21142; 316 }; 317 318 /* 319 * Some misc. statics, useful for debugging. 320 */ 321 struct tulip_stats { 322 u_long ts_tx_uf; /* transmit underflow errors */ 323 u_long ts_tx_to; /* transmit jabber timeouts */ 324 u_long ts_tx_ec; /* excessive collision count */ 325 u_long ts_tx_lc; /* late collision count */ 326 }; 327 328 #ifndef _STANDALONE 329 /* 330 * Software state per device. 331 */ 332 struct tulip_softc { 333 device_t sc_dev; /* generic device information */ 334 bus_space_tag_t sc_st; /* bus space tag */ 335 bus_space_handle_t sc_sh; /* bus space handle */ 336 bus_dma_tag_t sc_dmat; /* bus DMA tag */ 337 struct ethercom sc_ethercom; /* ethernet common data */ 338 339 struct tulip_stats sc_stats; /* debugging stats */ 340 341 /* 342 * Contents of the SROM. 343 */ 344 uint8_t *sc_srom; 345 int sc_srom_addrbits; 346 347 /* 348 * Media access functions for this chip. 349 */ 350 const struct tulip_mediasw *sc_mediasw; 351 mii_bitbang_ops_t sc_bitbang_ops; 352 353 /* 354 * For chips with built-in NWay blocks, these are state 355 * variables required for autonegotiation. 356 */ 357 int sc_nway_ticks; /* tick counter */ 358 struct ifmedia_entry *sc_nway_active; /* the active media */ 359 struct callout sc_nway_callout; 360 361 tulip_chip_t sc_chip; /* chip type */ 362 int sc_rev; /* chip revision */ 363 int sc_flags; /* misc flags. */ 364 char sc_name[32]; /* board name */ 365 uint32_t sc_cacheline; /* cache line size */ 366 uint32_t sc_maxburst; /* maximum burst length */ 367 int sc_devno; /* PCI device # */ 368 369 struct mii_data sc_mii; /* MII/media information */ 370 371 const struct tulip_txthresh_tab *sc_txth; 372 int sc_txthresh; /* current transmit threshold */ 373 374 uint8_t sc_gp_dir; /* GPIO pin direction bits (21140) */ 375 int sc_media_seen; /* ISV media block types seen */ 376 int sc_tlp_minst; /* Tulip internal media instance */ 377 uint32_t sc_sia_cap; /* SIA media capabilities (21143) */ 378 379 /* Reset function. */ 380 void (*sc_reset)(struct tulip_softc *); 381 382 /* Pre-init function. */ 383 void (*sc_preinit)(struct tulip_softc *); 384 385 /* Filter setup function. */ 386 void (*sc_filter_setup)(struct tulip_softc *); 387 388 /* Media status update function. */ 389 void (*sc_statchg)(device_t); 390 391 /* Media tick function. */ 392 void (*sc_tick)(void *); 393 struct callout sc_tick_callout; 394 395 /* Power management hooks. */ 396 int (*sc_enable)(struct tulip_softc *); 397 void (*sc_disable)(struct tulip_softc *); 398 void (*sc_power)(struct tulip_softc *, int); 399 400 /* 401 * The Winbond 89C840F places registers 4 bytes apart, instead 402 * of 8. 403 */ 404 int sc_regshift; 405 406 uint32_t sc_busmode; /* copy of CSR_BUSMODE */ 407 uint32_t sc_opmode; /* copy of CSR_OPMODE */ 408 uint32_t sc_inten; /* copy of CSR_INTEN */ 409 410 uint32_t sc_rxint_mask; /* mask of Rx interrupts we want */ 411 uint32_t sc_txint_mask; /* mask of Tx interrupts we want */ 412 413 uint32_t sc_filtmode; /* filter mode we're using */ 414 415 bus_dma_segment_t sc_cdseg; /* control data memory */ 416 int sc_cdnseg; /* number of segments */ 417 bus_dmamap_t sc_cddmamap; /* control data DMA map */ 418 #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr 419 420 /* 421 * Software state for transmit and receive descriptors. 422 */ 423 struct tulip_txsoft sc_txsoft[TULIP_TXQUEUELEN]; 424 struct tulip_rxsoft sc_rxsoft[TULIP_NRXDESC]; 425 426 /* 427 * Control data structures. 428 */ 429 struct tulip_control_data *sc_control_data; 430 #define sc_txdescs sc_control_data->tcd_txdescs 431 #define sc_rxdescs sc_control_data->tcd_rxdescs 432 #define sc_setup_desc sc_control_data->tcd_setup_desc 433 434 int sc_txfree; /* number of free Tx descriptors */ 435 int sc_txnext; /* next ready Tx descriptor */ 436 int sc_ntxsegs; /* number of transmit segs per pkt */ 437 438 uint32_t sc_tdctl_ch; /* conditional desc chaining */ 439 uint32_t sc_tdctl_er; /* conditional desc end-of-ring */ 440 441 uint32_t sc_setup_fsls; /* FS|LS on setup descriptor */ 442 443 struct tulip_txsq sc_txfreeq; /* free Tx descsofts */ 444 struct tulip_txsq sc_txdirtyq; /* dirty Tx descsofts */ 445 446 short sc_if_flags; 447 448 int sc_rxptr; /* next ready RX descriptor/descsoft */ 449 450 #if NRND > 0 451 rndsource_element_t sc_rnd_source; /* random source */ 452 #endif 453 }; 454 #endif 455 456 /* sc_flags */ 457 #define TULIPF_WANT_SETUP 0x00000001 /* want filter setup */ 458 #define TULIPF_DOING_SETUP 0x00000002 /* doing multicast setup */ 459 #define TULIPF_HAS_MII 0x00000004 /* has media on MII */ 460 #define TULIPF_IC_FS 0x00000008 /* IC bit on first tx seg */ 461 #define TULIPF_MRL 0x00000010 /* memory read line okay */ 462 #define TULIPF_MRM 0x00000020 /* memory read multi okay */ 463 #define TULIPF_MWI 0x00000040 /* memory write inval okay */ 464 #define TULIPF_AUTOPOLL 0x00000080 /* chip supports auto-poll */ 465 #define TULIPF_LINK_UP 0x00000100 /* link is up (non-MII) */ 466 #define TULIPF_LINK_VALID 0x00000200 /* link state valid */ 467 #define TULIPF_DOINGAUTO 0x00000400 /* doing autoneg (non-MII) */ 468 #define TULIPF_ATTACHED 0x00000800 /* attach has succeeded */ 469 #define TULIPF_ENABLED 0x00001000 /* chip is enabled */ 470 #define TULIPF_BLE 0x00002000 /* data is big endian */ 471 #define TULIPF_DBO 0x00004000 /* descriptor is big endian */ 472 #define TULIPF_VPC 0x00008000 /* Virtual PC Ethernet */ 473 474 #define TULIP_IS_ENABLED(sc) ((sc)->sc_flags & TULIPF_ENABLED) 475 476 /* 477 * This macro returns the current media entry. 478 */ 479 #define TULIP_CURRENT_MEDIA(sc) ((sc)->sc_mii.mii_media.ifm_cur) 480 481 /* 482 * This macro determines if a change to media-related OPMODE bits requires 483 * a chip reset. 484 */ 485 #define TULIP_MEDIA_NEEDSRESET(sc, newbits) \ 486 (((sc)->sc_opmode & OPMODE_MEDIA_BITS) != \ 487 ((newbits) & OPMODE_MEDIA_BITS)) 488 489 #define TULIP_CDTXADDR(sc, x) ((sc)->sc_cddma + TULIP_CDTXOFF((x))) 490 #define TULIP_CDRXADDR(sc, x) ((sc)->sc_cddma + TULIP_CDRXOFF((x))) 491 492 #define TULIP_CDSPADDR(sc) ((sc)->sc_cddma + TULIP_CDSPOFF) 493 494 #define TULIP_CDSP(sc) ((sc)->sc_control_data->tcd_setup_packet) 495 496 #define TULIP_CDTXSYNC(sc, x, n, ops) \ 497 do { \ 498 int __x, __n; \ 499 \ 500 __x = (x); \ 501 __n = (n); \ 502 \ 503 /* If it will wrap around, sync to the end of the ring. */ \ 504 if ((__x + __n) > TULIP_NTXDESC) { \ 505 bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \ 506 TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) * \ 507 (TULIP_NTXDESC - __x), (ops)); \ 508 __n -= (TULIP_NTXDESC - __x); \ 509 __x = 0; \ 510 } \ 511 \ 512 /* Now sync whatever is left. */ \ 513 bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \ 514 TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) * __n, (ops)); \ 515 } while (0) 516 517 #define TULIP_CDRXSYNC(sc, x, ops) \ 518 bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \ 519 TULIP_CDRXOFF((x)), sizeof(struct tulip_desc), (ops)) 520 521 #define TULIP_CDSPSYNC(sc, ops) \ 522 bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \ 523 TULIP_CDSPOFF, TULIP_SETUP_PACKET_LEN, (ops)) 524 525 /* 526 * Note we rely on MCLBYTES being a power of two. Because the `length' 527 * field is only 11 bits, we must subtract 1 from the length to avoid 528 * having it truncated to 0! 529 */ 530 #define TULIP_INIT_RXDESC(sc, x) \ 531 do { \ 532 struct tulip_rxsoft *__rxs = &sc->sc_rxsoft[(x)]; \ 533 struct tulip_desc *__rxd = &sc->sc_rxdescs[(x)]; \ 534 struct mbuf *__m = __rxs->rxs_mbuf; \ 535 \ 536 __m->m_data = __m->m_ext.ext_buf; \ 537 __rxd->td_bufaddr1 = \ 538 htole32(__rxs->rxs_dmamap->dm_segs[0].ds_addr); \ 539 __rxd->td_bufaddr2 = \ 540 htole32(TULIP_CDRXADDR((sc), TULIP_NEXTRX((x)))); \ 541 __rxd->td_ctl = \ 542 htole32((((__m->m_ext.ext_size - 1) & ~0x3U) \ 543 << TDCTL_SIZE1_SHIFT) | (sc)->sc_tdctl_ch | \ 544 ((x) == (TULIP_NRXDESC - 1) ? sc->sc_tdctl_er : 0)); \ 545 __rxd->td_status = htole32(TDSTAT_OWN|TDSTAT_Rx_FS|TDSTAT_Rx_LS); \ 546 TULIP_CDRXSYNC((sc), (x), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \ 547 } while (0) 548 549 /* CSR access */ 550 #define TULIP_CSR_OFFSET(sc, csr) \ 551 (TULIP_CSR_INDEX(csr) << (sc)->sc_regshift) 552 553 #define TULIP_READ(sc, reg) \ 554 bus_space_read_4((sc)->sc_st, (sc)->sc_sh, \ 555 TULIP_CSR_OFFSET((sc), (reg))) 556 557 #define TULIP_WRITE(sc, reg, val) \ 558 bus_space_write_4((sc)->sc_st, (sc)->sc_sh, \ 559 TULIP_CSR_OFFSET((sc), (reg)), (val)) 560 561 #define TULIP_SET(sc, reg, mask) \ 562 TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) | (mask)) 563 564 #define TULIP_CLR(sc, reg, mask) \ 565 TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) & ~(mask)) 566 567 #define TULIP_ISSET(sc, reg, mask) \ 568 (TULIP_READ((sc), (reg)) & (mask)) 569 570 #define TULIP_SP_FIELD_C(a, b) ((b) << 8 | (a)) 571 #define TULIP_SP_FIELD(x, f) TULIP_SP_FIELD_C((x)[f * 2], (x)[f * 2 + 1]) 572 573 #ifdef _KERNEL 574 extern const char * const tlp_chip_names[]; 575 576 extern const struct tulip_mediasw tlp_21040_mediasw; 577 extern const struct tulip_mediasw tlp_21040_tp_mediasw; 578 extern const struct tulip_mediasw tlp_21040_auibnc_mediasw; 579 extern const struct tulip_mediasw tlp_21041_mediasw; 580 extern const struct tulip_mediasw tlp_2114x_isv_mediasw; 581 extern const struct tulip_mediasw tlp_sio_mii_mediasw; 582 extern const struct tulip_mediasw tlp_pnic_mediasw; 583 extern const struct tulip_mediasw tlp_pmac_mediasw; 584 extern const struct tulip_mediasw tlp_al981_mediasw; 585 extern const struct tulip_mediasw tlp_an985_mediasw; 586 extern const struct tulip_mediasw tlp_dm9102_mediasw; 587 extern const struct tulip_mediasw tlp_asix_mediasw; 588 extern const struct tulip_mediasw tlp_rs7112_mediasw; 589 590 int tlp_attach(struct tulip_softc *, const uint8_t *); 591 int tlp_activate(device_t, enum devact); 592 int tlp_detach(struct tulip_softc *); 593 int tlp_intr(void *); 594 int tlp_read_srom(struct tulip_softc *); 595 int tlp_srom_crcok(const uint8_t *); 596 int tlp_isv_srom(const uint8_t *); 597 int tlp_isv_srom_enaddr(struct tulip_softc *, uint8_t *); 598 int tlp_parse_old_srom(struct tulip_softc *, uint8_t *); 599 void tlp_reset(struct tulip_softc *); 600 void tlp_idle(struct tulip_softc *, uint32_t); 601 602 int tlp_mediachange(struct ifnet *); 603 void tlp_mediastatus(struct ifnet *, struct ifmediareq *); 604 605 void tlp_21140_gpio_get(struct tulip_softc *sc, struct ifmediareq *ifmr); 606 int tlp_21140_gpio_set(struct tulip_softc *sc); 607 608 #endif /* _KERNEL */ 609 610 #endif /* _DEV_IC_TULIPVAR_H_ */ 611