xref: /onnv-gate/usr/src/uts/common/io/afe/afe.h (revision 9860:20e31304c39b)
14992Sgd78059 /*
24992Sgd78059  * Solaris DLPI driver for ethernet cards based on the ADMtek Centaur
34992Sgd78059  *
44992Sgd78059  * Copyright (c) 2007 by Garrett D'Amore <garrett@damore.org>.
54992Sgd78059  * All rights reserved.
64992Sgd78059  *
74992Sgd78059  * Redistribution and use in source and binary forms, with or without
84992Sgd78059  * modification, are permitted provided that the following conditions
94992Sgd78059  * are met:
104992Sgd78059  * 1. Redistributions of source code must retain the above copyright
114992Sgd78059  *    notice, this list of conditions and the following disclaimer.
124992Sgd78059  * 2. Redistributions in binary form must reproduce the above copyright
134992Sgd78059  *    notice, this list of conditions and the following disclaimer in the
144992Sgd78059  *    documentation and/or other materials provided with the distribution.
154992Sgd78059  * 3. Neither the name of the author nor the names of any co-contributors
164992Sgd78059  *    may be used to endorse or promote products derived from this software
174992Sgd78059  *    without specific prior written permission.
184992Sgd78059  *
194992Sgd78059  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
204992Sgd78059  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
214992Sgd78059  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
224992Sgd78059  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
234992Sgd78059  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
244992Sgd78059  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
254992Sgd78059  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
264992Sgd78059  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
274992Sgd78059  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
284992Sgd78059  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
294992Sgd78059  * POSSIBILITY OF SUCH DAMAGE.
304992Sgd78059  */
31*9860Sgdamore@opensolaris.org /*
32*9860Sgdamore@opensolaris.org  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
33*9860Sgdamore@opensolaris.org  * Use is subject to license terms.
34*9860Sgdamore@opensolaris.org  */
354992Sgd78059 
364992Sgd78059 #ifndef	_AFE_H
374992Sgd78059 #define	_AFE_H
384992Sgd78059 
394992Sgd78059 #ifdef	__cplusplus
404992Sgd78059 extern "C" {
414992Sgd78059 #endif
424992Sgd78059 
434992Sgd78059 /*
444992Sgd78059  * Registers and values are here, becuase they can be exported to userland
454992Sgd78059  * via the AFEIOC_GETCSR and friends ioctls.  These are private to this
464992Sgd78059  * driver and the bundled diagnostic utility, and should not be used by
474992Sgd78059  * end user application programs.
484992Sgd78059  */
494992Sgd78059 
504992Sgd78059 /*
514992Sgd78059  * AFE register definitions.
524992Sgd78059  */
534992Sgd78059 /* PCI configuration registers */
544992Sgd78059 #define	PCI_VID		0x00	/* Loaded vendor ID */
554992Sgd78059 #define	PCI_DID		0x02	/* Loaded device ID */
564992Sgd78059 #define	PCI_CMD		0x04	/* Configuration command register */
574992Sgd78059 #define	PCI_STAT	0x06	/* Configuration status register */
584992Sgd78059 #define	PCI_RID		0x08	/* Revision ID */
594992Sgd78059 #define	PCI_CLS		0x0c	/* Cache line size */
604992Sgd78059 #define	PCI_SVID	0x2c	/* Subsystem vendor ID */
614992Sgd78059 #define	PCI_SSID	0x2e	/* Subsystem ID */
624992Sgd78059 #define	PCI_MINGNT	0x3e	/* Minimum Grant */
634992Sgd78059 #define	PCI_MAXLAT	0x3f	/* Maximum latency */
644992Sgd78059 #define	PCI_SIG		0x80	/* Signature of AN983 */
654992Sgd78059 #define	PCI_PMR0	0xc0	/* Power Management Register 0 */
664992Sgd78059 #define	PCI_PMR1	0xc4	/* Power Management Register 1 */
674992Sgd78059 
684992Sgd78059 /*
694992Sgd78059  * Bits for PCI command register.
704992Sgd78059  */
714992Sgd78059 #define	PCI_CMD_MWIE	0x0010	/* memory write-invalidate enable */
724992Sgd78059 #define	PCI_CMD_BME	0x0004	/* bus master enable */
734992Sgd78059 #define	PCI_CMD_MAE	0x0002	/* memory access enable */
744992Sgd78059 #define	PCI_CMD_IOE	0x0001	/* I/O access enable */
754992Sgd78059 
764992Sgd78059 /*
774992Sgd78059  * Signature values for PCI_SIG
784992Sgd78059  */
794992Sgd78059 #define	SIG_AN983	0x09811317
804992Sgd78059 #define	SIG_AN985	0x09851317
814992Sgd78059 #define	SIG_ADM9511	0x69851317
824992Sgd78059 
834992Sgd78059 /* Ordinary control/status registers */
844992Sgd78059 #define	CSR_PAR		0x00	/* PCI access register */
854992Sgd78059 #define	CSR_TDR		0x08	/* Transmit demand register */
864992Sgd78059 #define	CSR_RDR		0x10	/* Receive demand register */
874992Sgd78059 #define	CSR_RDB		0x18	/* Receive descriptor base address */
884992Sgd78059 #define	CSR_TDB		0x20	/* Transmit descriptor base address */
894992Sgd78059 #define	CSR_SR		0x28	/* Status register */
904992Sgd78059 #define	CSR_NAR		0x30	/* Network access register */
914992Sgd78059 #define	CSR_IER		0x38	/* Interrupt enable register */
924992Sgd78059 #define	CSR_LPC		0x40	/* Lost packet counter */
934992Sgd78059 #define	CSR_SPR		0x48	/* Serial port register */
944992Sgd78059 #define	CSR_TIMER	0x58	/* Timer */
954992Sgd78059 #define	CSR_SR2		0x80	/* Status register 2 */
964992Sgd78059 #define	CSR_IER2	0x84	/* Interrupt enable register 2 */
974992Sgd78059 #define	CSR_CR		0x88	/* Command register */
984992Sgd78059 #define	CSR_PMCSR	0x90	/* Power Management Command and Status */
994992Sgd78059 #define	CSR_PAR0	0xa4	/* Physical address register 0 */
1004992Sgd78059 #define	CSR_PAR1	0xa8	/* Physical address register 1 */
1014992Sgd78059 #define	CSR_MAR0	0xac	/* Multicast address hash table register 0 */
1024992Sgd78059 #define	CSR_MAR1	0xb0	/* Multicast address hash table register 1 */
1034992Sgd78059 #define	CSR_BMCR	0xb4	/* PHY BMCR (comet only) */
1044992Sgd78059 #define	CSR_BMSR	0xb8	/* PHY BMSR (comet only) */
1054992Sgd78059 #define	CSR_PHYIDR1	0xbc	/* PHY PHYIDR1 (comet only) */
1064992Sgd78059 #define	CSR_PHYIDR2	0xc0	/* PHY PHYIDR2 (comet only) */
1074992Sgd78059 #define	CSR_ANAR	0xc4	/* PHY ANAR (comet only) */
1084992Sgd78059 #define	CSR_ANLPAR	0xc8	/* PHY ANLPAR (comet only) */
1094992Sgd78059 #define	CSR_ANER	0xcc	/* PHY ANER (comet only) */
1104992Sgd78059 #define	CSR_XMC		0xd0	/* XCVR mode control (comet only) */
1114992Sgd78059 #define	CSR_XCIIS	0xd4	/* XCVR config info/int status (comet only) */
1124992Sgd78059 #define	CSR_XIE		0xd8	/* XCVR interupt enable (comet only) */
1134992Sgd78059 #define	CSR_OPM		0xfc	/* Opmode register (centaur only) */
1144992Sgd78059 
1154992Sgd78059 /*
1164992Sgd78059  * Bits for PCI access register.
1174992Sgd78059  */
1184992Sgd78059 #define	PAR_RESET	0x00000001U	/* Reset the entire chip */
1194992Sgd78059 #define	PAR_MWIE	0x01000000U	/* PCI memory-write-invalidate */
1204992Sgd78059 #define	PAR_MRLE	0x00800000U	/* PCI memory-read-line */
1214992Sgd78059 #define	PAR_MRME	0x00200000U	/* PCI memory-read-multiple */
1224992Sgd78059 #define	PAR_TXHIPRI	0x00000002U	/* Transmit higher priority */
1234992Sgd78059 #define	PAR_DESCSKIP	0x0000007cU	/* Descriptor skip length in DW */
1244992Sgd78059 #define	PAR_BIGENDIAN	0x00000080U	/* Use big endian data buffers */
1254992Sgd78059 #define	PAR_TXAUTOPOLL	0x00060000U	/* Programmable TX autopoll interval */
1264992Sgd78059 #define	PAR_RXFIFO_100	0x00009000U	/* RX FIFO control, Centaur only */
1274992Sgd78059 #define	PAR_RXFIFO_10	0x00002800U	/* RX FIFO control, Centaur only */
1284992Sgd78059 #define	PAR_CALIGN_NONE	0x00000000U	/* No cache alignment, Comet */
1294992Sgd78059 #define	PAR_CALIGN_8	0x00004000U	/* 8 DW cache alignment, Comet */
1304992Sgd78059 #define	PAR_CALIGN_16	0x00008000U	/* 16 DW cache alignment, Comet */
1314992Sgd78059 #define	PAR_CALIGN_32	0x0000c000U	/* 32 DW cache alignment, Comet */
1324992Sgd78059 #define	PAR_BURSTLEN	0x00003F00U	/* Programmable burst length, Comet */
1334992Sgd78059 #define	PAR_BURSTUNL	0x00000000U	/* Unlimited burst length, Comet */
1344992Sgd78059 #define	PAR_BURST_1	0x00000100U	/* 1 DW burst length, Comet */
1354992Sgd78059 #define	PAR_BURST_2	0x00000200U	/* 2 DW burst length, Comet */
1364992Sgd78059 #define	PAR_BURST_4	0x00000400U	/* 4 DW burst length, Comet */
1374992Sgd78059 #define	PAR_BURST_8	0x00000800U	/* 8 DW burst length, Comet */
1384992Sgd78059 #define	PAR_BURST_16	0x00001000U	/* 16 DW burst length, Comet */
1394992Sgd78059 #define	PAR_BURST_32	0x00002000U	/* 32 DW burst length, Comet */
1404992Sgd78059 
1414992Sgd78059 /*
1424992Sgd78059  * Bits for status register.
1434992Sgd78059  */
1444992Sgd78059 #define	SR_BERR_TYPE		0x03800000U	/* bus error type */
1454992Sgd78059 #define	SR_BERR_PARITY		0x00000000U	/* parity error */
1464992Sgd78059 #define	SR_BERR_TARGET_ABORT	0x01000000U	/* target abort */
1474992Sgd78059 #define	SR_BERR_MASTER_ABORT	0x00800000U	/* master abort */
1484992Sgd78059 #define	SR_TX_STATE		0x00700000U	/* transmit state */
1494992Sgd78059 #define	SR_RX_STATE		0x000E0000U	/* receive state */
1504992Sgd78059 
1514992Sgd78059 /*
1524992Sgd78059  * Interrupts.  These are in IER2 and SR2.  Some of them also appear
1534992Sgd78059  * in SR and IER, but we only use the ADMtek specific IER2 and SR2.
1544992Sgd78059  */
1554992Sgd78059 #define	INT_TXEARLY		0x80000000U	/* transmit early interrupt */
1564992Sgd78059 #define	INT_RXEARLY		0x40000000U	/* receive early interrupt */
1574992Sgd78059 #define	INT_LINKCHG		0x20000000U	/* link status changed */
1584992Sgd78059 #define	INT_TXDEFER		0x10000000U	/* transmit defer interrupt */
1594992Sgd78059 #define	INT_PAUSE		0x04000000U	/* pause frame received */
1604992Sgd78059 #define	INT_NORMAL		0x00010000U	/* normal interrupt */
1614992Sgd78059 #define	INT_ABNORMAL		0x00008000U	/* abnormal interrupt */
1624992Sgd78059 #define	INT_BUSERR		0x00002000U	/* fatal bus error */
1634992Sgd78059 #define	INT_TIMER		0x00000800U	/* onboard timer */
1644992Sgd78059 #define	INT_RXJABBER		0x00000200U	/* receive watchdog */
1654992Sgd78059 #define	INT_RXSTOPPED		0x00000100U	/* receive stopped */
1664992Sgd78059 #define	INT_RXNOBUF		0x00000080U	/* no rcv descriptor */
1674992Sgd78059 #define	INT_RXOK		0x00000040U	/* receive complete */
1684992Sgd78059 #define	INT_TXUNDERFLOW		0x00000020U	/* transmit underflow */
1694992Sgd78059 #define	INT_TXJABBER		0x00000008U	/* transmit jabber timeout */
1704992Sgd78059 #define	INT_TXNOBUF		0x00000004U	/* no xmt descriptor */
1714992Sgd78059 #define	INT_TXSTOPPED		0x00000002U	/* transmit stopped */
1724992Sgd78059 #define	INT_TXOK		0x00000001U	/* transmit ok interrupt */
1734992Sgd78059 
1744992Sgd78059 #define	INT_NONE		0x00000000U	/* no interrupts */
1754992Sgd78059 #define	INT_ALL			0xf401abefU	/* all interrupts */
1764992Sgd78059 #define	INT_WANTED		(INT_NORMAL | INT_ABNORMAL | \
1774992Sgd78059 				INT_BUSERR | INT_RXJABBER | \
1784992Sgd78059 				INT_RXOK | INT_RXNOBUF | \
1794992Sgd78059 				INT_TIMER | INT_LINKCHG | \
1804992Sgd78059 				INT_RXSTOPPED | INT_TXSTOPPED | \
1814992Sgd78059 				INT_TXUNDERFLOW | INT_TXJABBER)
1824992Sgd78059 
1834992Sgd78059 /*
1844992Sgd78059  * Bits for network access register.
1854992Sgd78059  */
1864992Sgd78059 #define	NAR_TX_ENABLE	0x00002000U	/* Enable transmit */
1874992Sgd78059 #define	NAR_RX_MULTI	0x00000080U	/* Receive all multicast packets */
1884992Sgd78059 #define	NAR_RX_PROMISC	0x00000040U	/* Receive any good packet */
1894992Sgd78059 #define	NAR_RX_BAD	0x00000008U	/* Pass bad packets */
1904992Sgd78059 #define	NAR_RX_ENABLE	0x00000002U	/* Enable receive */
1914992Sgd78059 #define	NAR_TR		0x0000c000U	/* Transmit threshold mask */
1924992Sgd78059 #define	NAR_TR_72	0x00000000U	/* 72 B (128 @ 100Mbps) tx thresh */
1934992Sgd78059 #define	NAR_TR_96	0x00004000U	/* 96 B (256 @ 100Mbps) tx thresh */
1944992Sgd78059 #define	NAR_TR_128	0x00008000U	/* 128 B (512 @ 100Mbps) tx thresh */
1954992Sgd78059 #define	NAR_TR_160	0x0000c000U	/* 160 B (1K @ 100Mbsp) tx thresh */
1964992Sgd78059 #define	NAR_SF		0x00200000U	/* store and forward */
1974992Sgd78059 #define	NAR_HBD		0x00080000U	/* Disable SQE heartbeat */
1984992Sgd78059 #define	NAR_FCOLL	0x00001000U	/* force collision */
1994992Sgd78059 #define	NAR_MODE	0x00000c00U	/* mode (loopback, etc.) */
2004992Sgd78059 #define	NAR_MACLOOP	0x00000400U	/* mac loop back */
2014992Sgd78059 
2024992Sgd78059 /*
2034992Sgd78059  * Bits for lost packet counter.
2044992Sgd78059  */
2054992Sgd78059 #define	LPC_COUNT	0x0000FFFFU	/* Count of missed frames */
2064992Sgd78059 #define	LPC_OFLOW	0x00010000U	/* Counter overflow bit */
2074992Sgd78059 
2084992Sgd78059 /*
2094992Sgd78059  * Bits for CSR_SPR (MII and SROM access)
2104992Sgd78059  */
2114992Sgd78059 #define	SPR_MII_DIN	0x00080000U	/* MII data input */
2124992Sgd78059 #define	SPR_MII_CTRL	0x00040000U	/* MII management control, 1=read */
2134992Sgd78059 #define	SPR_MII_DOUT	0x00020000U	/* MII data output */
2144992Sgd78059 #define	SPR_MII_CLOCK	0x00010000U	/* MII data clock */
2154992Sgd78059 #define	SPR_SROM_READ	0x00004000U	/* Serial EEPROM read control */
2164992Sgd78059 #define	SPR_SROM_WRITE	0x00002000U	/* Serial EEPROM write control */
2174992Sgd78059 #define	SPR_SROM_SEL	0x00000800U	/* Serial EEPROM select */
2184992Sgd78059 #define	SPR_SROM_DOUT	0x00000008U	/* Serial EEPROM data out */
2194992Sgd78059 #define	SPR_SROM_DIN	0x00000004U	/* Serial EEPROM data in */
2204992Sgd78059 #define	SPR_SROM_CLOCK	0x00000002U	/* Serial EEPROM clock */
2214992Sgd78059 #define	SPR_SROM_CHIP	0x00000001U	/* Serial EEPROM chip select */
2224992Sgd78059 #define	SROM_ENADDR		0x4	/* Offset of ethernet address */
2234992Sgd78059 #define	SROM_READCMD		0x6	/* command to read SROM */
2244992Sgd78059 
2254992Sgd78059 /*
2264992Sgd78059  * Bits for CSR_TIMER
2274992Sgd78059  */
2284992Sgd78059 #define	TIMER_LOOP	0x00010000U	/* continuous operating mode */
2294992Sgd78059 #define	TIMER_USEC		204		/* usecs per timer count */
2304992Sgd78059 
2314992Sgd78059 /*
2324992Sgd78059  * Bits for CSR_CR
2334992Sgd78059  */
234*9860Sgdamore@opensolaris.org #define	CR_PAUSE	0x00000020U	/* enable pause flow control */
2354992Sgd78059 #define	CR_TXURAUTOR	0x00000001U	/* transmit underrun auto recovery */
2364992Sgd78059 
2374992Sgd78059 /*
2384992Sgd78059  * Bits for XMC (Comet specific)
2394992Sgd78059  */
2404992Sgd78059 #define	XMC_LDIS	0x0800		/* long distance 10Base-T cable */
2414992Sgd78059 
2424992Sgd78059 /*
2434992Sgd78059  * Bits for XCIIS (Comet specific)
2444992Sgd78059  */
2454992Sgd78059 #define	XCIIS_SPEED		0x0200	/* 100 Mbps mode */
2464992Sgd78059 #define	XCIIS_DUPLEX		0x0100	/* full duplex mode */
2474992Sgd78059 #define	XCIIS_FLOWCTL		0x0080	/* flow control support */
2484992Sgd78059 #define	XCIIS_ANC		0x0040	/* autonegotiation complete */
2494992Sgd78059 #define	XCIIS_RF		0x0020	/* remote fault detected */
2504992Sgd78059 #define	XCIIS_LFAIL		0x0010	/* link fail */
2514992Sgd78059 #define	XCIIS_ANLPAR		0x0008	/* anar received from link partner */
2524992Sgd78059 #define	XCIIS_PDF		0x0004	/* parallel detection fault */
2534992Sgd78059 #define	XCIIS_ANPR		0x0002	/* autoneg. page received */
2544992Sgd78059 #define	XCIIS_REF		0x0001	/* receive error counter full */
2554992Sgd78059 
2564992Sgd78059 /*
2574992Sgd78059  * Bits for XIE (Comet specific)
2584992Sgd78059  */
2594992Sgd78059 #define	XIE_ANCE		0x0040	/* aneg complete interrupt enable */
2604992Sgd78059 #define	XIE_RFE			0x0020	/* remote fault interrupt enable */
2614992Sgd78059 #define	XIE_LDE			0x0010	/* link fail interrupt enable */
2624992Sgd78059 #define	XIE_ANAE		0x0008	/* aneg. ack. interrupt enable */
2634992Sgd78059 #define	XIE_PDFE		0x0004	/* parallel det. fault int. enable */
2644992Sgd78059 #define	XIE_ANPE		0x0002	/* autoneg. page rec'd int. enable */
2654992Sgd78059 #define	XIE_REFE		0x0001	/* receive error full int. enable */
2664992Sgd78059 
2674992Sgd78059 /*
2684992Sgd78059  * Centaur 1.1 extensions to MII.
2694992Sgd78059  */
2704992Sgd78059 #define	PHY_PILR	0x10		/* an983b 1.1 - polarity/int lvl */
2714992Sgd78059 #define	PHY_MCR		0x15		/* an983b 1.1 - mode control */
2724992Sgd78059 
2734992Sgd78059 #define	PILR_NOSQE	0x0800		/* disable 10BaseT SQE */
2744992Sgd78059 #define	MCR_FIBER	0x0001		/* enable fiber */
2754992Sgd78059 
2764992Sgd78059 /*
2774992Sgd78059  * Bits for Opmode (Centaur specific)
2784992Sgd78059  */
2794992Sgd78059 #define	OPM_SPEED	0x80000000U	/* 100 Mbps */
2804992Sgd78059 #define	OPM_DUPLEX	0x40000000U	/* full duplex */
2814992Sgd78059 #define	OPM_LINK	0x20000000U	/* link up? */
2824992Sgd78059 #define	OPM_MODE	0x00000007U	/* mode mask */
2834992Sgd78059 #define	OPM_INTPHY	0x00000007U	/* single chip mode, internal PHY */
2844992Sgd78059 #define	OPM_MACONLY	0x00000004U	/* MAC ony mode, external PHY */
2854992Sgd78059 
2864992Sgd78059 #ifdef	_KERNEL
2874992Sgd78059 /*
2884992Sgd78059  * Put exported kernel interfaces here.  (There should be none.)
2894992Sgd78059  */
2904992Sgd78059 #endif	/* _KERNEL */
2914992Sgd78059 
2924992Sgd78059 #ifdef __cplusplus
2934992Sgd78059 }
2944992Sgd78059 #endif
2954992Sgd78059 
2964992Sgd78059 #endif	/* _AFE_H */
297