xref: /titanic_52/usr/src/uts/common/io/hme/hme_mac.h (revision 7a92e70fb4f00cd79ef310c87c0daca81976ce9e)
10219346bSGarrett D'Amore /*
20219346bSGarrett D'Amore  * CDDL HEADER START
30219346bSGarrett D'Amore  *
40219346bSGarrett D'Amore  * The contents of this file are subject to the terms of the
50219346bSGarrett D'Amore  * Common Development and Distribution License (the "License").
60219346bSGarrett D'Amore  * You may not use this file except in compliance with the License.
70219346bSGarrett D'Amore  *
80219346bSGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90219346bSGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
100219346bSGarrett D'Amore  * See the License for the specific language governing permissions
110219346bSGarrett D'Amore  * and limitations under the License.
120219346bSGarrett D'Amore  *
130219346bSGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
140219346bSGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150219346bSGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
160219346bSGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
170219346bSGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
180219346bSGarrett D'Amore  *
190219346bSGarrett D'Amore  * CDDL HEADER END
200219346bSGarrett D'Amore  */
210219346bSGarrett D'Amore /*
22*7a92e70fSZeeshanul Huq - Sun Microsystems - Beijing China  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
230219346bSGarrett D'Amore  */
240219346bSGarrett D'Amore 
250219346bSGarrett D'Amore #ifndef	HME_MAC_H
260219346bSGarrett D'Amore #define	HME_MAC_H
270219346bSGarrett D'Amore 
280219346bSGarrett D'Amore /*
290219346bSGarrett D'Amore  * HOST MEMORY DATA STRUCTURES
300219346bSGarrett D'Amore  */
310219346bSGarrett D'Amore 
320219346bSGarrett D'Amore /* The pointers to the Descriptor Ring base Addresses must be 2K-byte aligned */
330219346bSGarrett D'Amore 
340219346bSGarrett D'Amore #define	HME_HMDALIGN	(2048)
350219346bSGarrett D'Amore 
360219346bSGarrett D'Amore /*
370219346bSGarrett D'Amore  * The transmit and receiver Descriptor Rings are organized as "wrap-around
380219346bSGarrett D'Amore  * descriptors of programmable size.
390219346bSGarrett D'Amore  */
400219346bSGarrett D'Amore #define	HME_TMDMAX	(64)	/* Transmit descriptor ring size */
410219346bSGarrett D'Amore #define	HME_RMDMAX	(64)	/* Receive descriptor ring size */
420219346bSGarrett D'Amore 
430219346bSGarrett D'Amore /* Transmit descriptor structure */
440219346bSGarrett D'Amore 
450219346bSGarrett D'Amore struct hme_tmd {
460219346bSGarrett D'Amore 	uint_t	tmd_flags;	/* OWN, SOP, EOP, cksum ctl and bufize */
470219346bSGarrett D'Amore 	uint_t	tmd_addr;	/* 8-bye aligned buffer address */
480219346bSGarrett D'Amore };
490219346bSGarrett D'Amore 
500219346bSGarrett D'Amore /* fields in the tmd_flags */
510219346bSGarrett D'Amore 
520219346bSGarrett D'Amore #define	HMETMD_BUFSIZE	(0x3fff << 0)	/* 0-13 : Tx Data buffer size */
530219346bSGarrett D'Amore #define	HMETMD_CSSTART	(0x3f << 14)	/* 14-19 : Checksum start offset */
540219346bSGarrett D'Amore #define	HMETMD_CSSTUFF	(0xff << 20)	/* 20-27 : Checksum stuff offset */
550219346bSGarrett D'Amore #define	HMETMD_CSENABL	(1 << 28)	/* 28 : Enable checksum computation */
560219346bSGarrett D'Amore #define	HMETMD_EOP	(1 << 29)	/* 29 : End Of Packet flag */
570219346bSGarrett D'Amore #define	HMETMD_SOP	(1 << 30)	/* 30 : Start Of Packet flag */
580219346bSGarrett D'Amore #define	HMETMD_OWN	(0x80000000)	/* 31 : Ownership flag */
590219346bSGarrett D'Amore 					/* 0 - owned by software */
600219346bSGarrett D'Amore 					/* 1 - owned by hardware */
610219346bSGarrett D'Amore 
62*7a92e70fSZeeshanul Huq - Sun Microsystems - Beijing China #define	HMETMD_CSSTART_MAX	0x3f	/* Maximum checksum start offset */
63*7a92e70fSZeeshanul Huq - Sun Microsystems - Beijing China #define	HMETMD_CSSTUFF_MAX	0xff	/* Maximum checksum stuff offset */
640219346bSGarrett D'Amore #define	HMETMD_CSSTART_SHIFT 14	/* checksum start bit position */
650219346bSGarrett D'Amore #define	HMETMD_CSSTUFF_SHIFT 20	/* checksum stuff bit position */
660219346bSGarrett D'Amore 
670219346bSGarrett D'Amore /*
680219346bSGarrett D'Amore  *	Programming Notes:
690219346bSGarrett D'Amore  *
700219346bSGarrett D'Amore  *	1. If a packet occupies more than one descriptor, the software must
710219346bSGarrett D'Amore  *	turn over the ownership of the descriptors to the hardware
720219346bSGarrett D'Amore  *	"last-to-first", in order to avoid race conditions.
730219346bSGarrett D'Amore  *
740219346bSGarrett D'Amore  *	2. If a packet resides in more than one buffer, the Checksum_Enable,
750219346bSGarrett D'Amore  *	Checksum_Stuff_Offset and Checksum_Start_Offset fields must have the
760219346bSGarrett D'Amore  *	same values in all the descriptors that were allocated to the packet.
770219346bSGarrett D'Amore  *
780219346bSGarrett D'Amore  *	3. The hardware implementation relies on the fact that if a buffer
790219346bSGarrett D'Amore  *	starts at an "odd" boundary, the DMA state machine can "rewind"
800219346bSGarrett D'Amore  *	to the nearest burst boundary and execute a full DVMA burst Read.
810219346bSGarrett D'Amore  *
820219346bSGarrett D'Amore  *	There is no other alignment restriction for the transmit data buffer.
830219346bSGarrett D'Amore  */
840219346bSGarrett D'Amore 
850219346bSGarrett D'Amore /* Receive Descriptor structure */
860219346bSGarrett D'Amore 
870219346bSGarrett D'Amore struct hme_rmd {
880219346bSGarrett D'Amore 	uint_t	rmd_flags;	/* OWN, OVFLOW, buf/data size, cksum */
890219346bSGarrett D'Amore 	uint_t	rmd_addr;	/* 8-byte aligned buffer address */
900219346bSGarrett D'Amore };
910219346bSGarrett D'Amore 
920219346bSGarrett D'Amore /* fields in the rmd_flags */
930219346bSGarrett D'Amore 
940219346bSGarrett D'Amore #define	HMERMD_CKSUM	(0xffff << 0)	/* 0-15 : checksum computed */
950219346bSGarrett D'Amore #define	HMERMD_BUFSIZE	(0x3fff << 16)	/* 16-29 : buffer/data size */
960219346bSGarrett D'Amore #define	HMERMD_OVFLOW	(1 << 30)	/* 30 : Rx buffer overflow */
970219346bSGarrett D'Amore #define	HMERMD_OWN	(0x80000000)	/* 31 : Ownership flag */
980219346bSGarrett D'Amore 					/* 0 - owned by software */
990219346bSGarrett D'Amore 					/* 1 - owned by hardware */
1000219346bSGarrett D'Amore 
1010219346bSGarrett D'Amore #define	HMERMD_BUFSIZE_SHIFT 16	/* buffer/data size bit position */
1020219346bSGarrett D'Amore 
1030219346bSGarrett D'Amore /* ************************************************************************* */
1040219346bSGarrett D'Amore 
1050219346bSGarrett D'Amore /* Global Register set in SEB (Shared Ethernet Block) */
1060219346bSGarrett D'Amore 
1070219346bSGarrett D'Amore struct hme_global {
1080219346bSGarrett D'Amore     uint_t reset;		/* Global Software Reset Command */
1090219346bSGarrett D'Amore     uint_t config;		/* Global Configuration Register */
1100219346bSGarrett D'Amore     uint_t reserved[62];
1110219346bSGarrett D'Amore     uint_t status;		/* Global Status Register */
1120219346bSGarrett D'Amore     uint_t intmask;		/* Global Interrupt Mask Register */
1130219346bSGarrett D'Amore };
1140219346bSGarrett D'Amore 
1150219346bSGarrett D'Amore 
1160219346bSGarrett D'Amore /*
1170219346bSGarrett D'Amore  * Global Software Reset Command Register - RW
1180219346bSGarrett D'Amore  * These bits become "self cleared" after the corresponding reset command
1190219346bSGarrett D'Amore  * has been executed. After a reset, the software must poll this register
1200219346bSGarrett D'Amore  * till both the bits are read as 0's.
1210219346bSGarrett D'Amore  */
1220219346bSGarrett D'Amore 
1230219346bSGarrett D'Amore #define	HMEG_RESET_ETX	(1 << 0)	/* Reset ETX */
1240219346bSGarrett D'Amore #define	HMEG_RESET_ERX	(1 << 1)	/* Reset ERX */
1250219346bSGarrett D'Amore 
1260219346bSGarrett D'Amore #define	HMEG_RESET_GLOBAL HMEG_RESET_ETX | HMEG_RESET_ERX
1270219346bSGarrett D'Amore 
1280219346bSGarrett D'Amore 
1290219346bSGarrett D'Amore /* Global Configuration Register - RW */
1300219346bSGarrett D'Amore 
1310219346bSGarrett D'Amore #define	HMEG_CONFIG_BURSTSZ	(0x3 << 0)	/* sbus max burst size */
1320219346bSGarrett D'Amore #define	HMEG_CONFIG_64BIT_XFER	(1 << 2)	/* Extended transfer mode */
1330219346bSGarrett D'Amore #define	HMEG_CONFIG_PARITY	(1 << 3)	/* sbus parity enable */
1340219346bSGarrett D'Amore #define	HMEG_CONFIG_RES1	(1 << 4)	/* reserved, should be 0 */
1350219346bSGarrett D'Amore 
1360219346bSGarrett D'Amore #define	HMEG_CONFIG_BURST16	0x00	/* sbus max burst size 16 */
1370219346bSGarrett D'Amore #define	HMEG_CONFIG_BURST32	0x01	/* sbus max burst size 32 */
1380219346bSGarrett D'Amore #define	HMEG_CONFIG_BURST64	0x02	/* sbus max burst size 64 */
1390219346bSGarrett D'Amore #define	HMEG_CONFIG_BURST_RES	0x03	/* sbus max burst size - reserved */
1400219346bSGarrett D'Amore 
1410219346bSGarrett D'Amore #define	HMEG_CONFIG_64BIT_SHIFT	2
1420219346bSGarrett D'Amore /*
1430219346bSGarrett D'Amore  * Global Status Register - R-AC
1440219346bSGarrett D'Amore  *
1450219346bSGarrett D'Amore  * All the bits in the Global Status Register are automatically cleared when
1460219346bSGarrett D'Amore  * read with the exception of bit 23. The MIF status bit will be cleared after
1470219346bSGarrett D'Amore  * the MIF Status Register is read.
1480219346bSGarrett D'Amore  */
1490219346bSGarrett D'Amore 
1500219346bSGarrett D'Amore 
1510219346bSGarrett D'Amore #define	HMEG_STATUS_FRAME_RCVD	(1 << 0)	/* from RX_MAC to RxFIFO */
1520219346bSGarrett D'Amore #define	HMEG_STATUS_RXF_CNT_EXP	(1 << 1)	/* Rx_frame_counter expired */
1530219346bSGarrett D'Amore #define	HMEG_STATUS_ALN_CNT_EXP	(1 << 2)	/* Alignment_Error_cntr exp */
1540219346bSGarrett D'Amore #define	HMEG_STATUS_CRC_CNT_EXP	(1 << 3)	/* CRC_Error_counter expired */
1550219346bSGarrett D'Amore #define	HMEG_STATUS_LEN_CNT_EXP	(1 << 4)	/* Length_Error_counter exp */
1560219346bSGarrett D'Amore #define	HMEG_STATUS_RXFIFO_OVFL	(1 << 5)	/* RxFIFO_Overflow in RX_MAC */
1570219346bSGarrett D'Amore #define	HMEG_STATUS_RCV_CNT_EXP	(1 << 6)	/* Code_Violation_counter exp */
1580219346bSGarrett D'Amore #define	HMEG_STATUS_SQE_TST_ERR	(1 << 7)	/* SQE Test error in XIF */
1590219346bSGarrett D'Amore 
1600219346bSGarrett D'Amore #define	HMEG_STATUS_FRAME_SENT	(1 << 8)	/* Frame sent from TX_MAC */
1610219346bSGarrett D'Amore #define	HMEG_STATUS_TXFIFO_UNDR	(1 << 9)	/* TxFIFO Underrun in TX_MAC */
1620219346bSGarrett D'Amore #define	HMEG_STATUS_MXPKTSZ_ERR	(1 << 10)	/* Maximum_Packet_Size error */
1630219346bSGarrett D'Amore #define	HMEG_STATUS_NRMCOLC_EXP	(1 << 11)	/* Normal_collision_cntr exp */
1640219346bSGarrett D'Amore #define	HMEG_STATUS_EXCOLC_EXP	(1 << 12)	/* Excessive_coll_cntr exp */
1650219346bSGarrett D'Amore #define	HMEG_STATUS_LATCOLC_EXP	(1 << 13)	/* Late_Collision_cntr exp */
1660219346bSGarrett D'Amore #define	HMEG_STATUS_FSTCOLC_EXP	(1 << 14)	/* First_Coll_cntr expired */
1670219346bSGarrett D'Amore #define	HMEG_STATUS_DEFTIMR_EXP	(1 << 15)	/* Defer_Timer expired */
1680219346bSGarrett D'Amore 
1690219346bSGarrett D'Amore #define	HMEG_STATUS_RINT	(1 << 16)	/* from RxFIFO to host memory */
1700219346bSGarrett D'Amore #define	HMEG_STATUS_RX_DROP	(1 << 17)	/* No free Rx descriptors */
1710219346bSGarrett D'Amore #define	HMEG_STATUS_RX_ERR_ACK	(1 << 18)	/* Error Ack in Rx DMA cycle */
1720219346bSGarrett D'Amore #define	HMEG_STATUS_RX_LATE_ERR	(1 << 19)	/* Late Error in Rx DMA cycle */
1730219346bSGarrett D'Amore #define	HMEG_STATUS_RX_PAR_ERR	(1 << 20)	/* Parity error in Rx DMA */
1740219346bSGarrett D'Amore #define	HMEG_STATUS_RX_TAG_ERR	(1 << 21)	/* No two consecutiv tag bits */
1750219346bSGarrett D'Amore #define	HMEG_STATUS_EOP_ERR	(1 << 22)	/* EOP not set in Tx desc */
1760219346bSGarrett D'Amore #define	HMEG_STATUS_MIF_INTR	(1 << 23)	/* MIF interrupt */
1770219346bSGarrett D'Amore 
1780219346bSGarrett D'Amore #define	HMEG_STATUS_TINT	(1 << 24)	/* from host mem to TxFIFO */
1790219346bSGarrett D'Amore #define	HMEG_STATUS_TX_ALL	(1 << 25)	/* TxFIFO empty */
1800219346bSGarrett D'Amore #define	HMEG_STATUS_TX_ERR_ACK	(1 << 26)	/* Error Ack in Tx DMA cycle */
1810219346bSGarrett D'Amore #define	HMEG_STATUS_TX_LATE_ERR	(1 << 27)	/* Late error in Tx DMA cycle */
1820219346bSGarrett D'Amore #define	HMEG_STATUS_TX_PAR_ERR	(1 << 28)	/* Parity error in Tx DMA */
1830219346bSGarrett D'Amore #define	HMEG_STATUS_TX_TAG_ERR	(1 << 29)	/* No two consecutiv tag bits */
1840219346bSGarrett D'Amore #define	HMEG_STATUS_SLV_ERR_ACK	(1 << 30)	/* Error Ack in PIO cycle */
1850219346bSGarrett D'Amore #define	HMEG_STATUS_SLV_PAR_ERR	(0x80000000)	/* Parity error in PIO write */
1860219346bSGarrett D'Amore 
1870219346bSGarrett D'Amore #define	HMEG_STATUS_FATAL_ERR	 0xfc7c0000	/* all fatal errors */
1880219346bSGarrett D'Amore #define	HMEG_STATUS_NONFATAL_ERR 0x0002fefc	/* all non-fatal errors */
1890219346bSGarrett D'Amore #define	HMEG_STATUS_NORMAL_INT	 0x01810000	/* normal interrupts */
1900219346bSGarrett D'Amore 
1910219346bSGarrett D'Amore #define	HMEG_STATUS_INTR	 0xfefffefc 	/* All interesting interrupts */
1920219346bSGarrett D'Amore 
1930219346bSGarrett D'Amore /*
1940219346bSGarrett D'Amore  * Global Interrupt Mask register
1950219346bSGarrett D'Amore  *
1960219346bSGarrett D'Amore  * There is one-to-one correspondence between the bits in this register and
1970219346bSGarrett D'Amore  * the Global Status register.
1980219346bSGarrett D'Amore  *
1990219346bSGarrett D'Amore  * The MIF interrupt [bit 23] is not maskable here. It should be masked at the
2000219346bSGarrett D'Amore  * source of the interrupt in the MIF.
2010219346bSGarrett D'Amore  *
2020219346bSGarrett D'Amore  * Default value of the Global Interrupt Mask register is 0xFF7FFFFF.
2030219346bSGarrett D'Amore  */
2040219346bSGarrett D'Amore 
2050219346bSGarrett D'Amore #define	HMEG_MASK_FRAME_RCVD	(1 << 0)	/* from RX_MAC to RxFIFO */
2060219346bSGarrett D'Amore #define	HMEG_MASK_RXF_CNT_EXP	(1 << 1)	/* Rx_frame_counter expired */
2070219346bSGarrett D'Amore #define	HMEG_MASK_ALN_CNT_EXP	(1 << 2)	/* Alignment_Error_cntr exp */
2080219346bSGarrett D'Amore #define	HMEG_MASK_CRC_CNT_EXP	(1 << 3)	/* CRC_Error_counter expired */
2090219346bSGarrett D'Amore #define	HMEG_MASK_LEN_CNT_EXP	(1 << 4)	/* Length_Error_counter exp */
2100219346bSGarrett D'Amore #define	HMEG_MASK_RXFIFO_OVFL	(1 << 5)	/* RxFIFO_Overflow in RX_MAC */
2110219346bSGarrett D'Amore #define	HMEG_MASK_RCV_CNT_EXP	(1 << 6)	/* Code_Violation_counter exp */
2120219346bSGarrett D'Amore #define	HMEG_MASK_SQE_TST_ERR	(1 << 7)	/* SQE Test error in XIF */
2130219346bSGarrett D'Amore 
2140219346bSGarrett D'Amore #define	HMEG_MASK_FRAME_SENT	(1 << 8)	/* Frame sent from TX_MAC */
2150219346bSGarrett D'Amore #define	HMEG_MASK_TXFIFO_UNDR	(1 << 9)	/* TxFIFO Underrun in TX_MAC */
2160219346bSGarrett D'Amore #define	HMEG_MASK_MXPKTSZ_ERR	(1 << 10)	/* Maximum_Packet_Size error */
2170219346bSGarrett D'Amore #define	HMEG_MASK_NRMCOLC_EXP	(1 << 11)	/* Normal_collision_cntr exp */
2180219346bSGarrett D'Amore #define	HMEG_MASK_EXECOLC_EXP	(1 << 12)	/* Excessive_coll_cntr exp */
2190219346bSGarrett D'Amore #define	HMEG_MASK_LATCOLC_EXP	(1 << 13)	/* Late_Collision_cntr exp */
2200219346bSGarrett D'Amore #define	HMEG_MASK_FSTCOLC_EXP	(1 << 14)	/* First_Coll_cntr expired */
2210219346bSGarrett D'Amore #define	HMEG_MASK_DEFTIMR_EXP	(1 << 15)	/* Defer_Timer expired */
2220219346bSGarrett D'Amore 
2230219346bSGarrett D'Amore #define	HMEG_MASK_RINT		(1 << 16)	/* from RxFIFO to host memory */
2240219346bSGarrett D'Amore #define	HMEG_MASK_RX_DROP	(1 << 17)	/* No free Rx descriptors */
2250219346bSGarrett D'Amore #define	HMEG_MASK_RX_ERR_ACK	(1 << 18)	/* Error Ack in Rx DMA cycle */
2260219346bSGarrett D'Amore #define	HMEG_MASK_RX_LATE_ERR	(1 << 19)	/* Late Error in Rx DMA cycle */
2270219346bSGarrett D'Amore #define	HMEG_MASK_RX_PAR_ERR	(1 << 20)	/* Parity error in Rx DMA */
2280219346bSGarrett D'Amore #define	HMEG_MASK_RX_TAG_ERR	(1 << 21)	/* No two consecutiv tag bits */
2290219346bSGarrett D'Amore #define	HMEG_MASK_EOP_ERR	(1 << 22)	/* EOP not set in Tx desc */
2300219346bSGarrett D'Amore #define	HMEG_MASK_MIF_INTR	(1 << 23)	/* MIF interrupt */
2310219346bSGarrett D'Amore 
2320219346bSGarrett D'Amore #define	HMEG_MASK_TINT		(1 << 24)	/* from host mem to TxFIFO */
2330219346bSGarrett D'Amore #define	HMEG_MASK_TX_ALL	(1 << 25)	/* TxFIFO empty */
2340219346bSGarrett D'Amore #define	HMEG_MASK_TX_ERR_ACK	(1 << 26)	/* Error Ack in Tx DMA cycle */
2350219346bSGarrett D'Amore #define	HMEG_MASK_TX_LATE_ERR	(1 << 27)	/* Late error in Tx DMA cycle */
2360219346bSGarrett D'Amore #define	HMEG_MASK_TX_PAR_ERR	(1 << 28)	/* Parity error in Tx DMA */
2370219346bSGarrett D'Amore #define	HMEG_MASK_TX_TAG_ERR	(1 << 29)	/* No two consecutiv tag bits */
2380219346bSGarrett D'Amore #define	HMEG_MASK_SLV_ERR_ACK	(1 << 30)	/* Error Ack in PIO cycle */
2390219346bSGarrett D'Amore #define	HMEG_MASK_SLV_PAR_ERR	(0x80000000)	/* Parity error in PIO write */
2400219346bSGarrett D'Amore 
2410219346bSGarrett D'Amore #define	HMEG_MASK_INTR		(~HMEG_STATUS_INTR)
2420219346bSGarrett D'Amore 						/* uninteresting interrupts */
2430219346bSGarrett D'Amore 
2440219346bSGarrett D'Amore /*
2450219346bSGarrett D'Amore  *	Interrupts which are not interesting are:
2460219346bSGarrett D'Amore  *	HMEG_MASK_FRAME_SENT
2470219346bSGarrett D'Amore  *	HMEG_MASK_RXF_CNT_EXP
2480219346bSGarrett D'Amore  *	HMEG_MASK_FRAME_RCVD
2490219346bSGarrett D'Amore  */
2500219346bSGarrett D'Amore 
2510219346bSGarrett D'Amore /* ************************************************************************* */
2520219346bSGarrett D'Amore 
2530219346bSGarrett D'Amore /* ETX Register set */
2540219346bSGarrett D'Amore 
2550219346bSGarrett D'Amore struct hme_etx {
2560219346bSGarrett D'Amore     uint_t txpend;		/* Transmit Pending Command */
2570219346bSGarrett D'Amore     uint_t config;		/* ETX Configuration Register */
2580219346bSGarrett D'Amore     uint_t txring;		/* Transmit Descriptor Ring Pointer */
2590219346bSGarrett D'Amore     uint_t txbuf_base;		/* Transmit Data Buffer Base Address */
2600219346bSGarrett D'Amore     uint_t txbuf_disp;		/* Transmit Data Buffer Displacement */
2610219346bSGarrett D'Amore     uint_t txfifo_wr_ptr;	/* TxFIFO Write Pointer */
2620219346bSGarrett D'Amore     uint_t txfifo_sdwr_ptr;	/* TxFIFO Shadow Write Pointer */
2630219346bSGarrett D'Amore     uint_t txfifo_rd_ptr;	/* TxFIFO Read pointer */
2640219346bSGarrett D'Amore     uint_t txfifo_sdrd_ptr;	/* TxFIFO Shadow Read pointer */
2650219346bSGarrett D'Amore     uint_t txfifo_pkt_cnt;	/* TxFIFO Packet Counter */
2660219346bSGarrett D'Amore     uint_t state_mach;		/* ETX State Machine Register */
2670219346bSGarrett D'Amore     uint_t txring_size;		/* Descriptor Ring Size */
2680219346bSGarrett D'Amore     uint_t txbuf_ptr;		/* Transmit Data Buffer Pointer */
2690219346bSGarrett D'Amore };
2700219346bSGarrett D'Amore 
2710219346bSGarrett D'Amore /*
2720219346bSGarrett D'Amore  * ETX Transmit Pending Command Register - RW
2730219346bSGarrett D'Amore  * This 1-bit command must be issued by the software for every packet that the
2740219346bSGarrett D'Amore  * driver posts to the hardware.
2750219346bSGarrett D'Amore  * This bit becomes "self-cleared" after the command is executed.
2760219346bSGarrett D'Amore  */
2770219346bSGarrett D'Amore 
2780219346bSGarrett D'Amore #define	HMET_TXPEND_TDMD	(1 << 0)	/* wake up Tx DMA engine */
2790219346bSGarrett D'Amore 
2800219346bSGarrett D'Amore /*
2810219346bSGarrett D'Amore  * ETX Configuration Register
2820219346bSGarrett D'Amore  * If the desire is to buffer an entire standard Ethernet frame before its
2830219346bSGarrett D'Amore  * transmission is enabled, the Tx-FIFO-Threshold field has to be proframmed
2840219346bSGarrett D'Amore  * to "0x1ff".
2850219346bSGarrett D'Amore  * The default value for the register is 0x3fe.
2860219346bSGarrett D'Amore  * Bit 10 is used to modify the functionality of the Tx_All interrupt.
2870219346bSGarrett D'Amore  * If it is 0, Tx_All interrupt is generated after processing the last
2880219346bSGarrett D'Amore  * transmit descriptor with the OWN bit set. This only implies that the
2890219346bSGarrett D'Amore  * data has been copied to the FIFO.
2900219346bSGarrett D'Amore  * If it is 1, Tx_All interrupt is generated only after the entire
2910219346bSGarrett D'Amore  * Transmit FIFO has been drained.
2920219346bSGarrett D'Amore  */
2930219346bSGarrett D'Amore 
2940219346bSGarrett D'Amore #define	HMET_CONFIG_TXDMA_EN	(1 << 0)	/* Enable Tx DMA */
2950219346bSGarrett D'Amore #define	HMET_CONFIG_TXFIFOTH	(0x1ff << 1)	/* 1-9 : TX FIFO Threshold */
2960219346bSGarrett D'Amore #define	HMET_CONFIG_DRAIN_INT	(1 << 10)	/* TX_all_int modifier */
2970219346bSGarrett D'Amore 
2980219346bSGarrett D'Amore /*
2990219346bSGarrett D'Amore  * Transmit Descriptor Pointer
3000219346bSGarrett D'Amore  *
3010219346bSGarrett D'Amore  * This 29-bit register points to the next descriptor in the ring. The 21 most
3020219346bSGarrett D'Amore  * significant bits are used as the base address for the desriptor ring,
3030219346bSGarrett D'Amore  * and the 8 least significant bits are used as a displacement for the current
3040219346bSGarrett D'Amore  * descriptor.
3050219346bSGarrett D'Amore  *
3060219346bSGarrett D'Amore  * This register should be initialized to a 2KByte-aligned value after power-on
3070219346bSGarrett D'Amore  * or Software Reset.
3080219346bSGarrett D'Amore  *
3090219346bSGarrett D'Amore  */
3100219346bSGarrett D'Amore 
3110219346bSGarrett D'Amore /*
3120219346bSGarrett D'Amore  * ETX TX ring size register
3130219346bSGarrett D'Amore  * This is a 4-bit register to determine the no. of descriptor entries in the
3140219346bSGarrett D'Amore  * TX-ring. The number of entries can vary from 16 through 256 in increments of
3150219346bSGarrett D'Amore  * 16.
3160219346bSGarrett D'Amore  */
3170219346bSGarrett D'Amore 
3180219346bSGarrett D'Amore #define	HMET_RINGSZ_SHIFT	4
3190219346bSGarrett D'Amore 
3200219346bSGarrett D'Amore /* ************************************************************************* */
3210219346bSGarrett D'Amore 
3220219346bSGarrett D'Amore /* ERX Register Set */
3230219346bSGarrett D'Amore 
3240219346bSGarrett D'Amore struct hme_erx {
3250219346bSGarrett D'Amore     uint_t config;		/* ERX Configuration Register */
3260219346bSGarrett D'Amore     uint_t rxring;		/* Receive Descriptor Ring Pointer */
3270219346bSGarrett D'Amore     uint_t rxbuf_ptr;		/* Receive Data Buffer Pointer */
3280219346bSGarrett D'Amore     uint_t rxfifo_wr_ptr;	/* RxFIFO Write Pointer */
3290219346bSGarrett D'Amore     uint_t rxfifo_sdwr_ptr;	/* RxFIFO Shadow Write Pointer */
3300219346bSGarrett D'Amore     uint_t rxfifo_rd_ptr;	/* RxFIFO Read pointer */
3310219346bSGarrett D'Amore     uint_t rxfifo_pkt_cnt;	/* RxFIFO Packet Counter */
3320219346bSGarrett D'Amore     uint_t state_mach;		/* ERX State Machine Register */
3330219346bSGarrett D'Amore };
3340219346bSGarrett D'Amore 
3350219346bSGarrett D'Amore /*
3360219346bSGarrett D'Amore  * ERX Configuration Register - RW
3370219346bSGarrett D'Amore  * This 23-bit register determines the ERX-specific parameters that control the
3380219346bSGarrett D'Amore  * operation of the receive DMA channel.
3390219346bSGarrett D'Amore  */
3400219346bSGarrett D'Amore 
3410219346bSGarrett D'Amore #define	HMER_CONFIG_RXDMA_EN	(1 << 0)	/* 0 : Enable Rx DMA */
3420219346bSGarrett D'Amore #define	HMER_CONFIG_RES1	(0x3 << 1)	/* 1,2 : reserverd */
3430219346bSGarrett D'Amore #define	HMER_CONFIG_FBOFFSET	(0x7 << 3)	/* 3-5 : First Byte Offset */
3440219346bSGarrett D'Amore #define	HMER_CONFIG_RES2	(0x7 << 6)	/* 6-8 : reserverd */
3450219346bSGarrett D'Amore #define	HMER_CONFIG_RXRINGSZ	(0x3 << 9)	/* 9,10 : RX desc. ring size */
3460219346bSGarrett D'Amore #define	HMER_CONFIG_RES3	(0x1f << 11)	/* 11-15 : reserverd */
3470219346bSGarrett D'Amore #define	HMER_CONFIG_RX_CSSTART	(0x7f << 16)	/* 16-22 : cksum start offset */
3480219346bSGarrett D'Amore 
3490219346bSGarrett D'Amore #define	HMER_CONFIG_RXRINGSZ32	(0x0 << 9)	/* Rx descr. ring size 32 */
3500219346bSGarrett D'Amore #define	HMER_CONFIG_RXRINGSZ64	(0x1 << 9)	/* Rx descr. ring size 64 */
3510219346bSGarrett D'Amore #define	HMER_CONFIG_RXRINGSZ128	(0x2 << 9)	/* Rx descr. ring size 128 */
3520219346bSGarrett D'Amore #define	HMER_CONFIG_RXRINGSZ256	(0x3 << 9)	/* Rx descr. ring size 256 */
3530219346bSGarrett D'Amore 
3540219346bSGarrett D'Amore #define	HMER_CONFIG_FBO_SHIFT	3
3550219346bSGarrett D'Amore #define	HMER_RXRINGSZ_SHIFT 	9
3560219346bSGarrett D'Amore #define	HMER_RX_CSSTART_SHIFT	16
3570219346bSGarrett D'Amore 
3580219346bSGarrett D'Amore /*
3590219346bSGarrett D'Amore  * Receive Descriptor Pointer
3600219346bSGarrett D'Amore  *
3610219346bSGarrett D'Amore  * This 29-bit register points to the next descriptor in the ring. The 21 most
3620219346bSGarrett D'Amore  * significant bits are used as the base address for the desriptor ring,
3630219346bSGarrett D'Amore  * and the 8 least significant bits are used as a displacement for the current
3640219346bSGarrett D'Amore  * descriptor.
3650219346bSGarrett D'Amore  *
3660219346bSGarrett D'Amore  * This register should be initialized to a 2KByte-aligned value after power-on
3670219346bSGarrett D'Amore  * or Software Reset.
3680219346bSGarrett D'Amore  *
3690219346bSGarrett D'Amore  */
3700219346bSGarrett D'Amore 
3710219346bSGarrett D'Amore /* ************************************************************************* */
3720219346bSGarrett D'Amore 
3730219346bSGarrett D'Amore 
3740219346bSGarrett D'Amore 
3750219346bSGarrett D'Amore /*
3760219346bSGarrett D'Amore  * Declarations and definitions specific to the BigMAC functional block.
3770219346bSGarrett D'Amore  *
3780219346bSGarrett D'Amore  * The BigMAC block will provide the MAC functons for 10 or 100 Mbps CSMA/CD
3790219346bSGarrett D'Amore  * protocol based interface.
3800219346bSGarrett D'Amore  *
3810219346bSGarrett D'Amore  */
3820219346bSGarrett D'Amore 
3830219346bSGarrett D'Amore /*
3840219346bSGarrett D'Amore  * BigMAC Register Set.
3850219346bSGarrett D'Amore  * BigMAC addresses map on a SBus word boundry. So all registers are
3860219346bSGarrett D'Amore  * declared for a size of 32 bits. Registers that use fewer than 32
3870219346bSGarrett D'Amore  * bits will return 0 in the bits not used.
3880219346bSGarrett D'Amore  */
3890219346bSGarrett D'Amore struct	hme_bmac {
3900219346bSGarrett D'Amore 	uint_t	xifc;		/* XIF Configuration register [9-0] (RW) */
3910219346bSGarrett D'Amore 	uint_t	pad1[129];	/* XXX unused */
3920219346bSGarrett D'Amore 	uint_t	txrst;		/* tx software reset (RW) */
3930219346bSGarrett D'Amore 	uint_t	txcfg;		/* tx configuration register [9-0] (RW) */
3940219346bSGarrett D'Amore 	uint_t	ipg1;		/* Inter Packet Gap 1 [7-0] (RW) */
3950219346bSGarrett D'Amore 	uint_t	ipg2;		/* Inter Packet Gap 2 [7-0] (RW) */
3960219346bSGarrett D'Amore 	uint_t	alimit;		/* attempt limit register [7-0] (RW) */
3970219346bSGarrett D'Amore 	uint_t	slot;		/* slot time register [7-0] (RW) */
3980219346bSGarrett D'Amore 	uint_t	palen;		/* preamble length register [7-0] (RW) */
3990219346bSGarrett D'Amore 	uint_t	papat;		/* preamble pattern register [7-0] (RW) */
4000219346bSGarrett D'Amore 	uint_t	txsfd;		/* tx start frame delimiter [7-0] (RW) */
4010219346bSGarrett D'Amore 	uint_t	jam;		/* jam size register [7-0] (RW) */
4020219346bSGarrett D'Amore 	uint_t	txmax;		/* tx maximum packet size [12-0] (RW) */
4030219346bSGarrett D'Amore 	uint_t	txmin;		/* tx minimum frame size [7-0] (RW) */
4040219346bSGarrett D'Amore 	uint_t	parg;		/* peak attempt count [7-0] (RW) */
4050219346bSGarrett D'Amore 	uint_t	dcnt;		/* defer timer counter [15-0] (RW) */
4060219346bSGarrett D'Amore 	uint_t	nccnt;		/* normal collision counter [15-0] (RW) */
4070219346bSGarrett D'Amore 	uint_t	fccnt;		/* first succesful coll. counter [15-0] (RW) */
4080219346bSGarrett D'Amore 	uint_t	excnt;		/* excess collision counter [7-0] (RW) */
4090219346bSGarrett D'Amore 	uint_t	ltcnt;		/* late collision counter [7-0] (RW) */
4100219346bSGarrett D'Amore 	uint_t	rseed;		/* random number seed [9-0] (RW) */
4110219346bSGarrett D'Amore 	uint_t	txsm;		/* tx state machine register [8-0] (R) */
4120219346bSGarrett D'Amore 	uint_t	pad2[44];	/* XXX Unused */
4130219346bSGarrett D'Amore 	uint_t	rxrst;		/* rx software reset register (RW) */
4140219346bSGarrett D'Amore 	uint_t	rxcfg;		/* rx configuration register [12-0] (RW) */
4150219346bSGarrett D'Amore 	uint_t	rxmax;		/* rx maximum packet size [12-0] (RW) */
4160219346bSGarrett D'Amore 	uint_t	rxmin;		/* rx minimum frame size [7-0] (RW) */
4170219346bSGarrett D'Amore 	uint_t	madd2;		/* mac address register 2 [47-32] (RW) */
4180219346bSGarrett D'Amore 	uint_t	madd1;		/* mac address register 1 [31-16] (RW) */
4190219346bSGarrett D'Amore 	uint_t	madd0;		/* mac address register 0 [15-0] (RW) */
4200219346bSGarrett D'Amore 	uint_t	frcnt;		/* receive frame count [15-0] (RW) */
4210219346bSGarrett D'Amore 	uint_t	lecnt;		/* rx giant length error count [7-0] (RW) */
4220219346bSGarrett D'Amore 	uint_t	aecnt;		/* rx alignment error count [7-0] (RW) */
4230219346bSGarrett D'Amore 	uint_t	fecnt;		/* receive crc error count [7-0] (RW) */
4240219346bSGarrett D'Amore 	uint_t	rxsm;		/* rx state machine register (R) */
4250219346bSGarrett D'Amore 	uint_t	rxcv;		/* rx code voilation register (R) */
4260219346bSGarrett D'Amore 	uchar_t	pad3[4];
4270219346bSGarrett D'Amore 	uint_t	hash3;		/* hash table 3 [63-48] (RW) */
4280219346bSGarrett D'Amore 	uint_t	hash2;		/* hash table 2 [47-32] (RW) */
4290219346bSGarrett D'Amore 	uint_t	hash1;		/* hash table 1 [31-16] (RW) */
4300219346bSGarrett D'Amore 	uint_t	hash0;		/* hash table 0 [15-0] (RW) */
4310219346bSGarrett D'Amore 	uint_t	afr2;		/* addr filter register 0_2 [15-0] (RW) */
4320219346bSGarrett D'Amore 	uint_t	afr1;		/* addr filter register 0_1 [15-0] (RW) */
4330219346bSGarrett D'Amore 	uint_t	afr0;		/* addr filter register 0_0 [15-0] (RW) */
4340219346bSGarrett D'Amore 	uint_t	afmr;		/* addr filter mask reg 0 [15-0] (RW) */
4350219346bSGarrett D'Amore };
4360219346bSGarrett D'Amore 
4370219346bSGarrett D'Amore /*
4380219346bSGarrett D'Amore  * BigMAC Register Bit Masks.
4390219346bSGarrett D'Amore  */
4400219346bSGarrett D'Amore 
4410219346bSGarrett D'Amore /* XIF Configuration Register */
4420219346bSGarrett D'Amore 
4430219346bSGarrett D'Amore #define	BMAC_XIFC_ENAB		(1 << 0)	/* Enable XIF output drivers */
4440219346bSGarrett D'Amore #define	BMAC_XIFC_XIFLPBK	(1 << 1)	/* Enable XIF Loopback mode */
4450219346bSGarrett D'Amore #define	BMAC_XIFC_MIILPBK	(1 << 2)	/* Enable MII Loopback mode */
4460219346bSGarrett D'Amore #define	BMAC_XIFC_MIIBUFDIS	(1 << 3)	/* Disable MII Recv Buffers */
4470219346bSGarrett D'Amore 
4480219346bSGarrett D'Amore /* IN FEPS 2.1 or earlier rev */
4490219346bSGarrett D'Amore #define	BMAC_XIFC_SQETSTENB	(1 << 4)	/* Enable SQE Test */
4500219346bSGarrett D'Amore #define	BMAC_XIFC_SQETSTWIN	(0x1f << 5)	/* SQE Test time window */
4510219346bSGarrett D'Amore 
4520219346bSGarrett D'Amore /* IN FEPS 2.2 or later rev */
4530219346bSGarrett D'Amore #define	BMAC_XIFC_LANCE_ENAB	(1 << 4)	/* Enable  LANCE mode */
4540219346bSGarrett D'Amore #define	BMAC_XIFC_LANCE_IPG0	(0x1f << 5)	/* IPG0 for LANCE mode */
4550219346bSGarrett D'Amore 
4560219346bSGarrett D'Amore #define	BMAC_XIFC_IPG0_SHIFT	5
4570219346bSGarrett D'Amore 
4580219346bSGarrett D'Amore /*
4590219346bSGarrett D'Amore  * TX_MAC Software Reset Command Register
4600219346bSGarrett D'Amore  * This bit is set to 1 when a PIO write is done. This bit becomes self-cleared.
4610219346bSGarrett D'Amore  * after the command has been executed.
4620219346bSGarrett D'Amore  */
4630219346bSGarrett D'Amore 
4640219346bSGarrett D'Amore #define	BMAC_TX_RESET		(1 << 0)	/* TX_MAC Reset Command */
4650219346bSGarrett D'Amore 
4660219346bSGarrett D'Amore /*
4670219346bSGarrett D'Amore  * TX_MAC Configuration Register
4680219346bSGarrett D'Amore  * To Ensure proper operation of the TX_MAC, the TX_MAC_Enable bit must always
4690219346bSGarrett D'Amore  * be cleared to 0 and a delay imposed before a PIO write to any of the other
4700219346bSGarrett D'Amore  * bits in the TX_MAC Configuration register or any of the MAC parameter
4710219346bSGarrett D'Amore  * registers is done.
4720219346bSGarrett D'Amore  *
4730219346bSGarrett D'Amore  * The amount of delay required depends on the time required to transmit a max.
4740219346bSGarrett D'Amore  * size frame.
4750219346bSGarrett D'Amore  */
4760219346bSGarrett D'Amore 
4770219346bSGarrett D'Amore #define	BMACTXRSTDELAY		(125)		/* 125 us wait period */
4780219346bSGarrett D'Amore 
4790219346bSGarrett D'Amore #define	BMAC_TXCFG_ENAB		(1 << 0)	/* tx enable */
4800219346bSGarrett D'Amore #define	BMAC_TXCFG_RES1		(0xf << 1)	/* 1-4 : reserved */
4810219346bSGarrett D'Amore #define	BMAC_TXCFG_SLOW		(1 << 5)	/* carrier detect before tx */
4820219346bSGarrett D'Amore #define	BMAC_TXCFG_IGCOLL	(1 << 6)	/* tx ignore collision */
4830219346bSGarrett D'Amore #define	BMAC_TXCFG_NFCS		(1 << 7)	/* no FCS will be generated */
4840219346bSGarrett D'Amore #define	BMAC_TXCFG_NBKOFF	(1 << 8)	/* No Backoff */
4850219346bSGarrett D'Amore #define	BMAC_TXCFG_FDX		(1 << 9)	/* Full Duplex */
4860219346bSGarrett D'Amore #define	BMAC_TXCFG_NGU		(1 << 10)	/* Never Give Up */
4870219346bSGarrett D'Amore 
4880219346bSGarrett D'Amore /*
4890219346bSGarrett D'Amore  * RX_MAC Configuration Register
4900219346bSGarrett D'Amore  * A delay of 3.2 us should be allowed after clearing Rx_MAC_Enable or
4910219346bSGarrett D'Amore  * Hash_Filter_enable or Address_Filter_Enable bits.
4920219346bSGarrett D'Amore  */
4930219346bSGarrett D'Amore 
4940219346bSGarrett D'Amore #define	BMACRXRSTDELAY		(40)		/* 3.2 us wait period */
4950219346bSGarrett D'Amore 
4960219346bSGarrett D'Amore #define	BMAC_RXCFG_ENAB		(1 << 0)	/* rx enable */
4970219346bSGarrett D'Amore #define	BMAC_RXCFG_RES1		(0xf << 1)	/* 1-4 : reserved */
4980219346bSGarrett D'Amore #define	BMAC_RXCFG_STRIP	(1 << 5)	/* rx strip pad bytes */
4990219346bSGarrett D'Amore #define	BMAC_RXCFG_PROMIS	(1 << 6)	/* rx enable promiscous */
5000219346bSGarrett D'Amore #define	BMAC_RXCFG_ERR		(1 << 7)	/* rx disable error checking */
5010219346bSGarrett D'Amore #define	BMAC_RXCFG_CRC		(1 << 8)	/* rx disable CRC stripping */
5020219346bSGarrett D'Amore #define	BMAC_RXCFG_MYOWN	(1 << 9)	/* rx filter own packets */
5030219346bSGarrett D'Amore #define	BMAC_RXCFG_GRPROM	(1 << 10)	/* rx promiscuous group mode */
5040219346bSGarrett D'Amore #define	BMAC_RXCFG_HASH		(1 << 11)	/* rx enable hash filter */
5050219346bSGarrett D'Amore #define	BMAC_RXCFG_ADDR		(1 << 12)	/* rx enable address filter */
5060219346bSGarrett D'Amore 
5070219346bSGarrett D'Amore 
5080219346bSGarrett D'Amore 
5090219346bSGarrett D'Amore /* ************************************************************************* */
5100219346bSGarrett D'Amore 
5110219346bSGarrett D'Amore /*
5120219346bSGarrett D'Amore  * MII Transceiver Interface
5130219346bSGarrett D'Amore  *
5140219346bSGarrett D'Amore  * The Management Interface (MIF) allows the host to program and collect status
5150219346bSGarrett D'Amore  * from two transceivers connected to the MII. MIF supports three modes of
5160219346bSGarrett D'Amore  * operation:
5170219346bSGarrett D'Amore  *	1. Bit-Bang Mode
5180219346bSGarrett D'Amore  *	   This mode is imlemented using three 1-bit registers: data, clock,
5190219346bSGarrett D'Amore  *	   and output_enable.
5200219346bSGarrett D'Amore  *
5210219346bSGarrett D'Amore  *	2. Frame Mode
5220219346bSGarrett D'Amore  *	   This mode is supported using one 32-bit register: Frame register.
5230219346bSGarrett D'Amore  *	   The software loads the Frame Register with avalid instaruction
5240219346bSGarrett D'Amore  *	   ("frame"), and polls the Valid Bit for completion.
5250219346bSGarrett D'Amore  *
5260219346bSGarrett D'Amore  *	3. Polling Mode
5270219346bSGarrett D'Amore  *	   The Polling mechanism is used for detecting a status change in the
5280219346bSGarrett D'Amore  *	   transceiver. When this mode is enabled, the MIF will continuously
5290219346bSGarrett D'Amore  *	   poll a specified transceiver register and generate a maskable
5300219346bSGarrett D'Amore  *	   interrupt when a status change is detected. This mode of operation
5310219346bSGarrett D'Amore  *	   can only be used when the MIF is in the "Frame mode".
5320219346bSGarrett D'Amore  *
5330219346bSGarrett D'Amore  */
5340219346bSGarrett D'Amore 
5350219346bSGarrett D'Amore struct hme_mif {
5360219346bSGarrett D'Amore 	uint_t mif_bbclk;	/* MIF Bit Bang Clock */
5370219346bSGarrett D'Amore 	uint_t mif_bbdata;	/* MIF Bit Bang Data */
5380219346bSGarrett D'Amore 	uint_t mif_bbopenb;	/* MIF Bit Bang Output Enable */
5390219346bSGarrett D'Amore 	uint_t mif_frame;	/* MIF Frame - ctl and data */
5400219346bSGarrett D'Amore 	uint_t mif_cfg;		/* MIF Configuration */
5410219346bSGarrett D'Amore 	uint_t mif_imask;	/* MIF Interrupt mask */
5420219346bSGarrett D'Amore 	uint_t mif_bsts;	/* MIF Basic/Status register */
5430219346bSGarrett D'Amore 	uint_t mif_fsm;		/* MIF State machine register */
5440219346bSGarrett D'Amore };
5450219346bSGarrett D'Amore 
5460219346bSGarrett D'Amore /* mif_bbc - Bit Bang Clock register */
5470219346bSGarrett D'Amore #define	HME_MIF_BBCLK	(1 << 0);	/* Bit Babg Clock */
5480219346bSGarrett D'Amore 
5490219346bSGarrett D'Amore #define	HME_BBCLK_LOW 0
5500219346bSGarrett D'Amore #define	HME_BBCLK_HIGH 1
5510219346bSGarrett D'Amore 
5520219346bSGarrett D'Amore /* mif_bbdata - bit Bang Data register */
5530219346bSGarrett D'Amore #define	HME_MIF_BBDATA	(1 << 0);	/* Bit Bang Data */
5540219346bSGarrett D'Amore 
5550219346bSGarrett D'Amore /* mif_bbopenb - Bit Bang oOutput Enable register */
5560219346bSGarrett D'Amore #define	HME_MIF_BBOPENB	(1 << 0);	/* Bit Bang output Enable */
5570219346bSGarrett D'Amore 
5580219346bSGarrett D'Amore /*
5590219346bSGarrett D'Amore  * Management Frame Structure:
5600219346bSGarrett D'Amore  * <IDLE> <ST><OP><PHYAD><REGAD><TA>	 <DATA>		   <IDLE>
5610219346bSGarrett D'Amore  * READ:  <01><10><AAAAA><RRRRR><Z0><DDDDDDDDDDDDDDDD>
5620219346bSGarrett D'Amore  * WRITE: <01><01><AAAAA><RRRRR><10><DDDDDDDDDDDDDDDD>
5630219346bSGarrett D'Amore  */
5640219346bSGarrett D'Amore 
5650219346bSGarrett D'Amore /* mif_frame - MIF control and data register */
5660219346bSGarrett D'Amore 
5670219346bSGarrett D'Amore #define	HME_MIF_FRDATA	(0xffff << 0)	/* 0-15 : data bits */
5680219346bSGarrett D'Amore #define	HME_MIF_FRTA0	(0x1 << 16)	/* 16 : TA bit, 1 for completion */
5690219346bSGarrett D'Amore #define	HME_MIF_FRTA1	(0x1 << 17)	/* 16-17 : TA bits */
5700219346bSGarrett D'Amore #define	HME_MIF_FRREGAD	(0x1f << 18)	/* 18-22 : register address bits */
5710219346bSGarrett D'Amore #define	HME_MIF_FRPHYAD	(0x1f << 23)	/* 23-27 : PHY ad, should be 0 */
5720219346bSGarrett D'Amore #define	HME_MIF_FROP	(0x3 << 28)	/* 28-29 : Operation - Write/Read */
5730219346bSGarrett D'Amore #define	HME_MIF_FRST	(0xc0000000)	/* 30-31 : START bits */
5740219346bSGarrett D'Amore 
5750219346bSGarrett D'Amore #define	HME_MIF_FRREGAD_SHIFT	18
5760219346bSGarrett D'Amore #define	HME_MIF_FRPHYAD_SHIFT	23
5770219346bSGarrett D'Amore #define	HME_MIF_FRREAD		0x60020000
5780219346bSGarrett D'Amore #define	HME_MIF_FRWRITE		0x50020000
5790219346bSGarrett D'Amore 
5800219346bSGarrett D'Amore /* maximum delay for MIF Register Read/Write operation */
5810219346bSGarrett D'Amore #define	HMEMAXMIFDELAY	(100)
5820219346bSGarrett D'Amore 
5830219346bSGarrett D'Amore /* maximum delay for Transceiver Reset */
5840219346bSGarrett D'Amore #define	HME_PHYRST_MAXDELAY	(500)
5850219346bSGarrett D'Amore 
5860219346bSGarrett D'Amore /* mif_cfg - MIF Configuration Register */
5870219346bSGarrett D'Amore 
5880219346bSGarrett D'Amore #define	HME_MIF_CFGPS	(1 << 0)	/* PHY Select */
5890219346bSGarrett D'Amore #define	HME_MIF_CFGPE	(1 << 1)	/* Poll Enable */
5900219346bSGarrett D'Amore #define	HME_MIF_CFGBB	(1 << 2)	/* Bit Bang Enable */
5910219346bSGarrett D'Amore #define	HME_MIF_CFGPR	(0x1f << 3)	/* Poll Register address */
5920219346bSGarrett D'Amore #define	HME_MIF_CFGM0	(1 << 8)	/* MDIO_0 Data / MDIO_0 attached */
5930219346bSGarrett D'Amore #define	HME_MIF_CFGM1	(1 << 9)	/* MDIO_1 Data / MDIO_1 attached */
5940219346bSGarrett D'Amore #define	HME_MIF_CFGPD	(0x1f << 10)	/* Poll Device PHY address */
5950219346bSGarrett D'Amore 
5960219346bSGarrett D'Amore #define	HME_MIF_CFGPR_SHIFT	3
5970219346bSGarrett D'Amore #define	HME_MIF_CFGPD_SHIFT	10
5980219346bSGarrett D'Amore #define	HME_MIF_POLL_DELAY	200
5990219346bSGarrett D'Amore 
6000219346bSGarrett D'Amore /*
6010219346bSGarrett D'Amore  * MDIO_0 corresponds to the On Board Transceiver.
6020219346bSGarrett D'Amore  * MDIO_1 corresponds to the External Transceiver.
6030219346bSGarrett D'Amore  * The PHYAD for both is 0.
6040219346bSGarrett D'Amore  */
6050219346bSGarrett D'Amore 
6060219346bSGarrett D'Amore #define	HME_INTERNAL_PHYAD	1	/* PHY address for int. transceiver */
6070219346bSGarrett D'Amore #define	HME_EXTERNAL_PHYAD	0	/* PHY address for ext. transceiver */
6080219346bSGarrett D'Amore 
6090219346bSGarrett D'Amore 
6100219346bSGarrett D'Amore /* mif_imask - MIF Interrupt Mask Register */
6110219346bSGarrett D'Amore /*
6120219346bSGarrett D'Amore  * This register is bit-to-bit same as Basic/Status Register
6130219346bSGarrett D'Amore  */
6140219346bSGarrett D'Amore #define	HME_MIF_INTMASK	(0xffff << 0)	/* 0-15 : Interrupt mask */
6150219346bSGarrett D'Amore 
6160219346bSGarrett D'Amore /* mif_bassts - MIF Basic / Status register */
6170219346bSGarrett D'Amore /*
6180219346bSGarrett D'Amore  * The Basic portion of this register indicates the last value of the register
6190219346bSGarrett D'Amore  * read indicated in the POLL REG field of the Configuration Register.
6200219346bSGarrett D'Amore  * The Status portion indicates bit(s) that have changed.
6210219346bSGarrett D'Amore  * The MIF Mask register is corresponding to this register in terms of the
6220219346bSGarrett D'Amore  * bit(s) that need to be masked for generating interrupt on the MIF Interrupt
6230219346bSGarrett D'Amore  * Bit of the Global Status Rgister.
6240219346bSGarrett D'Amore  */
6250219346bSGarrett D'Amore 
6260219346bSGarrett D'Amore #define	HME_MIF_STATUS	(0xffff << 0)	/* 0-15 : Status */
6270219346bSGarrett D'Amore #define	HME_MIF_BASIC	(0xffff << 16)	/* 16-31 : Basic register */
6280219346bSGarrett D'Amore 
6290219346bSGarrett D'Amore /* mif_fsm - MIF State Machine register */
6300219346bSGarrett D'Amore 
6310219346bSGarrett D'Amore #define	HME_MIF_FSM	(0x3ff << 0)	/* 0-9 : MIF state */
6320219346bSGarrett D'Amore 
6330219346bSGarrett D'Amore /* ************************************************************************ */
6340219346bSGarrett D'Amore 
6350219346bSGarrett D'Amore 
6360219346bSGarrett D'Amore /*
6370219346bSGarrett D'Amore  * Definition for the time required to wait after a software
6380219346bSGarrett D'Amore  * reset has been issued.
6390219346bSGarrett D'Amore  */
6400219346bSGarrett D'Amore #define	HMEMAXRSTDELAY	(200)
6410219346bSGarrett D'Amore #define	HMEPERIOD	(20)	/* period to wait */
6420219346bSGarrett D'Amore #define	HMEWAITPERIOD	HMEPERIOD
6430219346bSGarrett D'Amore 
6440219346bSGarrett D'Amore #define	HMEDELAY(c, n) \
6450219346bSGarrett D'Amore 	{ \
6460219346bSGarrett D'Amore 		register int N = n / HMEWAITPERIOD; \
6470219346bSGarrett D'Amore 		while (--N > 0) { \
6480219346bSGarrett D'Amore 			if (c) \
6490219346bSGarrett D'Amore 				break; \
6500219346bSGarrett D'Amore 			drv_usecwait(HMEWAITPERIOD); \
6510219346bSGarrett D'Amore 		} \
6520219346bSGarrett D'Amore 	}
6530219346bSGarrett D'Amore 
6540219346bSGarrett D'Amore #endif	/* HME_MAC_H */
655