162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* $Id: sunhme.h,v 1.33 2001/08/03 06:23:04 davem Exp $ 362306a36Sopenharmony_ci * sunhme.h: Definitions for Sparc HME/BigMac 10/100baseT ethernet driver. 462306a36Sopenharmony_ci * Also known as the "Happy Meal". 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _SUNHME_H 1062306a36Sopenharmony_ci#define _SUNHME_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/pci.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* Happy Meal global registers. */ 1562306a36Sopenharmony_ci#define GREG_SWRESET 0x000UL /* Software Reset */ 1662306a36Sopenharmony_ci#define GREG_CFG 0x004UL /* Config Register */ 1762306a36Sopenharmony_ci#define GREG_STAT 0x100UL /* Status */ 1862306a36Sopenharmony_ci#define GREG_IMASK 0x104UL /* Interrupt Mask */ 1962306a36Sopenharmony_ci#define GREG_REG_SIZE 0x108UL 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* Global reset register. */ 2262306a36Sopenharmony_ci#define GREG_RESET_ETX 0x01 2362306a36Sopenharmony_ci#define GREG_RESET_ERX 0x02 2462306a36Sopenharmony_ci#define GREG_RESET_ALL 0x03 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* Global config register. */ 2762306a36Sopenharmony_ci#define GREG_CFG_BURSTMSK 0x03 2862306a36Sopenharmony_ci#define GREG_CFG_BURST16 0x00 2962306a36Sopenharmony_ci#define GREG_CFG_BURST32 0x01 3062306a36Sopenharmony_ci#define GREG_CFG_BURST64 0x02 3162306a36Sopenharmony_ci#define GREG_CFG_64BIT 0x04 3262306a36Sopenharmony_ci#define GREG_CFG_PARITY 0x08 3362306a36Sopenharmony_ci#define GREG_CFG_RESV 0x10 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* Global status register. */ 3662306a36Sopenharmony_ci#define GREG_STAT_GOTFRAME 0x00000001 /* Received a frame */ 3762306a36Sopenharmony_ci#define GREG_STAT_RCNTEXP 0x00000002 /* Receive frame counter expired */ 3862306a36Sopenharmony_ci#define GREG_STAT_ACNTEXP 0x00000004 /* Align-error counter expired */ 3962306a36Sopenharmony_ci#define GREG_STAT_CCNTEXP 0x00000008 /* CRC-error counter expired */ 4062306a36Sopenharmony_ci#define GREG_STAT_LCNTEXP 0x00000010 /* Length-error counter expired */ 4162306a36Sopenharmony_ci#define GREG_STAT_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 4262306a36Sopenharmony_ci#define GREG_STAT_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 4362306a36Sopenharmony_ci#define GREG_STAT_STSTERR 0x00000080 /* Test error in XIF for SQE */ 4462306a36Sopenharmony_ci#define GREG_STAT_SENTFRAME 0x00000100 /* Transmitted a frame */ 4562306a36Sopenharmony_ci#define GREG_STAT_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 4662306a36Sopenharmony_ci#define GREG_STAT_MAXPKTERR 0x00000400 /* Max-packet size error */ 4762306a36Sopenharmony_ci#define GREG_STAT_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 4862306a36Sopenharmony_ci#define GREG_STAT_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 4962306a36Sopenharmony_ci#define GREG_STAT_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 5062306a36Sopenharmony_ci#define GREG_STAT_FCNTEXP 0x00004000 /* First-collision counter expired */ 5162306a36Sopenharmony_ci#define GREG_STAT_DTIMEXP 0x00008000 /* Defer-timer expired */ 5262306a36Sopenharmony_ci#define GREG_STAT_RXTOHOST 0x00010000 /* Moved from receive-FIFO to host memory */ 5362306a36Sopenharmony_ci#define GREG_STAT_NORXD 0x00020000 /* No more receive descriptors */ 5462306a36Sopenharmony_ci#define GREG_STAT_RXERR 0x00040000 /* Error during receive dma */ 5562306a36Sopenharmony_ci#define GREG_STAT_RXLATERR 0x00080000 /* Late error during receive dma */ 5662306a36Sopenharmony_ci#define GREG_STAT_RXPERR 0x00100000 /* Parity error during receive dma */ 5762306a36Sopenharmony_ci#define GREG_STAT_RXTERR 0x00200000 /* Tag error during receive dma */ 5862306a36Sopenharmony_ci#define GREG_STAT_EOPERR 0x00400000 /* Transmit descriptor did not have EOP set */ 5962306a36Sopenharmony_ci#define GREG_STAT_MIFIRQ 0x00800000 /* MIF is signaling an interrupt condition */ 6062306a36Sopenharmony_ci#define GREG_STAT_HOSTTOTX 0x01000000 /* Moved from host memory to transmit-FIFO */ 6162306a36Sopenharmony_ci#define GREG_STAT_TXALL 0x02000000 /* Transmitted all packets in the tx-fifo */ 6262306a36Sopenharmony_ci#define GREG_STAT_TXEACK 0x04000000 /* Error during transmit dma */ 6362306a36Sopenharmony_ci#define GREG_STAT_TXLERR 0x08000000 /* Late error during transmit dma */ 6462306a36Sopenharmony_ci#define GREG_STAT_TXPERR 0x10000000 /* Parity error during transmit dma */ 6562306a36Sopenharmony_ci#define GREG_STAT_TXTERR 0x20000000 /* Tag error during transmit dma */ 6662306a36Sopenharmony_ci#define GREG_STAT_SLVERR 0x40000000 /* PIO access got an error */ 6762306a36Sopenharmony_ci#define GREG_STAT_SLVPERR 0x80000000 /* PIO access got a parity error */ 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* All interesting error conditions. */ 7062306a36Sopenharmony_ci#define GREG_STAT_ERRORS 0xfc7efefc 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* Global interrupt mask register. */ 7362306a36Sopenharmony_ci#define GREG_IMASK_GOTFRAME 0x00000001 /* Received a frame */ 7462306a36Sopenharmony_ci#define GREG_IMASK_RCNTEXP 0x00000002 /* Receive frame counter expired */ 7562306a36Sopenharmony_ci#define GREG_IMASK_ACNTEXP 0x00000004 /* Align-error counter expired */ 7662306a36Sopenharmony_ci#define GREG_IMASK_CCNTEXP 0x00000008 /* CRC-error counter expired */ 7762306a36Sopenharmony_ci#define GREG_IMASK_LCNTEXP 0x00000010 /* Length-error counter expired */ 7862306a36Sopenharmony_ci#define GREG_IMASK_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 7962306a36Sopenharmony_ci#define GREG_IMASK_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 8062306a36Sopenharmony_ci#define GREG_IMASK_STSTERR 0x00000080 /* Test error in XIF for SQE */ 8162306a36Sopenharmony_ci#define GREG_IMASK_SENTFRAME 0x00000100 /* Transmitted a frame */ 8262306a36Sopenharmony_ci#define GREG_IMASK_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 8362306a36Sopenharmony_ci#define GREG_IMASK_MAXPKTERR 0x00000400 /* Max-packet size error */ 8462306a36Sopenharmony_ci#define GREG_IMASK_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 8562306a36Sopenharmony_ci#define GREG_IMASK_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 8662306a36Sopenharmony_ci#define GREG_IMASK_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 8762306a36Sopenharmony_ci#define GREG_IMASK_FCNTEXP 0x00004000 /* First-collision counter expired */ 8862306a36Sopenharmony_ci#define GREG_IMASK_DTIMEXP 0x00008000 /* Defer-timer expired */ 8962306a36Sopenharmony_ci#define GREG_IMASK_RXTOHOST 0x00010000 /* Moved from receive-FIFO to host memory */ 9062306a36Sopenharmony_ci#define GREG_IMASK_NORXD 0x00020000 /* No more receive descriptors */ 9162306a36Sopenharmony_ci#define GREG_IMASK_RXERR 0x00040000 /* Error during receive dma */ 9262306a36Sopenharmony_ci#define GREG_IMASK_RXLATERR 0x00080000 /* Late error during receive dma */ 9362306a36Sopenharmony_ci#define GREG_IMASK_RXPERR 0x00100000 /* Parity error during receive dma */ 9462306a36Sopenharmony_ci#define GREG_IMASK_RXTERR 0x00200000 /* Tag error during receive dma */ 9562306a36Sopenharmony_ci#define GREG_IMASK_EOPERR 0x00400000 /* Transmit descriptor did not have EOP set */ 9662306a36Sopenharmony_ci#define GREG_IMASK_MIFIRQ 0x00800000 /* MIF is signaling an interrupt condition */ 9762306a36Sopenharmony_ci#define GREG_IMASK_HOSTTOTX 0x01000000 /* Moved from host memory to transmit-FIFO */ 9862306a36Sopenharmony_ci#define GREG_IMASK_TXALL 0x02000000 /* Transmitted all packets in the tx-fifo */ 9962306a36Sopenharmony_ci#define GREG_IMASK_TXEACK 0x04000000 /* Error during transmit dma */ 10062306a36Sopenharmony_ci#define GREG_IMASK_TXLERR 0x08000000 /* Late error during transmit dma */ 10162306a36Sopenharmony_ci#define GREG_IMASK_TXPERR 0x10000000 /* Parity error during transmit dma */ 10262306a36Sopenharmony_ci#define GREG_IMASK_TXTERR 0x20000000 /* Tag error during transmit dma */ 10362306a36Sopenharmony_ci#define GREG_IMASK_SLVERR 0x40000000 /* PIO access got an error */ 10462306a36Sopenharmony_ci#define GREG_IMASK_SLVPERR 0x80000000 /* PIO access got a parity error */ 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* Happy Meal external transmitter registers. */ 10762306a36Sopenharmony_ci#define ETX_PENDING 0x00UL /* Transmit pending/wakeup register */ 10862306a36Sopenharmony_ci#define ETX_CFG 0x04UL /* Transmit config register */ 10962306a36Sopenharmony_ci#define ETX_RING 0x08UL /* Transmit ring pointer */ 11062306a36Sopenharmony_ci#define ETX_BBASE 0x0cUL /* Transmit buffer base */ 11162306a36Sopenharmony_ci#define ETX_BDISP 0x10UL /* Transmit buffer displacement */ 11262306a36Sopenharmony_ci#define ETX_FIFOWPTR 0x14UL /* FIFO write ptr */ 11362306a36Sopenharmony_ci#define ETX_FIFOSWPTR 0x18UL /* FIFO write ptr (shadow register) */ 11462306a36Sopenharmony_ci#define ETX_FIFORPTR 0x1cUL /* FIFO read ptr */ 11562306a36Sopenharmony_ci#define ETX_FIFOSRPTR 0x20UL /* FIFO read ptr (shadow register) */ 11662306a36Sopenharmony_ci#define ETX_FIFOPCNT 0x24UL /* FIFO packet counter */ 11762306a36Sopenharmony_ci#define ETX_SMACHINE 0x28UL /* Transmitter state machine */ 11862306a36Sopenharmony_ci#define ETX_RSIZE 0x2cUL /* Ring descriptor size */ 11962306a36Sopenharmony_ci#define ETX_BPTR 0x30UL /* Transmit data buffer ptr */ 12062306a36Sopenharmony_ci#define ETX_REG_SIZE 0x34UL 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/* ETX transmit pending register. */ 12362306a36Sopenharmony_ci#define ETX_TP_DMAWAKEUP 0x00000001 /* Restart transmit dma */ 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* ETX config register. */ 12662306a36Sopenharmony_ci#define ETX_CFG_DMAENABLE 0x00000001 /* Enable transmit dma */ 12762306a36Sopenharmony_ci#define ETX_CFG_FIFOTHRESH 0x000003fe /* Transmit FIFO threshold */ 12862306a36Sopenharmony_ci#define ETX_CFG_IRQDAFTER 0x00000400 /* Interrupt after TX-FIFO drained */ 12962306a36Sopenharmony_ci#define ETX_CFG_IRQDBEFORE 0x00000000 /* Interrupt before TX-FIFO drained */ 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci#define ETX_RSIZE_SHIFT 4 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci/* Happy Meal external receiver registers. */ 13462306a36Sopenharmony_ci#define ERX_CFG 0x00UL /* Receiver config register */ 13562306a36Sopenharmony_ci#define ERX_RING 0x04UL /* Receiver ring ptr */ 13662306a36Sopenharmony_ci#define ERX_BPTR 0x08UL /* Receiver buffer ptr */ 13762306a36Sopenharmony_ci#define ERX_FIFOWPTR 0x0cUL /* FIFO write ptr */ 13862306a36Sopenharmony_ci#define ERX_FIFOSWPTR 0x10UL /* FIFO write ptr (shadow register) */ 13962306a36Sopenharmony_ci#define ERX_FIFORPTR 0x14UL /* FIFO read ptr */ 14062306a36Sopenharmony_ci#define ERX_FIFOSRPTR 0x18UL /* FIFO read ptr (shadow register) */ 14162306a36Sopenharmony_ci#define ERX_SMACHINE 0x1cUL /* Receiver state machine */ 14262306a36Sopenharmony_ci#define ERX_REG_SIZE 0x20UL 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/* ERX config register. */ 14562306a36Sopenharmony_ci#define ERX_CFG_DMAENABLE 0x00000001 /* Enable receive DMA */ 14662306a36Sopenharmony_ci#define ERX_CFG_RESV1 0x00000006 /* Unused... */ 14762306a36Sopenharmony_ci#define ERX_CFG_BYTEOFFSET 0x00000038 /* Receive first byte offset */ 14862306a36Sopenharmony_ci#define ERX_CFG_RESV2 0x000001c0 /* Unused... */ 14962306a36Sopenharmony_ci#define ERX_CFG_SIZE32 0x00000000 /* Receive ring size == 32 */ 15062306a36Sopenharmony_ci#define ERX_CFG_SIZE64 0x00000200 /* Receive ring size == 64 */ 15162306a36Sopenharmony_ci#define ERX_CFG_SIZE128 0x00000400 /* Receive ring size == 128 */ 15262306a36Sopenharmony_ci#define ERX_CFG_SIZE256 0x00000600 /* Receive ring size == 256 */ 15362306a36Sopenharmony_ci#define ERX_CFG_RESV3 0x0000f800 /* Unused... */ 15462306a36Sopenharmony_ci#define ERX_CFG_CSUMSTART 0x007f0000 /* Offset of checksum start, 15562306a36Sopenharmony_ci * in halfwords. */ 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci/* I'd like a Big Mac, small fries, small coke, and SparcLinux please. */ 15862306a36Sopenharmony_ci#define BMAC_XIFCFG 0x0000UL /* XIF config register */ 15962306a36Sopenharmony_ci /* 0x4-->0x204, reserved */ 16062306a36Sopenharmony_ci#define BMAC_TXSWRESET 0x208UL /* Transmitter software reset */ 16162306a36Sopenharmony_ci#define BMAC_TXCFG 0x20cUL /* Transmitter config register */ 16262306a36Sopenharmony_ci#define BMAC_IGAP1 0x210UL /* Inter-packet gap 1 */ 16362306a36Sopenharmony_ci#define BMAC_IGAP2 0x214UL /* Inter-packet gap 2 */ 16462306a36Sopenharmony_ci#define BMAC_ALIMIT 0x218UL /* Transmit attempt limit */ 16562306a36Sopenharmony_ci#define BMAC_STIME 0x21cUL /* Transmit slot time */ 16662306a36Sopenharmony_ci#define BMAC_PLEN 0x220UL /* Size of transmit preamble */ 16762306a36Sopenharmony_ci#define BMAC_PPAT 0x224UL /* Pattern for transmit preamble */ 16862306a36Sopenharmony_ci#define BMAC_TXSDELIM 0x228UL /* Transmit delimiter */ 16962306a36Sopenharmony_ci#define BMAC_JSIZE 0x22cUL /* Jam size */ 17062306a36Sopenharmony_ci#define BMAC_TXMAX 0x230UL /* Transmit max pkt size */ 17162306a36Sopenharmony_ci#define BMAC_TXMIN 0x234UL /* Transmit min pkt size */ 17262306a36Sopenharmony_ci#define BMAC_PATTEMPT 0x238UL /* Count of transmit peak attempts */ 17362306a36Sopenharmony_ci#define BMAC_DTCTR 0x23cUL /* Transmit defer timer */ 17462306a36Sopenharmony_ci#define BMAC_NCCTR 0x240UL /* Transmit normal-collision counter */ 17562306a36Sopenharmony_ci#define BMAC_FCCTR 0x244UL /* Transmit first-collision counter */ 17662306a36Sopenharmony_ci#define BMAC_EXCTR 0x248UL /* Transmit excess-collision counter */ 17762306a36Sopenharmony_ci#define BMAC_LTCTR 0x24cUL /* Transmit late-collision counter */ 17862306a36Sopenharmony_ci#define BMAC_RSEED 0x250UL /* Transmit random number seed */ 17962306a36Sopenharmony_ci#define BMAC_TXSMACHINE 0x254UL /* Transmit state machine */ 18062306a36Sopenharmony_ci /* 0x258-->0x304, reserved */ 18162306a36Sopenharmony_ci#define BMAC_RXSWRESET 0x308UL /* Receiver software reset */ 18262306a36Sopenharmony_ci#define BMAC_RXCFG 0x30cUL /* Receiver config register */ 18362306a36Sopenharmony_ci#define BMAC_RXMAX 0x310UL /* Receive max pkt size */ 18462306a36Sopenharmony_ci#define BMAC_RXMIN 0x314UL /* Receive min pkt size */ 18562306a36Sopenharmony_ci#define BMAC_MACADDR2 0x318UL /* Ether address register 2 */ 18662306a36Sopenharmony_ci#define BMAC_MACADDR1 0x31cUL /* Ether address register 1 */ 18762306a36Sopenharmony_ci#define BMAC_MACADDR0 0x320UL /* Ether address register 0 */ 18862306a36Sopenharmony_ci#define BMAC_FRCTR 0x324UL /* Receive frame receive counter */ 18962306a36Sopenharmony_ci#define BMAC_GLECTR 0x328UL /* Receive giant-length error counter */ 19062306a36Sopenharmony_ci#define BMAC_UNALECTR 0x32cUL /* Receive unaligned error counter */ 19162306a36Sopenharmony_ci#define BMAC_RCRCECTR 0x330UL /* Receive CRC error counter */ 19262306a36Sopenharmony_ci#define BMAC_RXSMACHINE 0x334UL /* Receiver state machine */ 19362306a36Sopenharmony_ci#define BMAC_RXCVALID 0x338UL /* Receiver code violation */ 19462306a36Sopenharmony_ci /* 0x33c, reserved */ 19562306a36Sopenharmony_ci#define BMAC_HTABLE3 0x340UL /* Hash table 3 */ 19662306a36Sopenharmony_ci#define BMAC_HTABLE2 0x344UL /* Hash table 2 */ 19762306a36Sopenharmony_ci#define BMAC_HTABLE1 0x348UL /* Hash table 1 */ 19862306a36Sopenharmony_ci#define BMAC_HTABLE0 0x34cUL /* Hash table 0 */ 19962306a36Sopenharmony_ci#define BMAC_AFILTER2 0x350UL /* Address filter 2 */ 20062306a36Sopenharmony_ci#define BMAC_AFILTER1 0x354UL /* Address filter 1 */ 20162306a36Sopenharmony_ci#define BMAC_AFILTER0 0x358UL /* Address filter 0 */ 20262306a36Sopenharmony_ci#define BMAC_AFMASK 0x35cUL /* Address filter mask */ 20362306a36Sopenharmony_ci#define BMAC_REG_SIZE 0x360UL 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci/* BigMac XIF config register. */ 20662306a36Sopenharmony_ci#define BIGMAC_XCFG_ODENABLE 0x00000001 /* Output driver enable */ 20762306a36Sopenharmony_ci#define BIGMAC_XCFG_XLBACK 0x00000002 /* Loopback-mode XIF enable */ 20862306a36Sopenharmony_ci#define BIGMAC_XCFG_MLBACK 0x00000004 /* Loopback-mode MII enable */ 20962306a36Sopenharmony_ci#define BIGMAC_XCFG_MIIDISAB 0x00000008 /* MII receive buffer disable */ 21062306a36Sopenharmony_ci#define BIGMAC_XCFG_SQENABLE 0x00000010 /* SQE test enable */ 21162306a36Sopenharmony_ci#define BIGMAC_XCFG_SQETWIN 0x000003e0 /* SQE time window */ 21262306a36Sopenharmony_ci#define BIGMAC_XCFG_LANCE 0x00000010 /* Lance mode enable */ 21362306a36Sopenharmony_ci#define BIGMAC_XCFG_LIPG0 0x000003e0 /* Lance mode IPG0 */ 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci/* BigMac transmit config register. */ 21662306a36Sopenharmony_ci#define BIGMAC_TXCFG_ENABLE 0x00000001 /* Enable the transmitter */ 21762306a36Sopenharmony_ci#define BIGMAC_TXCFG_SMODE 0x00000020 /* Enable slow transmit mode */ 21862306a36Sopenharmony_ci#define BIGMAC_TXCFG_CIGN 0x00000040 /* Ignore transmit collisions */ 21962306a36Sopenharmony_ci#define BIGMAC_TXCFG_FCSOFF 0x00000080 /* Do not emit FCS */ 22062306a36Sopenharmony_ci#define BIGMAC_TXCFG_DBACKOFF 0x00000100 /* Disable backoff */ 22162306a36Sopenharmony_ci#define BIGMAC_TXCFG_FULLDPLX 0x00000200 /* Enable full-duplex */ 22262306a36Sopenharmony_ci#define BIGMAC_TXCFG_DGIVEUP 0x00000400 /* Don't give up on transmits */ 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci/* BigMac receive config register. */ 22562306a36Sopenharmony_ci#define BIGMAC_RXCFG_ENABLE 0x00000001 /* Enable the receiver */ 22662306a36Sopenharmony_ci#define BIGMAC_RXCFG_PSTRIP 0x00000020 /* Pad byte strip enable */ 22762306a36Sopenharmony_ci#define BIGMAC_RXCFG_PMISC 0x00000040 /* Enable promiscuous mode */ 22862306a36Sopenharmony_ci#define BIGMAC_RXCFG_DERR 0x00000080 /* Disable error checking */ 22962306a36Sopenharmony_ci#define BIGMAC_RXCFG_DCRCS 0x00000100 /* Disable CRC stripping */ 23062306a36Sopenharmony_ci#define BIGMAC_RXCFG_REJME 0x00000200 /* Reject packets addressed to me */ 23162306a36Sopenharmony_ci#define BIGMAC_RXCFG_PGRP 0x00000400 /* Enable promisc group mode */ 23262306a36Sopenharmony_ci#define BIGMAC_RXCFG_HENABLE 0x00000800 /* Enable the hash filter */ 23362306a36Sopenharmony_ci#define BIGMAC_RXCFG_AENABLE 0x00001000 /* Enable the address filter */ 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci/* These are the "Management Interface" (ie. MIF) registers of the transceiver. */ 23662306a36Sopenharmony_ci#define TCVR_BBCLOCK 0x00UL /* Bit bang clock register */ 23762306a36Sopenharmony_ci#define TCVR_BBDATA 0x04UL /* Bit bang data register */ 23862306a36Sopenharmony_ci#define TCVR_BBOENAB 0x08UL /* Bit bang output enable */ 23962306a36Sopenharmony_ci#define TCVR_FRAME 0x0cUL /* Frame control/data register */ 24062306a36Sopenharmony_ci#define TCVR_CFG 0x10UL /* MIF config register */ 24162306a36Sopenharmony_ci#define TCVR_IMASK 0x14UL /* MIF interrupt mask */ 24262306a36Sopenharmony_ci#define TCVR_STATUS 0x18UL /* MIF status */ 24362306a36Sopenharmony_ci#define TCVR_SMACHINE 0x1cUL /* MIF state machine */ 24462306a36Sopenharmony_ci#define TCVR_REG_SIZE 0x20UL 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci/* Frame commands. */ 24762306a36Sopenharmony_ci#define FRAME_WRITE 0x50020000 24862306a36Sopenharmony_ci#define FRAME_READ 0x60020000 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci/* Transceiver config register */ 25162306a36Sopenharmony_ci#define TCV_CFG_PSELECT 0x00000001 /* Select PHY */ 25262306a36Sopenharmony_ci#define TCV_CFG_PENABLE 0x00000002 /* Enable MIF polling */ 25362306a36Sopenharmony_ci#define TCV_CFG_BENABLE 0x00000004 /* Enable the "bit banger" oh baby */ 25462306a36Sopenharmony_ci#define TCV_CFG_PREGADDR 0x000000f8 /* Address of poll register */ 25562306a36Sopenharmony_ci#define TCV_CFG_MDIO0 0x00000100 /* MDIO zero, data/attached */ 25662306a36Sopenharmony_ci#define TCV_CFG_MDIO1 0x00000200 /* MDIO one, data/attached */ 25762306a36Sopenharmony_ci#define TCV_CFG_PDADDR 0x00007c00 /* Device PHY address polling */ 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci/* Here are some PHY addresses. */ 26062306a36Sopenharmony_ci#define TCV_PADDR_ETX 0 /* Internal transceiver */ 26162306a36Sopenharmony_ci#define TCV_PADDR_ITX 1 /* External transceiver */ 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci/* Transceiver status register */ 26462306a36Sopenharmony_ci#define TCV_STAT_BASIC 0xffff0000 /* The "basic" part */ 26562306a36Sopenharmony_ci#define TCV_STAT_NORMAL 0x0000ffff /* The "non-basic" part */ 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci/* Inside the Happy Meal transceiver is the physical layer, they use an 26862306a36Sopenharmony_ci * implementations for National Semiconductor, part number DP83840VCE. 26962306a36Sopenharmony_ci * You can retrieve the data sheets and programming docs for this beast 27062306a36Sopenharmony_ci * from http://www.national.com/ 27162306a36Sopenharmony_ci * 27262306a36Sopenharmony_ci * The DP83840 is capable of both 10 and 100Mbps ethernet, in both 27362306a36Sopenharmony_ci * half and full duplex mode. It also supports auto negotiation. 27462306a36Sopenharmony_ci * 27562306a36Sopenharmony_ci * But.... THIS THING IS A PAIN IN THE ASS TO PROGRAM! 27662306a36Sopenharmony_ci * Debugging eeprom burnt code is more fun than programming this chip! 27762306a36Sopenharmony_ci */ 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci/* Generic MII registers defined in linux/mii.h, these below 28062306a36Sopenharmony_ci * are DP83840 specific. 28162306a36Sopenharmony_ci */ 28262306a36Sopenharmony_ci#define DP83840_CSCONFIG 0x17 /* CS configuration */ 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci/* The Carrier Sense config register. */ 28562306a36Sopenharmony_ci#define CSCONFIG_RESV1 0x0001 /* Unused... */ 28662306a36Sopenharmony_ci#define CSCONFIG_LED4 0x0002 /* Pin for full-dplx LED4 */ 28762306a36Sopenharmony_ci#define CSCONFIG_LED1 0x0004 /* Pin for conn-status LED1 */ 28862306a36Sopenharmony_ci#define CSCONFIG_RESV2 0x0008 /* Unused... */ 28962306a36Sopenharmony_ci#define CSCONFIG_TCVDISAB 0x0010 /* Turns off the transceiver */ 29062306a36Sopenharmony_ci#define CSCONFIG_DFBYPASS 0x0020 /* Bypass disconnect function */ 29162306a36Sopenharmony_ci#define CSCONFIG_GLFORCE 0x0040 /* Good link force for 100mbps */ 29262306a36Sopenharmony_ci#define CSCONFIG_CLKTRISTATE 0x0080 /* Tristate 25m clock */ 29362306a36Sopenharmony_ci#define CSCONFIG_RESV3 0x0700 /* Unused... */ 29462306a36Sopenharmony_ci#define CSCONFIG_ENCODE 0x0800 /* 1=MLT-3, 0=binary */ 29562306a36Sopenharmony_ci#define CSCONFIG_RENABLE 0x1000 /* Repeater mode enable */ 29662306a36Sopenharmony_ci#define CSCONFIG_TCDISABLE 0x2000 /* Disable timeout counter */ 29762306a36Sopenharmony_ci#define CSCONFIG_RESV4 0x4000 /* Unused... */ 29862306a36Sopenharmony_ci#define CSCONFIG_NDISABLE 0x8000 /* Disable NRZI */ 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci/* Happy Meal descriptor rings and such. 30162306a36Sopenharmony_ci * All descriptor rings must be aligned on a 2K boundary. 30262306a36Sopenharmony_ci * All receive buffers must be 64 byte aligned. 30362306a36Sopenharmony_ci * Always write the address first before setting the ownership 30462306a36Sopenharmony_ci * bits to avoid races with the hardware scanning the ring. 30562306a36Sopenharmony_ci */ 30662306a36Sopenharmony_citypedef u32 __bitwise hme32; 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_cistruct happy_meal_rxd { 30962306a36Sopenharmony_ci hme32 rx_flags; 31062306a36Sopenharmony_ci hme32 rx_addr; 31162306a36Sopenharmony_ci}; 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci#define RXFLAG_OWN 0x80000000 /* 1 = hardware, 0 = software */ 31462306a36Sopenharmony_ci#define RXFLAG_OVERFLOW 0x40000000 /* 1 = buffer overflow */ 31562306a36Sopenharmony_ci#define RXFLAG_SIZE 0x3fff0000 /* Size of the buffer */ 31662306a36Sopenharmony_ci#define RXFLAG_CSUM 0x0000ffff /* HW computed checksum */ 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_cistruct happy_meal_txd { 31962306a36Sopenharmony_ci hme32 tx_flags; 32062306a36Sopenharmony_ci hme32 tx_addr; 32162306a36Sopenharmony_ci}; 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci#define TXFLAG_OWN 0x80000000 /* 1 = hardware, 0 = software */ 32462306a36Sopenharmony_ci#define TXFLAG_SOP 0x40000000 /* 1 = start of packet */ 32562306a36Sopenharmony_ci#define TXFLAG_EOP 0x20000000 /* 1 = end of packet */ 32662306a36Sopenharmony_ci#define TXFLAG_CSENABLE 0x10000000 /* 1 = enable hw-checksums */ 32762306a36Sopenharmony_ci#define TXFLAG_CSLOCATION 0x0ff00000 /* Where to stick the csum */ 32862306a36Sopenharmony_ci#define TXFLAG_CSBUFBEGIN 0x000fc000 /* Where to begin checksum */ 32962306a36Sopenharmony_ci#define TXFLAG_SIZE 0x00003fff /* Size of the packet */ 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci#define TX_RING_SIZE 32 /* Must be >16 and <255, multiple of 16 */ 33262306a36Sopenharmony_ci#define RX_RING_SIZE 32 /* see ERX_CFG_SIZE* for possible values */ 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci#if (TX_RING_SIZE < 16 || TX_RING_SIZE > 256 || (TX_RING_SIZE % 16) != 0) 33562306a36Sopenharmony_ci#error TX_RING_SIZE holds illegal value 33662306a36Sopenharmony_ci#endif 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci#define TX_RING_MAXSIZE 256 33962306a36Sopenharmony_ci#define RX_RING_MAXSIZE 256 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* We use a 14 byte offset for checksum computation. */ 34262306a36Sopenharmony_ci#if (RX_RING_SIZE == 32) 34362306a36Sopenharmony_ci#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE32|((14/2)<<16)) 34462306a36Sopenharmony_ci#else 34562306a36Sopenharmony_ci#if (RX_RING_SIZE == 64) 34662306a36Sopenharmony_ci#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE64|((14/2)<<16)) 34762306a36Sopenharmony_ci#else 34862306a36Sopenharmony_ci#if (RX_RING_SIZE == 128) 34962306a36Sopenharmony_ci#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE128|((14/2)<<16)) 35062306a36Sopenharmony_ci#else 35162306a36Sopenharmony_ci#if (RX_RING_SIZE == 256) 35262306a36Sopenharmony_ci#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE256|((14/2)<<16)) 35362306a36Sopenharmony_ci#else 35462306a36Sopenharmony_ci#error RX_RING_SIZE holds illegal value 35562306a36Sopenharmony_ci#endif 35662306a36Sopenharmony_ci#endif 35762306a36Sopenharmony_ci#endif 35862306a36Sopenharmony_ci#endif 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci#define NEXT_RX(num) (((num) + 1) & (RX_RING_SIZE - 1)) 36162306a36Sopenharmony_ci#define NEXT_TX(num) (((num) + 1) & (TX_RING_SIZE - 1)) 36262306a36Sopenharmony_ci#define PREV_RX(num) (((num) - 1) & (RX_RING_SIZE - 1)) 36362306a36Sopenharmony_ci#define PREV_TX(num) (((num) - 1) & (TX_RING_SIZE - 1)) 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci#define TX_BUFFS_AVAIL(hp) \ 36662306a36Sopenharmony_ci (((hp)->tx_old <= (hp)->tx_new) ? \ 36762306a36Sopenharmony_ci (hp)->tx_old + (TX_RING_SIZE - 1) - (hp)->tx_new : \ 36862306a36Sopenharmony_ci (hp)->tx_old - (hp)->tx_new - 1) 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci#define RX_OFFSET 2 37162306a36Sopenharmony_ci#define RX_BUF_ALLOC_SIZE (1546 + RX_OFFSET + 64) 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci#define RX_COPY_THRESHOLD 256 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_cistruct hmeal_init_block { 37662306a36Sopenharmony_ci struct happy_meal_rxd happy_meal_rxd[RX_RING_MAXSIZE]; 37762306a36Sopenharmony_ci struct happy_meal_txd happy_meal_txd[TX_RING_MAXSIZE]; 37862306a36Sopenharmony_ci}; 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ci#define hblock_offset(mem, elem) \ 38162306a36Sopenharmony_ci((__u32)((unsigned long)(&(((struct hmeal_init_block *)0)->mem[elem])))) 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci/* Now software state stuff. */ 38462306a36Sopenharmony_cienum happy_transceiver { 38562306a36Sopenharmony_ci external = 0, 38662306a36Sopenharmony_ci internal = 1, 38762306a36Sopenharmony_ci none = 2, 38862306a36Sopenharmony_ci}; 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci/* Timer state engine. */ 39162306a36Sopenharmony_cienum happy_timer_state { 39262306a36Sopenharmony_ci arbwait = 0, /* Waiting for auto negotiation to complete. */ 39362306a36Sopenharmony_ci lupwait = 1, /* Auto-neg complete, awaiting link-up status. */ 39462306a36Sopenharmony_ci ltrywait = 2, /* Forcing try of all modes, from fastest to slowest. */ 39562306a36Sopenharmony_ci asleep = 3, /* Time inactive. */ 39662306a36Sopenharmony_ci}; 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_cistruct quattro; 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci/* Happy happy, joy joy! */ 40162306a36Sopenharmony_cistruct happy_meal { 40262306a36Sopenharmony_ci void __iomem *gregs; /* Happy meal global registers */ 40362306a36Sopenharmony_ci struct hmeal_init_block *happy_block; /* RX and TX descriptors (CPU addr) */ 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) 40662306a36Sopenharmony_ci u32 (*read_desc32)(hme32 *); 40762306a36Sopenharmony_ci void (*write_txd)(struct happy_meal_txd *, u32, u32); 40862306a36Sopenharmony_ci void (*write_rxd)(struct happy_meal_rxd *, u32, u32); 40962306a36Sopenharmony_ci#endif 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci /* This is either an platform_device or a pci_dev. */ 41262306a36Sopenharmony_ci void *happy_dev; 41362306a36Sopenharmony_ci struct device *dma_dev; 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci spinlock_t happy_lock; 41662306a36Sopenharmony_ci 41762306a36Sopenharmony_ci struct sk_buff *rx_skbs[RX_RING_SIZE]; 41862306a36Sopenharmony_ci struct sk_buff *tx_skbs[TX_RING_SIZE]; 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci int rx_new, tx_new, rx_old, tx_old; 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) 42362306a36Sopenharmony_ci u32 (*read32)(void __iomem *); 42462306a36Sopenharmony_ci void (*write32)(void __iomem *, u32); 42562306a36Sopenharmony_ci#endif 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci void __iomem *etxregs; /* External transmitter regs */ 42862306a36Sopenharmony_ci void __iomem *erxregs; /* External receiver regs */ 42962306a36Sopenharmony_ci void __iomem *bigmacregs; /* BIGMAC core regs */ 43062306a36Sopenharmony_ci void __iomem *tcvregs; /* MIF transceiver regs */ 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ci dma_addr_t hblock_dvma; /* DVMA visible address happy block */ 43362306a36Sopenharmony_ci unsigned int happy_flags; /* Driver state flags */ 43462306a36Sopenharmony_ci int irq; 43562306a36Sopenharmony_ci enum happy_transceiver tcvr_type; /* Kind of transceiver in use */ 43662306a36Sopenharmony_ci unsigned int happy_bursts; /* Get your mind out of the gutter */ 43762306a36Sopenharmony_ci unsigned int paddr; /* PHY address for transceiver */ 43862306a36Sopenharmony_ci unsigned short hm_revision; /* Happy meal revision */ 43962306a36Sopenharmony_ci unsigned short sw_bmcr; /* SW copy of BMCR */ 44062306a36Sopenharmony_ci unsigned short sw_bmsr; /* SW copy of BMSR */ 44162306a36Sopenharmony_ci unsigned short sw_physid1; /* SW copy of PHYSID1 */ 44262306a36Sopenharmony_ci unsigned short sw_physid2; /* SW copy of PHYSID2 */ 44362306a36Sopenharmony_ci unsigned short sw_advertise; /* SW copy of ADVERTISE */ 44462306a36Sopenharmony_ci unsigned short sw_lpa; /* SW copy of LPA */ 44562306a36Sopenharmony_ci unsigned short sw_expansion; /* SW copy of EXPANSION */ 44662306a36Sopenharmony_ci unsigned short sw_csconfig; /* SW copy of CSCONFIG */ 44762306a36Sopenharmony_ci unsigned int auto_speed; /* Auto-nego link speed */ 44862306a36Sopenharmony_ci unsigned int forced_speed; /* Force mode link speed */ 44962306a36Sopenharmony_ci unsigned int poll_data; /* MIF poll data */ 45062306a36Sopenharmony_ci unsigned int poll_flag; /* MIF poll flag */ 45162306a36Sopenharmony_ci unsigned int linkcheck; /* Have we checked the link yet? */ 45262306a36Sopenharmony_ci unsigned int lnkup; /* Is the link up as far as we know? */ 45362306a36Sopenharmony_ci unsigned int lnkdown; /* Trying to force the link down? */ 45462306a36Sopenharmony_ci unsigned int lnkcnt; /* Counter for link-up attempts. */ 45562306a36Sopenharmony_ci struct timer_list happy_timer; /* To watch the link when coming up. */ 45662306a36Sopenharmony_ci enum happy_timer_state timer_state; /* State of the auto-neg timer. */ 45762306a36Sopenharmony_ci unsigned int timer_ticks; /* Number of clicks at each state. */ 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_ci struct net_device *dev; /* Backpointer */ 46062306a36Sopenharmony_ci struct quattro *qfe_parent; /* For Quattro cards */ 46162306a36Sopenharmony_ci int qfe_ent; /* Which instance on quattro */ 46262306a36Sopenharmony_ci}; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci/* Here are the happy flags. */ 46562306a36Sopenharmony_ci#define HFLAG_FENABLE 0x00000002 /* The MII frame is enabled */ 46662306a36Sopenharmony_ci#define HFLAG_LANCE 0x00000004 /* We are using lance-mode */ 46762306a36Sopenharmony_ci#define HFLAG_RXENABLE 0x00000008 /* Receiver is enabled */ 46862306a36Sopenharmony_ci#define HFLAG_AUTO 0x00000010 /* Using auto-negotiation, 0 = force */ 46962306a36Sopenharmony_ci#define HFLAG_FULL 0x00000020 /* Full duplex enable */ 47062306a36Sopenharmony_ci#define HFLAG_MACFULL 0x00000040 /* Using full duplex in the MAC */ 47162306a36Sopenharmony_ci#define HFLAG_RXCV 0x00000100 /* XXX RXCV ENABLE */ 47262306a36Sopenharmony_ci#define HFLAG_INIT 0x00000200 /* Init called at least once */ 47362306a36Sopenharmony_ci#define HFLAG_LINKUP 0x00000400 /* 1 = Link is up */ 47462306a36Sopenharmony_ci#define HFLAG_PCI 0x00000800 /* PCI based Happy Meal */ 47562306a36Sopenharmony_ci#define HFLAG_QUATTRO 0x00001000 /* On QFE/Quattro card */ 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_ci#define HFLAG_20_21 HFLAG_FENABLE 47862306a36Sopenharmony_ci#define HFLAG_NOT_A0 (HFLAG_FENABLE | HFLAG_LANCE | HFLAG_RXCV) 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_ci/* Support for QFE/Quattro cards. */ 48162306a36Sopenharmony_cistruct quattro { 48262306a36Sopenharmony_ci struct net_device *happy_meals[4]; 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci /* This is either a sbus_dev or a pci_dev. */ 48562306a36Sopenharmony_ci void *quattro_dev; 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ci struct quattro *next; 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_ci /* PROM ranges, if any. */ 49062306a36Sopenharmony_ci#ifdef CONFIG_SBUS 49162306a36Sopenharmony_ci struct linux_prom_ranges ranges[8]; 49262306a36Sopenharmony_ci#endif 49362306a36Sopenharmony_ci int nranges; 49462306a36Sopenharmony_ci}; 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ci/* We use this to acquire receive skb's that we can DMA directly into. */ 49762306a36Sopenharmony_ci#define ALIGNED_RX_SKB_ADDR(addr) \ 49862306a36Sopenharmony_ci ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr)) 49962306a36Sopenharmony_ci#define happy_meal_alloc_skb(__length, __gfp_flags) \ 50062306a36Sopenharmony_ci({ struct sk_buff *__skb; \ 50162306a36Sopenharmony_ci __skb = alloc_skb((__length) + 64, (__gfp_flags)); \ 50262306a36Sopenharmony_ci if(__skb) { \ 50362306a36Sopenharmony_ci int __offset = (int) ALIGNED_RX_SKB_ADDR(__skb->data); \ 50462306a36Sopenharmony_ci if(__offset) \ 50562306a36Sopenharmony_ci skb_reserve(__skb, __offset); \ 50662306a36Sopenharmony_ci } \ 50762306a36Sopenharmony_ci __skb; \ 50862306a36Sopenharmony_ci}) 50962306a36Sopenharmony_ci 51062306a36Sopenharmony_ci#endif /* !(_SUNHME_H) */ 511