18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* $Id: sungem.h,v 1.10.2.4 2002/03/11 08:54:48 davem Exp $ 38c2ecf20Sopenharmony_ci * sungem.h: Definitions for Sun GEM ethernet driver. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2000 David S. Miller (davem@redhat.com) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SUNGEM_H 98c2ecf20Sopenharmony_ci#define _SUNGEM_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* Global Registers */ 128c2ecf20Sopenharmony_ci#define GREG_SEBSTATE 0x0000UL /* SEB State Register */ 138c2ecf20Sopenharmony_ci#define GREG_CFG 0x0004UL /* Configuration Register */ 148c2ecf20Sopenharmony_ci#define GREG_STAT 0x000CUL /* Status Register */ 158c2ecf20Sopenharmony_ci#define GREG_IMASK 0x0010UL /* Interrupt Mask Register */ 168c2ecf20Sopenharmony_ci#define GREG_IACK 0x0014UL /* Interrupt ACK Register */ 178c2ecf20Sopenharmony_ci#define GREG_STAT2 0x001CUL /* Alias of GREG_STAT */ 188c2ecf20Sopenharmony_ci#define GREG_PCIESTAT 0x1000UL /* PCI Error Status Register */ 198c2ecf20Sopenharmony_ci#define GREG_PCIEMASK 0x1004UL /* PCI Error Mask Register */ 208c2ecf20Sopenharmony_ci#define GREG_BIFCFG 0x1008UL /* BIF Configuration Register */ 218c2ecf20Sopenharmony_ci#define GREG_BIFDIAG 0x100CUL /* BIF Diagnostics Register */ 228c2ecf20Sopenharmony_ci#define GREG_SWRST 0x1010UL /* Software Reset Register */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* Global SEB State Register */ 258c2ecf20Sopenharmony_ci#define GREG_SEBSTATE_ARB 0x00000003 /* State of Arbiter */ 268c2ecf20Sopenharmony_ci#define GREG_SEBSTATE_RXWON 0x00000004 /* RX won internal arbitration */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Global Configuration Register */ 298c2ecf20Sopenharmony_ci#define GREG_CFG_IBURST 0x00000001 /* Infinite Burst */ 308c2ecf20Sopenharmony_ci#define GREG_CFG_TXDMALIM 0x0000003e /* TX DMA grant limit */ 318c2ecf20Sopenharmony_ci#define GREG_CFG_RXDMALIM 0x000007c0 /* RX DMA grant limit */ 328c2ecf20Sopenharmony_ci#define GREG_CFG_RONPAULBIT 0x00000800 /* Use mem read multiple for PCI read 338c2ecf20Sopenharmony_ci * after infinite burst (Apple) */ 348c2ecf20Sopenharmony_ci#define GREG_CFG_ENBUG2FIX 0x00001000 /* Fix Rx hang after overflow */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Global Interrupt Status Register. 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * Reading this register automatically clears bits 0 through 6. 398c2ecf20Sopenharmony_ci * This auto-clearing does not occur when the alias at GREG_STAT2 408c2ecf20Sopenharmony_ci * is read instead. The rest of the interrupt bits only clear when 418c2ecf20Sopenharmony_ci * the secondary interrupt status register corresponding to that 428c2ecf20Sopenharmony_ci * bit is read (ie. if GREG_STAT_PCS is set, it will be cleared by 438c2ecf20Sopenharmony_ci * reading PCS_ISTAT). 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci#define GREG_STAT_TXINTME 0x00000001 /* TX INTME frame transferred */ 468c2ecf20Sopenharmony_ci#define GREG_STAT_TXALL 0x00000002 /* All TX frames transferred */ 478c2ecf20Sopenharmony_ci#define GREG_STAT_TXDONE 0x00000004 /* One TX frame transferred */ 488c2ecf20Sopenharmony_ci#define GREG_STAT_RXDONE 0x00000010 /* One RX frame arrived */ 498c2ecf20Sopenharmony_ci#define GREG_STAT_RXNOBUF 0x00000020 /* No free RX buffers available */ 508c2ecf20Sopenharmony_ci#define GREG_STAT_RXTAGERR 0x00000040 /* RX tag framing is corrupt */ 518c2ecf20Sopenharmony_ci#define GREG_STAT_PCS 0x00002000 /* PCS signalled interrupt */ 528c2ecf20Sopenharmony_ci#define GREG_STAT_TXMAC 0x00004000 /* TX MAC signalled interrupt */ 538c2ecf20Sopenharmony_ci#define GREG_STAT_RXMAC 0x00008000 /* RX MAC signalled interrupt */ 548c2ecf20Sopenharmony_ci#define GREG_STAT_MAC 0x00010000 /* MAC Control signalled irq */ 558c2ecf20Sopenharmony_ci#define GREG_STAT_MIF 0x00020000 /* MIF signalled interrupt */ 568c2ecf20Sopenharmony_ci#define GREG_STAT_PCIERR 0x00040000 /* PCI Error interrupt */ 578c2ecf20Sopenharmony_ci#define GREG_STAT_TXNR 0xfff80000 /* == TXDMA_TXDONE reg val */ 588c2ecf20Sopenharmony_ci#define GREG_STAT_TXNR_SHIFT 19 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define GREG_STAT_ABNORMAL (GREG_STAT_RXNOBUF | GREG_STAT_RXTAGERR | \ 618c2ecf20Sopenharmony_ci GREG_STAT_PCS | GREG_STAT_TXMAC | GREG_STAT_RXMAC | \ 628c2ecf20Sopenharmony_ci GREG_STAT_MAC | GREG_STAT_MIF | GREG_STAT_PCIERR) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define GREG_STAT_NAPI (GREG_STAT_TXALL | GREG_STAT_TXINTME | \ 658c2ecf20Sopenharmony_ci GREG_STAT_RXDONE | GREG_STAT_ABNORMAL) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* The layout of GREG_IMASK and GREG_IACK is identical to GREG_STAT. 688c2ecf20Sopenharmony_ci * Bits set in GREG_IMASK will prevent that interrupt type from being 698c2ecf20Sopenharmony_ci * signalled to the cpu. GREG_IACK can be used to clear specific top-level 708c2ecf20Sopenharmony_ci * interrupt conditions in GREG_STAT, ie. it only works for bits 0 through 6. 718c2ecf20Sopenharmony_ci * Setting the bit will clear that interrupt, clear bits will have no effect 728c2ecf20Sopenharmony_ci * on GREG_STAT. 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* Global PCI Error Status Register */ 768c2ecf20Sopenharmony_ci#define GREG_PCIESTAT_BADACK 0x00000001 /* No ACK64# during ABS64 cycle */ 778c2ecf20Sopenharmony_ci#define GREG_PCIESTAT_DTRTO 0x00000002 /* Delayed transaction timeout */ 788c2ecf20Sopenharmony_ci#define GREG_PCIESTAT_OTHER 0x00000004 /* Other PCI error, check cfg space */ 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* The layout of the GREG_PCIEMASK is identical to that of GREG_PCIESTAT. 818c2ecf20Sopenharmony_ci * Bits set in GREG_PCIEMASK will prevent that interrupt type from being 828c2ecf20Sopenharmony_ci * signalled to the cpu. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* Global BIF Configuration Register */ 868c2ecf20Sopenharmony_ci#define GREG_BIFCFG_SLOWCLK 0x00000001 /* Set if PCI runs < 25Mhz */ 878c2ecf20Sopenharmony_ci#define GREG_BIFCFG_B64DIS 0x00000002 /* Disable 64bit wide data cycle*/ 888c2ecf20Sopenharmony_ci#define GREG_BIFCFG_M66EN 0x00000004 /* Set if on 66Mhz PCI segment */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* Global BIF Diagnostics Register */ 918c2ecf20Sopenharmony_ci#define GREG_BIFDIAG_BURSTSM 0x007f0000 /* PCI Burst state machine */ 928c2ecf20Sopenharmony_ci#define GREG_BIFDIAG_BIFSM 0xff000000 /* BIF state machine */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* Global Software Reset Register. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * This register is used to perform a global reset of the RX and TX portions 978c2ecf20Sopenharmony_ci * of the GEM asic. Setting the RX or TX reset bit will start the reset. 988c2ecf20Sopenharmony_ci * The driver _MUST_ poll these bits until they clear. One may not attempt 998c2ecf20Sopenharmony_ci * to program any other part of GEM until the bits clear. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci#define GREG_SWRST_TXRST 0x00000001 /* TX Software Reset */ 1028c2ecf20Sopenharmony_ci#define GREG_SWRST_RXRST 0x00000002 /* RX Software Reset */ 1038c2ecf20Sopenharmony_ci#define GREG_SWRST_RSTOUT 0x00000004 /* Force RST# pin active */ 1048c2ecf20Sopenharmony_ci#define GREG_SWRST_CACHESIZE 0x00ff0000 /* RIO only: cache line size */ 1058c2ecf20Sopenharmony_ci#define GREG_SWRST_CACHE_SHIFT 16 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* TX DMA Registers */ 1088c2ecf20Sopenharmony_ci#define TXDMA_KICK 0x2000UL /* TX Kick Register */ 1098c2ecf20Sopenharmony_ci#define TXDMA_CFG 0x2004UL /* TX Configuration Register */ 1108c2ecf20Sopenharmony_ci#define TXDMA_DBLOW 0x2008UL /* TX Desc. Base Low */ 1118c2ecf20Sopenharmony_ci#define TXDMA_DBHI 0x200CUL /* TX Desc. Base High */ 1128c2ecf20Sopenharmony_ci#define TXDMA_FWPTR 0x2014UL /* TX FIFO Write Pointer */ 1138c2ecf20Sopenharmony_ci#define TXDMA_FSWPTR 0x2018UL /* TX FIFO Shadow Write Pointer */ 1148c2ecf20Sopenharmony_ci#define TXDMA_FRPTR 0x201CUL /* TX FIFO Read Pointer */ 1158c2ecf20Sopenharmony_ci#define TXDMA_FSRPTR 0x2020UL /* TX FIFO Shadow Read Pointer */ 1168c2ecf20Sopenharmony_ci#define TXDMA_PCNT 0x2024UL /* TX FIFO Packet Counter */ 1178c2ecf20Sopenharmony_ci#define TXDMA_SMACHINE 0x2028UL /* TX State Machine Register */ 1188c2ecf20Sopenharmony_ci#define TXDMA_DPLOW 0x2030UL /* TX Data Pointer Low */ 1198c2ecf20Sopenharmony_ci#define TXDMA_DPHI 0x2034UL /* TX Data Pointer High */ 1208c2ecf20Sopenharmony_ci#define TXDMA_TXDONE 0x2100UL /* TX Completion Register */ 1218c2ecf20Sopenharmony_ci#define TXDMA_FADDR 0x2104UL /* TX FIFO Address */ 1228c2ecf20Sopenharmony_ci#define TXDMA_FTAG 0x2108UL /* TX FIFO Tag */ 1238c2ecf20Sopenharmony_ci#define TXDMA_DLOW 0x210CUL /* TX FIFO Data Low */ 1248c2ecf20Sopenharmony_ci#define TXDMA_DHIT1 0x2110UL /* TX FIFO Data HighT1 */ 1258c2ecf20Sopenharmony_ci#define TXDMA_DHIT0 0x2114UL /* TX FIFO Data HighT0 */ 1268c2ecf20Sopenharmony_ci#define TXDMA_FSZ 0x2118UL /* TX FIFO Size */ 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* TX Kick Register. 1298c2ecf20Sopenharmony_ci * 1308c2ecf20Sopenharmony_ci * This 13-bit register is programmed by the driver to hold the descriptor 1318c2ecf20Sopenharmony_ci * entry index which follows the last valid transmit descriptor. 1328c2ecf20Sopenharmony_ci */ 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* TX Completion Register. 1358c2ecf20Sopenharmony_ci * 1368c2ecf20Sopenharmony_ci * This 13-bit register is updated by GEM to hold to descriptor entry index 1378c2ecf20Sopenharmony_ci * which follows the last descriptor already processed by GEM. Note that 1388c2ecf20Sopenharmony_ci * this value is mirrored in GREG_STAT which eliminates the need to even 1398c2ecf20Sopenharmony_ci * access this register in the driver during interrupt processing. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* TX Configuration Register. 1438c2ecf20Sopenharmony_ci * 1448c2ecf20Sopenharmony_ci * Note that TXDMA_CFG_FTHRESH, the TX FIFO Threshold, is an obsolete feature 1458c2ecf20Sopenharmony_ci * that was meant to be used with jumbo packets. It should be set to the 1468c2ecf20Sopenharmony_ci * maximum value of 0x4ff, else one risks getting TX MAC Underrun errors. 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci#define TXDMA_CFG_ENABLE 0x00000001 /* Enable TX DMA channel */ 1498c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ 0x0000001e /* TX descriptor ring size */ 1508c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_32 0x00000000 /* 32 TX descriptors */ 1518c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_64 0x00000002 /* 64 TX descriptors */ 1528c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_128 0x00000004 /* 128 TX descriptors */ 1538c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_256 0x00000006 /* 256 TX descriptors */ 1548c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_512 0x00000008 /* 512 TX descriptors */ 1558c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_1K 0x0000000a /* 1024 TX descriptors */ 1568c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_2K 0x0000000c /* 2048 TX descriptors */ 1578c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_4K 0x0000000e /* 4096 TX descriptors */ 1588c2ecf20Sopenharmony_ci#define TXDMA_CFG_RINGSZ_8K 0x00000010 /* 8192 TX descriptors */ 1598c2ecf20Sopenharmony_ci#define TXDMA_CFG_PIOSEL 0x00000020 /* Enable TX FIFO PIO from cpu */ 1608c2ecf20Sopenharmony_ci#define TXDMA_CFG_FTHRESH 0x001ffc00 /* TX FIFO Threshold, obsolete */ 1618c2ecf20Sopenharmony_ci#define TXDMA_CFG_PMODE 0x00200000 /* TXALL irq means TX FIFO empty*/ 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* TX Descriptor Base Low/High. 1648c2ecf20Sopenharmony_ci * 1658c2ecf20Sopenharmony_ci * These two registers store the 53 most significant bits of the base address 1668c2ecf20Sopenharmony_ci * of the TX descriptor table. The 11 least significant bits are always 1678c2ecf20Sopenharmony_ci * zero. As a result, the TX descriptor table must be 2K aligned. 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* The rest of the TXDMA_* registers are for diagnostics and debug, I will document 1718c2ecf20Sopenharmony_ci * them later. -DaveM 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* WakeOnLan Registers */ 1758c2ecf20Sopenharmony_ci#define WOL_MATCH0 0x3000UL 1768c2ecf20Sopenharmony_ci#define WOL_MATCH1 0x3004UL 1778c2ecf20Sopenharmony_ci#define WOL_MATCH2 0x3008UL 1788c2ecf20Sopenharmony_ci#define WOL_MCOUNT 0x300CUL 1798c2ecf20Sopenharmony_ci#define WOL_WAKECSR 0x3010UL 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci/* WOL Match count register 1828c2ecf20Sopenharmony_ci */ 1838c2ecf20Sopenharmony_ci#define WOL_MCOUNT_N 0x00000010 1848c2ecf20Sopenharmony_ci#define WOL_MCOUNT_M 0x00000000 /* 0 << 8 */ 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#define WOL_WAKECSR_ENABLE 0x00000001 1878c2ecf20Sopenharmony_ci#define WOL_WAKECSR_MII 0x00000002 1888c2ecf20Sopenharmony_ci#define WOL_WAKECSR_SEEN 0x00000004 1898c2ecf20Sopenharmony_ci#define WOL_WAKECSR_FILT_UCAST 0x00000008 1908c2ecf20Sopenharmony_ci#define WOL_WAKECSR_FILT_MCAST 0x00000010 1918c2ecf20Sopenharmony_ci#define WOL_WAKECSR_FILT_BCAST 0x00000020 1928c2ecf20Sopenharmony_ci#define WOL_WAKECSR_FILT_SEEN 0x00000040 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* Receive DMA Registers */ 1968c2ecf20Sopenharmony_ci#define RXDMA_CFG 0x4000UL /* RX Configuration Register */ 1978c2ecf20Sopenharmony_ci#define RXDMA_DBLOW 0x4004UL /* RX Descriptor Base Low */ 1988c2ecf20Sopenharmony_ci#define RXDMA_DBHI 0x4008UL /* RX Descriptor Base High */ 1998c2ecf20Sopenharmony_ci#define RXDMA_FWPTR 0x400CUL /* RX FIFO Write Pointer */ 2008c2ecf20Sopenharmony_ci#define RXDMA_FSWPTR 0x4010UL /* RX FIFO Shadow Write Pointer */ 2018c2ecf20Sopenharmony_ci#define RXDMA_FRPTR 0x4014UL /* RX FIFO Read Pointer */ 2028c2ecf20Sopenharmony_ci#define RXDMA_PCNT 0x4018UL /* RX FIFO Packet Counter */ 2038c2ecf20Sopenharmony_ci#define RXDMA_SMACHINE 0x401CUL /* RX State Machine Register */ 2048c2ecf20Sopenharmony_ci#define RXDMA_PTHRESH 0x4020UL /* Pause Thresholds */ 2058c2ecf20Sopenharmony_ci#define RXDMA_DPLOW 0x4024UL /* RX Data Pointer Low */ 2068c2ecf20Sopenharmony_ci#define RXDMA_DPHI 0x4028UL /* RX Data Pointer High */ 2078c2ecf20Sopenharmony_ci#define RXDMA_KICK 0x4100UL /* RX Kick Register */ 2088c2ecf20Sopenharmony_ci#define RXDMA_DONE 0x4104UL /* RX Completion Register */ 2098c2ecf20Sopenharmony_ci#define RXDMA_BLANK 0x4108UL /* RX Blanking Register */ 2108c2ecf20Sopenharmony_ci#define RXDMA_FADDR 0x410CUL /* RX FIFO Address */ 2118c2ecf20Sopenharmony_ci#define RXDMA_FTAG 0x4110UL /* RX FIFO Tag */ 2128c2ecf20Sopenharmony_ci#define RXDMA_DLOW 0x4114UL /* RX FIFO Data Low */ 2138c2ecf20Sopenharmony_ci#define RXDMA_DHIT1 0x4118UL /* RX FIFO Data HighT0 */ 2148c2ecf20Sopenharmony_ci#define RXDMA_DHIT0 0x411CUL /* RX FIFO Data HighT1 */ 2158c2ecf20Sopenharmony_ci#define RXDMA_FSZ 0x4120UL /* RX FIFO Size */ 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* RX Configuration Register. */ 2188c2ecf20Sopenharmony_ci#define RXDMA_CFG_ENABLE 0x00000001 /* Enable RX DMA channel */ 2198c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ 0x0000001e /* RX descriptor ring size */ 2208c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_32 0x00000000 /* - 32 entries */ 2218c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_64 0x00000002 /* - 64 entries */ 2228c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_128 0x00000004 /* - 128 entries */ 2238c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_256 0x00000006 /* - 256 entries */ 2248c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_512 0x00000008 /* - 512 entries */ 2258c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_1K 0x0000000a /* - 1024 entries */ 2268c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_2K 0x0000000c /* - 2048 entries */ 2278c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_4K 0x0000000e /* - 4096 entries */ 2288c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_8K 0x00000010 /* - 8192 entries */ 2298c2ecf20Sopenharmony_ci#define RXDMA_CFG_RINGSZ_BDISAB 0x00000020 /* Disable RX desc batching */ 2308c2ecf20Sopenharmony_ci#define RXDMA_CFG_FBOFF 0x00001c00 /* Offset of first data byte */ 2318c2ecf20Sopenharmony_ci#define RXDMA_CFG_CSUMOFF 0x000fe000 /* Skip bytes before csum calc */ 2328c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH 0x07000000 /* RX FIFO dma start threshold */ 2338c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_64 0x00000000 /* - 64 bytes */ 2348c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_128 0x01000000 /* - 128 bytes */ 2358c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_256 0x02000000 /* - 256 bytes */ 2368c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_512 0x03000000 /* - 512 bytes */ 2378c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_1K 0x04000000 /* - 1024 bytes */ 2388c2ecf20Sopenharmony_ci#define RXDMA_CFG_FTHRESH_2K 0x05000000 /* - 2048 bytes */ 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci/* RX Descriptor Base Low/High. 2418c2ecf20Sopenharmony_ci * 2428c2ecf20Sopenharmony_ci * These two registers store the 53 most significant bits of the base address 2438c2ecf20Sopenharmony_ci * of the RX descriptor table. The 11 least significant bits are always 2448c2ecf20Sopenharmony_ci * zero. As a result, the RX descriptor table must be 2K aligned. 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* RX PAUSE Thresholds. 2488c2ecf20Sopenharmony_ci * 2498c2ecf20Sopenharmony_ci * These values determine when XOFF and XON PAUSE frames are emitted by 2508c2ecf20Sopenharmony_ci * GEM. The thresholds measure RX FIFO occupancy in units of 64 bytes. 2518c2ecf20Sopenharmony_ci */ 2528c2ecf20Sopenharmony_ci#define RXDMA_PTHRESH_OFF 0x000001ff /* XOFF emitted w/FIFO > this */ 2538c2ecf20Sopenharmony_ci#define RXDMA_PTHRESH_ON 0x001ff000 /* XON emitted w/FIFO < this */ 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci/* RX Kick Register. 2568c2ecf20Sopenharmony_ci * 2578c2ecf20Sopenharmony_ci * This 13-bit register is written by the host CPU and holds the last 2588c2ecf20Sopenharmony_ci * valid RX descriptor number plus one. This is, if 'N' is written to 2598c2ecf20Sopenharmony_ci * this register, it means that all RX descriptors up to but excluding 2608c2ecf20Sopenharmony_ci * 'N' are valid. 2618c2ecf20Sopenharmony_ci * 2628c2ecf20Sopenharmony_ci * The hardware requires that RX descriptors are posted in increments 2638c2ecf20Sopenharmony_ci * of 4. This means 'N' must be a multiple of four. For the best 2648c2ecf20Sopenharmony_ci * performance, the first new descriptor being posted should be (PCI) 2658c2ecf20Sopenharmony_ci * cache line aligned. 2668c2ecf20Sopenharmony_ci */ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci/* RX Completion Register. 2698c2ecf20Sopenharmony_ci * 2708c2ecf20Sopenharmony_ci * This 13-bit register is updated by GEM to indicate which RX descriptors 2718c2ecf20Sopenharmony_ci * have already been used for receive frames. All descriptors up to but 2728c2ecf20Sopenharmony_ci * excluding the value in this register are ready to be processed. GEM 2738c2ecf20Sopenharmony_ci * updates this register value after the RX FIFO empties completely into 2748c2ecf20Sopenharmony_ci * the RX descriptor's buffer, but before the RX_DONE bit is set in the 2758c2ecf20Sopenharmony_ci * interrupt status register. 2768c2ecf20Sopenharmony_ci */ 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci/* RX Blanking Register. */ 2798c2ecf20Sopenharmony_ci#define RXDMA_BLANK_IPKTS 0x000001ff /* RX_DONE asserted after this 2808c2ecf20Sopenharmony_ci * many packets received since 2818c2ecf20Sopenharmony_ci * previous RX_DONE. 2828c2ecf20Sopenharmony_ci */ 2838c2ecf20Sopenharmony_ci#define RXDMA_BLANK_ITIME 0x000ff000 /* RX_DONE asserted after this 2848c2ecf20Sopenharmony_ci * many clocks (measured in 2048 2858c2ecf20Sopenharmony_ci * PCI clocks) were counted since 2868c2ecf20Sopenharmony_ci * the previous RX_DONE. 2878c2ecf20Sopenharmony_ci */ 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci/* RX FIFO Size. 2908c2ecf20Sopenharmony_ci * 2918c2ecf20Sopenharmony_ci * This 11-bit read-only register indicates how large, in units of 64-bytes, 2928c2ecf20Sopenharmony_ci * the RX FIFO is. The driver uses this to properly configure the RX PAUSE 2938c2ecf20Sopenharmony_ci * thresholds. 2948c2ecf20Sopenharmony_ci */ 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci/* The rest of the RXDMA_* registers are for diagnostics and debug, I will document 2978c2ecf20Sopenharmony_ci * them later. -DaveM 2988c2ecf20Sopenharmony_ci */ 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci/* MAC Registers */ 3018c2ecf20Sopenharmony_ci#define MAC_TXRST 0x6000UL /* TX MAC Software Reset Command*/ 3028c2ecf20Sopenharmony_ci#define MAC_RXRST 0x6004UL /* RX MAC Software Reset Command*/ 3038c2ecf20Sopenharmony_ci#define MAC_SNDPAUSE 0x6008UL /* Send Pause Command Register */ 3048c2ecf20Sopenharmony_ci#define MAC_TXSTAT 0x6010UL /* TX MAC Status Register */ 3058c2ecf20Sopenharmony_ci#define MAC_RXSTAT 0x6014UL /* RX MAC Status Register */ 3068c2ecf20Sopenharmony_ci#define MAC_CSTAT 0x6018UL /* MAC Control Status Register */ 3078c2ecf20Sopenharmony_ci#define MAC_TXMASK 0x6020UL /* TX MAC Mask Register */ 3088c2ecf20Sopenharmony_ci#define MAC_RXMASK 0x6024UL /* RX MAC Mask Register */ 3098c2ecf20Sopenharmony_ci#define MAC_MCMASK 0x6028UL /* MAC Control Mask Register */ 3108c2ecf20Sopenharmony_ci#define MAC_TXCFG 0x6030UL /* TX MAC Configuration Register*/ 3118c2ecf20Sopenharmony_ci#define MAC_RXCFG 0x6034UL /* RX MAC Configuration Register*/ 3128c2ecf20Sopenharmony_ci#define MAC_MCCFG 0x6038UL /* MAC Control Config Register */ 3138c2ecf20Sopenharmony_ci#define MAC_XIFCFG 0x603CUL /* XIF Configuration Register */ 3148c2ecf20Sopenharmony_ci#define MAC_IPG0 0x6040UL /* InterPacketGap0 Register */ 3158c2ecf20Sopenharmony_ci#define MAC_IPG1 0x6044UL /* InterPacketGap1 Register */ 3168c2ecf20Sopenharmony_ci#define MAC_IPG2 0x6048UL /* InterPacketGap2 Register */ 3178c2ecf20Sopenharmony_ci#define MAC_STIME 0x604CUL /* SlotTime Register */ 3188c2ecf20Sopenharmony_ci#define MAC_MINFSZ 0x6050UL /* MinFrameSize Register */ 3198c2ecf20Sopenharmony_ci#define MAC_MAXFSZ 0x6054UL /* MaxFrameSize Register */ 3208c2ecf20Sopenharmony_ci#define MAC_PASIZE 0x6058UL /* PA Size Register */ 3218c2ecf20Sopenharmony_ci#define MAC_JAMSIZE 0x605CUL /* JamSize Register */ 3228c2ecf20Sopenharmony_ci#define MAC_ATTLIM 0x6060UL /* Attempt Limit Register */ 3238c2ecf20Sopenharmony_ci#define MAC_MCTYPE 0x6064UL /* MAC Control Type Register */ 3248c2ecf20Sopenharmony_ci#define MAC_ADDR0 0x6080UL /* MAC Address 0 Register */ 3258c2ecf20Sopenharmony_ci#define MAC_ADDR1 0x6084UL /* MAC Address 1 Register */ 3268c2ecf20Sopenharmony_ci#define MAC_ADDR2 0x6088UL /* MAC Address 2 Register */ 3278c2ecf20Sopenharmony_ci#define MAC_ADDR3 0x608CUL /* MAC Address 3 Register */ 3288c2ecf20Sopenharmony_ci#define MAC_ADDR4 0x6090UL /* MAC Address 4 Register */ 3298c2ecf20Sopenharmony_ci#define MAC_ADDR5 0x6094UL /* MAC Address 5 Register */ 3308c2ecf20Sopenharmony_ci#define MAC_ADDR6 0x6098UL /* MAC Address 6 Register */ 3318c2ecf20Sopenharmony_ci#define MAC_ADDR7 0x609CUL /* MAC Address 7 Register */ 3328c2ecf20Sopenharmony_ci#define MAC_ADDR8 0x60A0UL /* MAC Address 8 Register */ 3338c2ecf20Sopenharmony_ci#define MAC_AFILT0 0x60A4UL /* Address Filter 0 Register */ 3348c2ecf20Sopenharmony_ci#define MAC_AFILT1 0x60A8UL /* Address Filter 1 Register */ 3358c2ecf20Sopenharmony_ci#define MAC_AFILT2 0x60ACUL /* Address Filter 2 Register */ 3368c2ecf20Sopenharmony_ci#define MAC_AF21MSK 0x60B0UL /* Address Filter 2&1 Mask Reg */ 3378c2ecf20Sopenharmony_ci#define MAC_AF0MSK 0x60B4UL /* Address Filter 0 Mask Reg */ 3388c2ecf20Sopenharmony_ci#define MAC_HASH0 0x60C0UL /* Hash Table 0 Register */ 3398c2ecf20Sopenharmony_ci#define MAC_HASH1 0x60C4UL /* Hash Table 1 Register */ 3408c2ecf20Sopenharmony_ci#define MAC_HASH2 0x60C8UL /* Hash Table 2 Register */ 3418c2ecf20Sopenharmony_ci#define MAC_HASH3 0x60CCUL /* Hash Table 3 Register */ 3428c2ecf20Sopenharmony_ci#define MAC_HASH4 0x60D0UL /* Hash Table 4 Register */ 3438c2ecf20Sopenharmony_ci#define MAC_HASH5 0x60D4UL /* Hash Table 5 Register */ 3448c2ecf20Sopenharmony_ci#define MAC_HASH6 0x60D8UL /* Hash Table 6 Register */ 3458c2ecf20Sopenharmony_ci#define MAC_HASH7 0x60DCUL /* Hash Table 7 Register */ 3468c2ecf20Sopenharmony_ci#define MAC_HASH8 0x60E0UL /* Hash Table 8 Register */ 3478c2ecf20Sopenharmony_ci#define MAC_HASH9 0x60E4UL /* Hash Table 9 Register */ 3488c2ecf20Sopenharmony_ci#define MAC_HASH10 0x60E8UL /* Hash Table 10 Register */ 3498c2ecf20Sopenharmony_ci#define MAC_HASH11 0x60ECUL /* Hash Table 11 Register */ 3508c2ecf20Sopenharmony_ci#define MAC_HASH12 0x60F0UL /* Hash Table 12 Register */ 3518c2ecf20Sopenharmony_ci#define MAC_HASH13 0x60F4UL /* Hash Table 13 Register */ 3528c2ecf20Sopenharmony_ci#define MAC_HASH14 0x60F8UL /* Hash Table 14 Register */ 3538c2ecf20Sopenharmony_ci#define MAC_HASH15 0x60FCUL /* Hash Table 15 Register */ 3548c2ecf20Sopenharmony_ci#define MAC_NCOLL 0x6100UL /* Normal Collision Counter */ 3558c2ecf20Sopenharmony_ci#define MAC_FASUCC 0x6104UL /* First Attmpt. Succ Coll Ctr. */ 3568c2ecf20Sopenharmony_ci#define MAC_ECOLL 0x6108UL /* Excessive Collision Counter */ 3578c2ecf20Sopenharmony_ci#define MAC_LCOLL 0x610CUL /* Late Collision Counter */ 3588c2ecf20Sopenharmony_ci#define MAC_DTIMER 0x6110UL /* Defer Timer */ 3598c2ecf20Sopenharmony_ci#define MAC_PATMPS 0x6114UL /* Peak Attempts Register */ 3608c2ecf20Sopenharmony_ci#define MAC_RFCTR 0x6118UL /* Receive Frame Counter */ 3618c2ecf20Sopenharmony_ci#define MAC_LERR 0x611CUL /* Length Error Counter */ 3628c2ecf20Sopenharmony_ci#define MAC_AERR 0x6120UL /* Alignment Error Counter */ 3638c2ecf20Sopenharmony_ci#define MAC_FCSERR 0x6124UL /* FCS Error Counter */ 3648c2ecf20Sopenharmony_ci#define MAC_RXCVERR 0x6128UL /* RX code Violation Error Ctr */ 3658c2ecf20Sopenharmony_ci#define MAC_RANDSEED 0x6130UL /* Random Number Seed Register */ 3668c2ecf20Sopenharmony_ci#define MAC_SMACHINE 0x6134UL /* State Machine Register */ 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci/* TX MAC Software Reset Command. */ 3698c2ecf20Sopenharmony_ci#define MAC_TXRST_CMD 0x00000001 /* Start sw reset, self-clears */ 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* RX MAC Software Reset Command. */ 3728c2ecf20Sopenharmony_ci#define MAC_RXRST_CMD 0x00000001 /* Start sw reset, self-clears */ 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* Send Pause Command. */ 3758c2ecf20Sopenharmony_ci#define MAC_SNDPAUSE_TS 0x0000ffff /* The pause_time operand used in 3768c2ecf20Sopenharmony_ci * Send_Pause and flow-control 3778c2ecf20Sopenharmony_ci * handshakes. 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci#define MAC_SNDPAUSE_SP 0x00010000 /* Setting this bit instructs the MAC 3808c2ecf20Sopenharmony_ci * to send a Pause Flow Control 3818c2ecf20Sopenharmony_ci * frame onto the network. 3828c2ecf20Sopenharmony_ci */ 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/* TX MAC Status Register. */ 3858c2ecf20Sopenharmony_ci#define MAC_TXSTAT_XMIT 0x00000001 /* Frame Transmitted */ 3868c2ecf20Sopenharmony_ci#define MAC_TXSTAT_URUN 0x00000002 /* TX Underrun */ 3878c2ecf20Sopenharmony_ci#define MAC_TXSTAT_MPE 0x00000004 /* Max Packet Size Error */ 3888c2ecf20Sopenharmony_ci#define MAC_TXSTAT_NCE 0x00000008 /* Normal Collision Cntr Expire */ 3898c2ecf20Sopenharmony_ci#define MAC_TXSTAT_ECE 0x00000010 /* Excess Collision Cntr Expire */ 3908c2ecf20Sopenharmony_ci#define MAC_TXSTAT_LCE 0x00000020 /* Late Collision Cntr Expire */ 3918c2ecf20Sopenharmony_ci#define MAC_TXSTAT_FCE 0x00000040 /* First Collision Cntr Expire */ 3928c2ecf20Sopenharmony_ci#define MAC_TXSTAT_DTE 0x00000080 /* Defer Timer Expire */ 3938c2ecf20Sopenharmony_ci#define MAC_TXSTAT_PCE 0x00000100 /* Peak Attempts Cntr Expire */ 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci/* RX MAC Status Register. */ 3968c2ecf20Sopenharmony_ci#define MAC_RXSTAT_RCV 0x00000001 /* Frame Received */ 3978c2ecf20Sopenharmony_ci#define MAC_RXSTAT_OFLW 0x00000002 /* Receive Overflow */ 3988c2ecf20Sopenharmony_ci#define MAC_RXSTAT_FCE 0x00000004 /* Frame Cntr Expire */ 3998c2ecf20Sopenharmony_ci#define MAC_RXSTAT_ACE 0x00000008 /* Align Error Cntr Expire */ 4008c2ecf20Sopenharmony_ci#define MAC_RXSTAT_CCE 0x00000010 /* CRC Error Cntr Expire */ 4018c2ecf20Sopenharmony_ci#define MAC_RXSTAT_LCE 0x00000020 /* Length Error Cntr Expire */ 4028c2ecf20Sopenharmony_ci#define MAC_RXSTAT_VCE 0x00000040 /* Code Violation Cntr Expire */ 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci/* MAC Control Status Register. */ 4058c2ecf20Sopenharmony_ci#define MAC_CSTAT_PRCV 0x00000001 /* Pause Received */ 4068c2ecf20Sopenharmony_ci#define MAC_CSTAT_PS 0x00000002 /* Paused State */ 4078c2ecf20Sopenharmony_ci#define MAC_CSTAT_NPS 0x00000004 /* Not Paused State */ 4088c2ecf20Sopenharmony_ci#define MAC_CSTAT_PTR 0xffff0000 /* Pause Time Received */ 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci/* The layout of the MAC_{TX,RX,C}MASK registers is identical to that 4118c2ecf20Sopenharmony_ci * of MAC_{TX,RX,C}STAT. Bits set in MAC_{TX,RX,C}MASK will prevent 4128c2ecf20Sopenharmony_ci * that interrupt type from being signalled to front end of GEM. For 4138c2ecf20Sopenharmony_ci * the interrupt to actually get sent to the cpu, it is necessary to 4148c2ecf20Sopenharmony_ci * properly set the appropriate GREG_IMASK_{TX,RX,}MAC bits as well. 4158c2ecf20Sopenharmony_ci */ 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci/* TX MAC Configuration Register. 4188c2ecf20Sopenharmony_ci * 4198c2ecf20Sopenharmony_ci * NOTE: The TX MAC Enable bit must be cleared and polled until 4208c2ecf20Sopenharmony_ci * zero before any other bits in this register are changed. 4218c2ecf20Sopenharmony_ci * 4228c2ecf20Sopenharmony_ci * Also, enabling the Carrier Extension feature of GEM is 4238c2ecf20Sopenharmony_ci * a 3 step process 1) Set TX Carrier Extension 2) Set 4248c2ecf20Sopenharmony_ci * RX Carrier Extension 3) Set Slot Time to 0x200. This 4258c2ecf20Sopenharmony_ci * mode must be enabled when in half-duplex at 1Gbps, else 4268c2ecf20Sopenharmony_ci * it must be disabled. 4278c2ecf20Sopenharmony_ci */ 4288c2ecf20Sopenharmony_ci#define MAC_TXCFG_ENAB 0x00000001 /* TX MAC Enable */ 4298c2ecf20Sopenharmony_ci#define MAC_TXCFG_ICS 0x00000002 /* Ignore Carrier Sense */ 4308c2ecf20Sopenharmony_ci#define MAC_TXCFG_ICOLL 0x00000004 /* Ignore Collisions */ 4318c2ecf20Sopenharmony_ci#define MAC_TXCFG_EIPG0 0x00000008 /* Enable IPG0 */ 4328c2ecf20Sopenharmony_ci#define MAC_TXCFG_NGU 0x00000010 /* Never Give Up */ 4338c2ecf20Sopenharmony_ci#define MAC_TXCFG_NGUL 0x00000020 /* Never Give Up Limit */ 4348c2ecf20Sopenharmony_ci#define MAC_TXCFG_NBO 0x00000040 /* No Backoff */ 4358c2ecf20Sopenharmony_ci#define MAC_TXCFG_SD 0x00000080 /* Slow Down */ 4368c2ecf20Sopenharmony_ci#define MAC_TXCFG_NFCS 0x00000100 /* No FCS */ 4378c2ecf20Sopenharmony_ci#define MAC_TXCFG_TCE 0x00000200 /* TX Carrier Extension */ 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci/* RX MAC Configuration Register. 4408c2ecf20Sopenharmony_ci * 4418c2ecf20Sopenharmony_ci * NOTE: The RX MAC Enable bit must be cleared and polled until 4428c2ecf20Sopenharmony_ci * zero before any other bits in this register are changed. 4438c2ecf20Sopenharmony_ci * 4448c2ecf20Sopenharmony_ci * Similar rules apply to the Hash Filter Enable bit when 4458c2ecf20Sopenharmony_ci * programming the hash table registers, and the Address Filter 4468c2ecf20Sopenharmony_ci * Enable bit when programming the address filter registers. 4478c2ecf20Sopenharmony_ci */ 4488c2ecf20Sopenharmony_ci#define MAC_RXCFG_ENAB 0x00000001 /* RX MAC Enable */ 4498c2ecf20Sopenharmony_ci#define MAC_RXCFG_SPAD 0x00000002 /* Strip Pad */ 4508c2ecf20Sopenharmony_ci#define MAC_RXCFG_SFCS 0x00000004 /* Strip FCS */ 4518c2ecf20Sopenharmony_ci#define MAC_RXCFG_PROM 0x00000008 /* Promiscuous Mode */ 4528c2ecf20Sopenharmony_ci#define MAC_RXCFG_PGRP 0x00000010 /* Promiscuous Group */ 4538c2ecf20Sopenharmony_ci#define MAC_RXCFG_HFE 0x00000020 /* Hash Filter Enable */ 4548c2ecf20Sopenharmony_ci#define MAC_RXCFG_AFE 0x00000040 /* Address Filter Enable */ 4558c2ecf20Sopenharmony_ci#define MAC_RXCFG_DDE 0x00000080 /* Disable Discard on Error */ 4568c2ecf20Sopenharmony_ci#define MAC_RXCFG_RCE 0x00000100 /* RX Carrier Extension */ 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci/* MAC Control Config Register. */ 4598c2ecf20Sopenharmony_ci#define MAC_MCCFG_SPE 0x00000001 /* Send Pause Enable */ 4608c2ecf20Sopenharmony_ci#define MAC_MCCFG_RPE 0x00000002 /* Receive Pause Enable */ 4618c2ecf20Sopenharmony_ci#define MAC_MCCFG_PMC 0x00000004 /* Pass MAC Control */ 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci/* XIF Configuration Register. 4648c2ecf20Sopenharmony_ci * 4658c2ecf20Sopenharmony_ci * NOTE: When leaving or entering loopback mode, a global hardware 4668c2ecf20Sopenharmony_ci * init of GEM should be performed. 4678c2ecf20Sopenharmony_ci */ 4688c2ecf20Sopenharmony_ci#define MAC_XIFCFG_OE 0x00000001 /* MII TX Output Driver Enable */ 4698c2ecf20Sopenharmony_ci#define MAC_XIFCFG_LBCK 0x00000002 /* Loopback TX to RX */ 4708c2ecf20Sopenharmony_ci#define MAC_XIFCFG_DISE 0x00000004 /* Disable RX path during TX */ 4718c2ecf20Sopenharmony_ci#define MAC_XIFCFG_GMII 0x00000008 /* Use GMII clocks + datapath */ 4728c2ecf20Sopenharmony_ci#define MAC_XIFCFG_MBOE 0x00000010 /* Controls MII_BUF_EN pin */ 4738c2ecf20Sopenharmony_ci#define MAC_XIFCFG_LLED 0x00000020 /* Force LINKLED# active (low) */ 4748c2ecf20Sopenharmony_ci#define MAC_XIFCFG_FLED 0x00000040 /* Force FDPLXLED# active (low) */ 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci/* InterPacketGap0 Register. This 8-bit value is used as an extension 4778c2ecf20Sopenharmony_ci * to the InterPacketGap1 Register. Specifically it contributes to the 4788c2ecf20Sopenharmony_ci * timing of the RX-to-TX IPG. This value is ignored and presumed to 4798c2ecf20Sopenharmony_ci * be zero for TX-to-TX IPG calculations and/or when the Enable IPG0 bit 4808c2ecf20Sopenharmony_ci * is cleared in the TX MAC Configuration Register. 4818c2ecf20Sopenharmony_ci * 4828c2ecf20Sopenharmony_ci * This value in this register in terms of media byte time. 4838c2ecf20Sopenharmony_ci * 4848c2ecf20Sopenharmony_ci * Recommended value: 0x00 4858c2ecf20Sopenharmony_ci */ 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci/* InterPacketGap1 Register. This 8-bit value defines the first 2/3 4888c2ecf20Sopenharmony_ci * portion of the Inter Packet Gap. 4898c2ecf20Sopenharmony_ci * 4908c2ecf20Sopenharmony_ci * This value in this register in terms of media byte time. 4918c2ecf20Sopenharmony_ci * 4928c2ecf20Sopenharmony_ci * Recommended value: 0x08 4938c2ecf20Sopenharmony_ci */ 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci/* InterPacketGap2 Register. This 8-bit value defines the second 1/3 4968c2ecf20Sopenharmony_ci * portion of the Inter Packet Gap. 4978c2ecf20Sopenharmony_ci * 4988c2ecf20Sopenharmony_ci * This value in this register in terms of media byte time. 4998c2ecf20Sopenharmony_ci * 5008c2ecf20Sopenharmony_ci * Recommended value: 0x04 5018c2ecf20Sopenharmony_ci */ 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci/* Slot Time Register. This 10-bit value specifies the slot time 5048c2ecf20Sopenharmony_ci * parameter in units of media byte time. It determines the physical 5058c2ecf20Sopenharmony_ci * span of the network. 5068c2ecf20Sopenharmony_ci * 5078c2ecf20Sopenharmony_ci * Recommended value: 0x40 5088c2ecf20Sopenharmony_ci */ 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci/* Minimum Frame Size Register. This 10-bit register specifies the 5118c2ecf20Sopenharmony_ci * smallest sized frame the TXMAC will send onto the medium, and the 5128c2ecf20Sopenharmony_ci * RXMAC will receive from the medium. 5138c2ecf20Sopenharmony_ci * 5148c2ecf20Sopenharmony_ci * Recommended value: 0x40 5158c2ecf20Sopenharmony_ci */ 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci/* Maximum Frame and Burst Size Register. 5188c2ecf20Sopenharmony_ci * 5198c2ecf20Sopenharmony_ci * This register specifies two things. First it specifies the maximum 5208c2ecf20Sopenharmony_ci * sized frame the TXMAC will send and the RXMAC will recognize as 5218c2ecf20Sopenharmony_ci * valid. Second, it specifies the maximum run length of a burst of 5228c2ecf20Sopenharmony_ci * packets sent in half-duplex gigabit modes. 5238c2ecf20Sopenharmony_ci * 5248c2ecf20Sopenharmony_ci * Recommended value: 0x200005ee 5258c2ecf20Sopenharmony_ci */ 5268c2ecf20Sopenharmony_ci#define MAC_MAXFSZ_MFS 0x00007fff /* Max Frame Size */ 5278c2ecf20Sopenharmony_ci#define MAC_MAXFSZ_MBS 0x7fff0000 /* Max Burst Size */ 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci/* PA Size Register. This 10-bit register specifies the number of preamble 5308c2ecf20Sopenharmony_ci * bytes which will be transmitted at the beginning of each frame. A 5318c2ecf20Sopenharmony_ci * value of two or greater should be programmed here. 5328c2ecf20Sopenharmony_ci * 5338c2ecf20Sopenharmony_ci * Recommended value: 0x07 5348c2ecf20Sopenharmony_ci */ 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci/* Jam Size Register. This 4-bit register specifies the duration of 5378c2ecf20Sopenharmony_ci * the jam in units of media byte time. 5388c2ecf20Sopenharmony_ci * 5398c2ecf20Sopenharmony_ci * Recommended value: 0x04 5408c2ecf20Sopenharmony_ci */ 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_ci/* Attempts Limit Register. This 8-bit register specifies the number 5438c2ecf20Sopenharmony_ci * of attempts that the TXMAC will make to transmit a frame, before it 5448c2ecf20Sopenharmony_ci * resets its Attempts Counter. After reaching the Attempts Limit the 5458c2ecf20Sopenharmony_ci * TXMAC may or may not drop the frame, as determined by the NGU 5468c2ecf20Sopenharmony_ci * (Never Give Up) and NGUL (Never Give Up Limit) bits in the TXMAC 5478c2ecf20Sopenharmony_ci * Configuration Register. 5488c2ecf20Sopenharmony_ci * 5498c2ecf20Sopenharmony_ci * Recommended value: 0x10 5508c2ecf20Sopenharmony_ci */ 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci/* MAX Control Type Register. This 16-bit register specifies the 5538c2ecf20Sopenharmony_ci * "type" field of a MAC Control frame. The TXMAC uses this field to 5548c2ecf20Sopenharmony_ci * encapsulate the MAC Control frame for transmission, and the RXMAC 5558c2ecf20Sopenharmony_ci * uses it for decoding valid MAC Control frames received from the 5568c2ecf20Sopenharmony_ci * network. 5578c2ecf20Sopenharmony_ci * 5588c2ecf20Sopenharmony_ci * Recommended value: 0x8808 5598c2ecf20Sopenharmony_ci */ 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci/* MAC Address Registers. Each of these registers specify the 5628c2ecf20Sopenharmony_ci * ethernet MAC of the interface, 16-bits at a time. Register 5638c2ecf20Sopenharmony_ci * 0 specifies bits [47:32], register 1 bits [31:16], and register 5648c2ecf20Sopenharmony_ci * 2 bits [15:0]. 5658c2ecf20Sopenharmony_ci * 5668c2ecf20Sopenharmony_ci * Registers 3 through and including 5 specify an alternate 5678c2ecf20Sopenharmony_ci * MAC address for the interface. 5688c2ecf20Sopenharmony_ci * 5698c2ecf20Sopenharmony_ci * Registers 6 through and including 8 specify the MAC Control 5708c2ecf20Sopenharmony_ci * Address, which must be the reserved multicast address for MAC 5718c2ecf20Sopenharmony_ci * Control frames. 5728c2ecf20Sopenharmony_ci * 5738c2ecf20Sopenharmony_ci * Example: To program primary station address a:b:c:d:e:f into 5748c2ecf20Sopenharmony_ci * the chip. 5758c2ecf20Sopenharmony_ci * MAC_Address_2 = (a << 8) | b 5768c2ecf20Sopenharmony_ci * MAC_Address_1 = (c << 8) | d 5778c2ecf20Sopenharmony_ci * MAC_Address_0 = (e << 8) | f 5788c2ecf20Sopenharmony_ci */ 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci/* Address Filter Registers. Registers 0 through 2 specify bit 5818c2ecf20Sopenharmony_ci * fields [47:32] through [15:0], respectively, of the address 5828c2ecf20Sopenharmony_ci * filter. The Address Filter 2&1 Mask Register denotes the 8-bit 5838c2ecf20Sopenharmony_ci * nibble mask for Address Filter Registers 2 and 1. The Address 5848c2ecf20Sopenharmony_ci * Filter 0 Mask Register denotes the 16-bit mask for the Address 5858c2ecf20Sopenharmony_ci * Filter Register 0. 5868c2ecf20Sopenharmony_ci */ 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci/* Hash Table Registers. Registers 0 through 15 specify bit fields 5898c2ecf20Sopenharmony_ci * [255:240] through [15:0], respectively, of the hash table. 5908c2ecf20Sopenharmony_ci */ 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci/* Statistics Registers. All of these registers are 16-bits and 5938c2ecf20Sopenharmony_ci * track occurrences of a specific event. GEM can be configured 5948c2ecf20Sopenharmony_ci * to interrupt the host cpu when any of these counters overflow. 5958c2ecf20Sopenharmony_ci * They should all be explicitly initialized to zero when the interface 5968c2ecf20Sopenharmony_ci * is brought up. 5978c2ecf20Sopenharmony_ci */ 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci/* Random Number Seed Register. This 10-bit value is used as the 6008c2ecf20Sopenharmony_ci * RNG seed inside GEM for the CSMA/CD backoff algorithm. It is 6018c2ecf20Sopenharmony_ci * recommended to program this register to the 10 LSB of the 6028c2ecf20Sopenharmony_ci * interfaces MAC address. 6038c2ecf20Sopenharmony_ci */ 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci/* Pause Timer, read-only. This 16-bit timer is used to time the pause 6068c2ecf20Sopenharmony_ci * interval as indicated by a received pause flow control frame. 6078c2ecf20Sopenharmony_ci * A non-zero value in this timer indicates that the MAC is currently in 6088c2ecf20Sopenharmony_ci * the paused state. 6098c2ecf20Sopenharmony_ci */ 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci/* MIF Registers */ 6128c2ecf20Sopenharmony_ci#define MIF_BBCLK 0x6200UL /* MIF Bit-Bang Clock */ 6138c2ecf20Sopenharmony_ci#define MIF_BBDATA 0x6204UL /* MIF Bit-Band Data */ 6148c2ecf20Sopenharmony_ci#define MIF_BBOENAB 0x6208UL /* MIF Bit-Bang Output Enable */ 6158c2ecf20Sopenharmony_ci#define MIF_FRAME 0x620CUL /* MIF Frame/Output Register */ 6168c2ecf20Sopenharmony_ci#define MIF_CFG 0x6210UL /* MIF Configuration Register */ 6178c2ecf20Sopenharmony_ci#define MIF_MASK 0x6214UL /* MIF Mask Register */ 6188c2ecf20Sopenharmony_ci#define MIF_STATUS 0x6218UL /* MIF Status Register */ 6198c2ecf20Sopenharmony_ci#define MIF_SMACHINE 0x621CUL /* MIF State Machine Register */ 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci/* MIF Bit-Bang Clock. This 1-bit register is used to generate the 6228c2ecf20Sopenharmony_ci * MDC clock waveform on the MII Management Interface when the MIF is 6238c2ecf20Sopenharmony_ci * programmed in the "Bit-Bang" mode. Writing a '1' after a '0' into 6248c2ecf20Sopenharmony_ci * this register will create a rising edge on the MDC, while writing 6258c2ecf20Sopenharmony_ci * a '0' after a '1' will create a falling edge. For every bit that 6268c2ecf20Sopenharmony_ci * is transferred on the management interface, both edges have to be 6278c2ecf20Sopenharmony_ci * generated. 6288c2ecf20Sopenharmony_ci */ 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci/* MIF Bit-Bang Data. This 1-bit register is used to generate the 6318c2ecf20Sopenharmony_ci * outgoing data (MDO) on the MII Management Interface when the MIF 6328c2ecf20Sopenharmony_ci * is programmed in the "Bit-Bang" mode. The daa will be steered to the 6338c2ecf20Sopenharmony_ci * appropriate MDIO based on the state of the PHY_Select bit in the MIF 6348c2ecf20Sopenharmony_ci * Configuration Register. 6358c2ecf20Sopenharmony_ci */ 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci/* MIF Big-Band Output Enable. THis 1-bit register is used to enable 6388c2ecf20Sopenharmony_ci * ('1') or disable ('0') the I-directional driver on the MII when the 6398c2ecf20Sopenharmony_ci * MIF is programmed in the "Bit-Bang" mode. The MDIO should be enabled 6408c2ecf20Sopenharmony_ci * when data bits are transferred from the MIF to the transceiver, and it 6418c2ecf20Sopenharmony_ci * should be disabled when the interface is idle or when data bits are 6428c2ecf20Sopenharmony_ci * transferred from the transceiver to the MIF (data portion of a read 6438c2ecf20Sopenharmony_ci * instruction). Only one MDIO will be enabled at a given time, depending 6448c2ecf20Sopenharmony_ci * on the state of the PHY_Select bit in the MIF Configuration Register. 6458c2ecf20Sopenharmony_ci */ 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci/* MIF Configuration Register. This 15-bit register controls the operation 6488c2ecf20Sopenharmony_ci * of the MIF. 6498c2ecf20Sopenharmony_ci */ 6508c2ecf20Sopenharmony_ci#define MIF_CFG_PSELECT 0x00000001 /* Xcvr slct: 0=mdio0 1=mdio1 */ 6518c2ecf20Sopenharmony_ci#define MIF_CFG_POLL 0x00000002 /* Enable polling mechanism */ 6528c2ecf20Sopenharmony_ci#define MIF_CFG_BBMODE 0x00000004 /* 1=bit-bang 0=frame mode */ 6538c2ecf20Sopenharmony_ci#define MIF_CFG_PRADDR 0x000000f8 /* Xcvr poll register address */ 6548c2ecf20Sopenharmony_ci#define MIF_CFG_MDI0 0x00000100 /* MDIO_0 present or read-bit */ 6558c2ecf20Sopenharmony_ci#define MIF_CFG_MDI1 0x00000200 /* MDIO_1 present or read-bit */ 6568c2ecf20Sopenharmony_ci#define MIF_CFG_PPADDR 0x00007c00 /* Xcvr poll PHY address */ 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci/* MIF Frame/Output Register. This 32-bit register allows the host to 6598c2ecf20Sopenharmony_ci * communicate with a transceiver in frame mode (as opposed to big-bang 6608c2ecf20Sopenharmony_ci * mode). Writes by the host specify an instrution. After being issued 6618c2ecf20Sopenharmony_ci * the host must poll this register for completion. Also, after 6628c2ecf20Sopenharmony_ci * completion this register holds the data returned by the transceiver 6638c2ecf20Sopenharmony_ci * if applicable. 6648c2ecf20Sopenharmony_ci */ 6658c2ecf20Sopenharmony_ci#define MIF_FRAME_ST 0xc0000000 /* STart of frame */ 6668c2ecf20Sopenharmony_ci#define MIF_FRAME_OP 0x30000000 /* OPcode */ 6678c2ecf20Sopenharmony_ci#define MIF_FRAME_PHYAD 0x0f800000 /* PHY ADdress */ 6688c2ecf20Sopenharmony_ci#define MIF_FRAME_REGAD 0x007c0000 /* REGister ADdress */ 6698c2ecf20Sopenharmony_ci#define MIF_FRAME_TAMSB 0x00020000 /* Turn Around MSB */ 6708c2ecf20Sopenharmony_ci#define MIF_FRAME_TALSB 0x00010000 /* Turn Around LSB */ 6718c2ecf20Sopenharmony_ci#define MIF_FRAME_DATA 0x0000ffff /* Instruction Payload */ 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci/* MIF Status Register. This register reports status when the MIF is 6748c2ecf20Sopenharmony_ci * operating in the poll mode. The poll status field is auto-clearing 6758c2ecf20Sopenharmony_ci * on read. 6768c2ecf20Sopenharmony_ci */ 6778c2ecf20Sopenharmony_ci#define MIF_STATUS_DATA 0xffff0000 /* Live image of XCVR reg */ 6788c2ecf20Sopenharmony_ci#define MIF_STATUS_STAT 0x0000ffff /* Which bits have changed */ 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci/* MIF Mask Register. This 16-bit register is used when in poll mode 6818c2ecf20Sopenharmony_ci * to say which bits of the polled register will cause an interrupt 6828c2ecf20Sopenharmony_ci * when changed. 6838c2ecf20Sopenharmony_ci */ 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci/* PCS/Serialink Registers */ 6868c2ecf20Sopenharmony_ci#define PCS_MIICTRL 0x9000UL /* PCS MII Control Register */ 6878c2ecf20Sopenharmony_ci#define PCS_MIISTAT 0x9004UL /* PCS MII Status Register */ 6888c2ecf20Sopenharmony_ci#define PCS_MIIADV 0x9008UL /* PCS MII Advertisement Reg */ 6898c2ecf20Sopenharmony_ci#define PCS_MIILP 0x900CUL /* PCS MII Link Partner Ability */ 6908c2ecf20Sopenharmony_ci#define PCS_CFG 0x9010UL /* PCS Configuration Register */ 6918c2ecf20Sopenharmony_ci#define PCS_SMACHINE 0x9014UL /* PCS State Machine Register */ 6928c2ecf20Sopenharmony_ci#define PCS_ISTAT 0x9018UL /* PCS Interrupt Status Reg */ 6938c2ecf20Sopenharmony_ci#define PCS_DMODE 0x9050UL /* Datapath Mode Register */ 6948c2ecf20Sopenharmony_ci#define PCS_SCTRL 0x9054UL /* Serialink Control Register */ 6958c2ecf20Sopenharmony_ci#define PCS_SOS 0x9058UL /* Shared Output Select Reg */ 6968c2ecf20Sopenharmony_ci#define PCS_SSTATE 0x905CUL /* Serialink State Register */ 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci/* PCD MII Control Register. */ 6998c2ecf20Sopenharmony_ci#define PCS_MIICTRL_SPD 0x00000040 /* Read as one, writes ignored */ 7008c2ecf20Sopenharmony_ci#define PCS_MIICTRL_CT 0x00000080 /* Force COL signal active */ 7018c2ecf20Sopenharmony_ci#define PCS_MIICTRL_DM 0x00000100 /* Duplex mode, forced low */ 7028c2ecf20Sopenharmony_ci#define PCS_MIICTRL_RAN 0x00000200 /* Restart auto-neg, self clear */ 7038c2ecf20Sopenharmony_ci#define PCS_MIICTRL_ISO 0x00000400 /* Read as zero, writes ignored */ 7048c2ecf20Sopenharmony_ci#define PCS_MIICTRL_PD 0x00000800 /* Read as zero, writes ignored */ 7058c2ecf20Sopenharmony_ci#define PCS_MIICTRL_ANE 0x00001000 /* Auto-neg enable */ 7068c2ecf20Sopenharmony_ci#define PCS_MIICTRL_SS 0x00002000 /* Read as zero, writes ignored */ 7078c2ecf20Sopenharmony_ci#define PCS_MIICTRL_WB 0x00004000 /* Wrapback, loopback at 10-bit 7088c2ecf20Sopenharmony_ci * input side of Serialink 7098c2ecf20Sopenharmony_ci */ 7108c2ecf20Sopenharmony_ci#define PCS_MIICTRL_RST 0x00008000 /* Resets PCS, self clearing */ 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci/* PCS MII Status Register. */ 7138c2ecf20Sopenharmony_ci#define PCS_MIISTAT_EC 0x00000001 /* Ext Capability: Read as zero */ 7148c2ecf20Sopenharmony_ci#define PCS_MIISTAT_JD 0x00000002 /* Jabber Detect: Read as zero */ 7158c2ecf20Sopenharmony_ci#define PCS_MIISTAT_LS 0x00000004 /* Link Status: 1=up 0=down */ 7168c2ecf20Sopenharmony_ci#define PCS_MIISTAT_ANA 0x00000008 /* Auto-neg Ability, always 1 */ 7178c2ecf20Sopenharmony_ci#define PCS_MIISTAT_RF 0x00000010 /* Remote Fault */ 7188c2ecf20Sopenharmony_ci#define PCS_MIISTAT_ANC 0x00000020 /* Auto-neg complete */ 7198c2ecf20Sopenharmony_ci#define PCS_MIISTAT_ES 0x00000100 /* Extended Status, always 1 */ 7208c2ecf20Sopenharmony_ci 7218c2ecf20Sopenharmony_ci/* PCS MII Advertisement Register. */ 7228c2ecf20Sopenharmony_ci#define PCS_MIIADV_FD 0x00000020 /* Advertise Full Duplex */ 7238c2ecf20Sopenharmony_ci#define PCS_MIIADV_HD 0x00000040 /* Advertise Half Duplex */ 7248c2ecf20Sopenharmony_ci#define PCS_MIIADV_SP 0x00000080 /* Advertise Symmetric Pause */ 7258c2ecf20Sopenharmony_ci#define PCS_MIIADV_AP 0x00000100 /* Advertise Asymmetric Pause */ 7268c2ecf20Sopenharmony_ci#define PCS_MIIADV_RF 0x00003000 /* Remote Fault */ 7278c2ecf20Sopenharmony_ci#define PCS_MIIADV_ACK 0x00004000 /* Read-only */ 7288c2ecf20Sopenharmony_ci#define PCS_MIIADV_NP 0x00008000 /* Next-page, forced low */ 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci/* PCS MII Link Partner Ability Register. This register is equivalent 7318c2ecf20Sopenharmony_ci * to the Link Partnet Ability Register of the standard MII register set. 7328c2ecf20Sopenharmony_ci * It's layout corresponds to the PCS MII Advertisement Register. 7338c2ecf20Sopenharmony_ci */ 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_ci/* PCS Configuration Register. */ 7368c2ecf20Sopenharmony_ci#define PCS_CFG_ENABLE 0x00000001 /* Must be zero while changing 7378c2ecf20Sopenharmony_ci * PCS MII advertisement reg. 7388c2ecf20Sopenharmony_ci */ 7398c2ecf20Sopenharmony_ci#define PCS_CFG_SDO 0x00000002 /* Signal detect override */ 7408c2ecf20Sopenharmony_ci#define PCS_CFG_SDL 0x00000004 /* Signal detect active low */ 7418c2ecf20Sopenharmony_ci#define PCS_CFG_JS 0x00000018 /* Jitter-study: 7428c2ecf20Sopenharmony_ci * 0 = normal operation 7438c2ecf20Sopenharmony_ci * 1 = high-frequency test pattern 7448c2ecf20Sopenharmony_ci * 2 = low-frequency test pattern 7458c2ecf20Sopenharmony_ci * 3 = reserved 7468c2ecf20Sopenharmony_ci */ 7478c2ecf20Sopenharmony_ci#define PCS_CFG_TO 0x00000020 /* 10ms auto-neg timer override */ 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci/* PCS Interrupt Status Register. This register is self-clearing 7508c2ecf20Sopenharmony_ci * when read. 7518c2ecf20Sopenharmony_ci */ 7528c2ecf20Sopenharmony_ci#define PCS_ISTAT_LSC 0x00000004 /* Link Status Change */ 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci/* Datapath Mode Register. */ 7558c2ecf20Sopenharmony_ci#define PCS_DMODE_SM 0x00000001 /* 1 = use internal Serialink */ 7568c2ecf20Sopenharmony_ci#define PCS_DMODE_ESM 0x00000002 /* External SERDES mode */ 7578c2ecf20Sopenharmony_ci#define PCS_DMODE_MGM 0x00000004 /* MII/GMII mode */ 7588c2ecf20Sopenharmony_ci#define PCS_DMODE_GMOE 0x00000008 /* GMII Output Enable */ 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci/* Serialink Control Register. 7618c2ecf20Sopenharmony_ci * 7628c2ecf20Sopenharmony_ci * NOTE: When in SERDES mode, the loopback bit has inverse logic. 7638c2ecf20Sopenharmony_ci */ 7648c2ecf20Sopenharmony_ci#define PCS_SCTRL_LOOP 0x00000001 /* Loopback enable */ 7658c2ecf20Sopenharmony_ci#define PCS_SCTRL_ESCD 0x00000002 /* Enable sync char detection */ 7668c2ecf20Sopenharmony_ci#define PCS_SCTRL_LOCK 0x00000004 /* Lock to reference clock */ 7678c2ecf20Sopenharmony_ci#define PCS_SCTRL_EMP 0x00000018 /* Output driver emphasis */ 7688c2ecf20Sopenharmony_ci#define PCS_SCTRL_STEST 0x000001c0 /* Self test patterns */ 7698c2ecf20Sopenharmony_ci#define PCS_SCTRL_PDWN 0x00000200 /* Software power-down */ 7708c2ecf20Sopenharmony_ci#define PCS_SCTRL_RXZ 0x00000c00 /* PLL input to Serialink */ 7718c2ecf20Sopenharmony_ci#define PCS_SCTRL_RXP 0x00003000 /* PLL input to Serialink */ 7728c2ecf20Sopenharmony_ci#define PCS_SCTRL_TXZ 0x0000c000 /* PLL input to Serialink */ 7738c2ecf20Sopenharmony_ci#define PCS_SCTRL_TXP 0x00030000 /* PLL input to Serialink */ 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_ci/* Shared Output Select Register. For test and debug, allows multiplexing 7768c2ecf20Sopenharmony_ci * test outputs into the PROM address pins. Set to zero for normal 7778c2ecf20Sopenharmony_ci * operation. 7788c2ecf20Sopenharmony_ci */ 7798c2ecf20Sopenharmony_ci#define PCS_SOS_PADDR 0x00000003 /* PROM Address */ 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_ci/* PROM Image Space */ 7828c2ecf20Sopenharmony_ci#define PROM_START 0x100000UL /* Expansion ROM run time access*/ 7838c2ecf20Sopenharmony_ci#define PROM_SIZE 0x0fffffUL /* Size of ROM */ 7848c2ecf20Sopenharmony_ci#define PROM_END 0x200000UL /* End of ROM */ 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_ci/* MII definitions missing from mii.h */ 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci#define BMCR_SPD2 0x0040 /* Gigabit enable? (bcm5411) */ 7898c2ecf20Sopenharmony_ci#define LPA_PAUSE 0x0400 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci/* More PHY registers (specific to Broadcom models) */ 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci/* MII BCM5201 MULTIPHY interrupt register */ 7948c2ecf20Sopenharmony_ci#define MII_BCM5201_INTERRUPT 0x1A 7958c2ecf20Sopenharmony_ci#define MII_BCM5201_INTERRUPT_INTENABLE 0x4000 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci#define MII_BCM5201_AUXMODE2 0x1B 7988c2ecf20Sopenharmony_ci#define MII_BCM5201_AUXMODE2_LOWPOWER 0x0008 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci#define MII_BCM5201_MULTIPHY 0x1E 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci/* MII BCM5201 MULTIPHY register bits */ 8038c2ecf20Sopenharmony_ci#define MII_BCM5201_MULTIPHY_SERIALMODE 0x0002 8048c2ecf20Sopenharmony_ci#define MII_BCM5201_MULTIPHY_SUPERISOLATE 0x0008 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci/* MII BCM5400 1000-BASET Control register */ 8078c2ecf20Sopenharmony_ci#define MII_BCM5400_GB_CONTROL 0x09 8088c2ecf20Sopenharmony_ci#define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci/* MII BCM5400 AUXCONTROL register */ 8118c2ecf20Sopenharmony_ci#define MII_BCM5400_AUXCONTROL 0x18 8128c2ecf20Sopenharmony_ci#define MII_BCM5400_AUXCONTROL_PWR10BASET 0x0004 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci/* MII BCM5400 AUXSTATUS register */ 8158c2ecf20Sopenharmony_ci#define MII_BCM5400_AUXSTATUS 0x19 8168c2ecf20Sopenharmony_ci#define MII_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700 8178c2ecf20Sopenharmony_ci#define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci/* When it can, GEM internally caches 4 aligned TX descriptors 8208c2ecf20Sopenharmony_ci * at a time, so that it can use full cacheline DMA reads. 8218c2ecf20Sopenharmony_ci * 8228c2ecf20Sopenharmony_ci * Note that unlike HME, there is no ownership bit in the descriptor 8238c2ecf20Sopenharmony_ci * control word. The same functionality is obtained via the TX-Kick 8248c2ecf20Sopenharmony_ci * and TX-Complete registers. As a result, GEM need not write back 8258c2ecf20Sopenharmony_ci * updated values to the TX descriptor ring, it only performs reads. 8268c2ecf20Sopenharmony_ci * 8278c2ecf20Sopenharmony_ci * Since TX descriptors are never modified by GEM, the driver can 8288c2ecf20Sopenharmony_ci * use the buffer DMA address as a place to keep track of allocated 8298c2ecf20Sopenharmony_ci * DMA mappings for a transmitted packet. 8308c2ecf20Sopenharmony_ci */ 8318c2ecf20Sopenharmony_cistruct gem_txd { 8328c2ecf20Sopenharmony_ci __le64 control_word; 8338c2ecf20Sopenharmony_ci __le64 buffer; 8348c2ecf20Sopenharmony_ci}; 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci#define TXDCTRL_BUFSZ 0x0000000000007fffULL /* Buffer Size */ 8378c2ecf20Sopenharmony_ci#define TXDCTRL_CSTART 0x00000000001f8000ULL /* CSUM Start Offset */ 8388c2ecf20Sopenharmony_ci#define TXDCTRL_COFF 0x000000001fe00000ULL /* CSUM Stuff Offset */ 8398c2ecf20Sopenharmony_ci#define TXDCTRL_CENAB 0x0000000020000000ULL /* CSUM Enable */ 8408c2ecf20Sopenharmony_ci#define TXDCTRL_EOF 0x0000000040000000ULL /* End of Frame */ 8418c2ecf20Sopenharmony_ci#define TXDCTRL_SOF 0x0000000080000000ULL /* Start of Frame */ 8428c2ecf20Sopenharmony_ci#define TXDCTRL_INTME 0x0000000100000000ULL /* "Interrupt Me" */ 8438c2ecf20Sopenharmony_ci#define TXDCTRL_NOCRC 0x0000000200000000ULL /* No CRC Present */ 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci/* GEM requires that RX descriptors are provided four at a time, 8468c2ecf20Sopenharmony_ci * aligned. Also, the RX ring may not wrap around. This means that 8478c2ecf20Sopenharmony_ci * there will be at least 4 unused descriptor entries in the middle 8488c2ecf20Sopenharmony_ci * of the RX ring at all times. 8498c2ecf20Sopenharmony_ci * 8508c2ecf20Sopenharmony_ci * Similar to HME, GEM assumes that it can write garbage bytes before 8518c2ecf20Sopenharmony_ci * the beginning of the buffer and right after the end in order to DMA 8528c2ecf20Sopenharmony_ci * whole cachelines. 8538c2ecf20Sopenharmony_ci * 8548c2ecf20Sopenharmony_ci * Unlike for TX, GEM does update the status word in the RX descriptors 8558c2ecf20Sopenharmony_ci * when packets arrive. Therefore an ownership bit does exist in the 8568c2ecf20Sopenharmony_ci * RX descriptors. It is advisory, GEM clears it but does not check 8578c2ecf20Sopenharmony_ci * it in any way. So when buffers are posted to the RX ring (via the 8588c2ecf20Sopenharmony_ci * RX Kick register) by the driver it must make sure the buffers are 8598c2ecf20Sopenharmony_ci * truly ready and that the ownership bits are set properly. 8608c2ecf20Sopenharmony_ci * 8618c2ecf20Sopenharmony_ci * Even though GEM modifies the RX descriptors, it guarantees that the 8628c2ecf20Sopenharmony_ci * buffer DMA address field will stay the same when it performs these 8638c2ecf20Sopenharmony_ci * updates. Therefore it can be used to keep track of DMA mappings 8648c2ecf20Sopenharmony_ci * by the host driver just as in the TX descriptor case above. 8658c2ecf20Sopenharmony_ci */ 8668c2ecf20Sopenharmony_cistruct gem_rxd { 8678c2ecf20Sopenharmony_ci __le64 status_word; 8688c2ecf20Sopenharmony_ci __le64 buffer; 8698c2ecf20Sopenharmony_ci}; 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci#define RXDCTRL_TCPCSUM 0x000000000000ffffULL /* TCP Pseudo-CSUM */ 8728c2ecf20Sopenharmony_ci#define RXDCTRL_BUFSZ 0x000000007fff0000ULL /* Buffer Size */ 8738c2ecf20Sopenharmony_ci#define RXDCTRL_OWN 0x0000000080000000ULL /* GEM owns this entry */ 8748c2ecf20Sopenharmony_ci#define RXDCTRL_HASHVAL 0x0ffff00000000000ULL /* Hash Value */ 8758c2ecf20Sopenharmony_ci#define RXDCTRL_HPASS 0x1000000000000000ULL /* Passed Hash Filter */ 8768c2ecf20Sopenharmony_ci#define RXDCTRL_ALTMAC 0x2000000000000000ULL /* Matched ALT MAC */ 8778c2ecf20Sopenharmony_ci#define RXDCTRL_BAD 0x4000000000000000ULL /* Frame has bad CRC */ 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_ci#define RXDCTRL_FRESH(gp) \ 8808c2ecf20Sopenharmony_ci ((((RX_BUF_ALLOC_SIZE(gp) - RX_OFFSET) << 16) & RXDCTRL_BUFSZ) | \ 8818c2ecf20Sopenharmony_ci RXDCTRL_OWN) 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci#define TX_RING_SIZE 128 8848c2ecf20Sopenharmony_ci#define RX_RING_SIZE 128 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_ci#if TX_RING_SIZE == 32 8878c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_32 8888c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 64 8898c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_64 8908c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 128 8918c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_128 8928c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 256 8938c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_256 8948c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 512 8958c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_512 8968c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 1024 8978c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_1K 8988c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 2048 8998c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_2K 9008c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 4096 9018c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_4K 9028c2ecf20Sopenharmony_ci#elif TX_RING_SIZE == 8192 9038c2ecf20Sopenharmony_ci#define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_8K 9048c2ecf20Sopenharmony_ci#else 9058c2ecf20Sopenharmony_ci#error TX_RING_SIZE value is illegal... 9068c2ecf20Sopenharmony_ci#endif 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci#if RX_RING_SIZE == 32 9098c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_32 9108c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 64 9118c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_64 9128c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 128 9138c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_128 9148c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 256 9158c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_256 9168c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 512 9178c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_512 9188c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 1024 9198c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_1K 9208c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 2048 9218c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_2K 9228c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 4096 9238c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_4K 9248c2ecf20Sopenharmony_ci#elif RX_RING_SIZE == 8192 9258c2ecf20Sopenharmony_ci#define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_8K 9268c2ecf20Sopenharmony_ci#else 9278c2ecf20Sopenharmony_ci#error RX_RING_SIZE is illegal... 9288c2ecf20Sopenharmony_ci#endif 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_ci#define NEXT_TX(N) (((N) + 1) & (TX_RING_SIZE - 1)) 9318c2ecf20Sopenharmony_ci#define NEXT_RX(N) (((N) + 1) & (RX_RING_SIZE - 1)) 9328c2ecf20Sopenharmony_ci 9338c2ecf20Sopenharmony_ci#define TX_BUFFS_AVAIL(GP) \ 9348c2ecf20Sopenharmony_ci (((GP)->tx_old <= (GP)->tx_new) ? \ 9358c2ecf20Sopenharmony_ci (GP)->tx_old + (TX_RING_SIZE - 1) - (GP)->tx_new : \ 9368c2ecf20Sopenharmony_ci (GP)->tx_old - (GP)->tx_new - 1) 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci#define RX_OFFSET 2 9398c2ecf20Sopenharmony_ci#define RX_BUF_ALLOC_SIZE(gp) ((gp)->rx_buf_sz + 28 + RX_OFFSET + 64) 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci#define RX_COPY_THRESHOLD 256 9428c2ecf20Sopenharmony_ci 9438c2ecf20Sopenharmony_ci#if TX_RING_SIZE < 128 9448c2ecf20Sopenharmony_ci#define INIT_BLOCK_TX_RING_SIZE 128 9458c2ecf20Sopenharmony_ci#else 9468c2ecf20Sopenharmony_ci#define INIT_BLOCK_TX_RING_SIZE TX_RING_SIZE 9478c2ecf20Sopenharmony_ci#endif 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_ci#if RX_RING_SIZE < 128 9508c2ecf20Sopenharmony_ci#define INIT_BLOCK_RX_RING_SIZE 128 9518c2ecf20Sopenharmony_ci#else 9528c2ecf20Sopenharmony_ci#define INIT_BLOCK_RX_RING_SIZE RX_RING_SIZE 9538c2ecf20Sopenharmony_ci#endif 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_cistruct gem_init_block { 9568c2ecf20Sopenharmony_ci struct gem_txd txd[INIT_BLOCK_TX_RING_SIZE]; 9578c2ecf20Sopenharmony_ci struct gem_rxd rxd[INIT_BLOCK_RX_RING_SIZE]; 9588c2ecf20Sopenharmony_ci}; 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_cienum gem_phy_type { 9618c2ecf20Sopenharmony_ci phy_mii_mdio0, 9628c2ecf20Sopenharmony_ci phy_mii_mdio1, 9638c2ecf20Sopenharmony_ci phy_serialink, 9648c2ecf20Sopenharmony_ci phy_serdes, 9658c2ecf20Sopenharmony_ci}; 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_cienum link_state { 9688c2ecf20Sopenharmony_ci link_down = 0, /* No link, will retry */ 9698c2ecf20Sopenharmony_ci link_aneg, /* Autoneg in progress */ 9708c2ecf20Sopenharmony_ci link_force_try, /* Try Forced link speed */ 9718c2ecf20Sopenharmony_ci link_force_ret, /* Forced mode worked, retrying autoneg */ 9728c2ecf20Sopenharmony_ci link_force_ok, /* Stay in forced mode */ 9738c2ecf20Sopenharmony_ci link_up /* Link is up */ 9748c2ecf20Sopenharmony_ci}; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_cistruct gem { 9778c2ecf20Sopenharmony_ci void __iomem *regs; 9788c2ecf20Sopenharmony_ci int rx_new, rx_old; 9798c2ecf20Sopenharmony_ci int tx_new, tx_old; 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ci unsigned int has_wol : 1; /* chip supports wake-on-lan */ 9828c2ecf20Sopenharmony_ci unsigned int asleep_wol : 1; /* was asleep with WOL enabled */ 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci int cell_enabled; 9858c2ecf20Sopenharmony_ci u32 msg_enable; 9868c2ecf20Sopenharmony_ci u32 status; 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_ci struct napi_struct napi; 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci int tx_fifo_sz; 9918c2ecf20Sopenharmony_ci int rx_fifo_sz; 9928c2ecf20Sopenharmony_ci int rx_pause_off; 9938c2ecf20Sopenharmony_ci int rx_pause_on; 9948c2ecf20Sopenharmony_ci int rx_buf_sz; 9958c2ecf20Sopenharmony_ci u64 pause_entered; 9968c2ecf20Sopenharmony_ci u16 pause_last_time_recvd; 9978c2ecf20Sopenharmony_ci u32 mac_rx_cfg; 9988c2ecf20Sopenharmony_ci u32 swrst_base; 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_ci int want_autoneg; 10018c2ecf20Sopenharmony_ci int last_forced_speed; 10028c2ecf20Sopenharmony_ci enum link_state lstate; 10038c2ecf20Sopenharmony_ci struct timer_list link_timer; 10048c2ecf20Sopenharmony_ci int timer_ticks; 10058c2ecf20Sopenharmony_ci int wake_on_lan; 10068c2ecf20Sopenharmony_ci struct work_struct reset_task; 10078c2ecf20Sopenharmony_ci volatile int reset_task_pending; 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_ci enum gem_phy_type phy_type; 10108c2ecf20Sopenharmony_ci struct mii_phy phy_mii; 10118c2ecf20Sopenharmony_ci int mii_phy_addr; 10128c2ecf20Sopenharmony_ci 10138c2ecf20Sopenharmony_ci struct gem_init_block *init_block; 10148c2ecf20Sopenharmony_ci struct sk_buff *rx_skbs[RX_RING_SIZE]; 10158c2ecf20Sopenharmony_ci struct sk_buff *tx_skbs[TX_RING_SIZE]; 10168c2ecf20Sopenharmony_ci dma_addr_t gblock_dvma; 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci struct pci_dev *pdev; 10198c2ecf20Sopenharmony_ci struct net_device *dev; 10208c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_SPARC) 10218c2ecf20Sopenharmony_ci struct device_node *of_node; 10228c2ecf20Sopenharmony_ci#endif 10238c2ecf20Sopenharmony_ci}; 10248c2ecf20Sopenharmony_ci 10258c2ecf20Sopenharmony_ci#define found_mii_phy(gp) ((gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) && \ 10268c2ecf20Sopenharmony_ci gp->phy_mii.def && gp->phy_mii.def->ops) 10278c2ecf20Sopenharmony_ci 10288c2ecf20Sopenharmony_ci#endif /* _SUNGEM_H */ 1029