1*b3697b90SSteven Stallion /* 2*b3697b90SSteven Stallion * Copyright (c) 2010 Steven Stallion. All rights reserved. 3*b3697b90SSteven Stallion * 4*b3697b90SSteven Stallion * Redistribution and use in source and binary forms, with or without 5*b3697b90SSteven Stallion * modification, are permitted provided that the following conditions are 6*b3697b90SSteven Stallion * met: 7*b3697b90SSteven Stallion * 8*b3697b90SSteven Stallion * 1. Redistributions of source code must retain the above copyright 9*b3697b90SSteven Stallion * notice, this list of conditions and the following disclaimer. 10*b3697b90SSteven Stallion * 2. Redistributions in binary form must reproduce the above 11*b3697b90SSteven Stallion * copyright notice, this list of conditions and the following 12*b3697b90SSteven Stallion * disclaimer in the documentation and/or other materials provided 13*b3697b90SSteven Stallion * with the distribution. 14*b3697b90SSteven Stallion * 3. Neither the name of the copyright owner nor the names of any 15*b3697b90SSteven Stallion * contributors may be used to endorse or promote products derived 16*b3697b90SSteven Stallion * from this software without specific prior written permission. 17*b3697b90SSteven Stallion * 18*b3697b90SSteven Stallion * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND 19*b3697b90SSteven Stallion * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*b3697b90SSteven Stallion * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*b3697b90SSteven Stallion * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22*b3697b90SSteven Stallion * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23*b3697b90SSteven Stallion * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24*b3697b90SSteven Stallion * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25*b3697b90SSteven Stallion * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26*b3697b90SSteven Stallion * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27*b3697b90SSteven Stallion * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28*b3697b90SSteven Stallion * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*b3697b90SSteven Stallion */ 30*b3697b90SSteven Stallion 31*b3697b90SSteven Stallion #ifndef _EFE_H 32*b3697b90SSteven Stallion #define _EFE_H 33*b3697b90SSteven Stallion 34*b3697b90SSteven Stallion #ifdef __cplusplus 35*b3697b90SSteven Stallion extern "C" { 36*b3697b90SSteven Stallion #endif 37*b3697b90SSteven Stallion 38*b3697b90SSteven Stallion #define VENDOR_ID 0x10B8 39*b3697b90SSteven Stallion #define DEVICE_ID 0x0005 40*b3697b90SSteven Stallion 41*b3697b90SSteven Stallion #define RESET_DELAY 1 42*b3697b90SSteven Stallion #define RESET_TEST_CYCLES 16 43*b3697b90SSteven Stallion 44*b3697b90SSteven Stallion #define STOP_DELAY 10 45*b3697b90SSteven Stallion #define STOP_DELAY_CYCLES 160 46*b3697b90SSteven Stallion 47*b3697b90SSteven Stallion #define MII_DELAY 1 48*b3697b90SSteven Stallion #define MII_DELAY_CYCLES 16 49*b3697b90SSteven Stallion 50*b3697b90SSteven Stallion #define EEPROM_DELAY 3 51*b3697b90SSteven Stallion #define EEPROM_WORDSZ 16 52*b3697b90SSteven Stallion 53*b3697b90SSteven Stallion #define AT93C46_ADDRLEN 6 54*b3697b90SSteven Stallion #define AT93C56_ADDRLEN 8 55*b3697b90SSteven Stallion 56*b3697b90SSteven Stallion #define FLAG_RUNNING (1UL << 0) 57*b3697b90SSteven Stallion #define FLAG_SUSPENDED (1UL << 1) 58*b3697b90SSteven Stallion 59*b3697b90SSteven Stallion #define MCHASHL 64 60*b3697b90SSteven Stallion #define MCHASHSZ 16 61*b3697b90SSteven Stallion 62*b3697b90SSteven Stallion #define BURSTLEN 0x3F 63*b3697b90SSteven Stallion 64*b3697b90SSteven Stallion #define RXDESCL 128 65*b3697b90SSteven Stallion #define TXDESCL 128 66*b3697b90SSteven Stallion 67*b3697b90SSteven Stallion #define BUFSZ 1536 68*b3697b90SSteven Stallion 69*b3697b90SSteven Stallion /* 70*b3697b90SSteven Stallion * Control/Status registers. 71*b3697b90SSteven Stallion */ 72*b3697b90SSteven Stallion #define CSR_COMMAND 0x00 /* Control Register */ 73*b3697b90SSteven Stallion #define CSR_INTSTAT 0x04 /* Interrupt Status Register */ 74*b3697b90SSteven Stallion #define CSR_INTMASK 0x08 /* Interrupt Mask Register */ 75*b3697b90SSteven Stallion #define CSR_GENCTL 0x0C /* General Control Register */ 76*b3697b90SSteven Stallion #define CSR_NVCTL 0x10 /* Non-volatile Control Register */ 77*b3697b90SSteven Stallion #define CSR_EECTL 0x14 /* EEPROM Control Register */ 78*b3697b90SSteven Stallion #define CSR_PBLCNT 0x18 /* Programmable Burst Length Counter */ 79*b3697b90SSteven Stallion #define CSR_TEST 0x1C /* Test Register */ 80*b3697b90SSteven Stallion #define CSR_CRCCNT 0x20 /* CRC Error Counter */ 81*b3697b90SSteven Stallion #define CSR_ALICNT 0x24 /* Frame Alignment Error Counter */ 82*b3697b90SSteven Stallion #define CSR_MPCNT 0x28 /* Missed Packet Counter */ 83*b3697b90SSteven Stallion #define CSR_RXFIFO 0x2C /* Receive FIFO Contents */ 84*b3697b90SSteven Stallion #define CSR_MMCTL 0x30 /* MII Control Register */ 85*b3697b90SSteven Stallion #define CSR_MMDATA 0x34 /* MII Interface Register */ 86*b3697b90SSteven Stallion #define CSR_MMCFG 0x38 /* MII Configuration Register */ 87*b3697b90SSteven Stallion #define CSR_IPG 0x3C /* Interpacket Gap Register */ 88*b3697b90SSteven Stallion #define CSR_LAN0 0x40 /* LAN Address Register 0 */ 89*b3697b90SSteven Stallion #define CSR_LAN1 0x44 /* LAN Address Register 1 */ 90*b3697b90SSteven Stallion #define CSR_LAN2 0x48 /* LAN Address Register 2 */ 91*b3697b90SSteven Stallion #define CSR_IDCHK 0x4C /* Board ID/Checksum Register */ 92*b3697b90SSteven Stallion #define CSR_MC0 0x50 /* Multicast Address Register 0 */ 93*b3697b90SSteven Stallion #define CSR_MC1 0x54 /* Multicast Address Register 1 */ 94*b3697b90SSteven Stallion #define CSR_MC2 0x58 /* Multicast Address Register 2 */ 95*b3697b90SSteven Stallion #define CSR_MC3 0x5C /* Multicast Address Register 3 */ 96*b3697b90SSteven Stallion #define CSR_RXCON 0x60 /* Receive Control Register */ 97*b3697b90SSteven Stallion #define CSR_RXSTAT 0x64 /* Receive Status Register */ 98*b3697b90SSteven Stallion #define CSR_RXCNT 0x68 /* Receive Byte Count */ 99*b3697b90SSteven Stallion #define CSR_RXTEST 0x6C /* Receive Test */ 100*b3697b90SSteven Stallion #define CSR_TXCON 0x70 /* Transmit Control Register */ 101*b3697b90SSteven Stallion #define CSR_TXSTAT 0x74 /* Transmit Status Register */ 102*b3697b90SSteven Stallion #define CSR_TDPAR 0x78 /* Transmit Packet Address */ 103*b3697b90SSteven Stallion #define CSR_TXTEST 0x7C /* Transmit Test */ 104*b3697b90SSteven Stallion #define CSR_PRFDAR 0x80 /* PCI Receive First Descriptor Address */ 105*b3697b90SSteven Stallion #define CSR_PRCDAR 0x84 /* PCI Receive Current Descriptor Address */ 106*b3697b90SSteven Stallion #define CSR_PRHDAR 0x88 /* PCI Receive Host Data Address */ 107*b3697b90SSteven Stallion #define CSR_PRFLAR 0x8C /* PCI Receive Fragment List Address */ 108*b3697b90SSteven Stallion #define CSR_PRDLGTH 0x90 /* PCI Receive DMA Length/Control */ 109*b3697b90SSteven Stallion #define CSR_PRFCNT 0x94 /* PCI Receive Fragment Count */ 110*b3697b90SSteven Stallion #define CSR_PRLCAR 0x98 /* PCI Receive RAM Current Address */ 111*b3697b90SSteven Stallion #define CSR_PRLPAR 0x9C /* PCI Receive RAM Packet Address */ 112*b3697b90SSteven Stallion #define CSR_PREFAR 0xA0 /* PCI Receive End of Frame Address */ 113*b3697b90SSteven Stallion #define CSR_PRSTAT 0xA4 /* PCI Receive DMA Status Register */ 114*b3697b90SSteven Stallion #define CSR_PRBUF 0xA8 /* Receive RAM Buffer */ 115*b3697b90SSteven Stallion #define CSR_RDNCAR 0xAC /* Receive MTU Current Address */ 116*b3697b90SSteven Stallion #define CSR_PRCPTHR 0xB0 /* PCI Receive Copy Threshold Register */ 117*b3697b90SSteven Stallion #define CSR_ROMDATA 0xB4 /* ROMDATA */ 118*b3697b90SSteven Stallion #define CSR_PREEMPR 0xBC /* Preemptive Interrupt */ 119*b3697b90SSteven Stallion #define CSR_PTFDAR 0xC0 /* PCI Transmit First Descriptor Address */ 120*b3697b90SSteven Stallion #define CSR_PTCDAR 0xC4 /* PCI Transmit Current Descriptor Address */ 121*b3697b90SSteven Stallion #define CSR_PTHDAR 0xC8 /* PCI Transmit Host Data Address */ 122*b3697b90SSteven Stallion #define CSR_PTFLAR 0xCC /* PCI Transmit Fragment List Address */ 123*b3697b90SSteven Stallion #define CSR_PTDLGTH 0xD0 /* PCI Transmit DMA Length/Control */ 124*b3697b90SSteven Stallion #define CSR_PTFCNT 0xD4 /* PCI Transmit Fragment Count */ 125*b3697b90SSteven Stallion #define CSR_PTLCAR 0xD8 /* PCI Transmit RAM Current Address */ 126*b3697b90SSteven Stallion #define CSR_ETXTHR 0xDC /* PCI Early Transmit Threshold Register */ 127*b3697b90SSteven Stallion #define CSR_PTETXC 0xE0 /* PCI Early Transmit Count */ 128*b3697b90SSteven Stallion #define CSR_PTSTAT 0xE4 /* PCI Transmit DMA Status */ 129*b3697b90SSteven Stallion #define CSR_PTBUF 0xE8 /* Transmit RAM Buffer */ 130*b3697b90SSteven Stallion #define CSR_PTFDAR2 0xEC /* PCI Transmit 2 First Descriptor Address */ 131*b3697b90SSteven Stallion #define CSR_FEVTR 0xF0 /* CardBus (UNUSED) */ 132*b3697b90SSteven Stallion #define CSR_FEVTRMSKR 0xF4 /* CardBus (UNUSED) */ 133*b3697b90SSteven Stallion #define CSR_FPRSTSTR 0xF8 /* CardBus (UNUSED) */ 134*b3697b90SSteven Stallion #define CSR_FFRCEVTR 0xFF /* CardBus (UNUSED) */ 135*b3697b90SSteven Stallion 136*b3697b90SSteven Stallion /* 137*b3697b90SSteven Stallion * Register fields. 138*b3697b90SSteven Stallion */ 139*b3697b90SSteven Stallion #define COMMAND_STOP_RX (1UL << 0) /* Stop Receiver */ 140*b3697b90SSteven Stallion #define COMMAND_START_RX (1UL << 1) /* Start Receiver */ 141*b3697b90SSteven Stallion #define COMMAND_TXQUEUED (1UL << 2) /* Queue TX Descriptor */ 142*b3697b90SSteven Stallion #define COMMAND_RXQUEUED (1UL << 3) /* Queue RX Descriptor */ 143*b3697b90SSteven Stallion #define COMMAND_NEXTFRAME (1UL << 4) /* Release RX Frame */ 144*b3697b90SSteven Stallion #define COMMAND_STOP_TDMA (1UL << 5) /* Stop TX DMA */ 145*b3697b90SSteven Stallion #define COMMAND_STOP_RDMA (1UL << 6) /* Stop RX DMA */ 146*b3697b90SSteven Stallion #define COMMAND_TXUGO (1UL << 7) /* Restart Transmission */ 147*b3697b90SSteven Stallion 148*b3697b90SSteven Stallion #define INTSTAT_RCC (1UL << 0) /* Receive Copy Complete */ 149*b3697b90SSteven Stallion #define INTSTAT_HCC (1UL << 1) /* Header Copy Complete */ 150*b3697b90SSteven Stallion #define INTSTAT_RQE (1UL << 2) /* Receive Queue Empty */ 151*b3697b90SSteven Stallion #define INTSTAT_OVW (1UL << 3) /* Receive Overflow */ 152*b3697b90SSteven Stallion #define INTSTAT_RXE (1UL << 4) /* Receive Error */ 153*b3697b90SSteven Stallion #define INTSTAT_TXC (1UL << 5) /* Transmit Complete */ 154*b3697b90SSteven Stallion #define INTSTAT_TCC (1UL << 6) /* Transmit Chain Complete */ 155*b3697b90SSteven Stallion #define INTSTAT_TQE (1UL << 7) /* Transmit Queue Empty */ 156*b3697b90SSteven Stallion #define INTSTAT_TXU (1UL << 8) /* Transmit Underrun */ 157*b3697b90SSteven Stallion #define INTSTAT_CNT (1UL << 9) /* Counter Overflow */ 158*b3697b90SSteven Stallion #define INTSTAT_PREI (1UL << 10) /* Preemptive Interrupt */ 159*b3697b90SSteven Stallion #define INTSTAT_RCT (1UL << 11) /* Receive Copy Threshold */ 160*b3697b90SSteven Stallion #define INTSTAT_FATAL (1UL << 12) /* Fatal Error */ 161*b3697b90SSteven Stallion #define INTSTAT_PME (1UL << 14) /* Power Management Event */ 162*b3697b90SSteven Stallion #define INTSTAT_GP2 (1UL << 15) /* GPIO Event */ 163*b3697b90SSteven Stallion #define INTSTAT_ACTV (1UL << 16) /* Interrupt Active */ 164*b3697b90SSteven Stallion #define INTSTAT_RXIDLE (1UL << 17) /* Receive Idle */ 165*b3697b90SSteven Stallion #define INTSTAT_TXIDLE (1UL << 18) /* Transmit Idle */ 166*b3697b90SSteven Stallion #define INTSTAT_RCIP (1UL << 19) /* Receive Copy in Progress */ 167*b3697b90SSteven Stallion #define INTSTAT_TCIP (1UL << 20) /* Transmit Copy in Progress */ 168*b3697b90SSteven Stallion #define INTSTAT_RBE (1UL << 21) /* Receive Buffers Empty */ 169*b3697b90SSteven Stallion #define INTSTAT_RCTS (1UL << 22) /* Receive Copy Threshold Status */ 170*b3697b90SSteven Stallion #define INTSTAT_RSV (1UL << 23) /* Receive Status Valid */ 171*b3697b90SSteven Stallion #define INTSTAT_DPE (1UL << 24) /* PCI Data Parity Error */ 172*b3697b90SSteven Stallion #define INTSTAT_APE (1UL << 25) /* PCI Address Parity Error */ 173*b3697b90SSteven Stallion #define INTSTAT_PMA (1UL << 26) /* PCI Master Abort */ 174*b3697b90SSteven Stallion #define INTSTAT_PTA (1UL << 27) /* PCI Target Abort */ 175*b3697b90SSteven Stallion 176*b3697b90SSteven Stallion #define INTMASK_RCC (1UL << 0) /* Receive Copy Complete */ 177*b3697b90SSteven Stallion #define INTMASK_HCC (1UL << 1) /* Header Copy Complete */ 178*b3697b90SSteven Stallion #define INTMASK_RQE (1UL << 2) /* Receive Queue Empty */ 179*b3697b90SSteven Stallion #define INTMASK_OVW (1UL << 3) /* Receive Overflow */ 180*b3697b90SSteven Stallion #define INTMASK_RXE (1UL << 4) /* Receive Error */ 181*b3697b90SSteven Stallion #define INTMASK_TXC (1UL << 5) /* Transmit Complete */ 182*b3697b90SSteven Stallion #define INTMASK_TCC (1UL << 6) /* Transmit Chain Complete */ 183*b3697b90SSteven Stallion #define INTMASK_TQE (1UL << 7) /* Transmit Queue Empty */ 184*b3697b90SSteven Stallion #define INTMASK_TXU (1UL << 8) /* Transmit Underrun */ 185*b3697b90SSteven Stallion #define INTMASK_CNT (1UL << 9) /* Counter Overflow */ 186*b3697b90SSteven Stallion #define INTMASK_PREI (1UL << 10) /* Preemptive Interrupt */ 187*b3697b90SSteven Stallion #define INTMASK_RCT (1UL << 11) /* Receive Copy Threshold */ 188*b3697b90SSteven Stallion #define INTMASK_FATAL (1UL << 12) /* Fatal Error */ 189*b3697b90SSteven Stallion #define INTMASK_PME (1UL << 14) /* Power Management Event */ 190*b3697b90SSteven Stallion #define INTMASK_GP2 (1UL << 15) /* GPIO Event */ 191*b3697b90SSteven Stallion 192*b3697b90SSteven Stallion #define GENCTL_RESET (1UL << 0) /* Soft Reset */ 193*b3697b90SSteven Stallion #define GENCTL_INT (1UL << 1) /* Interrupt Enable */ 194*b3697b90SSteven Stallion #define GENCTL_SWINT (1UL << 2) /* Software Interrupt */ 195*b3697b90SSteven Stallion #define GENCTL_PWRDWN (1UL << 3) /* Power Down */ 196*b3697b90SSteven Stallion #define GENCTL_ONECOPY (1UL << 4) /* One Copy per Receive Frame */ 197*b3697b90SSteven Stallion #define GENCTL_BE (1UL << 5) /* Big Endian */ 198*b3697b90SSteven Stallion #define GENCTL_RDP (1UL << 6) /* Receive DMA Priority */ 199*b3697b90SSteven Stallion #define GENCTL_TDP (1UL << 7) /* Transmit DMA Priority */ 200*b3697b90SSteven Stallion #define GENCTL_RFT_32 (0UL << 8) /* Receive FIFO Threshold (1/4) */ 201*b3697b90SSteven Stallion #define GENCTL_RFT_64 (1UL << 8) /* Receive FIFO Threshold (1/2) */ 202*b3697b90SSteven Stallion #define GENCTL_RFT_96 (2UL << 8) /* Receive FIFO Threshold (3/4) */ 203*b3697b90SSteven Stallion #define GENCTL_RFT_128 (3UL << 8) /* Receive FIFO Threshold (FULL) */ 204*b3697b90SSteven Stallion #define GENCTL_MRM (1UL << 10) /* Memory Read Multiple */ 205*b3697b90SSteven Stallion #define GENCTL_MRL (1UL << 11) /* Memory Read Line */ 206*b3697b90SSteven Stallion #define GENCTL_SOFT0 (1UL << 12) /* Software Bit 0 */ 207*b3697b90SSteven Stallion #define GENCTL_SOFT1 (1UL << 13) /* Software Bit 1 */ 208*b3697b90SSteven Stallion #define GENCTL_RSTPHY (1UL << 14) /* PHY Reset */ 209*b3697b90SSteven Stallion #define GENCTL_SCLK (1UL << 16) /* System Clock */ 210*b3697b90SSteven Stallion #define GENCTL_RD (1UL << 17) /* Reset Disable */ 211*b3697b90SSteven Stallion #define GENCTL_MPE (1UL << 18) /* Magic Packet Enable */ 212*b3697b90SSteven Stallion #define GENCTL_PME (1UL << 19) /* PME Interrupt Enable */ 213*b3697b90SSteven Stallion #define GENCTL_PS_00 (0UL << 20) /* Power State "00" */ 214*b3697b90SSteven Stallion #define GENCTL_PS_01 (1UL << 20) /* Power State "01" */ 215*b3697b90SSteven Stallion #define GENCTL_PS_10 (2UL << 20) /* Power State "10" */ 216*b3697b90SSteven Stallion #define GENCTL_PS_11 (3UL << 20) /* Power State "11" */ 217*b3697b90SSteven Stallion #define GENCTL_OPLE (1UL << 22) /* On Power Loss Enable */ 218*b3697b90SSteven Stallion 219*b3697b90SSteven Stallion #define NVCTL_EMM (1UL << 0) /* Enable Memory Map */ 220*b3697b90SSteven Stallion #define NVCTL_CRS (1UL << 1) /* Clock Run Supported */ 221*b3697b90SSteven Stallion #define NVCTL_GPOE1 (1UL << 2) /* General Purpose Output Enable 1 */ 222*b3697b90SSteven Stallion #define NVCTL_GPOE2 (1UL << 3) /* General Purpose Output Enable 2 */ 223*b3697b90SSteven Stallion #define NVCTL_GPIO1 (1UL << 4) /* General Purpose I/O 1 */ 224*b3697b90SSteven Stallion #define NVCTL_GPIO2 (1UL << 5) /* General Purpose I/O 2 */ 225*b3697b90SSteven Stallion #define NVCTL_CB_MODE (1UL << 6) /* CardBus (UNUSED) */ 226*b3697b90SSteven Stallion #define NVCTL_IPG_DLY 7 /* Inter-packet Gap Timer Delay */ 227*b3697b90SSteven Stallion 228*b3697b90SSteven Stallion #define EECTL_ENABLE (1UL << 0) /* EEPROM Enable */ 229*b3697b90SSteven Stallion #define EECTL_EECS (1UL << 1) /* EEPROM Chip Select */ 230*b3697b90SSteven Stallion #define EECTL_EESK (1UL << 2) /* EEPROM Clock */ 231*b3697b90SSteven Stallion #define EECTL_EEDI (1UL << 3) /* EEPROM Data Input */ 232*b3697b90SSteven Stallion #define EECTL_EEDO (1UL << 4) /* EEPROM Data Output */ 233*b3697b90SSteven Stallion #define EECTL_EERDY (1UL << 5) /* EEPROM Ready */ 234*b3697b90SSteven Stallion #define EECTL_SIZE (1UL << 6) /* EEPROM Size */ 235*b3697b90SSteven Stallion 236*b3697b90SSteven Stallion #define TEST_CLOCK (1UL << 3) /* Clock Test */ 237*b3697b90SSteven Stallion 238*b3697b90SSteven Stallion #define MMCTL_READ (1UL << 0) /* MII Read */ 239*b3697b90SSteven Stallion #define MMCTL_WRITE (1UL << 1) /* MII Write */ 240*b3697b90SSteven Stallion #define MMCTL_RESPONDER (1UL << 3) /* MII Responder */ 241*b3697b90SSteven Stallion #define MMCTL_PHYREG 4 /* PHY Address */ 242*b3697b90SSteven Stallion #define MMCTL_PHYADDR 9 /* PHY Register Address */ 243*b3697b90SSteven Stallion 244*b3697b90SSteven Stallion #define MMCFG_SME (1UL << 0) /* Serial Mode Enable */ 245*b3697b90SSteven Stallion #define MMCFG_EN694 (1UL << 1) /* EN694 Pin */ 246*b3697b90SSteven Stallion #define MMCFG_694LNK (1UL << 2) /* 694LNK Pin */ 247*b3697b90SSteven Stallion #define MMCFG_PHY (1UL << 3) /* PHY Present */ 248*b3697b90SSteven Stallion #define MMCFG_SMI (1UL << 4) /* Enable Serial Management */ 249*b3697b90SSteven Stallion #define MMCFG_ALTCS (1UL << 5) /* Alternate Clock Source */ 250*b3697b90SSteven Stallion #define MMCFG_ALTDATA (1UL << 6) /* Alternate Data */ 251*b3697b90SSteven Stallion #define MMCFG_STXC (1UL << 14) /* Select TX Clock */ 252*b3697b90SSteven Stallion #define MMCFG_SNTXC (1UL << 15) /* Set No TX Clock */ 253*b3697b90SSteven Stallion 254*b3697b90SSteven Stallion #define RXCON_SEP (1UL << 0) /* Save Errored Packets */ 255*b3697b90SSteven Stallion #define RXCON_RRF (1UL << 1) /* Receive Runt Frames */ 256*b3697b90SSteven Stallion #define RXCON_RBF (1UL << 2) /* Receive Broadcast Frames */ 257*b3697b90SSteven Stallion #define RXCON_RMF (1UL << 3) /* Receive Multicast Frames */ 258*b3697b90SSteven Stallion #define RXCON_RIIA (1UL << 4) /* Receive Inverse Addresses */ 259*b3697b90SSteven Stallion #define RXCON_PROMISC (1UL << 5) /* Promiscuous Mode */ 260*b3697b90SSteven Stallion #define RXCON_MONITOR (1UL << 6) /* Monitor Mode */ 261*b3697b90SSteven Stallion #define RXCON_ERE (1UL << 7) /* Early Receive Enable */ 262*b3697b90SSteven Stallion #define RXCON_EB_INT (0UL << 8) /* External Buffer (Inernal) */ 263*b3697b90SSteven Stallion #define RXCON_EB_16K (1UL << 8) /* External Buffer (16K) */ 264*b3697b90SSteven Stallion #define RXCON_EB_32K (2UL << 8) /* External Buffer (32K) */ 265*b3697b90SSteven Stallion #define RXCON_EB_128K (3UL << 8) /* External Buffer (128K) */ 266*b3697b90SSteven Stallion 267*b3697b90SSteven Stallion #define RXSTAT_PRI (1UL << 0) /* Packet Received Intact */ 268*b3697b90SSteven Stallion #define RXSTAT_FAE (1UL << 1) /* Frame Alignment Error */ 269*b3697b90SSteven Stallion #define RXSTAT_CRC (1UL << 2) /* CRC Error */ 270*b3697b90SSteven Stallion #define RXSTAT_MP (1UL << 3) /* Missed Packet */ 271*b3697b90SSteven Stallion #define RXSTAT_MAR (1UL << 4) /* Multicast Address Recognized */ 272*b3697b90SSteven Stallion #define RXSTAT_BAR (1UL << 5) /* Broadcast Address Recognized */ 273*b3697b90SSteven Stallion #define RXSTAT_RD (1UL << 6) /* Receiver Disabled */ 274*b3697b90SSteven Stallion #define RXSTAT_NSV (1UL << 12) /* Network Status Valid */ 275*b3697b90SSteven Stallion #define RXSTAT_FLE (1UL << 13) /* Fragment List Error */ 276*b3697b90SSteven Stallion #define RXSTAT_HC (1UL << 14) /* Header Copied */ 277*b3697b90SSteven Stallion #define RXSTAT_OWNER (1UL << 15) /* Descriptor Ownership Bit */ 278*b3697b90SSteven Stallion 279*b3697b90SSteven Stallion #define RXCTL_FRAGLIST (1UL << 0) /* Fragment List */ 280*b3697b90SSteven Stallion #define RXCTL_LFFORM (1UL << 1) /* Fragment List Format */ 281*b3697b90SSteven Stallion #define RXCTL_HEADER (1UL << 2) /* Header Copy */ 282*b3697b90SSteven Stallion 283*b3697b90SSteven Stallion #define TXCON_ETE (1UL << 0) /* Early Transmit Enable */ 284*b3697b90SSteven Stallion #define TXCON_LB_0 (0UL << 1) /* Normal Operation */ 285*b3697b90SSteven Stallion #define TXCON_LB_1 (1UL << 1) /* Internal Loopback */ 286*b3697b90SSteven Stallion #define TXCON_LB_2 (2UL << 1) /* External Loopback */ 287*b3697b90SSteven Stallion #define TXCON_LB_3 (3UL << 1) /* Full Duplex Mode */ 288*b3697b90SSteven Stallion #define TXCON_SLOT 3 /* Slot Time */ 289*b3697b90SSteven Stallion 290*b3697b90SSteven Stallion #define TXSTAT_PTX (1UL << 0) /* Packet Transmitted */ 291*b3697b90SSteven Stallion #define TXSTAT_ND (1UL << 1) /* Non-deferred Transmission */ 292*b3697b90SSteven Stallion #define TXSTAT_COLL (1UL << 2) /* Transmitted w/Collisions */ 293*b3697b90SSteven Stallion #define TXSTAT_CSL (1UL << 3) /* Carrier Sense Lost */ 294*b3697b90SSteven Stallion #define TXSTAT_UFLO (1UL << 4) /* TX Underrun */ 295*b3697b90SSteven Stallion #define TXSTAT_CDH (1UL << 5) /* Collision Detect Heartbeat */ 296*b3697b90SSteven Stallion #define TXSTAT_OWC (1UL << 6) /* Out of Window Collision */ 297*b3697b90SSteven Stallion #define TXSTAT_DEFER (1UL << 7) /* IGP Deferring */ 298*b3697b90SSteven Stallion #define TXSTAT_CCNT 8 /* Collision Count */ 299*b3697b90SSteven Stallion #define TXSTAT_CCNTMASK 0x1F /* Collision Count Mask */ 300*b3697b90SSteven Stallion #define TXSTAT_EXCOLL (1UL << 12) /* Excessive Collisions */ 301*b3697b90SSteven Stallion #define TXSTAT_OWNER (1UL << 15) /* Descriptor Ownership Bit */ 302*b3697b90SSteven Stallion 303*b3697b90SSteven Stallion #define TXCTL_FRAGLIST (1UL << 0) /* Fragment List */ 304*b3697b90SSteven Stallion #define TXCTL_LFFORM (1UL << 1) /* Fragment List Format */ 305*b3697b90SSteven Stallion #define TXCTL_IAF (1UL << 2) /* Interrupt After Frame */ 306*b3697b90SSteven Stallion #define TXCTL_NOCRC (1UL << 3) /* Disable CRC Generation */ 307*b3697b90SSteven Stallion #define TXCTL_LASTDESCR (1UL << 4) /* Last Transmit Descriptor */ 308*b3697b90SSteven Stallion 309*b3697b90SSteven Stallion /* 310*b3697b90SSteven Stallion * Register access. 311*b3697b90SSteven Stallion */ 312*b3697b90SSteven Stallion #define GETCSR(efep, reg) \ 313*b3697b90SSteven Stallion ddi_get32((efep)->efe_regs_acch, \ 314*b3697b90SSteven Stallion (efep)->efe_regs + ((reg) / sizeof (uint32_t))) 315*b3697b90SSteven Stallion 316*b3697b90SSteven Stallion #define PUTCSR(efep, reg, val) \ 317*b3697b90SSteven Stallion ddi_put32((efep)->efe_regs_acch, \ 318*b3697b90SSteven Stallion (efep)->efe_regs + ((reg) / sizeof (uint32_t)), (val)) 319*b3697b90SSteven Stallion 320*b3697b90SSteven Stallion #define CLRBIT(efep, reg, bit) \ 321*b3697b90SSteven Stallion PUTCSR(efep, reg, (GETCSR(efep, reg) & ~(bit))) 322*b3697b90SSteven Stallion 323*b3697b90SSteven Stallion #define SETBIT(efep, reg, bit) \ 324*b3697b90SSteven Stallion PUTCSR(efep, reg, (GETCSR(efep, reg) | (bit))) 325*b3697b90SSteven Stallion 326*b3697b90SSteven Stallion /* 327*b3697b90SSteven Stallion * DMA access. 328*b3697b90SSteven Stallion */ 329*b3697b90SSteven Stallion #define DESCSZ(x) (sizeof (efe_desc_t) * (x)) 330*b3697b90SSteven Stallion #define BUFPSZ(x) (sizeof (efe_buf_t *) * (x)) 331*b3697b90SSteven Stallion 332*b3697b90SSteven Stallion #define DESCADDR(rp, x) ((rp)->r_dmac.dmac_address + DESCSZ(x)) 333*b3697b90SSteven Stallion #define DESCLEN(rp) ((rp)->r_len) 334*b3697b90SSteven Stallion 335*b3697b90SSteven Stallion #define BUFADDR(bp) ((bp)->b_dmac.dmac_address) 336*b3697b90SSteven Stallion #define BUFLEN(bp) ((bp)->b_len) 337*b3697b90SSteven Stallion 338*b3697b90SSteven Stallion #define NEXTDESC(rp, x) (((x) + 1) % (rp)->r_len) 339*b3697b90SSteven Stallion #define NEXTDESCADDR(rp, x) DESCADDR(rp, NEXTDESC(rp, x)) 340*b3697b90SSteven Stallion 341*b3697b90SSteven Stallion #define GETDESC(rp, x) (&(rp)->r_descp[(x)]) 342*b3697b90SSteven Stallion 343*b3697b90SSteven Stallion #define GETDESC16(rp, addr) \ 344*b3697b90SSteven Stallion ddi_get16((rp)->r_acch, (addr)) 345*b3697b90SSteven Stallion 346*b3697b90SSteven Stallion #define PUTDESC16(rp, addr, val) \ 347*b3697b90SSteven Stallion ddi_put16((rp)->r_acch, (addr), (val)) 348*b3697b90SSteven Stallion 349*b3697b90SSteven Stallion #define GETDESC32(rp, addr) \ 350*b3697b90SSteven Stallion ddi_get32((rp)->r_acch, (addr)) 351*b3697b90SSteven Stallion 352*b3697b90SSteven Stallion #define PUTDESC32(rp, addr, val) \ 353*b3697b90SSteven Stallion ddi_put32((rp)->r_acch, (addr), (val)) 354*b3697b90SSteven Stallion 355*b3697b90SSteven Stallion #define SYNCDESC(rp, x, type) \ 356*b3697b90SSteven Stallion (void) ddi_dma_sync((rp)->r_dmah, DESCSZ(x), \ 357*b3697b90SSteven Stallion sizeof (efe_desc_t), (type)) 358*b3697b90SSteven Stallion 359*b3697b90SSteven Stallion #define GETBUF(rp, x) ((rp)->r_bufpp[(x)]) 360*b3697b90SSteven Stallion 361*b3697b90SSteven Stallion #define SYNCBUF(bp, type) \ 362*b3697b90SSteven Stallion (void) ddi_dma_sync((bp)->b_dmah, 0, (bp)->b_len, (type)) 363*b3697b90SSteven Stallion 364*b3697b90SSteven Stallion /* 365*b3697b90SSteven Stallion * Soft state. 366*b3697b90SSteven Stallion */ 367*b3697b90SSteven Stallion typedef struct { 368*b3697b90SSteven Stallion uint16_t d_status; 369*b3697b90SSteven Stallion uint16_t d_len; 370*b3697b90SSteven Stallion uint32_t d_bufaddr; 371*b3697b90SSteven Stallion uint16_t d_buflen; 372*b3697b90SSteven Stallion uint16_t d_control; 373*b3697b90SSteven Stallion uint32_t d_next; 374*b3697b90SSteven Stallion } efe_desc_t; 375*b3697b90SSteven Stallion 376*b3697b90SSteven Stallion typedef struct { 377*b3697b90SSteven Stallion ddi_dma_handle_t b_dmah; 378*b3697b90SSteven Stallion ddi_acc_handle_t b_acch; 379*b3697b90SSteven Stallion ddi_dma_cookie_t b_dmac; 380*b3697b90SSteven Stallion size_t b_len; 381*b3697b90SSteven Stallion caddr_t b_kaddr; 382*b3697b90SSteven Stallion } efe_buf_t; 383*b3697b90SSteven Stallion 384*b3697b90SSteven Stallion typedef struct { 385*b3697b90SSteven Stallion ddi_dma_handle_t r_dmah; 386*b3697b90SSteven Stallion ddi_acc_handle_t r_acch; 387*b3697b90SSteven Stallion ddi_dma_cookie_t r_dmac; 388*b3697b90SSteven Stallion size_t r_len; 389*b3697b90SSteven Stallion efe_desc_t *r_descp; 390*b3697b90SSteven Stallion efe_buf_t **r_bufpp; 391*b3697b90SSteven Stallion } efe_ring_t; 392*b3697b90SSteven Stallion 393*b3697b90SSteven Stallion typedef struct { 394*b3697b90SSteven Stallion dev_info_t *efe_dip; 395*b3697b90SSteven Stallion 396*b3697b90SSteven Stallion mii_handle_t efe_miih; 397*b3697b90SSteven Stallion mac_handle_t efe_mh; 398*b3697b90SSteven Stallion 399*b3697b90SSteven Stallion uint32_t *efe_regs; 400*b3697b90SSteven Stallion ddi_acc_handle_t efe_regs_acch; 401*b3697b90SSteven Stallion 402*b3697b90SSteven Stallion ddi_intr_handle_t efe_intrh; 403*b3697b90SSteven Stallion 404*b3697b90SSteven Stallion kmutex_t efe_intrlock; 405*b3697b90SSteven Stallion kmutex_t efe_txlock; 406*b3697b90SSteven Stallion 407*b3697b90SSteven Stallion int efe_flags; 408*b3697b90SSteven Stallion boolean_t efe_promisc; 409*b3697b90SSteven Stallion 410*b3697b90SSteven Stallion uint8_t efe_macaddr[ETHERADDRL]; 411*b3697b90SSteven Stallion 412*b3697b90SSteven Stallion uint_t efe_mccount[MCHASHL]; 413*b3697b90SSteven Stallion uint16_t efe_mchash[MCHASHL / MCHASHSZ]; 414*b3697b90SSteven Stallion 415*b3697b90SSteven Stallion efe_ring_t *efe_rx_ring; 416*b3697b90SSteven Stallion uint_t efe_rx_desc; 417*b3697b90SSteven Stallion 418*b3697b90SSteven Stallion efe_ring_t *efe_tx_ring; 419*b3697b90SSteven Stallion uint_t efe_tx_desc; 420*b3697b90SSteven Stallion uint_t efe_tx_sent; 421*b3697b90SSteven Stallion 422*b3697b90SSteven Stallion /* 423*b3697b90SSteven Stallion * Driver statistics. 424*b3697b90SSteven Stallion */ 425*b3697b90SSteven Stallion uint64_t efe_multircv; 426*b3697b90SSteven Stallion uint64_t efe_brdcstrcv; 427*b3697b90SSteven Stallion uint64_t efe_multixmt; 428*b3697b90SSteven Stallion uint64_t efe_brdcstxmt; 429*b3697b90SSteven Stallion uint64_t efe_norcvbuf; 430*b3697b90SSteven Stallion uint64_t efe_ierrors; 431*b3697b90SSteven Stallion uint64_t efe_noxmtbuf; 432*b3697b90SSteven Stallion uint64_t efe_oerrors; 433*b3697b90SSteven Stallion uint64_t efe_collisions; 434*b3697b90SSteven Stallion uint64_t efe_rbytes; 435*b3697b90SSteven Stallion uint64_t efe_ipackets; 436*b3697b90SSteven Stallion uint64_t efe_obytes; 437*b3697b90SSteven Stallion uint64_t efe_opackets; 438*b3697b90SSteven Stallion uint64_t efe_uflo; 439*b3697b90SSteven Stallion uint64_t efe_oflo; 440*b3697b90SSteven Stallion uint64_t efe_align_errors; 441*b3697b90SSteven Stallion uint64_t efe_fcs_errors; 442*b3697b90SSteven Stallion uint64_t efe_first_collisions; 443*b3697b90SSteven Stallion uint64_t efe_tx_late_collisions; 444*b3697b90SSteven Stallion uint64_t efe_defer_xmts; 445*b3697b90SSteven Stallion uint64_t efe_ex_collisions; 446*b3697b90SSteven Stallion uint64_t efe_macxmt_errors; 447*b3697b90SSteven Stallion uint64_t efe_carrier_errors; 448*b3697b90SSteven Stallion uint64_t efe_toolong_errors; 449*b3697b90SSteven Stallion uint64_t efe_macrcv_errors; 450*b3697b90SSteven Stallion uint64_t efe_runt_errors; 451*b3697b90SSteven Stallion uint64_t efe_jabber_errors; 452*b3697b90SSteven Stallion } efe_t; 453*b3697b90SSteven Stallion 454*b3697b90SSteven Stallion #ifdef __cplusplus 455*b3697b90SSteven Stallion } 456*b3697b90SSteven Stallion #endif 457*b3697b90SSteven Stallion 458*b3697b90SSteven Stallion #endif /* _EFE_H */ 459