Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:57

0001 /*  $NetBSD: if_wmreg.h,v 1.22 2007/04/29 20:35:21 bouyer Exp $ */
0002 
0003 /*
0004  * Copyright (c) 2001 Wasabi Systems, Inc.
0005  * All rights reserved.
0006  *
0007  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
0008  * Some are added by Shuchen Kate Feng <feng1@bnl.gov>,
0009  *            NSLS, Brookhaven National Laboratory. All rights reserved.
0010  *            under the Deaprtment of Energy contract DE-AC02-98CH10886
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  * 3. All advertising materials mentioning features or use of this software
0021  *    must display the following acknowledgement:
0022  *  This product includes software developed for the NetBSD Project by
0023  *  Wasabi Systems, Inc.
0024  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
0025  *    or promote products derived from this software without specific prior
0026  *    written permission.
0027  *
0028  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
0029  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
0030  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0031  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
0032  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0033  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0034  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0035  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0036  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0037  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038  * POSSIBILITY OF SUCH DAMAGE.
0039  */
0040 
0041 /*
0042  * Register description for the Intel i82542 (``Wiseman''),
0043  * i82543 (``Livengood''), and i82544 (``Cordova'') Gigabit
0044  * Ethernet chips.
0045  */
0046 
0047 /*
0048  * The wiseman supports 64-bit PCI addressing.  This structure
0049  * describes the address in descriptors.
0050  */
0051 typedef struct wiseman_addr {
0052     uint32_t    wa_low;     /* low-order 32 bits */
0053     uint32_t    wa_high;    /* high-order 32 bits */
0054 } __attribute__((__packed__)) wiseman_addr_t;
0055 
0056 /*
0057  * The Wiseman receive descriptor.
0058  *
0059  * The receive descriptor ring must be aligned to a 4K boundary,
0060  * and there must be an even multiple of 8 descriptors in the ring.
0061  */
0062 typedef volatile struct wiseman_rxdesc {
0063     wiseman_addr_t  wrx_addr;   /* buffer address */
0064 
0065     uint16_t    wrx_len;    /* buffer length */
0066     uint16_t    wrx_cksum;  /* checksum (starting at PCSS) */
0067 
0068     uint8_t     wrx_status; /* Rx status */
0069     uint8_t     wrx_errors; /* Rx errors */
0070     uint16_t    wrx_special;    /* special field (VLAN, etc.) */
0071 } __attribute__((__packed__)) wiseman_rxdesc_t;
0072 
0073 /* wrx_status bits */
0074 #define WRX_ST_DD   (1U << 0)   /* descriptor done */
0075 #define WRX_ST_EOP  (1U << 1)   /* end of packet */
0076 #define WRX_ST_IXSM (1U << 2)   /* ignore checksum indication */
0077 #define WRX_ST_VP   (1U << 3)   /* VLAN packet */
0078 #define WRX_ST_BPDU (1U << 4)   /* ??? */
0079 #define WRX_ST_TCPCS    (1U << 5)   /* TCP checksum performed */
0080 #define WRX_ST_IPCS (1U << 6)   /* IP checksum performed */
0081 #define WRX_ST_PIF  (1U << 7)   /* passed in-exact filter */
0082 
0083 /* wrx_error bits */
0084 #define WRX_ER_CE   (1U << 0)   /* CRC error */
0085 #define WRX_ER_SE   (1U << 1)   /* symbol error */
0086 #define WRX_ER_SEQ  (1U << 2)   /* sequence error */
0087 #define WRX_ER_ICE  (1U << 3)   /* ??? */
0088 #define WRX_ER_CXE  (1U << 4)   /* carrier extension error */
0089 #define WRX_ER_TCPE (1U << 5)   /* TCP checksum error */
0090 #define WRX_ER_IPE  (1U << 6)   /* IP checksum error */
0091 #define WRX_ER_RXE  (1U << 7)   /* Rx data error */
0092 
0093 /* wrx_special field for VLAN packets */
0094 #define WRX_VLAN_ID(x)  ((x) & 0x0fff)  /* VLAN identifier */
0095 #define WRX_VLAN_CFI    (1U << 12)  /* Canonical Form Indicator */
0096 #define WRX_VLAN_PRI(x) (((x) >> 13) & 7)/* VLAN priority field */
0097 
0098 /*
0099  * The Wiseman transmit descriptor.
0100  *
0101  * The transmit descriptor ring must be aligned to a 4K boundary,
0102  * and there must be an even multiple of 8 descriptors in the ring.
0103  */
0104 typedef struct wiseman_tx_fields {
0105     uint8_t wtxu_status;        /* Tx status */
0106     uint8_t wtxu_options;       /* options */
0107     uint16_t wtxu_vlan;     /* VLAN info */
0108 } __attribute__((__packed__)) wiseman_txfields_t;
0109 typedef volatile struct wiseman_txdesc {
0110     wiseman_addr_t  wtx_addr;   /* buffer address */
0111     uint32_t    wtx_cmdlen; /* command and length */
0112     wiseman_txfields_t wtx_fields;  /* fields; see below */
0113 } __attribute__((__packed__)) wiseman_txdesc_t;
0114 
0115 /* Commands for wtx_cmdlen */
0116 #define WTX_CMD_EOP (1U << 24)  /* end of packet */
0117 #define WTX_CMD_IFCS    (1U << 25)  /* insert FCS */
0118 #define WTX_CMD_RS  (1U << 27)  /* report status */
0119 #define WTX_CMD_RPS (1U << 28)  /* report packet sent */
0120 #define WTX_CMD_DEXT    (1U << 29)  /* descriptor extension */
0121 #define WTX_CMD_VLE (1U << 30)  /* VLAN enable */
0122 #define WTX_CMD_IDE (1U << 31)  /* interrupt delay enable */
0123 
0124 /* Descriptor types (if DEXT is set) */
0125 #define WTX_DTYP_C  (0U << 20)  /* context */
0126 #define WTX_DTYP_D  (1U << 20)  /* data */
0127 
0128 /* wtx_fields status bits */
0129 #define WTX_ST_DD   (1U << 0)   /* descriptor done */
0130 #define WTX_ST_EC   (1U << 1)   /* excessive collisions */
0131 #define WTX_ST_LC   (1U << 2)   /* late collision */
0132 #define WTX_ST_TU   (1U << 3)   /* transmit underrun */
0133 
0134 /* wtx_fields option bits for IP/TCP/UDP checksum offload */
0135 #define WTX_IXSM    (1U << 0)   /* IP checksum offload */
0136 #define WTX_TXSM    (1U << 1)   /* TCP/UDP checksum offload */
0137 
0138 /* Maximum payload per Tx descriptor */
0139 #define WTX_MAX_LEN 4096
0140 
0141 /*
0142  * The Livengood TCP/IP context descriptor.
0143  */
0144 struct livengood_tcpip_ctxdesc {
0145     uint32_t    tcpip_ipcs; /* IP checksum context */
0146     uint32_t    tcpip_tucs; /* TCP/UDP checksum context */
0147     uint32_t    tcpip_cmdlen;
0148     uint32_t    tcpip_seg;  /* TCP segmentation context */
0149 };
0150 
0151 /* commands for context descriptors */
0152 #define WTX_TCPIP_CMD_TCP   (1U << 24)  /* 1 = TCP, 0 = UDP */
0153 #define WTX_TCPIP_CMD_IP    (1U << 25)  /* 1 = IPv4, 0 = IPv6 */
0154 #define WTX_TCPIP_CMD_TSE   (1U << 26)  /* segmentation context valid */
0155 
0156 #define WTX_TCPIP_IPCSS(x)  ((x) << 0)  /* checksum start */
0157 #define WTX_TCPIP_IPCSO(x)  ((x) << 8)  /* checksum value offset */
0158 #define WTX_TCPIP_IPCSE(x)  ((x) << 16) /* checksum end */
0159 
0160 #define WTX_TCPIP_TUCSS(x)  ((x) << 0)  /* checksum start */
0161 #define WTX_TCPIP_TUCSO(x)  ((x) << 8)  /* checksum value offset */
0162 #define WTX_TCPIP_TUCSE(x)  ((x) << 16) /* checksum end */
0163 
0164 #define WTX_TCPIP_SEG_STATUS(x) ((x) << 0)
0165 #define WTX_TCPIP_SEG_HDRLEN(x) ((x) << 8)
0166 #define WTX_TCPIP_SEG_MSS(x)    ((x) << 16)
0167 
0168 /*
0169  * PCI config registers used by the Wiseman.
0170  */
0171 #define WM_PCI_MMBA PCI_MAPREG_START
0172 /* registers for FLASH access on ICH8 */
0173 #define WM_ICH8_FLASH   0x0014
0174 
0175 /*
0176  * Wiseman Control/Status Registers.
0177  */
0178 #define WMREG_CTRL  0x0000  /* Device Control Register */
0179 #define CTRL_FD     (1U << 0)   /* full duplex */
0180 #define CTRL_BEM    (1U << 1)   /* big-endian mode */
0181 #define CTRL_PRIOR  (1U << 2)   /* 0 = receive, 1 = fair */
0182 #define CTRL_LRST   (1U << 3)   /* link reset */
0183 #define CTRL_ASDE   (1U << 5)   /* auto speed detect enable */
0184 #define CTRL_SLU    (1U << 6)   /* set link up */
0185 #define CTRL_ILOS   (1U << 7)   /* invert loss of signal */
0186 #define CTRL_SPEED(x)   ((x) << 8)  /* speed (Livengood) */
0187 #define CTRL_SPEED_10   CTRL_SPEED(0)
0188 #define CTRL_SPEED_100  CTRL_SPEED(1)
0189 #define CTRL_SPEED_1000 CTRL_SPEED(2)
0190 #define CTRL_SPEED_MASK CTRL_SPEED(3)
0191 #define CTRL_FRCSPD (1U << 11)  /* force speed (Livengood) */
0192 #define CTRL_FRCFDX (1U << 12)  /* force full-duplex (Livengood) */
0193 #define CTRL_D_UD_EN    (1U << 13)  /* Dock/Undock enable */
0194 #define CTRL_D_UD_POL   (1U << 14)  /* Defined polarity of Dock/Undock indication in SDP[0] */
0195 #define CTRL_F_PHY_R    (1U << 15)  /* Reset both PHY ports, through PHYRST_N pin */
0196 #define CTRL_EXT_LINK_EN (1U << 16) /* enable link status from external LINK_0 and LINK_1 pins */
0197 #define CTRL_SWDPINS_SHIFT  18
0198 #define CTRL_SWDPINS_MASK   0x0f
0199 #define CTRL_SWDPIN(x)      (1U << (CTRL_SWDPINS_SHIFT + (x)))
0200 #define CTRL_SWDPIO_SHIFT   22
0201 #define CTRL_SWDPIO_MASK    0x0f
0202 #define CTRL_SWDPIO(x)      (1U << (CTRL_SWDPIO_SHIFT + (x)))
0203 #define CTRL_RST    (1U << 26)  /* device reset */
0204 #define CTRL_RFCE   (1U << 27)  /* Rx flow control enable */
0205 #define CTRL_TFCE   (1U << 28)  /* Tx flow control enable */
0206 #define CTRL_VME    (1U << 30)  /* VLAN Mode Enable */
0207 #define CTRL_PHY_RESET  (1U << 31)  /* PHY reset (Cordova) */
0208 
0209 #define WMREG_CTRL_SHADOW 0x0004    /* Device Control Register (shadow) */
0210 
0211 #define WMREG_STATUS    0x0008  /* Device Status Register */
0212 #define STATUS_FD   (1U << 0)   /* full duplex */
0213 #define STATUS_LU   (1U << 1)   /* link up */
0214 #define STATUS_TCKOK    (1U << 2)   /* Tx clock running */
0215 #define STATUS_RBCOK    (1U << 3)   /* Rx clock running */
0216 #define STATUS_FUNCID_SHIFT 2       /* 82546 function ID */
0217 #define STATUS_FUNCID_MASK  3       /* ... */
0218 #define STATUS_TXOFF    (1U << 4)   /* Tx paused */
0219 #define STATUS_TBIMODE  (1U << 5)   /* fiber mode (Livengood) */
0220 #define STATUS_SPEED(x) ((x) << 6)  /* speed indication */
0221 #define STATUS_SPEED_10   STATUS_SPEED(0)
0222 #define STATUS_SPEED_100  STATUS_SPEED(1)
0223 #define STATUS_SPEED_1000 STATUS_SPEED(2)
0224 #define STATUS_ASDV(x)  ((x) << 8)  /* auto speed det. val. (Livengood) */
0225 #define STATUS_MTXCKOK  (1U << 10)  /* MTXD clock running */
0226 #define STATUS_PCI66    (1U << 11)  /* 66MHz bus (Livengood) */
0227 #define STATUS_BUS64    (1U << 12)  /* 64-bit bus (Livengood) */
0228 #define STATUS_PCIX_MODE (1U << 13) /* PCIX mode (Cordova) */
0229 #define STATUS_PCIXSPD(x) ((x) << 14)   /* PCIX speed indication (Cordova) */
0230 #define STATUS_PCIXSPD_50_66   STATUS_PCIXSPD(0)
0231 #define STATUS_PCIXSPD_66_100  STATUS_PCIXSPD(1)
0232 #define STATUS_PCIXSPD_100_133 STATUS_PCIXSPD(2)
0233 #define STATUS_PCIXSPD_MASK    STATUS_PCIXSPD(3)
0234 
0235 #define WMREG_EECD  0x0010  /* EEPROM Control Register */
0236 #define EECD_SK     (1U << 0)   /* clock */
0237 #define EECD_CS     (1U << 1)   /* chip select */
0238 #define EECD_DI     (1U << 2)   /* data in */
0239 #define EECD_DO     (1U << 3)   /* data out */
0240 #define EECD_FWE(x) ((x) << 4)  /* flash write enable control */
0241 #define EECD_FWE_DISABLED EECD_FWE(1)
0242 #define EECD_FWE_ENABLED  EECD_FWE(2)
0243 #define EECD_EE_REQ (1U << 6)   /* (shared) EEPROM request */
0244 #define EECD_EE_GNT (1U << 7)   /* (shared) EEPROM grant */
0245 #define EECD_EE_PRES    (1U << 8)   /* EEPROM present */
0246 #define EECD_EE_SIZE    (1U << 9)   /* EEPROM size
0247                        (0 = 64 word, 1 = 256 word) */
0248 #define EECD_EE_AUTORD  (1U << 9)   /* auto read done */
0249 #define EECD_EE_ABITS   (1U << 10)  /* EEPROM address bits
0250                        (based on type) */
0251 #define EECD_EE_TYPE    (1U << 13)  /* EEPROM type
0252                        (0 = Microwire, 1 = SPI) */
0253 #define EECD_SEC1VAL    (1U << 22)  /* Sector One Valid */
0254 
0255 #define UWIRE_OPC_ERASE 0x04        /* MicroWire "erase" opcode */
0256 #define UWIRE_OPC_WRITE 0x05        /* MicroWire "write" opcode */
0257 #define UWIRE_OPC_READ  0x06        /* MicroWire "read" opcode */
0258 
0259 #define SPI_OPC_WRITE   0x02        /* SPI "write" opcode */
0260 #define SPI_OPC_READ    0x03        /* SPI "read" opcode */
0261 #define SPI_OPC_A8  0x08        /* opcode bit 3 == address bit 8 */
0262 #define SPI_OPC_WREN    0x06        /* SPI "set write enable" opcode */
0263 #define SPI_OPC_WRDI    0x04        /* SPI "clear write enable" opcode */
0264 #define SPI_OPC_RDSR    0x05        /* SPI "read status" opcode */
0265 #define SPI_OPC_WRSR    0x01        /* SPI "write status" opcode */
0266 #define SPI_MAX_RETRIES 5000        /* max wait of 5ms for RDY signal */
0267 
0268 #define SPI_SR_RDY  0x01
0269 #define SPI_SR_WEN  0x02
0270 #define SPI_SR_BP0  0x04
0271 #define SPI_SR_BP1  0x08
0272 #define SPI_SR_WPEN 0x80
0273 
0274 #define EEPROM_OFF_MACADDR  0x00    /* MAC address offset */
0275 #define EEPROM_OFF_CFG1     0x0a    /* config word 1 */
0276 #define EEPROM_OFF_CFG2     0x0f    /* config word 2 */
0277 #define EEPROM_OFF_SWDPIN   0x20    /* SWD Pins (Cordova) */
0278 
0279 #define EEPROM_CFG1_LVDID   (1U << 0)
0280 #define EEPROM_CFG1_LSSID   (1U << 1)
0281 #define EEPROM_CFG1_PME_CLOCK   (1U << 2)
0282 #define EEPROM_CFG1_PM      (1U << 3)
0283 #define EEPROM_CFG1_ILOS    (1U << 4)
0284 #define EEPROM_CFG1_SWDPIO_SHIFT 5
0285 #define EEPROM_CFG1_SWDPIO_MASK (0xf << EEPROM_CFG1_SWDPIO_SHIFT)
0286 #define EEPROM_CFG1_IPS1    (1U << 8)
0287 #define EEPROM_CFG1_LRST    (1U << 9)
0288 #define EEPROM_CFG1_FD      (1U << 10)
0289 #define EEPROM_CFG1_FRCSPD  (1U << 11)
0290 #define EEPROM_CFG1_IPS0    (1U << 12)
0291 #define EEPROM_CFG1_64_32_BAR   (1U << 13)
0292 
0293 #define EEPROM_CFG2_CSR_RD_SPLIT (1U << 1)
0294 #define EEPROM_CFG2_APM_EN  (1U << 2)
0295 #define EEPROM_CFG2_64_BIT  (1U << 3)
0296 #define EEPROM_CFG2_MAX_READ    (1U << 4)
0297 #define EEPROM_CFG2_DMCR_MAP    (1U << 5)
0298 #define EEPROM_CFG2_133_CAP (1U << 6)
0299 #define EEPROM_CFG2_MSI_DIS (1U << 7)
0300 #define EEPROM_CFG2_FLASH_DIS   (1U << 8)
0301 #define EEPROM_CFG2_FLASH_SIZE(x) (((x) & 3) >> 9)
0302 #define EEPROM_CFG2_ANE     (1U << 11)
0303 #define EEPROM_CFG2_PAUSE(x)    (((x) & 3) >> 12)
0304 #define EEPROM_CFG2_ASDE    (1U << 14)
0305 #define EEPROM_CFG2_APM_PME (1U << 15)
0306 #define EEPROM_CFG2_SWDPIO_SHIFT 4
0307 #define EEPROM_CFG2_SWDPIO_MASK (0xf << EEPROM_CFG2_SWDPIO_SHIFT)
0308 
0309 #define EEPROM_SWDPIN_MASK  0xdf
0310 #define EEPROM_SWDPIN_SWDPIN_SHIFT 0
0311 #define EEPROM_SWDPIN_SWDPIO_SHIFT 8
0312 
0313 #define WMREG_EERD  0x0014  /* EEPROM read */
0314 #define EERD_DONE   0x02    /* done bit */
0315 #define EERD_START  0x01    /* First bit for telling part to start operation */
0316 #define EERD_ADDR_SHIFT 2   /* Shift to the address bits */
0317 #define EERD_DATA_SHIFT 16  /* Offset to data in EEPROM read/write registers */
0318 
0319 #define WMREG_CTRL_EXT  0x0018  /* Extended Device Control Register */
0320 #define CTRL_EXT_GPI_EN(x)  (1U << (x)) /* gpin interrupt enable */
0321 #define CTRL_EXT_SWDPINS_SHIFT  4
0322 #define CTRL_EXT_SWDPINS_MASK   0x0d
0323 #define CTRL_EXT_SWDPIN(x)  (1U << (CTRL_EXT_SWDPINS_SHIFT + (x) - 4))
0324 #define CTRL_EXT_SWDPIO_SHIFT   8
0325 #define CTRL_EXT_SWDPIO_MASK    0x0d
0326 #define CTRL_EXT_SWDPIO(x)  (1U << (CTRL_EXT_SWDPIO_SHIFT + (x) - 4))
0327 #define CTRL_EXT_ASDCHK     (1U << 12) /* ASD check */
0328 #define CTRL_EXT_EE_RST     (1U << 13) /* EEPROM reset */
0329 #define CTRL_EXT_IPS        (1U << 14) /* invert power state bit 0 */
0330 #define CTRL_EXT_SPD_BYPS   (1U << 15) /* speed select bypass */
0331 #define CTRL_EXT_IPS1       (1U << 16) /* invert power state bit 1 */
0332 #define CTRL_EXT_RO_DIS     (1U << 17) /* relaxed ordering disabled */
0333 #define CTRL_EXT_LINK_MODE_MASK 0x00C00000
0334 #define CTRL_EXT_LINK_MODE_GMII 0x00000000
0335 #define CTRL_EXT_LINK_MODE_TBI  0x00C00000
0336 #define CTRL_EXT_LINK_MODE_KMRN 0x00000000
0337 #define CTRL_EXT_LINK_MODE_SERDES 0x00C00000
0338 
0339 
0340 #define WMREG_MDIC  0x0020  /* MDI Control Register */
0341 #define MDIC_DATA(x)    ((x) & 0xffff)
0342 #define MDIC_REGADD(x)  ((x) << 16)
0343 #define MDIC_PHYADD(x)  ((x) << 21)
0344 #define MDIC_OP_WRITE   (1U << 26)
0345 #define MDIC_OP_READ    (2U << 26)
0346 #define MDIC_READY  (1U << 28)
0347 #define MDIC_I      (1U << 29)  /* interrupt on MDI complete */
0348 #define MDIC_E      (1U << 30)  /* MDI error */
0349 
0350 #define WMREG_FCAL  0x0028  /* Flow Control Address Low */
0351 #define FCAL_CONST  0x00c28001  /* Flow Control MAC addr low */
0352 
0353 #define WMREG_FCAH  0x002c  /* Flow Control Address High */
0354 #define FCAH_CONST  0x00000100  /* Flow Control MAC addr high */
0355 
0356 #define WMREG_FCT   0x0030  /* Flow Control Type */
0357 
0358 #define WMREG_VET   0x0038  /* VLAN Ethertype */
0359 
0360 #define WMREG_RAL_BASE  0x0040  /* Receive Address List */
0361 #define WMREG_CORDOVA_RAL_BASE 0x5400
0362 #define WMREG_RAL_LO(b, x) ((b) + ((x) << 3))
0363 #define WMREG_RAL_HI(b, x) (WMREG_RAL_LO(b, x) + 4)
0364     /*
0365      * Receive Address List: The LO part is the low-order 32-bits
0366      * of the MAC address.  The HI part is the high-order 16-bits
0367      * along with a few control bits.
0368      */
0369 #define RAL_AS(x)   ((x) << 16) /* address select */
0370 #define RAL_AS_DEST RAL_AS(0)   /* (cordova?) */
0371 #define RAL_AS_SOURCE   RAL_AS(1)   /* (cordova?) */
0372 #define RAL_RDR1    (1U << 30)  /* put packet in alt. rx ring */
0373 #define RAL_AV      (1U << 31)  /* entry is valid */
0374 
0375 #define WM_RAL_TABSIZE  16
0376 #define WM_ICH8_RAL_TABSIZE 7
0377 
0378 #define WMREG_ICR   0x00c0  /* Interrupt Cause Register */
0379 #define ICR_TXDW    (1U << 0)   /* Tx desc written back */
0380 #define ICR_TXQE    (1U << 1)   /* Tx queue empty */
0381 #define ICR_LSC     (1U << 2)   /* link status change */
0382 #define ICR_RXSEQ   (1U << 3)   /* receive sequence error */
0383 #define ICR_RXDMT0  (1U << 4)   /* Rx ring 0 nearly empty */
0384 #define ICR_RXO     (1U << 6)   /* Rx overrun */
0385 #define ICR_RXT0    (1U << 7)   /* Rx ring 0 timer */
0386 #define ICR_MDAC    (1U << 9)   /* MDIO access complete */
0387 #define ICR_RXCFG   (1U << 10)  /* Receiving /C/ */
0388 #define ICR_GPI(x)  (1U << (x)) /* general purpose interrupts */
0389 #define ICR_INT     (1U << 31)  /* device generated an interrupt */
0390 
0391 #define WMREG_ITR   0x00c4  /* Interrupt Throttling Register */
0392 #define ITR_IVAL_MASK   0xffff      /* Interval mask */
0393 #define ITR_IVAL_SHIFT  0       /* Interval shift */
0394 
0395 #define WMREG_ICS   0x00c8  /* Interrupt Cause Set Register */
0396     /* See ICR bits. */
0397 
0398 #define WMREG_IMS   0x00d0  /* Interrupt Mask Set Register */
0399     /* See ICR bits. */
0400 
0401 #define WMREG_IMC   0x00d8  /* Interrupt Mask Clear Register */
0402     /* See ICR bits. */
0403 
0404 #define WMREG_RCTL  0x0100  /* Receive Control */
0405 #define RCTL_EN     (1U << 1)   /* receiver enable */
0406 #define RCTL_SBP    (1U << 2)   /* store bad packets */
0407 #define RCTL_UPE    (1U << 3)   /* unicast promisc. enable */
0408 #define RCTL_MPE    (1U << 4)   /* multicast promisc. enable */
0409 #define RCTL_LPE    (1U << 5)   /* large packet enable */
0410 #define RCTL_LBM(x) ((x) << 6)  /* loopback mode */
0411 #define RCTL_LBM_NONE   RCTL_LBM(0)
0412 #define RCTL_LBM_PHY    RCTL_LBM(3)
0413 #define RCTL_RDMTS(x)   ((x) << 8)  /* receive desc. min thresh size */
0414 #define RCTL_RDMTS_1_2  RCTL_RDMTS(0)
0415 #define RCTL_RDMTS_1_4  RCTL_RDMTS(1)
0416 #define RCTL_RDMTS_1_8  RCTL_RDMTS(2)
0417 #define RCTL_RDMTS_MASK RCTL_RDMTS(3)
0418 #define RCTL_MO(x)  ((x) << 12) /* multicast offset */
0419 #define RCTL_BAM    (1U << 15)  /* broadcast accept mode */
0420 #define RCTL_2k     (0 << 16)   /* 2k Rx buffers */
0421 #define RCTL_1k     (1 << 16)   /* 1k Rx buffers */
0422 #define RCTL_512    (2 << 16)   /* 512 byte Rx buffers */
0423 #define RCTL_256    (3 << 16)   /* 256 byte Rx buffers */
0424 #define RCTL_BSEX_16k   (1 << 16)   /* 16k Rx buffers (BSEX) */
0425 #define RCTL_BSEX_8k    (2 << 16)   /* 8k Rx buffers (BSEX) */
0426 #define RCTL_BSEX_4k    (3 << 16)   /* 4k Rx buffers (BSEX) */
0427 #define RCTL_DPF    (1U << 22)  /* discard pause frames */
0428 #define RCTL_PMCF   (1U << 23)  /* pass MAC control frames */
0429 #define RCTL_BSEX   (1U << 25)  /* buffer size extension (Livengood) */
0430 #define RCTL_SECRC  (1U << 26)  /* strip Ethernet CRC */
0431 
0432 #define WMREG_OLD_RDTR0 0x0108  /* Receive Delay Timer (ring 0) */
0433 #define WMREG_RDTR  0x2820
0434 #define RDTR_FPD    (1U << 31)  /* flush partial descriptor */
0435 
0436 #define WMREG_RADV  0x282c  /* Receive Interrupt Absolute Delay Timer */
0437 
0438 #define WMREG_OLD_RDBAL0 0x0110 /* Receive Descriptor Base Low (ring 0) */
0439 #define WMREG_RDBAL 0x2800
0440 
0441 #define WMREG_OLD_RDBAH0 0x0114 /* Receive Descriptor Base High (ring 0) */
0442 #define WMREG_RDBAH 0x2804
0443 
0444 #define WMREG_OLD_RDLEN0 0x0118 /* Receive Descriptor Length (ring 0) */
0445 #define WMREG_RDLEN 0x2808
0446 
0447 #define WMREG_OLD_RDH0  0x0120  /* Receive Descriptor Head (ring 0) */
0448 #define WMREG_RDH   0x2810
0449 
0450 #define WMREG_OLD_RDT0  0x0128  /* Receive Descriptor Tail (ring 0) */
0451 #define WMREG_RDT   0x2818
0452 
0453 #define WMREG_RXDCTL    0x2828  /* Receive Descriptor Control */
0454 #define RXDCTL_PTHRESH(x) ((x) << 0)    /* prefetch threshold */
0455 #define RXDCTL_HTHRESH(x) ((x) << 8)    /* host threshold */
0456 #define RXDCTL_WTHRESH(x) ((x) << 16)   /* write back threshold */
0457 #define RXDCTL_GRAN (1U << 24)  /* 0 = cacheline, 1 = descriptor */
0458 
0459 #define WMREG_OLD_RDTR1 0x0130  /* Receive Delay Timer (ring 1) */
0460 
0461 #define WMREG_OLD_RDBA1_LO 0x0138 /* Receive Descriptor Base Low (ring 1) */
0462 
0463 #define WMREG_OLD_RDBA1_HI 0x013c /* Receive Descriptor Base High (ring 1) */
0464 
0465 #define WMREG_OLD_RDLEN1 0x0140 /* Receive Drscriptor Length (ring 1) */
0466 
0467 #define WMREG_OLD_RDH1  0x0148
0468 
0469 #define WMREG_OLD_RDT1  0x0150
0470 
0471 #define WMREG_OLD_FCRTH 0x0160  /* Flow Control Rx Threshold Hi (OLD) */
0472 #define WMREG_FCRTL 0x2160  /* Flow Control Rx Threshold Lo */
0473 #define FCRTH_DFLT  0x00008000
0474 
0475 #define WMREG_OLD_FCRTL 0x0168  /* Flow Control Rx Threshold Lo (OLD) */
0476 #define WMREG_FCRTH 0x2168  /* Flow Control Rx Threhsold Hi */
0477 #define FCRTL_DFLT  0x00004000
0478 #define FCRTL_XONE  0x80000000  /* Enable XON frame transmission */
0479 
0480 #define WMREG_FCTTV 0x0170  /* Flow Control Transmit Timer Value */
0481 #define FCTTV_DFLT  0x00000600
0482 
0483 #define WMREG_TXCW  0x0178  /* Transmit Configuration Word (TBI mode) */
0484     /* See MII ANAR_X bits. */
0485 #define TXCW_TxConfig   (1U << 30)  /* Tx Config */
0486 #define TXCW_ANE    (1U << 31)  /* Autonegotiate */
0487 
0488 #define WMREG_RXCW  0x0180  /* Receive Configuration Word (TBI mode) */
0489     /* See MII ANLPAR_X bits. */
0490 #define RXCW_NC     (1U << 26)  /* no carrier */
0491 #define RXCW_IV     (1U << 27)  /* config invalid */
0492 #define RXCW_CC     (1U << 28)  /* config change */
0493 #define RXCW_C      (1U << 29)  /* /C/ reception */
0494 #define RXCW_SYNCH  (1U << 30)  /* synchronized */
0495 #define RXCW_ANC    (1U << 31)  /* autonegotiation complete */
0496 
0497 #define WMREG_MTA   0x0200  /* Multicast Table Array */
0498 #define WMREG_CORDOVA_MTA 0x5200
0499 
0500 #define WMREG_TCTL  0x0400  /* Transmit Control Register */
0501 #define TCTL_EN     (1U << 1)   /* transmitter enable */
0502 #define TCTL_PSP    (1U << 3)   /* pad short packets */
0503 #define TCTL_CT(x)  (((x) & 0xff) << 4)   /* 4:11 - collision threshold */
0504 #define TCTL_COLD(x)    (((x) & 0x3ff) << 12) /* 12:21 - collision distance */
0505 #define TCTL_SWXOFF (1U << 22)  /* software XOFF */
0506 #define TCTL_RTLC   (1U << 24)  /* retransmit on late collision */
0507 #define TCTL_NRTU   (1U << 25)  /* no retransmit on underrun */
0508 #define TCTL_MULR   (1U << 28)  /* multiple request */
0509 
0510 #define TX_COLLISION_THRESHOLD      15
0511 #define TX_COLLISION_DISTANCE_HDX   512
0512 #define TX_COLLISION_DISTANCE_FDX   64
0513 
0514 #define WMREG_TCTL_EXT  0x0404  /* Transmit Control Register */
0515 #define TCTL_EXT_BST_MASK   0x000003FF /* Backoff Slot Time */
0516 #define TCTL_EXT_GCEX_MASK  0x000FFC00 /* Gigabit Carry Extend Padding */
0517 
0518 #define DEFAULT_80003ES2LAN_TCTL_EXT_GCEX 0x00010000
0519 
0520 #define WMREG_TQSA_LO   0x0408
0521 
0522 #define WMREG_TQSA_HI   0x040c
0523 
0524 #define WMREG_TIPG  0x0410  /* Transmit IPG Register */
0525 #define TIPG_IPGT(x)    (x)     /* IPG transmit time */
0526 #define TIPG_IPGR1(x)   ((x) << 10) /* IPG receive time 1 */
0527 #define TIPG_IPGR2(x)   ((x) << 20) /* IPG receive time 2 */
0528 
0529 #define TIPG_WM_DFLT    (TIPG_IPGT(0x0a) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x0a))
0530 #define TIPG_LG_DFLT    (TIPG_IPGT(0x06) | TIPG_IPGR1(0x08) | TIPG_IPGR2(0x06))
0531 #define TIPG_1000T_DFLT (TIPG_IPGT(0x08) | TIPG_IPGR1(0x08) | TIPG_IPGR2(0x06))
0532 #define TIPG_1000T_80003_DFLT \
0533     (TIPG_IPGT(0x08) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x07))
0534 #define TIPG_10_100_80003_DFLT \
0535     (TIPG_IPGT(0x09) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x07))
0536 
0537 #define WMREG_TQC   0x0418
0538 
0539 #define WMREG_EEWR  0x102c  /* EEPROM write */
0540 
0541 #define WMREG_RDFH  0x2410  /* Receive Data FIFO Head */
0542 
0543 #define WMREG_RDFT  0x2418  /* Receive Data FIFO Tail */
0544 
0545 #define WMREG_RDFHS 0x2420  /* Receive Data FIFO Head Saved */
0546 
0547 #define WMREG_RDFTS 0x2428  /* Receive Data FIFO Tail Saved */
0548 
0549 #define WMREG_TDFH  0x3410  /* Transmit Data FIFO Head */
0550 
0551 #define WMREG_TDFT  0x3418  /* Transmit Data FIFO Tail */
0552 
0553 #define WMREG_TDFHS 0x3420  /* Transmit Data FIFO Head Saved */
0554 
0555 #define WMREG_TDFTS 0x3428  /* Transmit Data FIFO Tail Saved */
0556 
0557 #define WMREG_TDFPC 0x3430  /* Transmit Data FIFO Packet Count */
0558 
0559 #define WMREG_OLD_TBDAL 0x0420  /* Transmit Descriptor Base Lo */
0560 #define WMREG_TBDAL 0x3800
0561 
0562 #define WMREG_OLD_TBDAH 0x0424  /* Transmit Descriptor Base Hi */
0563 #define WMREG_TBDAH 0x3804
0564 
0565 #define WMREG_OLD_TDLEN 0x0428  /* Transmit Descriptor Length */
0566 #define WMREG_TDLEN 0x3808
0567 
0568 #define WMREG_OLD_TDH   0x0430  /* Transmit Descriptor Head */
0569 #define WMREG_TDH   0x3810
0570 
0571 #define WMREG_OLD_TDT   0x0438  /* Transmit Descriptor Tail */
0572 #define WMREG_TDT   0x3818
0573 
0574 #define WMREG_OLD_TIDV  0x0440  /* Transmit Delay Interrupt Value */
0575 #define WMREG_TIDV  0x3820
0576 
0577 #define WMREG_TXDCTL    0x3828  /* Trandmit Descriptor Control */
0578 #define TXDCTL_PTHRESH(x) ((x) << 0)    /* prefetch threshold */
0579 #define TXDCTL_HTHRESH(x) ((x) << 8)    /* host threshold */
0580 #define TXDCTL_WTHRESH(x) ((x) << 16)   /* write back threshold */
0581 
0582 #define WMREG_TADV  0x382c  /* Transmit Absolute Interrupt Delay Timer */
0583 
0584 #define WMREG_AIT   0x0458  /* Adaptive IFS Throttle */
0585 
0586 #define WMREG_VFTA  0x0600
0587 
0588 #define WM_MC_TABSIZE   128
0589 #define WM_ICH8_MC_TABSIZE 32
0590 #define WM_VLAN_TABSIZE 128
0591 
0592 #define WMREG_PBA   0x1000  /* Packet Buffer Allocation */
0593 #define PBA_BYTE_SHIFT  10      /* KB -> bytes */
0594 #define PBA_ADDR_SHIFT  7       /* KB -> quadwords */
0595 #define PBA_8K      0x0008
0596 #define PBA_12K     0x000c
0597 #define PBA_16K     0x0010      /* 16K, default Tx allocation */
0598 #define PBA_22K     0x0016
0599 #define PBA_24K     0x0018
0600 #define PBA_30K     0x001e
0601 #define PBA_32K     0x0020
0602 #define PBA_40K     0x0028
0603 #define PBA_48K     0x0030      /* 48K, default Rx allocation */
0604 
0605 #define WMREG_PBS   0x1000  /* Packet Buffer Size (ICH8 only ?) */
0606 
0607 #define WMREG_TXDMAC    0x3000  /* Transfer DMA Control */
0608 #define TXDMAC_DPP  (1U << 0)   /* disable packet prefetch */
0609 
0610 #define WMREG_TSPMT 0x3830  /* TCP Segmentation Pad and Minimum
0611                    Threshold (Cordova) */
0612 #define TSPMT_TSMT(x)   (x)     /* TCP seg min transfer */
0613 #define TSPMT_TSPBP(x)  ((x) << 16) /* TCP seg pkt buf padding */
0614 
0615 #define WMREG_RXCSUM    0x5000  /* Receive Checksum register */
0616 #define RXCSUM_PCSS 0x000000ff  /* Packet Checksum Start */
0617 #define RXCSUM_IPOFL    (1U << 8)   /* IP checksum offload */
0618 #define RXCSUM_TUOFL    (1U << 9)   /* TCP/UDP checksum offload */
0619 #define RXCSUM_IPV6OFL  (1U << 10)  /* IPv6 checksum offload */
0620 
0621 #define WMREG_RXERRC    0x400C  /* receive error Count - R/clr */
0622 #define WMREG_COLC  0x4028  /* collision Count - R/clr */
0623 #define WMREG_XONRXC    0x4048  /* XON Rx Count - R/clr */
0624 #define WMREG_XONTXC    0x404c  /* XON Tx Count - R/clr */
0625 #define WMREG_XOFFRXC   0x4050  /* XOFF Rx Count - R/clr */
0626 #define WMREG_XOFFTXC   0x4054  /* XOFF Tx Count - R/clr */
0627 #define WMREG_FCRUC 0x4058  /* Flow Control Rx Unsupported Count - R/clr */
0628 
0629 #define WMREG_KUMCTRLSTA 0x0034 /* MAC-PHY interface - RW */
0630 #define KUMCTRLSTA_MASK         0x0000FFFF
0631 #define KUMCTRLSTA_OFFSET       0x001F0000
0632 #define KUMCTRLSTA_OFFSET_SHIFT     16
0633 #define KUMCTRLSTA_REN          0x00200000
0634 
0635 #define KUMCTRLSTA_OFFSET_FIFO_CTRL 0x00000000
0636 #define KUMCTRLSTA_OFFSET_CTRL      0x00000001
0637 #define KUMCTRLSTA_OFFSET_INB_CTRL  0x00000002
0638 #define KUMCTRLSTA_OFFSET_DIAG      0x00000003
0639 #define KUMCTRLSTA_OFFSET_TIMEOUTS  0x00000004
0640 #define KUMCTRLSTA_OFFSET_INB_PARAM 0x00000009
0641 #define KUMCTRLSTA_OFFSET_HD_CTRL   0x00000010
0642 #define KUMCTRLSTA_OFFSET_M2P_SERDES    0x0000001E
0643 #define KUMCTRLSTA_OFFSET_M2P_MODES 0x0000001F
0644 
0645 /* FIFO Control */
0646 #define KUMCTRLSTA_FIFO_CTRL_RX_BYPASS  0x00000008
0647 #define KUMCTRLSTA_FIFO_CTRL_TX_BYPASS  0x00000800
0648 
0649 /* In-Band Control */
0650 #define KUMCTRLSTA_INB_CTRL_LINK_TMOUT_DFLT 0x00000500
0651 #define KUMCTRLSTA_INB_CTRL_DIS_PADDING 0x00000010
0652 
0653 /* Half-Duplex Control */
0654 #define KUMCTRLSTA_HD_CTRL_10_100_DEFAULT 0x00000004
0655 #define KUMCTRLSTA_HD_CTRL_1000_DEFAULT 0x00000000
0656 
0657 #define WMREG_MDPHYA    0x003C  /* PHY address - RW */
0658 
0659 #define WMREG_MANC2H    0x5860  /* Managment Control To Host - RW */
0660 
0661 #define WMREG_SWSM  0x5b50  /* SW Semaphore */
0662 #define SWSM_SMBI   0x00000001  /* Driver Semaphore bit */
0663 #define SWSM_SWESMBI    0x00000002  /* FW Semaphore bit */
0664 #define SWSM_WMNG   0x00000004  /* Wake MNG Clock */
0665 #define SWSM_DRV_LOAD   0x00000008  /* Driver Loaded Bit */
0666 
0667 #define WMREG_SW_FW_SYNC 0x5b5c /* software-firmware semaphore */
0668 #define SWFW_EEP_SM     0x0001 /* eeprom access */
0669 #define SWFW_PHY0_SM        0x0002 /* first ctrl phy access */
0670 #define SWFW_PHY1_SM        0x0004 /* second ctrl phy access */
0671 #define SWFW_MAC_CSR_SM     0x0008
0672 #define SWFW_SOFT_SHIFT     0   /* software semaphores */
0673 #define SWFW_FIRM_SHIFT     16  /* firmware semaphores */
0674 
0675 #define WMREG_EXTCNFCTR     0x0f00  /* Extended Configuration Control */
0676 #define EXTCNFCTR_PCIE_WRITE_ENABLE 0x00000001
0677 #define EXTCNFCTR_PHY_WRITE_ENABLE  0x00000002
0678 #define EXTCNFCTR_D_UD_ENABLE       0x00000004
0679 #define EXTCNFCTR_D_UD_LATENCY      0x00000008
0680 #define EXTCNFCTR_D_UD_OWNER        0x00000010
0681 #define EXTCNFCTR_MDIO_SW_OWNERSHIP 0x00000020
0682 #define EXTCNFCTR_MDIO_HW_OWNERSHIP 0x00000040
0683 #define EXTCNFCTR_EXT_CNF_POINTER   0x0FFF0000
0684 #define E1000_EXTCNF_CTRL_SWFLAG    EXTCNFCTR_MDIO_SW_OWNERSHIP
0685 
0686 /* ich8 flash control */
0687 #define ICH_FLASH_COMMAND_TIMEOUT            5000    /* 5000 uSecs - adjusted */
0688 #define ICH_FLASH_ERASE_TIMEOUT              3000000 /* Up to 3 seconds - worst case */
0689 #define ICH_FLASH_CYCLE_REPEAT_COUNT         10      /* 10 cycles */
0690 #define ICH_FLASH_SEG_SIZE_256               256
0691 #define ICH_FLASH_SEG_SIZE_4K                4096
0692 #define ICH_FLASH_SEG_SIZE_64K               65536
0693 
0694 #define ICH_CYCLE_READ                       0x0
0695 #define ICH_CYCLE_RESERVED                   0x1
0696 #define ICH_CYCLE_WRITE                      0x2
0697 #define ICH_CYCLE_ERASE                      0x3
0698 
0699 #define ICH_FLASH_GFPREG   0x0000
0700 #define ICH_FLASH_HSFSTS   0x0004 /* Flash Status Register */
0701 #define HSFSTS_DONE     0x0001 /* Flash Cycle Done */
0702 #define HSFSTS_ERR      0x0002 /* Flash Cycle Error */
0703 #define HSFSTS_DAEL     0x0004 /* Direct Access error Log */
0704 #define HSFSTS_ERSZ_MASK    0x0018 /* Block/Sector Erase Size */
0705 #define HSFSTS_ERSZ_SHIFT   3
0706 #define HSFSTS_FLINPRO      0x0020 /* flash SPI cycle in Progress */
0707 #define HSFSTS_FLDVAL       0x4000 /* Flash Descriptor Valid */
0708 #define HSFSTS_FLLK     0x8000 /* Flash Configuration Lock-Down */
0709 #define ICH_FLASH_HSFCTL   0x0006 /* Flash control Register */
0710 #define HSFCTL_GO       0x0001 /* Flash Cycle Go */
0711 #define HSFCTL_CYCLE_MASK   0x0006 /* Flash Cycle */
0712 #define HSFCTL_CYCLE_SHIFT  1
0713 #define HSFCTL_BCOUNT_MASK  0x0300 /* Data Byte Count */
0714 #define HSFCTL_BCOUNT_SHIFT 8
0715 #define ICH_FLASH_FADDR    0x0008
0716 #define ICH_FLASH_FDATA0   0x0010
0717 #define ICH_FLASH_FRACC    0x0050
0718 #define ICH_FLASH_FREG0    0x0054
0719 #define ICH_FLASH_FREG1    0x0058
0720 #define ICH_FLASH_FREG2    0x005C
0721 #define ICH_FLASH_FREG3    0x0060
0722 #define ICH_FLASH_FPR0     0x0074
0723 #define ICH_FLASH_FPR1     0x0078
0724 #define ICH_FLASH_SSFSTS   0x0090
0725 #define ICH_FLASH_SSFCTL   0x0092
0726 #define ICH_FLASH_PREOP    0x0094
0727 #define ICH_FLASH_OPTYPE   0x0096
0728 #define ICH_FLASH_OPMENU   0x0098
0729 
0730 #define ICH_FLASH_REG_MAPSIZE      0x00A0
0731 #define ICH_FLASH_SECTOR_SIZE      4096
0732 #define ICH_GFPREG_BASE_MASK       0x1FFF
0733 #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
0734 
0735 /* start of Kate Feng added */
0736 #define WMREG_GPTC      0x4080  /* Good packets transmitted count */
0737 #define WMREG_GPRC      0x4074  /* Good packets received count */
0738 #define WMREG_CRCERRS   0x4000  /* CRC Error Count */
0739 #define WMREG_RLEC      0x4040  /* Receive Length Error Count */
0740 /* end of Kate Feng added */