18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* $Id: sunbmac.h,v 1.7 2000/07/11 22:35:22 davem Exp $ 38c2ecf20Sopenharmony_ci * sunbmac.h: Defines for the Sun "Big MAC" 100baseT ethernet cards. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SUNBMAC_H 98c2ecf20Sopenharmony_ci#define _SUNBMAC_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* QEC global registers. */ 128c2ecf20Sopenharmony_ci#define GLOB_CTRL 0x00UL /* Control */ 138c2ecf20Sopenharmony_ci#define GLOB_STAT 0x04UL /* Status */ 148c2ecf20Sopenharmony_ci#define GLOB_PSIZE 0x08UL /* Packet Size */ 158c2ecf20Sopenharmony_ci#define GLOB_MSIZE 0x0cUL /* Local-mem size (64K) */ 168c2ecf20Sopenharmony_ci#define GLOB_RSIZE 0x10UL /* Receive partition size */ 178c2ecf20Sopenharmony_ci#define GLOB_TSIZE 0x14UL /* Transmit partition size */ 188c2ecf20Sopenharmony_ci#define GLOB_REG_SIZE 0x18UL 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define GLOB_CTRL_MMODE 0x40000000 /* MACE qec mode */ 218c2ecf20Sopenharmony_ci#define GLOB_CTRL_BMODE 0x10000000 /* BigMAC qec mode */ 228c2ecf20Sopenharmony_ci#define GLOB_CTRL_EPAR 0x00000020 /* Enable parity */ 238c2ecf20Sopenharmony_ci#define GLOB_CTRL_ACNTRL 0x00000018 /* SBUS arbitration control */ 248c2ecf20Sopenharmony_ci#define GLOB_CTRL_B64 0x00000004 /* 64 byte dvma bursts */ 258c2ecf20Sopenharmony_ci#define GLOB_CTRL_B32 0x00000002 /* 32 byte dvma bursts */ 268c2ecf20Sopenharmony_ci#define GLOB_CTRL_B16 0x00000000 /* 16 byte dvma bursts */ 278c2ecf20Sopenharmony_ci#define GLOB_CTRL_RESET 0x00000001 /* Reset the QEC */ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define GLOB_STAT_TX 0x00000008 /* BigMAC Transmit IRQ */ 308c2ecf20Sopenharmony_ci#define GLOB_STAT_RX 0x00000004 /* BigMAC Receive IRQ */ 318c2ecf20Sopenharmony_ci#define GLOB_STAT_BM 0x00000002 /* BigMAC Global IRQ */ 328c2ecf20Sopenharmony_ci#define GLOB_STAT_ER 0x00000001 /* BigMAC Error IRQ */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define GLOB_PSIZE_2048 0x00 /* 2k packet size */ 358c2ecf20Sopenharmony_ci#define GLOB_PSIZE_4096 0x01 /* 4k packet size */ 368c2ecf20Sopenharmony_ci#define GLOB_PSIZE_6144 0x10 /* 6k packet size */ 378c2ecf20Sopenharmony_ci#define GLOB_PSIZE_8192 0x11 /* 8k packet size */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* QEC BigMAC channel registers. */ 408c2ecf20Sopenharmony_ci#define CREG_CTRL 0x00UL /* Control */ 418c2ecf20Sopenharmony_ci#define CREG_STAT 0x04UL /* Status */ 428c2ecf20Sopenharmony_ci#define CREG_RXDS 0x08UL /* RX descriptor ring ptr */ 438c2ecf20Sopenharmony_ci#define CREG_TXDS 0x0cUL /* TX descriptor ring ptr */ 448c2ecf20Sopenharmony_ci#define CREG_RIMASK 0x10UL /* RX Interrupt Mask */ 458c2ecf20Sopenharmony_ci#define CREG_TIMASK 0x14UL /* TX Interrupt Mask */ 468c2ecf20Sopenharmony_ci#define CREG_QMASK 0x18UL /* QEC Error Interrupt Mask */ 478c2ecf20Sopenharmony_ci#define CREG_BMASK 0x1cUL /* BigMAC Error Interrupt Mask*/ 488c2ecf20Sopenharmony_ci#define CREG_RXWBUFPTR 0x20UL /* Local memory rx write ptr */ 498c2ecf20Sopenharmony_ci#define CREG_RXRBUFPTR 0x24UL /* Local memory rx read ptr */ 508c2ecf20Sopenharmony_ci#define CREG_TXWBUFPTR 0x28UL /* Local memory tx write ptr */ 518c2ecf20Sopenharmony_ci#define CREG_TXRBUFPTR 0x2cUL /* Local memory tx read ptr */ 528c2ecf20Sopenharmony_ci#define CREG_CCNT 0x30UL /* Collision Counter */ 538c2ecf20Sopenharmony_ci#define CREG_REG_SIZE 0x34UL 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define CREG_CTRL_TWAKEUP 0x00000001 /* Transmitter Wakeup, 'go'. */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define CREG_STAT_BERROR 0x80000000 /* BigMAC error */ 588c2ecf20Sopenharmony_ci#define CREG_STAT_TXIRQ 0x00200000 /* Transmit Interrupt */ 598c2ecf20Sopenharmony_ci#define CREG_STAT_TXDERROR 0x00080000 /* TX Descriptor is bogus */ 608c2ecf20Sopenharmony_ci#define CREG_STAT_TXLERR 0x00040000 /* Late Transmit Error */ 618c2ecf20Sopenharmony_ci#define CREG_STAT_TXPERR 0x00020000 /* Transmit Parity Error */ 628c2ecf20Sopenharmony_ci#define CREG_STAT_TXSERR 0x00010000 /* Transmit SBUS error ack */ 638c2ecf20Sopenharmony_ci#define CREG_STAT_RXIRQ 0x00000020 /* Receive Interrupt */ 648c2ecf20Sopenharmony_ci#define CREG_STAT_RXDROP 0x00000010 /* Dropped a RX'd packet */ 658c2ecf20Sopenharmony_ci#define CREG_STAT_RXSMALL 0x00000008 /* Receive buffer too small */ 668c2ecf20Sopenharmony_ci#define CREG_STAT_RXLERR 0x00000004 /* Receive Late Error */ 678c2ecf20Sopenharmony_ci#define CREG_STAT_RXPERR 0x00000002 /* Receive Parity Error */ 688c2ecf20Sopenharmony_ci#define CREG_STAT_RXSERR 0x00000001 /* Receive SBUS Error ACK */ 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define CREG_STAT_ERRORS (CREG_STAT_BERROR|CREG_STAT_TXDERROR|CREG_STAT_TXLERR| \ 718c2ecf20Sopenharmony_ci CREG_STAT_TXPERR|CREG_STAT_TXSERR|CREG_STAT_RXDROP| \ 728c2ecf20Sopenharmony_ci CREG_STAT_RXSMALL|CREG_STAT_RXLERR|CREG_STAT_RXPERR| \ 738c2ecf20Sopenharmony_ci CREG_STAT_RXSERR) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define CREG_QMASK_TXDERROR 0x00080000 /* TXD error */ 768c2ecf20Sopenharmony_ci#define CREG_QMASK_TXLERR 0x00040000 /* TX late error */ 778c2ecf20Sopenharmony_ci#define CREG_QMASK_TXPERR 0x00020000 /* TX parity error */ 788c2ecf20Sopenharmony_ci#define CREG_QMASK_TXSERR 0x00010000 /* TX sbus error ack */ 798c2ecf20Sopenharmony_ci#define CREG_QMASK_RXDROP 0x00000010 /* RX drop */ 808c2ecf20Sopenharmony_ci#define CREG_QMASK_RXBERROR 0x00000008 /* RX buffer error */ 818c2ecf20Sopenharmony_ci#define CREG_QMASK_RXLEERR 0x00000004 /* RX late error */ 828c2ecf20Sopenharmony_ci#define CREG_QMASK_RXPERR 0x00000002 /* RX parity error */ 838c2ecf20Sopenharmony_ci#define CREG_QMASK_RXSERR 0x00000001 /* RX sbus error ack */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* BIGMAC core registers */ 868c2ecf20Sopenharmony_ci#define BMAC_XIFCFG 0x000UL /* XIF config register */ 878c2ecf20Sopenharmony_ci /* 0x004-->0x0fc, reserved */ 888c2ecf20Sopenharmony_ci#define BMAC_STATUS 0x100UL /* Status register, clear on read */ 898c2ecf20Sopenharmony_ci#define BMAC_IMASK 0x104UL /* Interrupt mask register */ 908c2ecf20Sopenharmony_ci /* 0x108-->0x204, reserved */ 918c2ecf20Sopenharmony_ci#define BMAC_TXSWRESET 0x208UL /* Transmitter software reset */ 928c2ecf20Sopenharmony_ci#define BMAC_TXCFG 0x20cUL /* Transmitter config register */ 938c2ecf20Sopenharmony_ci#define BMAC_IGAP1 0x210UL /* Inter-packet gap 1 */ 948c2ecf20Sopenharmony_ci#define BMAC_IGAP2 0x214UL /* Inter-packet gap 2 */ 958c2ecf20Sopenharmony_ci#define BMAC_ALIMIT 0x218UL /* Transmit attempt limit */ 968c2ecf20Sopenharmony_ci#define BMAC_STIME 0x21cUL /* Transmit slot time */ 978c2ecf20Sopenharmony_ci#define BMAC_PLEN 0x220UL /* Size of transmit preamble */ 988c2ecf20Sopenharmony_ci#define BMAC_PPAT 0x224UL /* Pattern for transmit preamble */ 998c2ecf20Sopenharmony_ci#define BMAC_TXDELIM 0x228UL /* Transmit delimiter */ 1008c2ecf20Sopenharmony_ci#define BMAC_JSIZE 0x22cUL /* Toe jam... */ 1018c2ecf20Sopenharmony_ci#define BMAC_TXPMAX 0x230UL /* Transmit max pkt size */ 1028c2ecf20Sopenharmony_ci#define BMAC_TXPMIN 0x234UL /* Transmit min pkt size */ 1038c2ecf20Sopenharmony_ci#define BMAC_PATTEMPT 0x238UL /* Count of transmit peak attempts */ 1048c2ecf20Sopenharmony_ci#define BMAC_DTCTR 0x23cUL /* Transmit defer timer */ 1058c2ecf20Sopenharmony_ci#define BMAC_NCCTR 0x240UL /* Transmit normal-collision counter */ 1068c2ecf20Sopenharmony_ci#define BMAC_FCCTR 0x244UL /* Transmit first-collision counter */ 1078c2ecf20Sopenharmony_ci#define BMAC_EXCTR 0x248UL /* Transmit excess-collision counter */ 1088c2ecf20Sopenharmony_ci#define BMAC_LTCTR 0x24cUL /* Transmit late-collision counter */ 1098c2ecf20Sopenharmony_ci#define BMAC_RSEED 0x250UL /* Transmit random number seed */ 1108c2ecf20Sopenharmony_ci#define BMAC_TXSMACHINE 0x254UL /* Transmit state machine */ 1118c2ecf20Sopenharmony_ci /* 0x258-->0x304, reserved */ 1128c2ecf20Sopenharmony_ci#define BMAC_RXSWRESET 0x308UL /* Receiver software reset */ 1138c2ecf20Sopenharmony_ci#define BMAC_RXCFG 0x30cUL /* Receiver config register */ 1148c2ecf20Sopenharmony_ci#define BMAC_RXPMAX 0x310UL /* Receive max pkt size */ 1158c2ecf20Sopenharmony_ci#define BMAC_RXPMIN 0x314UL /* Receive min pkt size */ 1168c2ecf20Sopenharmony_ci#define BMAC_MACADDR2 0x318UL /* Ether address register 2 */ 1178c2ecf20Sopenharmony_ci#define BMAC_MACADDR1 0x31cUL /* Ether address register 1 */ 1188c2ecf20Sopenharmony_ci#define BMAC_MACADDR0 0x320UL /* Ether address register 0 */ 1198c2ecf20Sopenharmony_ci#define BMAC_FRCTR 0x324UL /* Receive frame receive counter */ 1208c2ecf20Sopenharmony_ci#define BMAC_GLECTR 0x328UL /* Receive giant-length error counter */ 1218c2ecf20Sopenharmony_ci#define BMAC_UNALECTR 0x32cUL /* Receive unaligned error counter */ 1228c2ecf20Sopenharmony_ci#define BMAC_RCRCECTR 0x330UL /* Receive CRC error counter */ 1238c2ecf20Sopenharmony_ci#define BMAC_RXSMACHINE 0x334UL /* Receiver state machine */ 1248c2ecf20Sopenharmony_ci#define BMAC_RXCVALID 0x338UL /* Receiver code violation */ 1258c2ecf20Sopenharmony_ci /* 0x33c, reserved */ 1268c2ecf20Sopenharmony_ci#define BMAC_HTABLE3 0x340UL /* Hash table 3 */ 1278c2ecf20Sopenharmony_ci#define BMAC_HTABLE2 0x344UL /* Hash table 2 */ 1288c2ecf20Sopenharmony_ci#define BMAC_HTABLE1 0x348UL /* Hash table 1 */ 1298c2ecf20Sopenharmony_ci#define BMAC_HTABLE0 0x34cUL /* Hash table 0 */ 1308c2ecf20Sopenharmony_ci#define BMAC_AFILTER2 0x350UL /* Address filter 2 */ 1318c2ecf20Sopenharmony_ci#define BMAC_AFILTER1 0x354UL /* Address filter 1 */ 1328c2ecf20Sopenharmony_ci#define BMAC_AFILTER0 0x358UL /* Address filter 0 */ 1338c2ecf20Sopenharmony_ci#define BMAC_AFMASK 0x35cUL /* Address filter mask */ 1348c2ecf20Sopenharmony_ci#define BMAC_REG_SIZE 0x360UL 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* BigMac XIF config register. */ 1378c2ecf20Sopenharmony_ci#define BIGMAC_XCFG_ODENABLE 0x00000001 /* Output driver enable */ 1388c2ecf20Sopenharmony_ci#define BIGMAC_XCFG_RESV 0x00000002 /* Reserved, write always as 1 */ 1398c2ecf20Sopenharmony_ci#define BIGMAC_XCFG_MLBACK 0x00000004 /* Loopback-mode MII enable */ 1408c2ecf20Sopenharmony_ci#define BIGMAC_XCFG_SMODE 0x00000008 /* Enable serial mode */ 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* BigMAC status register. */ 1438c2ecf20Sopenharmony_ci#define BIGMAC_STAT_GOTFRAME 0x00000001 /* Received a frame */ 1448c2ecf20Sopenharmony_ci#define BIGMAC_STAT_RCNTEXP 0x00000002 /* Receive frame counter expired */ 1458c2ecf20Sopenharmony_ci#define BIGMAC_STAT_ACNTEXP 0x00000004 /* Align-error counter expired */ 1468c2ecf20Sopenharmony_ci#define BIGMAC_STAT_CCNTEXP 0x00000008 /* CRC-error counter expired */ 1478c2ecf20Sopenharmony_ci#define BIGMAC_STAT_LCNTEXP 0x00000010 /* Length-error counter expired */ 1488c2ecf20Sopenharmony_ci#define BIGMAC_STAT_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 1498c2ecf20Sopenharmony_ci#define BIGMAC_STAT_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 1508c2ecf20Sopenharmony_ci#define BIGMAC_STAT_SENTFRAME 0x00000100 /* Transmitted a frame */ 1518c2ecf20Sopenharmony_ci#define BIGMAC_STAT_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 1528c2ecf20Sopenharmony_ci#define BIGMAC_STAT_MAXPKTERR 0x00000400 /* Max-packet size error */ 1538c2ecf20Sopenharmony_ci#define BIGMAC_STAT_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 1548c2ecf20Sopenharmony_ci#define BIGMAC_STAT_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 1558c2ecf20Sopenharmony_ci#define BIGMAC_STAT_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 1568c2ecf20Sopenharmony_ci#define BIGMAC_STAT_FCNTEXP 0x00004000 /* First-collision counter expired */ 1578c2ecf20Sopenharmony_ci#define BIGMAC_STAT_DTIMEXP 0x00008000 /* Defer-timer expired */ 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* BigMAC interrupt mask register. */ 1608c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_GOTFRAME 0x00000001 /* Received a frame */ 1618c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_RCNTEXP 0x00000002 /* Receive frame counter expired */ 1628c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_ACNTEXP 0x00000004 /* Align-error counter expired */ 1638c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_CCNTEXP 0x00000008 /* CRC-error counter expired */ 1648c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_LCNTEXP 0x00000010 /* Length-error counter expired */ 1658c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 1668c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 1678c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_SENTFRAME 0x00000100 /* Transmitted a frame */ 1688c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 1698c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_MAXPKTERR 0x00000400 /* Max-packet size error */ 1708c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 1718c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 1728c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 1738c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_FCNTEXP 0x00004000 /* First-collision counter expired */ 1748c2ecf20Sopenharmony_ci#define BIGMAC_IMASK_DTIMEXP 0x00008000 /* Defer-timer expired */ 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* BigMac transmit config register. */ 1778c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_ENABLE 0x00000001 /* Enable the transmitter */ 1788c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_FIFO 0x00000010 /* Default tx fthresh... */ 1798c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_SMODE 0x00000020 /* Enable slow transmit mode */ 1808c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_CIGN 0x00000040 /* Ignore transmit collisions */ 1818c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_FCSOFF 0x00000080 /* Do not emit FCS */ 1828c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_DBACKOFF 0x00000100 /* Disable backoff */ 1838c2ecf20Sopenharmony_ci#define BIGMAC_TXCFG_FULLDPLX 0x00000200 /* Enable full-duplex */ 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* BigMac receive config register. */ 1868c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_ENABLE 0x00000001 /* Enable the receiver */ 1878c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_FIFO 0x0000000e /* Default rx fthresh... */ 1888c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_PSTRIP 0x00000020 /* Pad byte strip enable */ 1898c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_PMISC 0x00000040 /* Enable promiscuous mode */ 1908c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_DERR 0x00000080 /* Disable error checking */ 1918c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_DCRCS 0x00000100 /* Disable CRC stripping */ 1928c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_ME 0x00000200 /* Receive packets addressed to me */ 1938c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_PGRP 0x00000400 /* Enable promisc group mode */ 1948c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_HENABLE 0x00000800 /* Enable the hash filter */ 1958c2ecf20Sopenharmony_ci#define BIGMAC_RXCFG_AENABLE 0x00001000 /* Enable the address filter */ 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* The BigMAC PHY transceiver. Not nearly as sophisticated as the happy meal 1988c2ecf20Sopenharmony_ci * one. But it does have the "bit banger", oh baby. 1998c2ecf20Sopenharmony_ci */ 2008c2ecf20Sopenharmony_ci#define TCVR_TPAL 0x00UL 2018c2ecf20Sopenharmony_ci#define TCVR_MPAL 0x04UL 2028c2ecf20Sopenharmony_ci#define TCVR_REG_SIZE 0x08UL 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci/* Frame commands. */ 2058c2ecf20Sopenharmony_ci#define FRAME_WRITE 0x50020000 2068c2ecf20Sopenharmony_ci#define FRAME_READ 0x60020000 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/* Tranceiver registers. */ 2098c2ecf20Sopenharmony_ci#define TCVR_PAL_SERIAL 0x00000001 /* Enable serial mode */ 2108c2ecf20Sopenharmony_ci#define TCVR_PAL_EXTLBACK 0x00000002 /* Enable external loopback */ 2118c2ecf20Sopenharmony_ci#define TCVR_PAL_MSENSE 0x00000004 /* Media sense */ 2128c2ecf20Sopenharmony_ci#define TCVR_PAL_LTENABLE 0x00000008 /* Link test enable */ 2138c2ecf20Sopenharmony_ci#define TCVR_PAL_LTSTATUS 0x00000010 /* Link test status (P1 only) */ 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/* Management PAL. */ 2168c2ecf20Sopenharmony_ci#define MGMT_PAL_DCLOCK 0x00000001 /* Data clock */ 2178c2ecf20Sopenharmony_ci#define MGMT_PAL_OENAB 0x00000002 /* Output enabler */ 2188c2ecf20Sopenharmony_ci#define MGMT_PAL_MDIO 0x00000004 /* MDIO Data/attached */ 2198c2ecf20Sopenharmony_ci#define MGMT_PAL_TIMEO 0x00000008 /* Transmit enable timeout error */ 2208c2ecf20Sopenharmony_ci#define MGMT_PAL_EXT_MDIO MGMT_PAL_MDIO 2218c2ecf20Sopenharmony_ci#define MGMT_PAL_INT_MDIO MGMT_PAL_TIMEO 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/* Here are some PHY addresses. */ 2248c2ecf20Sopenharmony_ci#define BIGMAC_PHY_EXTERNAL 0 /* External transceiver */ 2258c2ecf20Sopenharmony_ci#define BIGMAC_PHY_INTERNAL 1 /* Internal transceiver */ 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci/* Ring descriptors and such, same as Quad Ethernet. */ 2288c2ecf20Sopenharmony_cistruct be_rxd { 2298c2ecf20Sopenharmony_ci u32 rx_flags; 2308c2ecf20Sopenharmony_ci u32 rx_addr; 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#define RXD_OWN 0x80000000 /* Ownership. */ 2348c2ecf20Sopenharmony_ci#define RXD_UPDATE 0x10000000 /* Being Updated? */ 2358c2ecf20Sopenharmony_ci#define RXD_LENGTH 0x000007ff /* Packet Length. */ 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_cistruct be_txd { 2388c2ecf20Sopenharmony_ci u32 tx_flags; 2398c2ecf20Sopenharmony_ci u32 tx_addr; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci#define TXD_OWN 0x80000000 /* Ownership. */ 2438c2ecf20Sopenharmony_ci#define TXD_SOP 0x40000000 /* Start Of Packet */ 2448c2ecf20Sopenharmony_ci#define TXD_EOP 0x20000000 /* End Of Packet */ 2458c2ecf20Sopenharmony_ci#define TXD_UPDATE 0x10000000 /* Being Updated? */ 2468c2ecf20Sopenharmony_ci#define TXD_LENGTH 0x000007ff /* Packet Length. */ 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci#define TX_RING_MAXSIZE 256 2498c2ecf20Sopenharmony_ci#define RX_RING_MAXSIZE 256 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci#define TX_RING_SIZE 256 2528c2ecf20Sopenharmony_ci#define RX_RING_SIZE 256 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci#define NEXT_RX(num) (((num) + 1) & (RX_RING_SIZE - 1)) 2558c2ecf20Sopenharmony_ci#define NEXT_TX(num) (((num) + 1) & (TX_RING_SIZE - 1)) 2568c2ecf20Sopenharmony_ci#define PREV_RX(num) (((num) - 1) & (RX_RING_SIZE - 1)) 2578c2ecf20Sopenharmony_ci#define PREV_TX(num) (((num) - 1) & (TX_RING_SIZE - 1)) 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci#define TX_BUFFS_AVAIL(bp) \ 2608c2ecf20Sopenharmony_ci (((bp)->tx_old <= (bp)->tx_new) ? \ 2618c2ecf20Sopenharmony_ci (bp)->tx_old + (TX_RING_SIZE - 1) - (bp)->tx_new : \ 2628c2ecf20Sopenharmony_ci (bp)->tx_old - (bp)->tx_new - 1) 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define RX_COPY_THRESHOLD 256 2668c2ecf20Sopenharmony_ci#define RX_BUF_ALLOC_SIZE (ETH_FRAME_LEN + (64 * 3)) 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistruct bmac_init_block { 2698c2ecf20Sopenharmony_ci struct be_rxd be_rxd[RX_RING_MAXSIZE]; 2708c2ecf20Sopenharmony_ci struct be_txd be_txd[TX_RING_MAXSIZE]; 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define bib_offset(mem, elem) \ 2748c2ecf20Sopenharmony_ci((__u32)((unsigned long)(&(((struct bmac_init_block *)0)->mem[elem])))) 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci/* Now software state stuff. */ 2778c2ecf20Sopenharmony_cienum bigmac_transceiver { 2788c2ecf20Sopenharmony_ci external = 0, 2798c2ecf20Sopenharmony_ci internal = 1, 2808c2ecf20Sopenharmony_ci none = 2, 2818c2ecf20Sopenharmony_ci}; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci/* Timer state engine. */ 2848c2ecf20Sopenharmony_cienum bigmac_timer_state { 2858c2ecf20Sopenharmony_ci ltrywait = 1, /* Forcing try of all modes, from fastest to slowest. */ 2868c2ecf20Sopenharmony_ci asleep = 2, /* Timer inactive. */ 2878c2ecf20Sopenharmony_ci}; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_cistruct bigmac { 2908c2ecf20Sopenharmony_ci void __iomem *gregs; /* QEC Global Registers */ 2918c2ecf20Sopenharmony_ci void __iomem *creg; /* QEC BigMAC Channel Registers */ 2928c2ecf20Sopenharmony_ci void __iomem *bregs; /* BigMAC Registers */ 2938c2ecf20Sopenharmony_ci void __iomem *tregs; /* BigMAC Transceiver */ 2948c2ecf20Sopenharmony_ci struct bmac_init_block *bmac_block; /* RX and TX descriptors */ 2958c2ecf20Sopenharmony_ci dma_addr_t bblock_dvma; /* RX and TX descriptors */ 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci spinlock_t lock; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci struct sk_buff *rx_skbs[RX_RING_SIZE]; 3008c2ecf20Sopenharmony_ci struct sk_buff *tx_skbs[TX_RING_SIZE]; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci int rx_new, tx_new, rx_old, tx_old; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci int board_rev; /* BigMAC board revision. */ 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci enum bigmac_transceiver tcvr_type; 3078c2ecf20Sopenharmony_ci unsigned int bigmac_bursts; 3088c2ecf20Sopenharmony_ci unsigned int paddr; 3098c2ecf20Sopenharmony_ci unsigned short sw_bmsr; /* SW copy of PHY BMSR */ 3108c2ecf20Sopenharmony_ci unsigned short sw_bmcr; /* SW copy of PHY BMCR */ 3118c2ecf20Sopenharmony_ci struct timer_list bigmac_timer; 3128c2ecf20Sopenharmony_ci enum bigmac_timer_state timer_state; 3138c2ecf20Sopenharmony_ci unsigned int timer_ticks; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci struct platform_device *qec_op; 3168c2ecf20Sopenharmony_ci struct platform_device *bigmac_op; 3178c2ecf20Sopenharmony_ci struct net_device *dev; 3188c2ecf20Sopenharmony_ci}; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/* We use this to acquire receive skb's that we can DMA directly into. */ 3218c2ecf20Sopenharmony_ci#define ALIGNED_RX_SKB_ADDR(addr) \ 3228c2ecf20Sopenharmony_ci ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr)) 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_cistatic inline struct sk_buff *big_mac_alloc_skb(unsigned int length, gfp_t gfp_flags) 3258c2ecf20Sopenharmony_ci{ 3268c2ecf20Sopenharmony_ci struct sk_buff *skb; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci skb = alloc_skb(length + 64, gfp_flags); 3298c2ecf20Sopenharmony_ci if(skb) { 3308c2ecf20Sopenharmony_ci int offset = ALIGNED_RX_SKB_ADDR(skb->data); 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci if(offset) 3338c2ecf20Sopenharmony_ci skb_reserve(skb, offset); 3348c2ecf20Sopenharmony_ci } 3358c2ecf20Sopenharmony_ci return skb; 3368c2ecf20Sopenharmony_ci} 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci#endif /* !(_SUNBMAC_H) */ 339