162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* $Id: sunbmac.h,v 1.7 2000/07/11 22:35:22 davem Exp $ 362306a36Sopenharmony_ci * sunbmac.h: Defines for the Sun "Big MAC" 100baseT ethernet cards. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _SUNBMAC_H 962306a36Sopenharmony_ci#define _SUNBMAC_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* QEC global registers. */ 1262306a36Sopenharmony_ci#define GLOB_CTRL 0x00UL /* Control */ 1362306a36Sopenharmony_ci#define GLOB_STAT 0x04UL /* Status */ 1462306a36Sopenharmony_ci#define GLOB_PSIZE 0x08UL /* Packet Size */ 1562306a36Sopenharmony_ci#define GLOB_MSIZE 0x0cUL /* Local-mem size (64K) */ 1662306a36Sopenharmony_ci#define GLOB_RSIZE 0x10UL /* Receive partition size */ 1762306a36Sopenharmony_ci#define GLOB_TSIZE 0x14UL /* Transmit partition size */ 1862306a36Sopenharmony_ci#define GLOB_REG_SIZE 0x18UL 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define GLOB_CTRL_MMODE 0x40000000 /* MACE qec mode */ 2162306a36Sopenharmony_ci#define GLOB_CTRL_BMODE 0x10000000 /* BigMAC qec mode */ 2262306a36Sopenharmony_ci#define GLOB_CTRL_EPAR 0x00000020 /* Enable parity */ 2362306a36Sopenharmony_ci#define GLOB_CTRL_ACNTRL 0x00000018 /* SBUS arbitration control */ 2462306a36Sopenharmony_ci#define GLOB_CTRL_B64 0x00000004 /* 64 byte dvma bursts */ 2562306a36Sopenharmony_ci#define GLOB_CTRL_B32 0x00000002 /* 32 byte dvma bursts */ 2662306a36Sopenharmony_ci#define GLOB_CTRL_B16 0x00000000 /* 16 byte dvma bursts */ 2762306a36Sopenharmony_ci#define GLOB_CTRL_RESET 0x00000001 /* Reset the QEC */ 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define GLOB_STAT_TX 0x00000008 /* BigMAC Transmit IRQ */ 3062306a36Sopenharmony_ci#define GLOB_STAT_RX 0x00000004 /* BigMAC Receive IRQ */ 3162306a36Sopenharmony_ci#define GLOB_STAT_BM 0x00000002 /* BigMAC Global IRQ */ 3262306a36Sopenharmony_ci#define GLOB_STAT_ER 0x00000001 /* BigMAC Error IRQ */ 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define GLOB_PSIZE_2048 0x00 /* 2k packet size */ 3562306a36Sopenharmony_ci#define GLOB_PSIZE_4096 0x01 /* 4k packet size */ 3662306a36Sopenharmony_ci#define GLOB_PSIZE_6144 0x10 /* 6k packet size */ 3762306a36Sopenharmony_ci#define GLOB_PSIZE_8192 0x11 /* 8k packet size */ 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* QEC BigMAC channel registers. */ 4062306a36Sopenharmony_ci#define CREG_CTRL 0x00UL /* Control */ 4162306a36Sopenharmony_ci#define CREG_STAT 0x04UL /* Status */ 4262306a36Sopenharmony_ci#define CREG_RXDS 0x08UL /* RX descriptor ring ptr */ 4362306a36Sopenharmony_ci#define CREG_TXDS 0x0cUL /* TX descriptor ring ptr */ 4462306a36Sopenharmony_ci#define CREG_RIMASK 0x10UL /* RX Interrupt Mask */ 4562306a36Sopenharmony_ci#define CREG_TIMASK 0x14UL /* TX Interrupt Mask */ 4662306a36Sopenharmony_ci#define CREG_QMASK 0x18UL /* QEC Error Interrupt Mask */ 4762306a36Sopenharmony_ci#define CREG_BMASK 0x1cUL /* BigMAC Error Interrupt Mask*/ 4862306a36Sopenharmony_ci#define CREG_RXWBUFPTR 0x20UL /* Local memory rx write ptr */ 4962306a36Sopenharmony_ci#define CREG_RXRBUFPTR 0x24UL /* Local memory rx read ptr */ 5062306a36Sopenharmony_ci#define CREG_TXWBUFPTR 0x28UL /* Local memory tx write ptr */ 5162306a36Sopenharmony_ci#define CREG_TXRBUFPTR 0x2cUL /* Local memory tx read ptr */ 5262306a36Sopenharmony_ci#define CREG_CCNT 0x30UL /* Collision Counter */ 5362306a36Sopenharmony_ci#define CREG_REG_SIZE 0x34UL 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define CREG_CTRL_TWAKEUP 0x00000001 /* Transmitter Wakeup, 'go'. */ 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#define CREG_STAT_BERROR 0x80000000 /* BigMAC error */ 5862306a36Sopenharmony_ci#define CREG_STAT_TXIRQ 0x00200000 /* Transmit Interrupt */ 5962306a36Sopenharmony_ci#define CREG_STAT_TXDERROR 0x00080000 /* TX Descriptor is bogus */ 6062306a36Sopenharmony_ci#define CREG_STAT_TXLERR 0x00040000 /* Late Transmit Error */ 6162306a36Sopenharmony_ci#define CREG_STAT_TXPERR 0x00020000 /* Transmit Parity Error */ 6262306a36Sopenharmony_ci#define CREG_STAT_TXSERR 0x00010000 /* Transmit SBUS error ack */ 6362306a36Sopenharmony_ci#define CREG_STAT_RXIRQ 0x00000020 /* Receive Interrupt */ 6462306a36Sopenharmony_ci#define CREG_STAT_RXDROP 0x00000010 /* Dropped a RX'd packet */ 6562306a36Sopenharmony_ci#define CREG_STAT_RXSMALL 0x00000008 /* Receive buffer too small */ 6662306a36Sopenharmony_ci#define CREG_STAT_RXLERR 0x00000004 /* Receive Late Error */ 6762306a36Sopenharmony_ci#define CREG_STAT_RXPERR 0x00000002 /* Receive Parity Error */ 6862306a36Sopenharmony_ci#define CREG_STAT_RXSERR 0x00000001 /* Receive SBUS Error ACK */ 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define CREG_STAT_ERRORS (CREG_STAT_BERROR|CREG_STAT_TXDERROR|CREG_STAT_TXLERR| \ 7162306a36Sopenharmony_ci CREG_STAT_TXPERR|CREG_STAT_TXSERR|CREG_STAT_RXDROP| \ 7262306a36Sopenharmony_ci CREG_STAT_RXSMALL|CREG_STAT_RXLERR|CREG_STAT_RXPERR| \ 7362306a36Sopenharmony_ci CREG_STAT_RXSERR) 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define CREG_QMASK_TXDERROR 0x00080000 /* TXD error */ 7662306a36Sopenharmony_ci#define CREG_QMASK_TXLERR 0x00040000 /* TX late error */ 7762306a36Sopenharmony_ci#define CREG_QMASK_TXPERR 0x00020000 /* TX parity error */ 7862306a36Sopenharmony_ci#define CREG_QMASK_TXSERR 0x00010000 /* TX sbus error ack */ 7962306a36Sopenharmony_ci#define CREG_QMASK_RXDROP 0x00000010 /* RX drop */ 8062306a36Sopenharmony_ci#define CREG_QMASK_RXBERROR 0x00000008 /* RX buffer error */ 8162306a36Sopenharmony_ci#define CREG_QMASK_RXLEERR 0x00000004 /* RX late error */ 8262306a36Sopenharmony_ci#define CREG_QMASK_RXPERR 0x00000002 /* RX parity error */ 8362306a36Sopenharmony_ci#define CREG_QMASK_RXSERR 0x00000001 /* RX sbus error ack */ 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/* BIGMAC core registers */ 8662306a36Sopenharmony_ci#define BMAC_XIFCFG 0x000UL /* XIF config register */ 8762306a36Sopenharmony_ci /* 0x004-->0x0fc, reserved */ 8862306a36Sopenharmony_ci#define BMAC_STATUS 0x100UL /* Status register, clear on read */ 8962306a36Sopenharmony_ci#define BMAC_IMASK 0x104UL /* Interrupt mask register */ 9062306a36Sopenharmony_ci /* 0x108-->0x204, reserved */ 9162306a36Sopenharmony_ci#define BMAC_TXSWRESET 0x208UL /* Transmitter software reset */ 9262306a36Sopenharmony_ci#define BMAC_TXCFG 0x20cUL /* Transmitter config register */ 9362306a36Sopenharmony_ci#define BMAC_IGAP1 0x210UL /* Inter-packet gap 1 */ 9462306a36Sopenharmony_ci#define BMAC_IGAP2 0x214UL /* Inter-packet gap 2 */ 9562306a36Sopenharmony_ci#define BMAC_ALIMIT 0x218UL /* Transmit attempt limit */ 9662306a36Sopenharmony_ci#define BMAC_STIME 0x21cUL /* Transmit slot time */ 9762306a36Sopenharmony_ci#define BMAC_PLEN 0x220UL /* Size of transmit preamble */ 9862306a36Sopenharmony_ci#define BMAC_PPAT 0x224UL /* Pattern for transmit preamble */ 9962306a36Sopenharmony_ci#define BMAC_TXDELIM 0x228UL /* Transmit delimiter */ 10062306a36Sopenharmony_ci#define BMAC_JSIZE 0x22cUL /* Toe jam... */ 10162306a36Sopenharmony_ci#define BMAC_TXPMAX 0x230UL /* Transmit max pkt size */ 10262306a36Sopenharmony_ci#define BMAC_TXPMIN 0x234UL /* Transmit min pkt size */ 10362306a36Sopenharmony_ci#define BMAC_PATTEMPT 0x238UL /* Count of transmit peak attempts */ 10462306a36Sopenharmony_ci#define BMAC_DTCTR 0x23cUL /* Transmit defer timer */ 10562306a36Sopenharmony_ci#define BMAC_NCCTR 0x240UL /* Transmit normal-collision counter */ 10662306a36Sopenharmony_ci#define BMAC_FCCTR 0x244UL /* Transmit first-collision counter */ 10762306a36Sopenharmony_ci#define BMAC_EXCTR 0x248UL /* Transmit excess-collision counter */ 10862306a36Sopenharmony_ci#define BMAC_LTCTR 0x24cUL /* Transmit late-collision counter */ 10962306a36Sopenharmony_ci#define BMAC_RSEED 0x250UL /* Transmit random number seed */ 11062306a36Sopenharmony_ci#define BMAC_TXSMACHINE 0x254UL /* Transmit state machine */ 11162306a36Sopenharmony_ci /* 0x258-->0x304, reserved */ 11262306a36Sopenharmony_ci#define BMAC_RXSWRESET 0x308UL /* Receiver software reset */ 11362306a36Sopenharmony_ci#define BMAC_RXCFG 0x30cUL /* Receiver config register */ 11462306a36Sopenharmony_ci#define BMAC_RXPMAX 0x310UL /* Receive max pkt size */ 11562306a36Sopenharmony_ci#define BMAC_RXPMIN 0x314UL /* Receive min pkt size */ 11662306a36Sopenharmony_ci#define BMAC_MACADDR2 0x318UL /* Ether address register 2 */ 11762306a36Sopenharmony_ci#define BMAC_MACADDR1 0x31cUL /* Ether address register 1 */ 11862306a36Sopenharmony_ci#define BMAC_MACADDR0 0x320UL /* Ether address register 0 */ 11962306a36Sopenharmony_ci#define BMAC_FRCTR 0x324UL /* Receive frame receive counter */ 12062306a36Sopenharmony_ci#define BMAC_GLECTR 0x328UL /* Receive giant-length error counter */ 12162306a36Sopenharmony_ci#define BMAC_UNALECTR 0x32cUL /* Receive unaligned error counter */ 12262306a36Sopenharmony_ci#define BMAC_RCRCECTR 0x330UL /* Receive CRC error counter */ 12362306a36Sopenharmony_ci#define BMAC_RXSMACHINE 0x334UL /* Receiver state machine */ 12462306a36Sopenharmony_ci#define BMAC_RXCVALID 0x338UL /* Receiver code violation */ 12562306a36Sopenharmony_ci /* 0x33c, reserved */ 12662306a36Sopenharmony_ci#define BMAC_HTABLE3 0x340UL /* Hash table 3 */ 12762306a36Sopenharmony_ci#define BMAC_HTABLE2 0x344UL /* Hash table 2 */ 12862306a36Sopenharmony_ci#define BMAC_HTABLE1 0x348UL /* Hash table 1 */ 12962306a36Sopenharmony_ci#define BMAC_HTABLE0 0x34cUL /* Hash table 0 */ 13062306a36Sopenharmony_ci#define BMAC_AFILTER2 0x350UL /* Address filter 2 */ 13162306a36Sopenharmony_ci#define BMAC_AFILTER1 0x354UL /* Address filter 1 */ 13262306a36Sopenharmony_ci#define BMAC_AFILTER0 0x358UL /* Address filter 0 */ 13362306a36Sopenharmony_ci#define BMAC_AFMASK 0x35cUL /* Address filter mask */ 13462306a36Sopenharmony_ci#define BMAC_REG_SIZE 0x360UL 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* BigMac XIF config register. */ 13762306a36Sopenharmony_ci#define BIGMAC_XCFG_ODENABLE 0x00000001 /* Output driver enable */ 13862306a36Sopenharmony_ci#define BIGMAC_XCFG_RESV 0x00000002 /* Reserved, write always as 1 */ 13962306a36Sopenharmony_ci#define BIGMAC_XCFG_MLBACK 0x00000004 /* Loopback-mode MII enable */ 14062306a36Sopenharmony_ci#define BIGMAC_XCFG_SMODE 0x00000008 /* Enable serial mode */ 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* BigMAC status register. */ 14362306a36Sopenharmony_ci#define BIGMAC_STAT_GOTFRAME 0x00000001 /* Received a frame */ 14462306a36Sopenharmony_ci#define BIGMAC_STAT_RCNTEXP 0x00000002 /* Receive frame counter expired */ 14562306a36Sopenharmony_ci#define BIGMAC_STAT_ACNTEXP 0x00000004 /* Align-error counter expired */ 14662306a36Sopenharmony_ci#define BIGMAC_STAT_CCNTEXP 0x00000008 /* CRC-error counter expired */ 14762306a36Sopenharmony_ci#define BIGMAC_STAT_LCNTEXP 0x00000010 /* Length-error counter expired */ 14862306a36Sopenharmony_ci#define BIGMAC_STAT_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 14962306a36Sopenharmony_ci#define BIGMAC_STAT_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 15062306a36Sopenharmony_ci#define BIGMAC_STAT_SENTFRAME 0x00000100 /* Transmitted a frame */ 15162306a36Sopenharmony_ci#define BIGMAC_STAT_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 15262306a36Sopenharmony_ci#define BIGMAC_STAT_MAXPKTERR 0x00000400 /* Max-packet size error */ 15362306a36Sopenharmony_ci#define BIGMAC_STAT_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 15462306a36Sopenharmony_ci#define BIGMAC_STAT_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 15562306a36Sopenharmony_ci#define BIGMAC_STAT_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 15662306a36Sopenharmony_ci#define BIGMAC_STAT_FCNTEXP 0x00004000 /* First-collision counter expired */ 15762306a36Sopenharmony_ci#define BIGMAC_STAT_DTIMEXP 0x00008000 /* Defer-timer expired */ 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci/* BigMAC interrupt mask register. */ 16062306a36Sopenharmony_ci#define BIGMAC_IMASK_GOTFRAME 0x00000001 /* Received a frame */ 16162306a36Sopenharmony_ci#define BIGMAC_IMASK_RCNTEXP 0x00000002 /* Receive frame counter expired */ 16262306a36Sopenharmony_ci#define BIGMAC_IMASK_ACNTEXP 0x00000004 /* Align-error counter expired */ 16362306a36Sopenharmony_ci#define BIGMAC_IMASK_CCNTEXP 0x00000008 /* CRC-error counter expired */ 16462306a36Sopenharmony_ci#define BIGMAC_IMASK_LCNTEXP 0x00000010 /* Length-error counter expired */ 16562306a36Sopenharmony_ci#define BIGMAC_IMASK_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 16662306a36Sopenharmony_ci#define BIGMAC_IMASK_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 16762306a36Sopenharmony_ci#define BIGMAC_IMASK_SENTFRAME 0x00000100 /* Transmitted a frame */ 16862306a36Sopenharmony_ci#define BIGMAC_IMASK_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 16962306a36Sopenharmony_ci#define BIGMAC_IMASK_MAXPKTERR 0x00000400 /* Max-packet size error */ 17062306a36Sopenharmony_ci#define BIGMAC_IMASK_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 17162306a36Sopenharmony_ci#define BIGMAC_IMASK_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 17262306a36Sopenharmony_ci#define BIGMAC_IMASK_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 17362306a36Sopenharmony_ci#define BIGMAC_IMASK_FCNTEXP 0x00004000 /* First-collision counter expired */ 17462306a36Sopenharmony_ci#define BIGMAC_IMASK_DTIMEXP 0x00008000 /* Defer-timer expired */ 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* BigMac transmit config register. */ 17762306a36Sopenharmony_ci#define BIGMAC_TXCFG_ENABLE 0x00000001 /* Enable the transmitter */ 17862306a36Sopenharmony_ci#define BIGMAC_TXCFG_FIFO 0x00000010 /* Default tx fthresh... */ 17962306a36Sopenharmony_ci#define BIGMAC_TXCFG_SMODE 0x00000020 /* Enable slow transmit mode */ 18062306a36Sopenharmony_ci#define BIGMAC_TXCFG_CIGN 0x00000040 /* Ignore transmit collisions */ 18162306a36Sopenharmony_ci#define BIGMAC_TXCFG_FCSOFF 0x00000080 /* Do not emit FCS */ 18262306a36Sopenharmony_ci#define BIGMAC_TXCFG_DBACKOFF 0x00000100 /* Disable backoff */ 18362306a36Sopenharmony_ci#define BIGMAC_TXCFG_FULLDPLX 0x00000200 /* Enable full-duplex */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci/* BigMac receive config register. */ 18662306a36Sopenharmony_ci#define BIGMAC_RXCFG_ENABLE 0x00000001 /* Enable the receiver */ 18762306a36Sopenharmony_ci#define BIGMAC_RXCFG_FIFO 0x0000000e /* Default rx fthresh... */ 18862306a36Sopenharmony_ci#define BIGMAC_RXCFG_PSTRIP 0x00000020 /* Pad byte strip enable */ 18962306a36Sopenharmony_ci#define BIGMAC_RXCFG_PMISC 0x00000040 /* Enable promiscuous mode */ 19062306a36Sopenharmony_ci#define BIGMAC_RXCFG_DERR 0x00000080 /* Disable error checking */ 19162306a36Sopenharmony_ci#define BIGMAC_RXCFG_DCRCS 0x00000100 /* Disable CRC stripping */ 19262306a36Sopenharmony_ci#define BIGMAC_RXCFG_ME 0x00000200 /* Receive packets addressed to me */ 19362306a36Sopenharmony_ci#define BIGMAC_RXCFG_PGRP 0x00000400 /* Enable promisc group mode */ 19462306a36Sopenharmony_ci#define BIGMAC_RXCFG_HENABLE 0x00000800 /* Enable the hash filter */ 19562306a36Sopenharmony_ci#define BIGMAC_RXCFG_AENABLE 0x00001000 /* Enable the address filter */ 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci/* The BigMAC PHY transceiver. Not nearly as sophisticated as the happy meal 19862306a36Sopenharmony_ci * one. But it does have the "bit banger", oh baby. 19962306a36Sopenharmony_ci */ 20062306a36Sopenharmony_ci#define TCVR_TPAL 0x00UL 20162306a36Sopenharmony_ci#define TCVR_MPAL 0x04UL 20262306a36Sopenharmony_ci#define TCVR_REG_SIZE 0x08UL 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* Frame commands. */ 20562306a36Sopenharmony_ci#define FRAME_WRITE 0x50020000 20662306a36Sopenharmony_ci#define FRAME_READ 0x60020000 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* Tranceiver registers. */ 20962306a36Sopenharmony_ci#define TCVR_PAL_SERIAL 0x00000001 /* Enable serial mode */ 21062306a36Sopenharmony_ci#define TCVR_PAL_EXTLBACK 0x00000002 /* Enable external loopback */ 21162306a36Sopenharmony_ci#define TCVR_PAL_MSENSE 0x00000004 /* Media sense */ 21262306a36Sopenharmony_ci#define TCVR_PAL_LTENABLE 0x00000008 /* Link test enable */ 21362306a36Sopenharmony_ci#define TCVR_PAL_LTSTATUS 0x00000010 /* Link test status (P1 only) */ 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci/* Management PAL. */ 21662306a36Sopenharmony_ci#define MGMT_PAL_DCLOCK 0x00000001 /* Data clock */ 21762306a36Sopenharmony_ci#define MGMT_PAL_OENAB 0x00000002 /* Output enabler */ 21862306a36Sopenharmony_ci#define MGMT_PAL_MDIO 0x00000004 /* MDIO Data/attached */ 21962306a36Sopenharmony_ci#define MGMT_PAL_TIMEO 0x00000008 /* Transmit enable timeout error */ 22062306a36Sopenharmony_ci#define MGMT_PAL_EXT_MDIO MGMT_PAL_MDIO 22162306a36Sopenharmony_ci#define MGMT_PAL_INT_MDIO MGMT_PAL_TIMEO 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci/* Here are some PHY addresses. */ 22462306a36Sopenharmony_ci#define BIGMAC_PHY_EXTERNAL 0 /* External transceiver */ 22562306a36Sopenharmony_ci#define BIGMAC_PHY_INTERNAL 1 /* Internal transceiver */ 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci/* Ring descriptors and such, same as Quad Ethernet. */ 22862306a36Sopenharmony_cistruct be_rxd { 22962306a36Sopenharmony_ci u32 rx_flags; 23062306a36Sopenharmony_ci u32 rx_addr; 23162306a36Sopenharmony_ci}; 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci#define RXD_OWN 0x80000000 /* Ownership. */ 23462306a36Sopenharmony_ci#define RXD_UPDATE 0x10000000 /* Being Updated? */ 23562306a36Sopenharmony_ci#define RXD_LENGTH 0x000007ff /* Packet Length. */ 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_cistruct be_txd { 23862306a36Sopenharmony_ci u32 tx_flags; 23962306a36Sopenharmony_ci u32 tx_addr; 24062306a36Sopenharmony_ci}; 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci#define TXD_OWN 0x80000000 /* Ownership. */ 24362306a36Sopenharmony_ci#define TXD_SOP 0x40000000 /* Start Of Packet */ 24462306a36Sopenharmony_ci#define TXD_EOP 0x20000000 /* End Of Packet */ 24562306a36Sopenharmony_ci#define TXD_UPDATE 0x10000000 /* Being Updated? */ 24662306a36Sopenharmony_ci#define TXD_LENGTH 0x000007ff /* Packet Length. */ 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci#define TX_RING_MAXSIZE 256 24962306a36Sopenharmony_ci#define RX_RING_MAXSIZE 256 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci#define TX_RING_SIZE 256 25262306a36Sopenharmony_ci#define RX_RING_SIZE 256 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci#define NEXT_RX(num) (((num) + 1) & (RX_RING_SIZE - 1)) 25562306a36Sopenharmony_ci#define NEXT_TX(num) (((num) + 1) & (TX_RING_SIZE - 1)) 25662306a36Sopenharmony_ci#define PREV_RX(num) (((num) - 1) & (RX_RING_SIZE - 1)) 25762306a36Sopenharmony_ci#define PREV_TX(num) (((num) - 1) & (TX_RING_SIZE - 1)) 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci#define TX_BUFFS_AVAIL(bp) \ 26062306a36Sopenharmony_ci (((bp)->tx_old <= (bp)->tx_new) ? \ 26162306a36Sopenharmony_ci (bp)->tx_old + (TX_RING_SIZE - 1) - (bp)->tx_new : \ 26262306a36Sopenharmony_ci (bp)->tx_old - (bp)->tx_new - 1) 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#define RX_COPY_THRESHOLD 256 26662306a36Sopenharmony_ci#define RX_BUF_ALLOC_SIZE (ETH_FRAME_LEN + (64 * 3)) 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_cistruct bmac_init_block { 26962306a36Sopenharmony_ci struct be_rxd be_rxd[RX_RING_MAXSIZE]; 27062306a36Sopenharmony_ci struct be_txd be_txd[TX_RING_MAXSIZE]; 27162306a36Sopenharmony_ci}; 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci#define bib_offset(mem, elem) \ 27462306a36Sopenharmony_ci((__u32)((unsigned long)(&(((struct bmac_init_block *)0)->mem[elem])))) 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci/* Now software state stuff. */ 27762306a36Sopenharmony_cienum bigmac_transceiver { 27862306a36Sopenharmony_ci external = 0, 27962306a36Sopenharmony_ci internal = 1, 28062306a36Sopenharmony_ci none = 2, 28162306a36Sopenharmony_ci}; 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ci/* Timer state engine. */ 28462306a36Sopenharmony_cienum bigmac_timer_state { 28562306a36Sopenharmony_ci ltrywait = 1, /* Forcing try of all modes, from fastest to slowest. */ 28662306a36Sopenharmony_ci asleep = 2, /* Timer inactive. */ 28762306a36Sopenharmony_ci}; 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_cistruct bigmac { 29062306a36Sopenharmony_ci void __iomem *gregs; /* QEC Global Registers */ 29162306a36Sopenharmony_ci void __iomem *creg; /* QEC BigMAC Channel Registers */ 29262306a36Sopenharmony_ci void __iomem *bregs; /* BigMAC Registers */ 29362306a36Sopenharmony_ci void __iomem *tregs; /* BigMAC Transceiver */ 29462306a36Sopenharmony_ci struct bmac_init_block *bmac_block; /* RX and TX descriptors */ 29562306a36Sopenharmony_ci dma_addr_t bblock_dvma; /* RX and TX descriptors */ 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ci spinlock_t lock; 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci struct sk_buff *rx_skbs[RX_RING_SIZE]; 30062306a36Sopenharmony_ci struct sk_buff *tx_skbs[TX_RING_SIZE]; 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ci int rx_new, tx_new, rx_old, tx_old; 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci int board_rev; /* BigMAC board revision. */ 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci enum bigmac_transceiver tcvr_type; 30762306a36Sopenharmony_ci unsigned int bigmac_bursts; 30862306a36Sopenharmony_ci unsigned int paddr; 30962306a36Sopenharmony_ci unsigned short sw_bmsr; /* SW copy of PHY BMSR */ 31062306a36Sopenharmony_ci unsigned short sw_bmcr; /* SW copy of PHY BMCR */ 31162306a36Sopenharmony_ci struct timer_list bigmac_timer; 31262306a36Sopenharmony_ci enum bigmac_timer_state timer_state; 31362306a36Sopenharmony_ci unsigned int timer_ticks; 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci struct platform_device *qec_op; 31662306a36Sopenharmony_ci struct platform_device *bigmac_op; 31762306a36Sopenharmony_ci struct net_device *dev; 31862306a36Sopenharmony_ci}; 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci/* We use this to acquire receive skb's that we can DMA directly into. */ 32162306a36Sopenharmony_ci#define ALIGNED_RX_SKB_ADDR(addr) \ 32262306a36Sopenharmony_ci ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr)) 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_cistatic inline struct sk_buff *big_mac_alloc_skb(unsigned int length, gfp_t gfp_flags) 32562306a36Sopenharmony_ci{ 32662306a36Sopenharmony_ci struct sk_buff *skb; 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci skb = alloc_skb(length + 64, gfp_flags); 32962306a36Sopenharmony_ci if(skb) { 33062306a36Sopenharmony_ci int offset = ALIGNED_RX_SKB_ADDR(skb->data); 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci if(offset) 33362306a36Sopenharmony_ci skb_reserve(skb, offset); 33462306a36Sopenharmony_ci } 33562306a36Sopenharmony_ci return skb; 33662306a36Sopenharmony_ci} 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci#endif /* !(_SUNBMAC_H) */ 339