1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* $Id: sungem.h,v 1.10.2.4 2002/03/11 08:54:48 davem Exp $ 3*4882a593Smuzhiyun * sungem.h: Definitions for Sun GEM ethernet driver. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2000 David S. Miller (davem@redhat.com) 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _SUNGEM_H 9*4882a593Smuzhiyun #define _SUNGEM_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* Global Registers */ 12*4882a593Smuzhiyun #define GREG_SEBSTATE 0x0000UL /* SEB State Register */ 13*4882a593Smuzhiyun #define GREG_CFG 0x0004UL /* Configuration Register */ 14*4882a593Smuzhiyun #define GREG_STAT 0x000CUL /* Status Register */ 15*4882a593Smuzhiyun #define GREG_IMASK 0x0010UL /* Interrupt Mask Register */ 16*4882a593Smuzhiyun #define GREG_IACK 0x0014UL /* Interrupt ACK Register */ 17*4882a593Smuzhiyun #define GREG_STAT2 0x001CUL /* Alias of GREG_STAT */ 18*4882a593Smuzhiyun #define GREG_PCIESTAT 0x1000UL /* PCI Error Status Register */ 19*4882a593Smuzhiyun #define GREG_PCIEMASK 0x1004UL /* PCI Error Mask Register */ 20*4882a593Smuzhiyun #define GREG_BIFCFG 0x1008UL /* BIF Configuration Register */ 21*4882a593Smuzhiyun #define GREG_BIFDIAG 0x100CUL /* BIF Diagnostics Register */ 22*4882a593Smuzhiyun #define GREG_SWRST 0x1010UL /* Software Reset Register */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /* Global SEB State Register */ 25*4882a593Smuzhiyun #define GREG_SEBSTATE_ARB 0x00000003 /* State of Arbiter */ 26*4882a593Smuzhiyun #define GREG_SEBSTATE_RXWON 0x00000004 /* RX won internal arbitration */ 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /* Global Configuration Register */ 29*4882a593Smuzhiyun #define GREG_CFG_IBURST 0x00000001 /* Infinite Burst */ 30*4882a593Smuzhiyun #define GREG_CFG_TXDMALIM 0x0000003e /* TX DMA grant limit */ 31*4882a593Smuzhiyun #define GREG_CFG_RXDMALIM 0x000007c0 /* RX DMA grant limit */ 32*4882a593Smuzhiyun #define GREG_CFG_RONPAULBIT 0x00000800 /* Use mem read multiple for PCI read 33*4882a593Smuzhiyun * after infinite burst (Apple) */ 34*4882a593Smuzhiyun #define GREG_CFG_ENBUG2FIX 0x00001000 /* Fix Rx hang after overflow */ 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* Global Interrupt Status Register. 37*4882a593Smuzhiyun * 38*4882a593Smuzhiyun * Reading this register automatically clears bits 0 through 6. 39*4882a593Smuzhiyun * This auto-clearing does not occur when the alias at GREG_STAT2 40*4882a593Smuzhiyun * is read instead. The rest of the interrupt bits only clear when 41*4882a593Smuzhiyun * the secondary interrupt status register corresponding to that 42*4882a593Smuzhiyun * bit is read (ie. if GREG_STAT_PCS is set, it will be cleared by 43*4882a593Smuzhiyun * reading PCS_ISTAT). 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun #define GREG_STAT_TXINTME 0x00000001 /* TX INTME frame transferred */ 46*4882a593Smuzhiyun #define GREG_STAT_TXALL 0x00000002 /* All TX frames transferred */ 47*4882a593Smuzhiyun #define GREG_STAT_TXDONE 0x00000004 /* One TX frame transferred */ 48*4882a593Smuzhiyun #define GREG_STAT_RXDONE 0x00000010 /* One RX frame arrived */ 49*4882a593Smuzhiyun #define GREG_STAT_RXNOBUF 0x00000020 /* No free RX buffers available */ 50*4882a593Smuzhiyun #define GREG_STAT_RXTAGERR 0x00000040 /* RX tag framing is corrupt */ 51*4882a593Smuzhiyun #define GREG_STAT_PCS 0x00002000 /* PCS signalled interrupt */ 52*4882a593Smuzhiyun #define GREG_STAT_TXMAC 0x00004000 /* TX MAC signalled interrupt */ 53*4882a593Smuzhiyun #define GREG_STAT_RXMAC 0x00008000 /* RX MAC signalled interrupt */ 54*4882a593Smuzhiyun #define GREG_STAT_MAC 0x00010000 /* MAC Control signalled irq */ 55*4882a593Smuzhiyun #define GREG_STAT_MIF 0x00020000 /* MIF signalled interrupt */ 56*4882a593Smuzhiyun #define GREG_STAT_PCIERR 0x00040000 /* PCI Error interrupt */ 57*4882a593Smuzhiyun #define GREG_STAT_TXNR 0xfff80000 /* == TXDMA_TXDONE reg val */ 58*4882a593Smuzhiyun #define GREG_STAT_TXNR_SHIFT 19 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #define GREG_STAT_ABNORMAL (GREG_STAT_RXNOBUF | GREG_STAT_RXTAGERR | \ 61*4882a593Smuzhiyun GREG_STAT_PCS | GREG_STAT_TXMAC | GREG_STAT_RXMAC | \ 62*4882a593Smuzhiyun GREG_STAT_MAC | GREG_STAT_MIF | GREG_STAT_PCIERR) 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun #define GREG_STAT_NAPI (GREG_STAT_TXALL | GREG_STAT_TXINTME | \ 65*4882a593Smuzhiyun GREG_STAT_RXDONE | GREG_STAT_ABNORMAL) 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun /* The layout of GREG_IMASK and GREG_IACK is identical to GREG_STAT. 68*4882a593Smuzhiyun * Bits set in GREG_IMASK will prevent that interrupt type from being 69*4882a593Smuzhiyun * signalled to the cpu. GREG_IACK can be used to clear specific top-level 70*4882a593Smuzhiyun * interrupt conditions in GREG_STAT, ie. it only works for bits 0 through 6. 71*4882a593Smuzhiyun * Setting the bit will clear that interrupt, clear bits will have no effect 72*4882a593Smuzhiyun * on GREG_STAT. 73*4882a593Smuzhiyun */ 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* Global PCI Error Status Register */ 76*4882a593Smuzhiyun #define GREG_PCIESTAT_BADACK 0x00000001 /* No ACK64# during ABS64 cycle */ 77*4882a593Smuzhiyun #define GREG_PCIESTAT_DTRTO 0x00000002 /* Delayed transaction timeout */ 78*4882a593Smuzhiyun #define GREG_PCIESTAT_OTHER 0x00000004 /* Other PCI error, check cfg space */ 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* The layout of the GREG_PCIEMASK is identical to that of GREG_PCIESTAT. 81*4882a593Smuzhiyun * Bits set in GREG_PCIEMASK will prevent that interrupt type from being 82*4882a593Smuzhiyun * signalled to the cpu. 83*4882a593Smuzhiyun */ 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* Global BIF Configuration Register */ 86*4882a593Smuzhiyun #define GREG_BIFCFG_SLOWCLK 0x00000001 /* Set if PCI runs < 25Mhz */ 87*4882a593Smuzhiyun #define GREG_BIFCFG_B64DIS 0x00000002 /* Disable 64bit wide data cycle*/ 88*4882a593Smuzhiyun #define GREG_BIFCFG_M66EN 0x00000004 /* Set if on 66Mhz PCI segment */ 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* Global BIF Diagnostics Register */ 91*4882a593Smuzhiyun #define GREG_BIFDIAG_BURSTSM 0x007f0000 /* PCI Burst state machine */ 92*4882a593Smuzhiyun #define GREG_BIFDIAG_BIFSM 0xff000000 /* BIF state machine */ 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun /* Global Software Reset Register. 95*4882a593Smuzhiyun * 96*4882a593Smuzhiyun * This register is used to perform a global reset of the RX and TX portions 97*4882a593Smuzhiyun * of the GEM asic. Setting the RX or TX reset bit will start the reset. 98*4882a593Smuzhiyun * The driver _MUST_ poll these bits until they clear. One may not attempt 99*4882a593Smuzhiyun * to program any other part of GEM until the bits clear. 100*4882a593Smuzhiyun */ 101*4882a593Smuzhiyun #define GREG_SWRST_TXRST 0x00000001 /* TX Software Reset */ 102*4882a593Smuzhiyun #define GREG_SWRST_RXRST 0x00000002 /* RX Software Reset */ 103*4882a593Smuzhiyun #define GREG_SWRST_RSTOUT 0x00000004 /* Force RST# pin active */ 104*4882a593Smuzhiyun #define GREG_SWRST_CACHESIZE 0x00ff0000 /* RIO only: cache line size */ 105*4882a593Smuzhiyun #define GREG_SWRST_CACHE_SHIFT 16 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun /* TX DMA Registers */ 108*4882a593Smuzhiyun #define TXDMA_KICK 0x2000UL /* TX Kick Register */ 109*4882a593Smuzhiyun #define TXDMA_CFG 0x2004UL /* TX Configuration Register */ 110*4882a593Smuzhiyun #define TXDMA_DBLOW 0x2008UL /* TX Desc. Base Low */ 111*4882a593Smuzhiyun #define TXDMA_DBHI 0x200CUL /* TX Desc. Base High */ 112*4882a593Smuzhiyun #define TXDMA_FWPTR 0x2014UL /* TX FIFO Write Pointer */ 113*4882a593Smuzhiyun #define TXDMA_FSWPTR 0x2018UL /* TX FIFO Shadow Write Pointer */ 114*4882a593Smuzhiyun #define TXDMA_FRPTR 0x201CUL /* TX FIFO Read Pointer */ 115*4882a593Smuzhiyun #define TXDMA_FSRPTR 0x2020UL /* TX FIFO Shadow Read Pointer */ 116*4882a593Smuzhiyun #define TXDMA_PCNT 0x2024UL /* TX FIFO Packet Counter */ 117*4882a593Smuzhiyun #define TXDMA_SMACHINE 0x2028UL /* TX State Machine Register */ 118*4882a593Smuzhiyun #define TXDMA_DPLOW 0x2030UL /* TX Data Pointer Low */ 119*4882a593Smuzhiyun #define TXDMA_DPHI 0x2034UL /* TX Data Pointer High */ 120*4882a593Smuzhiyun #define TXDMA_TXDONE 0x2100UL /* TX Completion Register */ 121*4882a593Smuzhiyun #define TXDMA_FADDR 0x2104UL /* TX FIFO Address */ 122*4882a593Smuzhiyun #define TXDMA_FTAG 0x2108UL /* TX FIFO Tag */ 123*4882a593Smuzhiyun #define TXDMA_DLOW 0x210CUL /* TX FIFO Data Low */ 124*4882a593Smuzhiyun #define TXDMA_DHIT1 0x2110UL /* TX FIFO Data HighT1 */ 125*4882a593Smuzhiyun #define TXDMA_DHIT0 0x2114UL /* TX FIFO Data HighT0 */ 126*4882a593Smuzhiyun #define TXDMA_FSZ 0x2118UL /* TX FIFO Size */ 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun /* TX Kick Register. 129*4882a593Smuzhiyun * 130*4882a593Smuzhiyun * This 13-bit register is programmed by the driver to hold the descriptor 131*4882a593Smuzhiyun * entry index which follows the last valid transmit descriptor. 132*4882a593Smuzhiyun */ 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun /* TX Completion Register. 135*4882a593Smuzhiyun * 136*4882a593Smuzhiyun * This 13-bit register is updated by GEM to hold to descriptor entry index 137*4882a593Smuzhiyun * which follows the last descriptor already processed by GEM. Note that 138*4882a593Smuzhiyun * this value is mirrored in GREG_STAT which eliminates the need to even 139*4882a593Smuzhiyun * access this register in the driver during interrupt processing. 140*4882a593Smuzhiyun */ 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun /* TX Configuration Register. 143*4882a593Smuzhiyun * 144*4882a593Smuzhiyun * Note that TXDMA_CFG_FTHRESH, the TX FIFO Threshold, is an obsolete feature 145*4882a593Smuzhiyun * that was meant to be used with jumbo packets. It should be set to the 146*4882a593Smuzhiyun * maximum value of 0x4ff, else one risks getting TX MAC Underrun errors. 147*4882a593Smuzhiyun */ 148*4882a593Smuzhiyun #define TXDMA_CFG_ENABLE 0x00000001 /* Enable TX DMA channel */ 149*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ 0x0000001e /* TX descriptor ring size */ 150*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_32 0x00000000 /* 32 TX descriptors */ 151*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_64 0x00000002 /* 64 TX descriptors */ 152*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_128 0x00000004 /* 128 TX descriptors */ 153*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_256 0x00000006 /* 256 TX descriptors */ 154*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_512 0x00000008 /* 512 TX descriptors */ 155*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_1K 0x0000000a /* 1024 TX descriptors */ 156*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_2K 0x0000000c /* 2048 TX descriptors */ 157*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_4K 0x0000000e /* 4096 TX descriptors */ 158*4882a593Smuzhiyun #define TXDMA_CFG_RINGSZ_8K 0x00000010 /* 8192 TX descriptors */ 159*4882a593Smuzhiyun #define TXDMA_CFG_PIOSEL 0x00000020 /* Enable TX FIFO PIO from cpu */ 160*4882a593Smuzhiyun #define TXDMA_CFG_FTHRESH 0x001ffc00 /* TX FIFO Threshold, obsolete */ 161*4882a593Smuzhiyun #define TXDMA_CFG_PMODE 0x00200000 /* TXALL irq means TX FIFO empty*/ 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun /* TX Descriptor Base Low/High. 164*4882a593Smuzhiyun * 165*4882a593Smuzhiyun * These two registers store the 53 most significant bits of the base address 166*4882a593Smuzhiyun * of the TX descriptor table. The 11 least significant bits are always 167*4882a593Smuzhiyun * zero. As a result, the TX descriptor table must be 2K aligned. 168*4882a593Smuzhiyun */ 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun /* The rest of the TXDMA_* registers are for diagnostics and debug, I will document 171*4882a593Smuzhiyun * them later. -DaveM 172*4882a593Smuzhiyun */ 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun /* WakeOnLan Registers */ 175*4882a593Smuzhiyun #define WOL_MATCH0 0x3000UL 176*4882a593Smuzhiyun #define WOL_MATCH1 0x3004UL 177*4882a593Smuzhiyun #define WOL_MATCH2 0x3008UL 178*4882a593Smuzhiyun #define WOL_MCOUNT 0x300CUL 179*4882a593Smuzhiyun #define WOL_WAKECSR 0x3010UL 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun /* WOL Match count register 182*4882a593Smuzhiyun */ 183*4882a593Smuzhiyun #define WOL_MCOUNT_N 0x00000010 184*4882a593Smuzhiyun #define WOL_MCOUNT_M 0x00000000 /* 0 << 8 */ 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun #define WOL_WAKECSR_ENABLE 0x00000001 187*4882a593Smuzhiyun #define WOL_WAKECSR_MII 0x00000002 188*4882a593Smuzhiyun #define WOL_WAKECSR_SEEN 0x00000004 189*4882a593Smuzhiyun #define WOL_WAKECSR_FILT_UCAST 0x00000008 190*4882a593Smuzhiyun #define WOL_WAKECSR_FILT_MCAST 0x00000010 191*4882a593Smuzhiyun #define WOL_WAKECSR_FILT_BCAST 0x00000020 192*4882a593Smuzhiyun #define WOL_WAKECSR_FILT_SEEN 0x00000040 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun /* Receive DMA Registers */ 196*4882a593Smuzhiyun #define RXDMA_CFG 0x4000UL /* RX Configuration Register */ 197*4882a593Smuzhiyun #define RXDMA_DBLOW 0x4004UL /* RX Descriptor Base Low */ 198*4882a593Smuzhiyun #define RXDMA_DBHI 0x4008UL /* RX Descriptor Base High */ 199*4882a593Smuzhiyun #define RXDMA_FWPTR 0x400CUL /* RX FIFO Write Pointer */ 200*4882a593Smuzhiyun #define RXDMA_FSWPTR 0x4010UL /* RX FIFO Shadow Write Pointer */ 201*4882a593Smuzhiyun #define RXDMA_FRPTR 0x4014UL /* RX FIFO Read Pointer */ 202*4882a593Smuzhiyun #define RXDMA_PCNT 0x4018UL /* RX FIFO Packet Counter */ 203*4882a593Smuzhiyun #define RXDMA_SMACHINE 0x401CUL /* RX State Machine Register */ 204*4882a593Smuzhiyun #define RXDMA_PTHRESH 0x4020UL /* Pause Thresholds */ 205*4882a593Smuzhiyun #define RXDMA_DPLOW 0x4024UL /* RX Data Pointer Low */ 206*4882a593Smuzhiyun #define RXDMA_DPHI 0x4028UL /* RX Data Pointer High */ 207*4882a593Smuzhiyun #define RXDMA_KICK 0x4100UL /* RX Kick Register */ 208*4882a593Smuzhiyun #define RXDMA_DONE 0x4104UL /* RX Completion Register */ 209*4882a593Smuzhiyun #define RXDMA_BLANK 0x4108UL /* RX Blanking Register */ 210*4882a593Smuzhiyun #define RXDMA_FADDR 0x410CUL /* RX FIFO Address */ 211*4882a593Smuzhiyun #define RXDMA_FTAG 0x4110UL /* RX FIFO Tag */ 212*4882a593Smuzhiyun #define RXDMA_DLOW 0x4114UL /* RX FIFO Data Low */ 213*4882a593Smuzhiyun #define RXDMA_DHIT1 0x4118UL /* RX FIFO Data HighT0 */ 214*4882a593Smuzhiyun #define RXDMA_DHIT0 0x411CUL /* RX FIFO Data HighT1 */ 215*4882a593Smuzhiyun #define RXDMA_FSZ 0x4120UL /* RX FIFO Size */ 216*4882a593Smuzhiyun 217*4882a593Smuzhiyun /* RX Configuration Register. */ 218*4882a593Smuzhiyun #define RXDMA_CFG_ENABLE 0x00000001 /* Enable RX DMA channel */ 219*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ 0x0000001e /* RX descriptor ring size */ 220*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_32 0x00000000 /* - 32 entries */ 221*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_64 0x00000002 /* - 64 entries */ 222*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_128 0x00000004 /* - 128 entries */ 223*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_256 0x00000006 /* - 256 entries */ 224*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_512 0x00000008 /* - 512 entries */ 225*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_1K 0x0000000a /* - 1024 entries */ 226*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_2K 0x0000000c /* - 2048 entries */ 227*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_4K 0x0000000e /* - 4096 entries */ 228*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_8K 0x00000010 /* - 8192 entries */ 229*4882a593Smuzhiyun #define RXDMA_CFG_RINGSZ_BDISAB 0x00000020 /* Disable RX desc batching */ 230*4882a593Smuzhiyun #define RXDMA_CFG_FBOFF 0x00001c00 /* Offset of first data byte */ 231*4882a593Smuzhiyun #define RXDMA_CFG_CSUMOFF 0x000fe000 /* Skip bytes before csum calc */ 232*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH 0x07000000 /* RX FIFO dma start threshold */ 233*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_64 0x00000000 /* - 64 bytes */ 234*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_128 0x01000000 /* - 128 bytes */ 235*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_256 0x02000000 /* - 256 bytes */ 236*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_512 0x03000000 /* - 512 bytes */ 237*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_1K 0x04000000 /* - 1024 bytes */ 238*4882a593Smuzhiyun #define RXDMA_CFG_FTHRESH_2K 0x05000000 /* - 2048 bytes */ 239*4882a593Smuzhiyun 240*4882a593Smuzhiyun /* RX Descriptor Base Low/High. 241*4882a593Smuzhiyun * 242*4882a593Smuzhiyun * These two registers store the 53 most significant bits of the base address 243*4882a593Smuzhiyun * of the RX descriptor table. The 11 least significant bits are always 244*4882a593Smuzhiyun * zero. As a result, the RX descriptor table must be 2K aligned. 245*4882a593Smuzhiyun */ 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun /* RX PAUSE Thresholds. 248*4882a593Smuzhiyun * 249*4882a593Smuzhiyun * These values determine when XOFF and XON PAUSE frames are emitted by 250*4882a593Smuzhiyun * GEM. The thresholds measure RX FIFO occupancy in units of 64 bytes. 251*4882a593Smuzhiyun */ 252*4882a593Smuzhiyun #define RXDMA_PTHRESH_OFF 0x000001ff /* XOFF emitted w/FIFO > this */ 253*4882a593Smuzhiyun #define RXDMA_PTHRESH_ON 0x001ff000 /* XON emitted w/FIFO < this */ 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun /* RX Kick Register. 256*4882a593Smuzhiyun * 257*4882a593Smuzhiyun * This 13-bit register is written by the host CPU and holds the last 258*4882a593Smuzhiyun * valid RX descriptor number plus one. This is, if 'N' is written to 259*4882a593Smuzhiyun * this register, it means that all RX descriptors up to but excluding 260*4882a593Smuzhiyun * 'N' are valid. 261*4882a593Smuzhiyun * 262*4882a593Smuzhiyun * The hardware requires that RX descriptors are posted in increments 263*4882a593Smuzhiyun * of 4. This means 'N' must be a multiple of four. For the best 264*4882a593Smuzhiyun * performance, the first new descriptor being posted should be (PCI) 265*4882a593Smuzhiyun * cache line aligned. 266*4882a593Smuzhiyun */ 267*4882a593Smuzhiyun 268*4882a593Smuzhiyun /* RX Completion Register. 269*4882a593Smuzhiyun * 270*4882a593Smuzhiyun * This 13-bit register is updated by GEM to indicate which RX descriptors 271*4882a593Smuzhiyun * have already been used for receive frames. All descriptors up to but 272*4882a593Smuzhiyun * excluding the value in this register are ready to be processed. GEM 273*4882a593Smuzhiyun * updates this register value after the RX FIFO empties completely into 274*4882a593Smuzhiyun * the RX descriptor's buffer, but before the RX_DONE bit is set in the 275*4882a593Smuzhiyun * interrupt status register. 276*4882a593Smuzhiyun */ 277*4882a593Smuzhiyun 278*4882a593Smuzhiyun /* RX Blanking Register. */ 279*4882a593Smuzhiyun #define RXDMA_BLANK_IPKTS 0x000001ff /* RX_DONE asserted after this 280*4882a593Smuzhiyun * many packets received since 281*4882a593Smuzhiyun * previous RX_DONE. 282*4882a593Smuzhiyun */ 283*4882a593Smuzhiyun #define RXDMA_BLANK_ITIME 0x000ff000 /* RX_DONE asserted after this 284*4882a593Smuzhiyun * many clocks (measured in 2048 285*4882a593Smuzhiyun * PCI clocks) were counted since 286*4882a593Smuzhiyun * the previous RX_DONE. 287*4882a593Smuzhiyun */ 288*4882a593Smuzhiyun 289*4882a593Smuzhiyun /* RX FIFO Size. 290*4882a593Smuzhiyun * 291*4882a593Smuzhiyun * This 11-bit read-only register indicates how large, in units of 64-bytes, 292*4882a593Smuzhiyun * the RX FIFO is. The driver uses this to properly configure the RX PAUSE 293*4882a593Smuzhiyun * thresholds. 294*4882a593Smuzhiyun */ 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun /* The rest of the RXDMA_* registers are for diagnostics and debug, I will document 297*4882a593Smuzhiyun * them later. -DaveM 298*4882a593Smuzhiyun */ 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun /* MAC Registers */ 301*4882a593Smuzhiyun #define MAC_TXRST 0x6000UL /* TX MAC Software Reset Command*/ 302*4882a593Smuzhiyun #define MAC_RXRST 0x6004UL /* RX MAC Software Reset Command*/ 303*4882a593Smuzhiyun #define MAC_SNDPAUSE 0x6008UL /* Send Pause Command Register */ 304*4882a593Smuzhiyun #define MAC_TXSTAT 0x6010UL /* TX MAC Status Register */ 305*4882a593Smuzhiyun #define MAC_RXSTAT 0x6014UL /* RX MAC Status Register */ 306*4882a593Smuzhiyun #define MAC_CSTAT 0x6018UL /* MAC Control Status Register */ 307*4882a593Smuzhiyun #define MAC_TXMASK 0x6020UL /* TX MAC Mask Register */ 308*4882a593Smuzhiyun #define MAC_RXMASK 0x6024UL /* RX MAC Mask Register */ 309*4882a593Smuzhiyun #define MAC_MCMASK 0x6028UL /* MAC Control Mask Register */ 310*4882a593Smuzhiyun #define MAC_TXCFG 0x6030UL /* TX MAC Configuration Register*/ 311*4882a593Smuzhiyun #define MAC_RXCFG 0x6034UL /* RX MAC Configuration Register*/ 312*4882a593Smuzhiyun #define MAC_MCCFG 0x6038UL /* MAC Control Config Register */ 313*4882a593Smuzhiyun #define MAC_XIFCFG 0x603CUL /* XIF Configuration Register */ 314*4882a593Smuzhiyun #define MAC_IPG0 0x6040UL /* InterPacketGap0 Register */ 315*4882a593Smuzhiyun #define MAC_IPG1 0x6044UL /* InterPacketGap1 Register */ 316*4882a593Smuzhiyun #define MAC_IPG2 0x6048UL /* InterPacketGap2 Register */ 317*4882a593Smuzhiyun #define MAC_STIME 0x604CUL /* SlotTime Register */ 318*4882a593Smuzhiyun #define MAC_MINFSZ 0x6050UL /* MinFrameSize Register */ 319*4882a593Smuzhiyun #define MAC_MAXFSZ 0x6054UL /* MaxFrameSize Register */ 320*4882a593Smuzhiyun #define MAC_PASIZE 0x6058UL /* PA Size Register */ 321*4882a593Smuzhiyun #define MAC_JAMSIZE 0x605CUL /* JamSize Register */ 322*4882a593Smuzhiyun #define MAC_ATTLIM 0x6060UL /* Attempt Limit Register */ 323*4882a593Smuzhiyun #define MAC_MCTYPE 0x6064UL /* MAC Control Type Register */ 324*4882a593Smuzhiyun #define MAC_ADDR0 0x6080UL /* MAC Address 0 Register */ 325*4882a593Smuzhiyun #define MAC_ADDR1 0x6084UL /* MAC Address 1 Register */ 326*4882a593Smuzhiyun #define MAC_ADDR2 0x6088UL /* MAC Address 2 Register */ 327*4882a593Smuzhiyun #define MAC_ADDR3 0x608CUL /* MAC Address 3 Register */ 328*4882a593Smuzhiyun #define MAC_ADDR4 0x6090UL /* MAC Address 4 Register */ 329*4882a593Smuzhiyun #define MAC_ADDR5 0x6094UL /* MAC Address 5 Register */ 330*4882a593Smuzhiyun #define MAC_ADDR6 0x6098UL /* MAC Address 6 Register */ 331*4882a593Smuzhiyun #define MAC_ADDR7 0x609CUL /* MAC Address 7 Register */ 332*4882a593Smuzhiyun #define MAC_ADDR8 0x60A0UL /* MAC Address 8 Register */ 333*4882a593Smuzhiyun #define MAC_AFILT0 0x60A4UL /* Address Filter 0 Register */ 334*4882a593Smuzhiyun #define MAC_AFILT1 0x60A8UL /* Address Filter 1 Register */ 335*4882a593Smuzhiyun #define MAC_AFILT2 0x60ACUL /* Address Filter 2 Register */ 336*4882a593Smuzhiyun #define MAC_AF21MSK 0x60B0UL /* Address Filter 2&1 Mask Reg */ 337*4882a593Smuzhiyun #define MAC_AF0MSK 0x60B4UL /* Address Filter 0 Mask Reg */ 338*4882a593Smuzhiyun #define MAC_HASH0 0x60C0UL /* Hash Table 0 Register */ 339*4882a593Smuzhiyun #define MAC_HASH1 0x60C4UL /* Hash Table 1 Register */ 340*4882a593Smuzhiyun #define MAC_HASH2 0x60C8UL /* Hash Table 2 Register */ 341*4882a593Smuzhiyun #define MAC_HASH3 0x60CCUL /* Hash Table 3 Register */ 342*4882a593Smuzhiyun #define MAC_HASH4 0x60D0UL /* Hash Table 4 Register */ 343*4882a593Smuzhiyun #define MAC_HASH5 0x60D4UL /* Hash Table 5 Register */ 344*4882a593Smuzhiyun #define MAC_HASH6 0x60D8UL /* Hash Table 6 Register */ 345*4882a593Smuzhiyun #define MAC_HASH7 0x60DCUL /* Hash Table 7 Register */ 346*4882a593Smuzhiyun #define MAC_HASH8 0x60E0UL /* Hash Table 8 Register */ 347*4882a593Smuzhiyun #define MAC_HASH9 0x60E4UL /* Hash Table 9 Register */ 348*4882a593Smuzhiyun #define MAC_HASH10 0x60E8UL /* Hash Table 10 Register */ 349*4882a593Smuzhiyun #define MAC_HASH11 0x60ECUL /* Hash Table 11 Register */ 350*4882a593Smuzhiyun #define MAC_HASH12 0x60F0UL /* Hash Table 12 Register */ 351*4882a593Smuzhiyun #define MAC_HASH13 0x60F4UL /* Hash Table 13 Register */ 352*4882a593Smuzhiyun #define MAC_HASH14 0x60F8UL /* Hash Table 14 Register */ 353*4882a593Smuzhiyun #define MAC_HASH15 0x60FCUL /* Hash Table 15 Register */ 354*4882a593Smuzhiyun #define MAC_NCOLL 0x6100UL /* Normal Collision Counter */ 355*4882a593Smuzhiyun #define MAC_FASUCC 0x6104UL /* First Attmpt. Succ Coll Ctr. */ 356*4882a593Smuzhiyun #define MAC_ECOLL 0x6108UL /* Excessive Collision Counter */ 357*4882a593Smuzhiyun #define MAC_LCOLL 0x610CUL /* Late Collision Counter */ 358*4882a593Smuzhiyun #define MAC_DTIMER 0x6110UL /* Defer Timer */ 359*4882a593Smuzhiyun #define MAC_PATMPS 0x6114UL /* Peak Attempts Register */ 360*4882a593Smuzhiyun #define MAC_RFCTR 0x6118UL /* Receive Frame Counter */ 361*4882a593Smuzhiyun #define MAC_LERR 0x611CUL /* Length Error Counter */ 362*4882a593Smuzhiyun #define MAC_AERR 0x6120UL /* Alignment Error Counter */ 363*4882a593Smuzhiyun #define MAC_FCSERR 0x6124UL /* FCS Error Counter */ 364*4882a593Smuzhiyun #define MAC_RXCVERR 0x6128UL /* RX code Violation Error Ctr */ 365*4882a593Smuzhiyun #define MAC_RANDSEED 0x6130UL /* Random Number Seed Register */ 366*4882a593Smuzhiyun #define MAC_SMACHINE 0x6134UL /* State Machine Register */ 367*4882a593Smuzhiyun 368*4882a593Smuzhiyun /* TX MAC Software Reset Command. */ 369*4882a593Smuzhiyun #define MAC_TXRST_CMD 0x00000001 /* Start sw reset, self-clears */ 370*4882a593Smuzhiyun 371*4882a593Smuzhiyun /* RX MAC Software Reset Command. */ 372*4882a593Smuzhiyun #define MAC_RXRST_CMD 0x00000001 /* Start sw reset, self-clears */ 373*4882a593Smuzhiyun 374*4882a593Smuzhiyun /* Send Pause Command. */ 375*4882a593Smuzhiyun #define MAC_SNDPAUSE_TS 0x0000ffff /* The pause_time operand used in 376*4882a593Smuzhiyun * Send_Pause and flow-control 377*4882a593Smuzhiyun * handshakes. 378*4882a593Smuzhiyun */ 379*4882a593Smuzhiyun #define MAC_SNDPAUSE_SP 0x00010000 /* Setting this bit instructs the MAC 380*4882a593Smuzhiyun * to send a Pause Flow Control 381*4882a593Smuzhiyun * frame onto the network. 382*4882a593Smuzhiyun */ 383*4882a593Smuzhiyun 384*4882a593Smuzhiyun /* TX MAC Status Register. */ 385*4882a593Smuzhiyun #define MAC_TXSTAT_XMIT 0x00000001 /* Frame Transmitted */ 386*4882a593Smuzhiyun #define MAC_TXSTAT_URUN 0x00000002 /* TX Underrun */ 387*4882a593Smuzhiyun #define MAC_TXSTAT_MPE 0x00000004 /* Max Packet Size Error */ 388*4882a593Smuzhiyun #define MAC_TXSTAT_NCE 0x00000008 /* Normal Collision Cntr Expire */ 389*4882a593Smuzhiyun #define MAC_TXSTAT_ECE 0x00000010 /* Excess Collision Cntr Expire */ 390*4882a593Smuzhiyun #define MAC_TXSTAT_LCE 0x00000020 /* Late Collision Cntr Expire */ 391*4882a593Smuzhiyun #define MAC_TXSTAT_FCE 0x00000040 /* First Collision Cntr Expire */ 392*4882a593Smuzhiyun #define MAC_TXSTAT_DTE 0x00000080 /* Defer Timer Expire */ 393*4882a593Smuzhiyun #define MAC_TXSTAT_PCE 0x00000100 /* Peak Attempts Cntr Expire */ 394*4882a593Smuzhiyun 395*4882a593Smuzhiyun /* RX MAC Status Register. */ 396*4882a593Smuzhiyun #define MAC_RXSTAT_RCV 0x00000001 /* Frame Received */ 397*4882a593Smuzhiyun #define MAC_RXSTAT_OFLW 0x00000002 /* Receive Overflow */ 398*4882a593Smuzhiyun #define MAC_RXSTAT_FCE 0x00000004 /* Frame Cntr Expire */ 399*4882a593Smuzhiyun #define MAC_RXSTAT_ACE 0x00000008 /* Align Error Cntr Expire */ 400*4882a593Smuzhiyun #define MAC_RXSTAT_CCE 0x00000010 /* CRC Error Cntr Expire */ 401*4882a593Smuzhiyun #define MAC_RXSTAT_LCE 0x00000020 /* Length Error Cntr Expire */ 402*4882a593Smuzhiyun #define MAC_RXSTAT_VCE 0x00000040 /* Code Violation Cntr Expire */ 403*4882a593Smuzhiyun 404*4882a593Smuzhiyun /* MAC Control Status Register. */ 405*4882a593Smuzhiyun #define MAC_CSTAT_PRCV 0x00000001 /* Pause Received */ 406*4882a593Smuzhiyun #define MAC_CSTAT_PS 0x00000002 /* Paused State */ 407*4882a593Smuzhiyun #define MAC_CSTAT_NPS 0x00000004 /* Not Paused State */ 408*4882a593Smuzhiyun #define MAC_CSTAT_PTR 0xffff0000 /* Pause Time Received */ 409*4882a593Smuzhiyun 410*4882a593Smuzhiyun /* The layout of the MAC_{TX,RX,C}MASK registers is identical to that 411*4882a593Smuzhiyun * of MAC_{TX,RX,C}STAT. Bits set in MAC_{TX,RX,C}MASK will prevent 412*4882a593Smuzhiyun * that interrupt type from being signalled to front end of GEM. For 413*4882a593Smuzhiyun * the interrupt to actually get sent to the cpu, it is necessary to 414*4882a593Smuzhiyun * properly set the appropriate GREG_IMASK_{TX,RX,}MAC bits as well. 415*4882a593Smuzhiyun */ 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun /* TX MAC Configuration Register. 418*4882a593Smuzhiyun * 419*4882a593Smuzhiyun * NOTE: The TX MAC Enable bit must be cleared and polled until 420*4882a593Smuzhiyun * zero before any other bits in this register are changed. 421*4882a593Smuzhiyun * 422*4882a593Smuzhiyun * Also, enabling the Carrier Extension feature of GEM is 423*4882a593Smuzhiyun * a 3 step process 1) Set TX Carrier Extension 2) Set 424*4882a593Smuzhiyun * RX Carrier Extension 3) Set Slot Time to 0x200. This 425*4882a593Smuzhiyun * mode must be enabled when in half-duplex at 1Gbps, else 426*4882a593Smuzhiyun * it must be disabled. 427*4882a593Smuzhiyun */ 428*4882a593Smuzhiyun #define MAC_TXCFG_ENAB 0x00000001 /* TX MAC Enable */ 429*4882a593Smuzhiyun #define MAC_TXCFG_ICS 0x00000002 /* Ignore Carrier Sense */ 430*4882a593Smuzhiyun #define MAC_TXCFG_ICOLL 0x00000004 /* Ignore Collisions */ 431*4882a593Smuzhiyun #define MAC_TXCFG_EIPG0 0x00000008 /* Enable IPG0 */ 432*4882a593Smuzhiyun #define MAC_TXCFG_NGU 0x00000010 /* Never Give Up */ 433*4882a593Smuzhiyun #define MAC_TXCFG_NGUL 0x00000020 /* Never Give Up Limit */ 434*4882a593Smuzhiyun #define MAC_TXCFG_NBO 0x00000040 /* No Backoff */ 435*4882a593Smuzhiyun #define MAC_TXCFG_SD 0x00000080 /* Slow Down */ 436*4882a593Smuzhiyun #define MAC_TXCFG_NFCS 0x00000100 /* No FCS */ 437*4882a593Smuzhiyun #define MAC_TXCFG_TCE 0x00000200 /* TX Carrier Extension */ 438*4882a593Smuzhiyun 439*4882a593Smuzhiyun /* RX MAC Configuration Register. 440*4882a593Smuzhiyun * 441*4882a593Smuzhiyun * NOTE: The RX MAC Enable bit must be cleared and polled until 442*4882a593Smuzhiyun * zero before any other bits in this register are changed. 443*4882a593Smuzhiyun * 444*4882a593Smuzhiyun * Similar rules apply to the Hash Filter Enable bit when 445*4882a593Smuzhiyun * programming the hash table registers, and the Address Filter 446*4882a593Smuzhiyun * Enable bit when programming the address filter registers. 447*4882a593Smuzhiyun */ 448*4882a593Smuzhiyun #define MAC_RXCFG_ENAB 0x00000001 /* RX MAC Enable */ 449*4882a593Smuzhiyun #define MAC_RXCFG_SPAD 0x00000002 /* Strip Pad */ 450*4882a593Smuzhiyun #define MAC_RXCFG_SFCS 0x00000004 /* Strip FCS */ 451*4882a593Smuzhiyun #define MAC_RXCFG_PROM 0x00000008 /* Promiscuous Mode */ 452*4882a593Smuzhiyun #define MAC_RXCFG_PGRP 0x00000010 /* Promiscuous Group */ 453*4882a593Smuzhiyun #define MAC_RXCFG_HFE 0x00000020 /* Hash Filter Enable */ 454*4882a593Smuzhiyun #define MAC_RXCFG_AFE 0x00000040 /* Address Filter Enable */ 455*4882a593Smuzhiyun #define MAC_RXCFG_DDE 0x00000080 /* Disable Discard on Error */ 456*4882a593Smuzhiyun #define MAC_RXCFG_RCE 0x00000100 /* RX Carrier Extension */ 457*4882a593Smuzhiyun 458*4882a593Smuzhiyun /* MAC Control Config Register. */ 459*4882a593Smuzhiyun #define MAC_MCCFG_SPE 0x00000001 /* Send Pause Enable */ 460*4882a593Smuzhiyun #define MAC_MCCFG_RPE 0x00000002 /* Receive Pause Enable */ 461*4882a593Smuzhiyun #define MAC_MCCFG_PMC 0x00000004 /* Pass MAC Control */ 462*4882a593Smuzhiyun 463*4882a593Smuzhiyun /* XIF Configuration Register. 464*4882a593Smuzhiyun * 465*4882a593Smuzhiyun * NOTE: When leaving or entering loopback mode, a global hardware 466*4882a593Smuzhiyun * init of GEM should be performed. 467*4882a593Smuzhiyun */ 468*4882a593Smuzhiyun #define MAC_XIFCFG_OE 0x00000001 /* MII TX Output Driver Enable */ 469*4882a593Smuzhiyun #define MAC_XIFCFG_LBCK 0x00000002 /* Loopback TX to RX */ 470*4882a593Smuzhiyun #define MAC_XIFCFG_DISE 0x00000004 /* Disable RX path during TX */ 471*4882a593Smuzhiyun #define MAC_XIFCFG_GMII 0x00000008 /* Use GMII clocks + datapath */ 472*4882a593Smuzhiyun #define MAC_XIFCFG_MBOE 0x00000010 /* Controls MII_BUF_EN pin */ 473*4882a593Smuzhiyun #define MAC_XIFCFG_LLED 0x00000020 /* Force LINKLED# active (low) */ 474*4882a593Smuzhiyun #define MAC_XIFCFG_FLED 0x00000040 /* Force FDPLXLED# active (low) */ 475*4882a593Smuzhiyun 476*4882a593Smuzhiyun /* InterPacketGap0 Register. This 8-bit value is used as an extension 477*4882a593Smuzhiyun * to the InterPacketGap1 Register. Specifically it contributes to the 478*4882a593Smuzhiyun * timing of the RX-to-TX IPG. This value is ignored and presumed to 479*4882a593Smuzhiyun * be zero for TX-to-TX IPG calculations and/or when the Enable IPG0 bit 480*4882a593Smuzhiyun * is cleared in the TX MAC Configuration Register. 481*4882a593Smuzhiyun * 482*4882a593Smuzhiyun * This value in this register in terms of media byte time. 483*4882a593Smuzhiyun * 484*4882a593Smuzhiyun * Recommended value: 0x00 485*4882a593Smuzhiyun */ 486*4882a593Smuzhiyun 487*4882a593Smuzhiyun /* InterPacketGap1 Register. This 8-bit value defines the first 2/3 488*4882a593Smuzhiyun * portion of the Inter Packet Gap. 489*4882a593Smuzhiyun * 490*4882a593Smuzhiyun * This value in this register in terms of media byte time. 491*4882a593Smuzhiyun * 492*4882a593Smuzhiyun * Recommended value: 0x08 493*4882a593Smuzhiyun */ 494*4882a593Smuzhiyun 495*4882a593Smuzhiyun /* InterPacketGap2 Register. This 8-bit value defines the second 1/3 496*4882a593Smuzhiyun * portion of the Inter Packet Gap. 497*4882a593Smuzhiyun * 498*4882a593Smuzhiyun * This value in this register in terms of media byte time. 499*4882a593Smuzhiyun * 500*4882a593Smuzhiyun * Recommended value: 0x04 501*4882a593Smuzhiyun */ 502*4882a593Smuzhiyun 503*4882a593Smuzhiyun /* Slot Time Register. This 10-bit value specifies the slot time 504*4882a593Smuzhiyun * parameter in units of media byte time. It determines the physical 505*4882a593Smuzhiyun * span of the network. 506*4882a593Smuzhiyun * 507*4882a593Smuzhiyun * Recommended value: 0x40 508*4882a593Smuzhiyun */ 509*4882a593Smuzhiyun 510*4882a593Smuzhiyun /* Minimum Frame Size Register. This 10-bit register specifies the 511*4882a593Smuzhiyun * smallest sized frame the TXMAC will send onto the medium, and the 512*4882a593Smuzhiyun * RXMAC will receive from the medium. 513*4882a593Smuzhiyun * 514*4882a593Smuzhiyun * Recommended value: 0x40 515*4882a593Smuzhiyun */ 516*4882a593Smuzhiyun 517*4882a593Smuzhiyun /* Maximum Frame and Burst Size Register. 518*4882a593Smuzhiyun * 519*4882a593Smuzhiyun * This register specifies two things. First it specifies the maximum 520*4882a593Smuzhiyun * sized frame the TXMAC will send and the RXMAC will recognize as 521*4882a593Smuzhiyun * valid. Second, it specifies the maximum run length of a burst of 522*4882a593Smuzhiyun * packets sent in half-duplex gigabit modes. 523*4882a593Smuzhiyun * 524*4882a593Smuzhiyun * Recommended value: 0x200005ee 525*4882a593Smuzhiyun */ 526*4882a593Smuzhiyun #define MAC_MAXFSZ_MFS 0x00007fff /* Max Frame Size */ 527*4882a593Smuzhiyun #define MAC_MAXFSZ_MBS 0x7fff0000 /* Max Burst Size */ 528*4882a593Smuzhiyun 529*4882a593Smuzhiyun /* PA Size Register. This 10-bit register specifies the number of preamble 530*4882a593Smuzhiyun * bytes which will be transmitted at the beginning of each frame. A 531*4882a593Smuzhiyun * value of two or greater should be programmed here. 532*4882a593Smuzhiyun * 533*4882a593Smuzhiyun * Recommended value: 0x07 534*4882a593Smuzhiyun */ 535*4882a593Smuzhiyun 536*4882a593Smuzhiyun /* Jam Size Register. This 4-bit register specifies the duration of 537*4882a593Smuzhiyun * the jam in units of media byte time. 538*4882a593Smuzhiyun * 539*4882a593Smuzhiyun * Recommended value: 0x04 540*4882a593Smuzhiyun */ 541*4882a593Smuzhiyun 542*4882a593Smuzhiyun /* Attempts Limit Register. This 8-bit register specifies the number 543*4882a593Smuzhiyun * of attempts that the TXMAC will make to transmit a frame, before it 544*4882a593Smuzhiyun * resets its Attempts Counter. After reaching the Attempts Limit the 545*4882a593Smuzhiyun * TXMAC may or may not drop the frame, as determined by the NGU 546*4882a593Smuzhiyun * (Never Give Up) and NGUL (Never Give Up Limit) bits in the TXMAC 547*4882a593Smuzhiyun * Configuration Register. 548*4882a593Smuzhiyun * 549*4882a593Smuzhiyun * Recommended value: 0x10 550*4882a593Smuzhiyun */ 551*4882a593Smuzhiyun 552*4882a593Smuzhiyun /* MAX Control Type Register. This 16-bit register specifies the 553*4882a593Smuzhiyun * "type" field of a MAC Control frame. The TXMAC uses this field to 554*4882a593Smuzhiyun * encapsulate the MAC Control frame for transmission, and the RXMAC 555*4882a593Smuzhiyun * uses it for decoding valid MAC Control frames received from the 556*4882a593Smuzhiyun * network. 557*4882a593Smuzhiyun * 558*4882a593Smuzhiyun * Recommended value: 0x8808 559*4882a593Smuzhiyun */ 560*4882a593Smuzhiyun 561*4882a593Smuzhiyun /* MAC Address Registers. Each of these registers specify the 562*4882a593Smuzhiyun * ethernet MAC of the interface, 16-bits at a time. Register 563*4882a593Smuzhiyun * 0 specifies bits [47:32], register 1 bits [31:16], and register 564*4882a593Smuzhiyun * 2 bits [15:0]. 565*4882a593Smuzhiyun * 566*4882a593Smuzhiyun * Registers 3 through and including 5 specify an alternate 567*4882a593Smuzhiyun * MAC address for the interface. 568*4882a593Smuzhiyun * 569*4882a593Smuzhiyun * Registers 6 through and including 8 specify the MAC Control 570*4882a593Smuzhiyun * Address, which must be the reserved multicast address for MAC 571*4882a593Smuzhiyun * Control frames. 572*4882a593Smuzhiyun * 573*4882a593Smuzhiyun * Example: To program primary station address a:b:c:d:e:f into 574*4882a593Smuzhiyun * the chip. 575*4882a593Smuzhiyun * MAC_Address_2 = (a << 8) | b 576*4882a593Smuzhiyun * MAC_Address_1 = (c << 8) | d 577*4882a593Smuzhiyun * MAC_Address_0 = (e << 8) | f 578*4882a593Smuzhiyun */ 579*4882a593Smuzhiyun 580*4882a593Smuzhiyun /* Address Filter Registers. Registers 0 through 2 specify bit 581*4882a593Smuzhiyun * fields [47:32] through [15:0], respectively, of the address 582*4882a593Smuzhiyun * filter. The Address Filter 2&1 Mask Register denotes the 8-bit 583*4882a593Smuzhiyun * nibble mask for Address Filter Registers 2 and 1. The Address 584*4882a593Smuzhiyun * Filter 0 Mask Register denotes the 16-bit mask for the Address 585*4882a593Smuzhiyun * Filter Register 0. 586*4882a593Smuzhiyun */ 587*4882a593Smuzhiyun 588*4882a593Smuzhiyun /* Hash Table Registers. Registers 0 through 15 specify bit fields 589*4882a593Smuzhiyun * [255:240] through [15:0], respectively, of the hash table. 590*4882a593Smuzhiyun */ 591*4882a593Smuzhiyun 592*4882a593Smuzhiyun /* Statistics Registers. All of these registers are 16-bits and 593*4882a593Smuzhiyun * track occurrences of a specific event. GEM can be configured 594*4882a593Smuzhiyun * to interrupt the host cpu when any of these counters overflow. 595*4882a593Smuzhiyun * They should all be explicitly initialized to zero when the interface 596*4882a593Smuzhiyun * is brought up. 597*4882a593Smuzhiyun */ 598*4882a593Smuzhiyun 599*4882a593Smuzhiyun /* Random Number Seed Register. This 10-bit value is used as the 600*4882a593Smuzhiyun * RNG seed inside GEM for the CSMA/CD backoff algorithm. It is 601*4882a593Smuzhiyun * recommended to program this register to the 10 LSB of the 602*4882a593Smuzhiyun * interfaces MAC address. 603*4882a593Smuzhiyun */ 604*4882a593Smuzhiyun 605*4882a593Smuzhiyun /* Pause Timer, read-only. This 16-bit timer is used to time the pause 606*4882a593Smuzhiyun * interval as indicated by a received pause flow control frame. 607*4882a593Smuzhiyun * A non-zero value in this timer indicates that the MAC is currently in 608*4882a593Smuzhiyun * the paused state. 609*4882a593Smuzhiyun */ 610*4882a593Smuzhiyun 611*4882a593Smuzhiyun /* MIF Registers */ 612*4882a593Smuzhiyun #define MIF_BBCLK 0x6200UL /* MIF Bit-Bang Clock */ 613*4882a593Smuzhiyun #define MIF_BBDATA 0x6204UL /* MIF Bit-Band Data */ 614*4882a593Smuzhiyun #define MIF_BBOENAB 0x6208UL /* MIF Bit-Bang Output Enable */ 615*4882a593Smuzhiyun #define MIF_FRAME 0x620CUL /* MIF Frame/Output Register */ 616*4882a593Smuzhiyun #define MIF_CFG 0x6210UL /* MIF Configuration Register */ 617*4882a593Smuzhiyun #define MIF_MASK 0x6214UL /* MIF Mask Register */ 618*4882a593Smuzhiyun #define MIF_STATUS 0x6218UL /* MIF Status Register */ 619*4882a593Smuzhiyun #define MIF_SMACHINE 0x621CUL /* MIF State Machine Register */ 620*4882a593Smuzhiyun 621*4882a593Smuzhiyun /* MIF Bit-Bang Clock. This 1-bit register is used to generate the 622*4882a593Smuzhiyun * MDC clock waveform on the MII Management Interface when the MIF is 623*4882a593Smuzhiyun * programmed in the "Bit-Bang" mode. Writing a '1' after a '0' into 624*4882a593Smuzhiyun * this register will create a rising edge on the MDC, while writing 625*4882a593Smuzhiyun * a '0' after a '1' will create a falling edge. For every bit that 626*4882a593Smuzhiyun * is transferred on the management interface, both edges have to be 627*4882a593Smuzhiyun * generated. 628*4882a593Smuzhiyun */ 629*4882a593Smuzhiyun 630*4882a593Smuzhiyun /* MIF Bit-Bang Data. This 1-bit register is used to generate the 631*4882a593Smuzhiyun * outgoing data (MDO) on the MII Management Interface when the MIF 632*4882a593Smuzhiyun * is programmed in the "Bit-Bang" mode. The daa will be steered to the 633*4882a593Smuzhiyun * appropriate MDIO based on the state of the PHY_Select bit in the MIF 634*4882a593Smuzhiyun * Configuration Register. 635*4882a593Smuzhiyun */ 636*4882a593Smuzhiyun 637*4882a593Smuzhiyun /* MIF Big-Band Output Enable. THis 1-bit register is used to enable 638*4882a593Smuzhiyun * ('1') or disable ('0') the I-directional driver on the MII when the 639*4882a593Smuzhiyun * MIF is programmed in the "Bit-Bang" mode. The MDIO should be enabled 640*4882a593Smuzhiyun * when data bits are transferred from the MIF to the transceiver, and it 641*4882a593Smuzhiyun * should be disabled when the interface is idle or when data bits are 642*4882a593Smuzhiyun * transferred from the transceiver to the MIF (data portion of a read 643*4882a593Smuzhiyun * instruction). Only one MDIO will be enabled at a given time, depending 644*4882a593Smuzhiyun * on the state of the PHY_Select bit in the MIF Configuration Register. 645*4882a593Smuzhiyun */ 646*4882a593Smuzhiyun 647*4882a593Smuzhiyun /* MIF Configuration Register. This 15-bit register controls the operation 648*4882a593Smuzhiyun * of the MIF. 649*4882a593Smuzhiyun */ 650*4882a593Smuzhiyun #define MIF_CFG_PSELECT 0x00000001 /* Xcvr slct: 0=mdio0 1=mdio1 */ 651*4882a593Smuzhiyun #define MIF_CFG_POLL 0x00000002 /* Enable polling mechanism */ 652*4882a593Smuzhiyun #define MIF_CFG_BBMODE 0x00000004 /* 1=bit-bang 0=frame mode */ 653*4882a593Smuzhiyun #define MIF_CFG_PRADDR 0x000000f8 /* Xcvr poll register address */ 654*4882a593Smuzhiyun #define MIF_CFG_MDI0 0x00000100 /* MDIO_0 present or read-bit */ 655*4882a593Smuzhiyun #define MIF_CFG_MDI1 0x00000200 /* MDIO_1 present or read-bit */ 656*4882a593Smuzhiyun #define MIF_CFG_PPADDR 0x00007c00 /* Xcvr poll PHY address */ 657*4882a593Smuzhiyun 658*4882a593Smuzhiyun /* MIF Frame/Output Register. This 32-bit register allows the host to 659*4882a593Smuzhiyun * communicate with a transceiver in frame mode (as opposed to big-bang 660*4882a593Smuzhiyun * mode). Writes by the host specify an instrution. After being issued 661*4882a593Smuzhiyun * the host must poll this register for completion. Also, after 662*4882a593Smuzhiyun * completion this register holds the data returned by the transceiver 663*4882a593Smuzhiyun * if applicable. 664*4882a593Smuzhiyun */ 665*4882a593Smuzhiyun #define MIF_FRAME_ST 0xc0000000 /* STart of frame */ 666*4882a593Smuzhiyun #define MIF_FRAME_OP 0x30000000 /* OPcode */ 667*4882a593Smuzhiyun #define MIF_FRAME_PHYAD 0x0f800000 /* PHY ADdress */ 668*4882a593Smuzhiyun #define MIF_FRAME_REGAD 0x007c0000 /* REGister ADdress */ 669*4882a593Smuzhiyun #define MIF_FRAME_TAMSB 0x00020000 /* Turn Around MSB */ 670*4882a593Smuzhiyun #define MIF_FRAME_TALSB 0x00010000 /* Turn Around LSB */ 671*4882a593Smuzhiyun #define MIF_FRAME_DATA 0x0000ffff /* Instruction Payload */ 672*4882a593Smuzhiyun 673*4882a593Smuzhiyun /* MIF Status Register. This register reports status when the MIF is 674*4882a593Smuzhiyun * operating in the poll mode. The poll status field is auto-clearing 675*4882a593Smuzhiyun * on read. 676*4882a593Smuzhiyun */ 677*4882a593Smuzhiyun #define MIF_STATUS_DATA 0xffff0000 /* Live image of XCVR reg */ 678*4882a593Smuzhiyun #define MIF_STATUS_STAT 0x0000ffff /* Which bits have changed */ 679*4882a593Smuzhiyun 680*4882a593Smuzhiyun /* MIF Mask Register. This 16-bit register is used when in poll mode 681*4882a593Smuzhiyun * to say which bits of the polled register will cause an interrupt 682*4882a593Smuzhiyun * when changed. 683*4882a593Smuzhiyun */ 684*4882a593Smuzhiyun 685*4882a593Smuzhiyun /* PCS/Serialink Registers */ 686*4882a593Smuzhiyun #define PCS_MIICTRL 0x9000UL /* PCS MII Control Register */ 687*4882a593Smuzhiyun #define PCS_MIISTAT 0x9004UL /* PCS MII Status Register */ 688*4882a593Smuzhiyun #define PCS_MIIADV 0x9008UL /* PCS MII Advertisement Reg */ 689*4882a593Smuzhiyun #define PCS_MIILP 0x900CUL /* PCS MII Link Partner Ability */ 690*4882a593Smuzhiyun #define PCS_CFG 0x9010UL /* PCS Configuration Register */ 691*4882a593Smuzhiyun #define PCS_SMACHINE 0x9014UL /* PCS State Machine Register */ 692*4882a593Smuzhiyun #define PCS_ISTAT 0x9018UL /* PCS Interrupt Status Reg */ 693*4882a593Smuzhiyun #define PCS_DMODE 0x9050UL /* Datapath Mode Register */ 694*4882a593Smuzhiyun #define PCS_SCTRL 0x9054UL /* Serialink Control Register */ 695*4882a593Smuzhiyun #define PCS_SOS 0x9058UL /* Shared Output Select Reg */ 696*4882a593Smuzhiyun #define PCS_SSTATE 0x905CUL /* Serialink State Register */ 697*4882a593Smuzhiyun 698*4882a593Smuzhiyun /* PCD MII Control Register. */ 699*4882a593Smuzhiyun #define PCS_MIICTRL_SPD 0x00000040 /* Read as one, writes ignored */ 700*4882a593Smuzhiyun #define PCS_MIICTRL_CT 0x00000080 /* Force COL signal active */ 701*4882a593Smuzhiyun #define PCS_MIICTRL_DM 0x00000100 /* Duplex mode, forced low */ 702*4882a593Smuzhiyun #define PCS_MIICTRL_RAN 0x00000200 /* Restart auto-neg, self clear */ 703*4882a593Smuzhiyun #define PCS_MIICTRL_ISO 0x00000400 /* Read as zero, writes ignored */ 704*4882a593Smuzhiyun #define PCS_MIICTRL_PD 0x00000800 /* Read as zero, writes ignored */ 705*4882a593Smuzhiyun #define PCS_MIICTRL_ANE 0x00001000 /* Auto-neg enable */ 706*4882a593Smuzhiyun #define PCS_MIICTRL_SS 0x00002000 /* Read as zero, writes ignored */ 707*4882a593Smuzhiyun #define PCS_MIICTRL_WB 0x00004000 /* Wrapback, loopback at 10-bit 708*4882a593Smuzhiyun * input side of Serialink 709*4882a593Smuzhiyun */ 710*4882a593Smuzhiyun #define PCS_MIICTRL_RST 0x00008000 /* Resets PCS, self clearing */ 711*4882a593Smuzhiyun 712*4882a593Smuzhiyun /* PCS MII Status Register. */ 713*4882a593Smuzhiyun #define PCS_MIISTAT_EC 0x00000001 /* Ext Capability: Read as zero */ 714*4882a593Smuzhiyun #define PCS_MIISTAT_JD 0x00000002 /* Jabber Detect: Read as zero */ 715*4882a593Smuzhiyun #define PCS_MIISTAT_LS 0x00000004 /* Link Status: 1=up 0=down */ 716*4882a593Smuzhiyun #define PCS_MIISTAT_ANA 0x00000008 /* Auto-neg Ability, always 1 */ 717*4882a593Smuzhiyun #define PCS_MIISTAT_RF 0x00000010 /* Remote Fault */ 718*4882a593Smuzhiyun #define PCS_MIISTAT_ANC 0x00000020 /* Auto-neg complete */ 719*4882a593Smuzhiyun #define PCS_MIISTAT_ES 0x00000100 /* Extended Status, always 1 */ 720*4882a593Smuzhiyun 721*4882a593Smuzhiyun /* PCS MII Advertisement Register. */ 722*4882a593Smuzhiyun #define PCS_MIIADV_FD 0x00000020 /* Advertise Full Duplex */ 723*4882a593Smuzhiyun #define PCS_MIIADV_HD 0x00000040 /* Advertise Half Duplex */ 724*4882a593Smuzhiyun #define PCS_MIIADV_SP 0x00000080 /* Advertise Symmetric Pause */ 725*4882a593Smuzhiyun #define PCS_MIIADV_AP 0x00000100 /* Advertise Asymmetric Pause */ 726*4882a593Smuzhiyun #define PCS_MIIADV_RF 0x00003000 /* Remote Fault */ 727*4882a593Smuzhiyun #define PCS_MIIADV_ACK 0x00004000 /* Read-only */ 728*4882a593Smuzhiyun #define PCS_MIIADV_NP 0x00008000 /* Next-page, forced low */ 729*4882a593Smuzhiyun 730*4882a593Smuzhiyun /* PCS MII Link Partner Ability Register. This register is equivalent 731*4882a593Smuzhiyun * to the Link Partnet Ability Register of the standard MII register set. 732*4882a593Smuzhiyun * It's layout corresponds to the PCS MII Advertisement Register. 733*4882a593Smuzhiyun */ 734*4882a593Smuzhiyun 735*4882a593Smuzhiyun /* PCS Configuration Register. */ 736*4882a593Smuzhiyun #define PCS_CFG_ENABLE 0x00000001 /* Must be zero while changing 737*4882a593Smuzhiyun * PCS MII advertisement reg. 738*4882a593Smuzhiyun */ 739*4882a593Smuzhiyun #define PCS_CFG_SDO 0x00000002 /* Signal detect override */ 740*4882a593Smuzhiyun #define PCS_CFG_SDL 0x00000004 /* Signal detect active low */ 741*4882a593Smuzhiyun #define PCS_CFG_JS 0x00000018 /* Jitter-study: 742*4882a593Smuzhiyun * 0 = normal operation 743*4882a593Smuzhiyun * 1 = high-frequency test pattern 744*4882a593Smuzhiyun * 2 = low-frequency test pattern 745*4882a593Smuzhiyun * 3 = reserved 746*4882a593Smuzhiyun */ 747*4882a593Smuzhiyun #define PCS_CFG_TO 0x00000020 /* 10ms auto-neg timer override */ 748*4882a593Smuzhiyun 749*4882a593Smuzhiyun /* PCS Interrupt Status Register. This register is self-clearing 750*4882a593Smuzhiyun * when read. 751*4882a593Smuzhiyun */ 752*4882a593Smuzhiyun #define PCS_ISTAT_LSC 0x00000004 /* Link Status Change */ 753*4882a593Smuzhiyun 754*4882a593Smuzhiyun /* Datapath Mode Register. */ 755*4882a593Smuzhiyun #define PCS_DMODE_SM 0x00000001 /* 1 = use internal Serialink */ 756*4882a593Smuzhiyun #define PCS_DMODE_ESM 0x00000002 /* External SERDES mode */ 757*4882a593Smuzhiyun #define PCS_DMODE_MGM 0x00000004 /* MII/GMII mode */ 758*4882a593Smuzhiyun #define PCS_DMODE_GMOE 0x00000008 /* GMII Output Enable */ 759*4882a593Smuzhiyun 760*4882a593Smuzhiyun /* Serialink Control Register. 761*4882a593Smuzhiyun * 762*4882a593Smuzhiyun * NOTE: When in SERDES mode, the loopback bit has inverse logic. 763*4882a593Smuzhiyun */ 764*4882a593Smuzhiyun #define PCS_SCTRL_LOOP 0x00000001 /* Loopback enable */ 765*4882a593Smuzhiyun #define PCS_SCTRL_ESCD 0x00000002 /* Enable sync char detection */ 766*4882a593Smuzhiyun #define PCS_SCTRL_LOCK 0x00000004 /* Lock to reference clock */ 767*4882a593Smuzhiyun #define PCS_SCTRL_EMP 0x00000018 /* Output driver emphasis */ 768*4882a593Smuzhiyun #define PCS_SCTRL_STEST 0x000001c0 /* Self test patterns */ 769*4882a593Smuzhiyun #define PCS_SCTRL_PDWN 0x00000200 /* Software power-down */ 770*4882a593Smuzhiyun #define PCS_SCTRL_RXZ 0x00000c00 /* PLL input to Serialink */ 771*4882a593Smuzhiyun #define PCS_SCTRL_RXP 0x00003000 /* PLL input to Serialink */ 772*4882a593Smuzhiyun #define PCS_SCTRL_TXZ 0x0000c000 /* PLL input to Serialink */ 773*4882a593Smuzhiyun #define PCS_SCTRL_TXP 0x00030000 /* PLL input to Serialink */ 774*4882a593Smuzhiyun 775*4882a593Smuzhiyun /* Shared Output Select Register. For test and debug, allows multiplexing 776*4882a593Smuzhiyun * test outputs into the PROM address pins. Set to zero for normal 777*4882a593Smuzhiyun * operation. 778*4882a593Smuzhiyun */ 779*4882a593Smuzhiyun #define PCS_SOS_PADDR 0x00000003 /* PROM Address */ 780*4882a593Smuzhiyun 781*4882a593Smuzhiyun /* PROM Image Space */ 782*4882a593Smuzhiyun #define PROM_START 0x100000UL /* Expansion ROM run time access*/ 783*4882a593Smuzhiyun #define PROM_SIZE 0x0fffffUL /* Size of ROM */ 784*4882a593Smuzhiyun #define PROM_END 0x200000UL /* End of ROM */ 785*4882a593Smuzhiyun 786*4882a593Smuzhiyun /* MII definitions missing from mii.h */ 787*4882a593Smuzhiyun 788*4882a593Smuzhiyun #define BMCR_SPD2 0x0040 /* Gigabit enable? (bcm5411) */ 789*4882a593Smuzhiyun #define LPA_PAUSE 0x0400 790*4882a593Smuzhiyun 791*4882a593Smuzhiyun /* More PHY registers (specific to Broadcom models) */ 792*4882a593Smuzhiyun 793*4882a593Smuzhiyun /* MII BCM5201 MULTIPHY interrupt register */ 794*4882a593Smuzhiyun #define MII_BCM5201_INTERRUPT 0x1A 795*4882a593Smuzhiyun #define MII_BCM5201_INTERRUPT_INTENABLE 0x4000 796*4882a593Smuzhiyun 797*4882a593Smuzhiyun #define MII_BCM5201_AUXMODE2 0x1B 798*4882a593Smuzhiyun #define MII_BCM5201_AUXMODE2_LOWPOWER 0x0008 799*4882a593Smuzhiyun 800*4882a593Smuzhiyun #define MII_BCM5201_MULTIPHY 0x1E 801*4882a593Smuzhiyun 802*4882a593Smuzhiyun /* MII BCM5201 MULTIPHY register bits */ 803*4882a593Smuzhiyun #define MII_BCM5201_MULTIPHY_SERIALMODE 0x0002 804*4882a593Smuzhiyun #define MII_BCM5201_MULTIPHY_SUPERISOLATE 0x0008 805*4882a593Smuzhiyun 806*4882a593Smuzhiyun /* MII BCM5400 1000-BASET Control register */ 807*4882a593Smuzhiyun #define MII_BCM5400_GB_CONTROL 0x09 808*4882a593Smuzhiyun #define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200 809*4882a593Smuzhiyun 810*4882a593Smuzhiyun /* MII BCM5400 AUXCONTROL register */ 811*4882a593Smuzhiyun #define MII_BCM5400_AUXCONTROL 0x18 812*4882a593Smuzhiyun #define MII_BCM5400_AUXCONTROL_PWR10BASET 0x0004 813*4882a593Smuzhiyun 814*4882a593Smuzhiyun /* MII BCM5400 AUXSTATUS register */ 815*4882a593Smuzhiyun #define MII_BCM5400_AUXSTATUS 0x19 816*4882a593Smuzhiyun #define MII_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700 817*4882a593Smuzhiyun #define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8 818*4882a593Smuzhiyun 819*4882a593Smuzhiyun /* When it can, GEM internally caches 4 aligned TX descriptors 820*4882a593Smuzhiyun * at a time, so that it can use full cacheline DMA reads. 821*4882a593Smuzhiyun * 822*4882a593Smuzhiyun * Note that unlike HME, there is no ownership bit in the descriptor 823*4882a593Smuzhiyun * control word. The same functionality is obtained via the TX-Kick 824*4882a593Smuzhiyun * and TX-Complete registers. As a result, GEM need not write back 825*4882a593Smuzhiyun * updated values to the TX descriptor ring, it only performs reads. 826*4882a593Smuzhiyun * 827*4882a593Smuzhiyun * Since TX descriptors are never modified by GEM, the driver can 828*4882a593Smuzhiyun * use the buffer DMA address as a place to keep track of allocated 829*4882a593Smuzhiyun * DMA mappings for a transmitted packet. 830*4882a593Smuzhiyun */ 831*4882a593Smuzhiyun struct gem_txd { 832*4882a593Smuzhiyun __le64 control_word; 833*4882a593Smuzhiyun __le64 buffer; 834*4882a593Smuzhiyun }; 835*4882a593Smuzhiyun 836*4882a593Smuzhiyun #define TXDCTRL_BUFSZ 0x0000000000007fffULL /* Buffer Size */ 837*4882a593Smuzhiyun #define TXDCTRL_CSTART 0x00000000001f8000ULL /* CSUM Start Offset */ 838*4882a593Smuzhiyun #define TXDCTRL_COFF 0x000000001fe00000ULL /* CSUM Stuff Offset */ 839*4882a593Smuzhiyun #define TXDCTRL_CENAB 0x0000000020000000ULL /* CSUM Enable */ 840*4882a593Smuzhiyun #define TXDCTRL_EOF 0x0000000040000000ULL /* End of Frame */ 841*4882a593Smuzhiyun #define TXDCTRL_SOF 0x0000000080000000ULL /* Start of Frame */ 842*4882a593Smuzhiyun #define TXDCTRL_INTME 0x0000000100000000ULL /* "Interrupt Me" */ 843*4882a593Smuzhiyun #define TXDCTRL_NOCRC 0x0000000200000000ULL /* No CRC Present */ 844*4882a593Smuzhiyun 845*4882a593Smuzhiyun /* GEM requires that RX descriptors are provided four at a time, 846*4882a593Smuzhiyun * aligned. Also, the RX ring may not wrap around. This means that 847*4882a593Smuzhiyun * there will be at least 4 unused descriptor entries in the middle 848*4882a593Smuzhiyun * of the RX ring at all times. 849*4882a593Smuzhiyun * 850*4882a593Smuzhiyun * Similar to HME, GEM assumes that it can write garbage bytes before 851*4882a593Smuzhiyun * the beginning of the buffer and right after the end in order to DMA 852*4882a593Smuzhiyun * whole cachelines. 853*4882a593Smuzhiyun * 854*4882a593Smuzhiyun * Unlike for TX, GEM does update the status word in the RX descriptors 855*4882a593Smuzhiyun * when packets arrive. Therefore an ownership bit does exist in the 856*4882a593Smuzhiyun * RX descriptors. It is advisory, GEM clears it but does not check 857*4882a593Smuzhiyun * it in any way. So when buffers are posted to the RX ring (via the 858*4882a593Smuzhiyun * RX Kick register) by the driver it must make sure the buffers are 859*4882a593Smuzhiyun * truly ready and that the ownership bits are set properly. 860*4882a593Smuzhiyun * 861*4882a593Smuzhiyun * Even though GEM modifies the RX descriptors, it guarantees that the 862*4882a593Smuzhiyun * buffer DMA address field will stay the same when it performs these 863*4882a593Smuzhiyun * updates. Therefore it can be used to keep track of DMA mappings 864*4882a593Smuzhiyun * by the host driver just as in the TX descriptor case above. 865*4882a593Smuzhiyun */ 866*4882a593Smuzhiyun struct gem_rxd { 867*4882a593Smuzhiyun __le64 status_word; 868*4882a593Smuzhiyun __le64 buffer; 869*4882a593Smuzhiyun }; 870*4882a593Smuzhiyun 871*4882a593Smuzhiyun #define RXDCTRL_TCPCSUM 0x000000000000ffffULL /* TCP Pseudo-CSUM */ 872*4882a593Smuzhiyun #define RXDCTRL_BUFSZ 0x000000007fff0000ULL /* Buffer Size */ 873*4882a593Smuzhiyun #define RXDCTRL_OWN 0x0000000080000000ULL /* GEM owns this entry */ 874*4882a593Smuzhiyun #define RXDCTRL_HASHVAL 0x0ffff00000000000ULL /* Hash Value */ 875*4882a593Smuzhiyun #define RXDCTRL_HPASS 0x1000000000000000ULL /* Passed Hash Filter */ 876*4882a593Smuzhiyun #define RXDCTRL_ALTMAC 0x2000000000000000ULL /* Matched ALT MAC */ 877*4882a593Smuzhiyun #define RXDCTRL_BAD 0x4000000000000000ULL /* Frame has bad CRC */ 878*4882a593Smuzhiyun 879*4882a593Smuzhiyun #define RXDCTRL_FRESH(gp) \ 880*4882a593Smuzhiyun ((((RX_BUF_ALLOC_SIZE(gp) - RX_OFFSET) << 16) & RXDCTRL_BUFSZ) | \ 881*4882a593Smuzhiyun RXDCTRL_OWN) 882*4882a593Smuzhiyun 883*4882a593Smuzhiyun #define TX_RING_SIZE 128 884*4882a593Smuzhiyun #define RX_RING_SIZE 128 885*4882a593Smuzhiyun 886*4882a593Smuzhiyun #if TX_RING_SIZE == 32 887*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_32 888*4882a593Smuzhiyun #elif TX_RING_SIZE == 64 889*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_64 890*4882a593Smuzhiyun #elif TX_RING_SIZE == 128 891*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_128 892*4882a593Smuzhiyun #elif TX_RING_SIZE == 256 893*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_256 894*4882a593Smuzhiyun #elif TX_RING_SIZE == 512 895*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_512 896*4882a593Smuzhiyun #elif TX_RING_SIZE == 1024 897*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_1K 898*4882a593Smuzhiyun #elif TX_RING_SIZE == 2048 899*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_2K 900*4882a593Smuzhiyun #elif TX_RING_SIZE == 4096 901*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_4K 902*4882a593Smuzhiyun #elif TX_RING_SIZE == 8192 903*4882a593Smuzhiyun #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_8K 904*4882a593Smuzhiyun #else 905*4882a593Smuzhiyun #error TX_RING_SIZE value is illegal... 906*4882a593Smuzhiyun #endif 907*4882a593Smuzhiyun 908*4882a593Smuzhiyun #if RX_RING_SIZE == 32 909*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_32 910*4882a593Smuzhiyun #elif RX_RING_SIZE == 64 911*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_64 912*4882a593Smuzhiyun #elif RX_RING_SIZE == 128 913*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_128 914*4882a593Smuzhiyun #elif RX_RING_SIZE == 256 915*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_256 916*4882a593Smuzhiyun #elif RX_RING_SIZE == 512 917*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_512 918*4882a593Smuzhiyun #elif RX_RING_SIZE == 1024 919*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_1K 920*4882a593Smuzhiyun #elif RX_RING_SIZE == 2048 921*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_2K 922*4882a593Smuzhiyun #elif RX_RING_SIZE == 4096 923*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_4K 924*4882a593Smuzhiyun #elif RX_RING_SIZE == 8192 925*4882a593Smuzhiyun #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_8K 926*4882a593Smuzhiyun #else 927*4882a593Smuzhiyun #error RX_RING_SIZE is illegal... 928*4882a593Smuzhiyun #endif 929*4882a593Smuzhiyun 930*4882a593Smuzhiyun #define NEXT_TX(N) (((N) + 1) & (TX_RING_SIZE - 1)) 931*4882a593Smuzhiyun #define NEXT_RX(N) (((N) + 1) & (RX_RING_SIZE - 1)) 932*4882a593Smuzhiyun 933*4882a593Smuzhiyun #define TX_BUFFS_AVAIL(GP) \ 934*4882a593Smuzhiyun (((GP)->tx_old <= (GP)->tx_new) ? \ 935*4882a593Smuzhiyun (GP)->tx_old + (TX_RING_SIZE - 1) - (GP)->tx_new : \ 936*4882a593Smuzhiyun (GP)->tx_old - (GP)->tx_new - 1) 937*4882a593Smuzhiyun 938*4882a593Smuzhiyun #define RX_OFFSET 2 939*4882a593Smuzhiyun #define RX_BUF_ALLOC_SIZE(gp) ((gp)->rx_buf_sz + 28 + RX_OFFSET + 64) 940*4882a593Smuzhiyun 941*4882a593Smuzhiyun #define RX_COPY_THRESHOLD 256 942*4882a593Smuzhiyun 943*4882a593Smuzhiyun #if TX_RING_SIZE < 128 944*4882a593Smuzhiyun #define INIT_BLOCK_TX_RING_SIZE 128 945*4882a593Smuzhiyun #else 946*4882a593Smuzhiyun #define INIT_BLOCK_TX_RING_SIZE TX_RING_SIZE 947*4882a593Smuzhiyun #endif 948*4882a593Smuzhiyun 949*4882a593Smuzhiyun #if RX_RING_SIZE < 128 950*4882a593Smuzhiyun #define INIT_BLOCK_RX_RING_SIZE 128 951*4882a593Smuzhiyun #else 952*4882a593Smuzhiyun #define INIT_BLOCK_RX_RING_SIZE RX_RING_SIZE 953*4882a593Smuzhiyun #endif 954*4882a593Smuzhiyun 955*4882a593Smuzhiyun struct gem_init_block { 956*4882a593Smuzhiyun struct gem_txd txd[INIT_BLOCK_TX_RING_SIZE]; 957*4882a593Smuzhiyun struct gem_rxd rxd[INIT_BLOCK_RX_RING_SIZE]; 958*4882a593Smuzhiyun }; 959*4882a593Smuzhiyun 960*4882a593Smuzhiyun enum gem_phy_type { 961*4882a593Smuzhiyun phy_mii_mdio0, 962*4882a593Smuzhiyun phy_mii_mdio1, 963*4882a593Smuzhiyun phy_serialink, 964*4882a593Smuzhiyun phy_serdes, 965*4882a593Smuzhiyun }; 966*4882a593Smuzhiyun 967*4882a593Smuzhiyun enum link_state { 968*4882a593Smuzhiyun link_down = 0, /* No link, will retry */ 969*4882a593Smuzhiyun link_aneg, /* Autoneg in progress */ 970*4882a593Smuzhiyun link_force_try, /* Try Forced link speed */ 971*4882a593Smuzhiyun link_force_ret, /* Forced mode worked, retrying autoneg */ 972*4882a593Smuzhiyun link_force_ok, /* Stay in forced mode */ 973*4882a593Smuzhiyun link_up /* Link is up */ 974*4882a593Smuzhiyun }; 975*4882a593Smuzhiyun 976*4882a593Smuzhiyun struct gem { 977*4882a593Smuzhiyun void __iomem *regs; 978*4882a593Smuzhiyun int rx_new, rx_old; 979*4882a593Smuzhiyun int tx_new, tx_old; 980*4882a593Smuzhiyun 981*4882a593Smuzhiyun unsigned int has_wol : 1; /* chip supports wake-on-lan */ 982*4882a593Smuzhiyun unsigned int asleep_wol : 1; /* was asleep with WOL enabled */ 983*4882a593Smuzhiyun 984*4882a593Smuzhiyun int cell_enabled; 985*4882a593Smuzhiyun u32 msg_enable; 986*4882a593Smuzhiyun u32 status; 987*4882a593Smuzhiyun 988*4882a593Smuzhiyun struct napi_struct napi; 989*4882a593Smuzhiyun 990*4882a593Smuzhiyun int tx_fifo_sz; 991*4882a593Smuzhiyun int rx_fifo_sz; 992*4882a593Smuzhiyun int rx_pause_off; 993*4882a593Smuzhiyun int rx_pause_on; 994*4882a593Smuzhiyun int rx_buf_sz; 995*4882a593Smuzhiyun u64 pause_entered; 996*4882a593Smuzhiyun u16 pause_last_time_recvd; 997*4882a593Smuzhiyun u32 mac_rx_cfg; 998*4882a593Smuzhiyun u32 swrst_base; 999*4882a593Smuzhiyun 1000*4882a593Smuzhiyun int want_autoneg; 1001*4882a593Smuzhiyun int last_forced_speed; 1002*4882a593Smuzhiyun enum link_state lstate; 1003*4882a593Smuzhiyun struct timer_list link_timer; 1004*4882a593Smuzhiyun int timer_ticks; 1005*4882a593Smuzhiyun int wake_on_lan; 1006*4882a593Smuzhiyun struct work_struct reset_task; 1007*4882a593Smuzhiyun volatile int reset_task_pending; 1008*4882a593Smuzhiyun 1009*4882a593Smuzhiyun enum gem_phy_type phy_type; 1010*4882a593Smuzhiyun struct mii_phy phy_mii; 1011*4882a593Smuzhiyun int mii_phy_addr; 1012*4882a593Smuzhiyun 1013*4882a593Smuzhiyun struct gem_init_block *init_block; 1014*4882a593Smuzhiyun struct sk_buff *rx_skbs[RX_RING_SIZE]; 1015*4882a593Smuzhiyun struct sk_buff *tx_skbs[TX_RING_SIZE]; 1016*4882a593Smuzhiyun dma_addr_t gblock_dvma; 1017*4882a593Smuzhiyun 1018*4882a593Smuzhiyun struct pci_dev *pdev; 1019*4882a593Smuzhiyun struct net_device *dev; 1020*4882a593Smuzhiyun #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_SPARC) 1021*4882a593Smuzhiyun struct device_node *of_node; 1022*4882a593Smuzhiyun #endif 1023*4882a593Smuzhiyun }; 1024*4882a593Smuzhiyun 1025*4882a593Smuzhiyun #define found_mii_phy(gp) ((gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) && \ 1026*4882a593Smuzhiyun gp->phy_mii.def && gp->phy_mii.def->ops) 1027*4882a593Smuzhiyun 1028*4882a593Smuzhiyun #endif /* _SUNGEM_H */ 1029