xref: /onnv-gate/usr/src/uts/common/io/hme/hme_mac.h (revision 12981:2ec828581df0)
19610Sgdamore@opensolaris.org /*
29610Sgdamore@opensolaris.org  * CDDL HEADER START
39610Sgdamore@opensolaris.org  *
49610Sgdamore@opensolaris.org  * The contents of this file are subject to the terms of the
59610Sgdamore@opensolaris.org  * Common Development and Distribution License (the "License").
69610Sgdamore@opensolaris.org  * You may not use this file except in compliance with the License.
79610Sgdamore@opensolaris.org  *
89610Sgdamore@opensolaris.org  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99610Sgdamore@opensolaris.org  * or http://www.opensolaris.org/os/licensing.
109610Sgdamore@opensolaris.org  * See the License for the specific language governing permissions
119610Sgdamore@opensolaris.org  * and limitations under the License.
129610Sgdamore@opensolaris.org  *
139610Sgdamore@opensolaris.org  * When distributing Covered Code, include this CDDL HEADER in each
149610Sgdamore@opensolaris.org  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159610Sgdamore@opensolaris.org  * If applicable, add the following below this CDDL HEADER, with the
169610Sgdamore@opensolaris.org  * fields enclosed by brackets "[]" replaced with your own identifying
179610Sgdamore@opensolaris.org  * information: Portions Copyright [yyyy] [name of copyright owner]
189610Sgdamore@opensolaris.org  *
199610Sgdamore@opensolaris.org  * CDDL HEADER END
209610Sgdamore@opensolaris.org  */
219610Sgdamore@opensolaris.org /*
22*12981SZeeshanul.Huq@Sun.COM  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
239610Sgdamore@opensolaris.org  */
249610Sgdamore@opensolaris.org 
259610Sgdamore@opensolaris.org #ifndef	HME_MAC_H
269610Sgdamore@opensolaris.org #define	HME_MAC_H
279610Sgdamore@opensolaris.org 
289610Sgdamore@opensolaris.org /*
299610Sgdamore@opensolaris.org  * HOST MEMORY DATA STRUCTURES
309610Sgdamore@opensolaris.org  */
319610Sgdamore@opensolaris.org 
329610Sgdamore@opensolaris.org /* The pointers to the Descriptor Ring base Addresses must be 2K-byte aligned */
339610Sgdamore@opensolaris.org 
349610Sgdamore@opensolaris.org #define	HME_HMDALIGN	(2048)
359610Sgdamore@opensolaris.org 
369610Sgdamore@opensolaris.org /*
379610Sgdamore@opensolaris.org  * The transmit and receiver Descriptor Rings are organized as "wrap-around
389610Sgdamore@opensolaris.org  * descriptors of programmable size.
399610Sgdamore@opensolaris.org  */
409610Sgdamore@opensolaris.org #define	HME_TMDMAX	(64)	/* Transmit descriptor ring size */
419610Sgdamore@opensolaris.org #define	HME_RMDMAX	(64)	/* Receive descriptor ring size */
429610Sgdamore@opensolaris.org 
439610Sgdamore@opensolaris.org /* Transmit descriptor structure */
449610Sgdamore@opensolaris.org 
459610Sgdamore@opensolaris.org struct hme_tmd {
469610Sgdamore@opensolaris.org 	uint_t	tmd_flags;	/* OWN, SOP, EOP, cksum ctl and bufize */
479610Sgdamore@opensolaris.org 	uint_t	tmd_addr;	/* 8-bye aligned buffer address */
489610Sgdamore@opensolaris.org };
499610Sgdamore@opensolaris.org 
509610Sgdamore@opensolaris.org /* fields in the tmd_flags */
519610Sgdamore@opensolaris.org 
529610Sgdamore@opensolaris.org #define	HMETMD_BUFSIZE	(0x3fff << 0)	/* 0-13 : Tx Data buffer size */
539610Sgdamore@opensolaris.org #define	HMETMD_CSSTART	(0x3f << 14)	/* 14-19 : Checksum start offset */
549610Sgdamore@opensolaris.org #define	HMETMD_CSSTUFF	(0xff << 20)	/* 20-27 : Checksum stuff offset */
559610Sgdamore@opensolaris.org #define	HMETMD_CSENABL	(1 << 28)	/* 28 : Enable checksum computation */
569610Sgdamore@opensolaris.org #define	HMETMD_EOP	(1 << 29)	/* 29 : End Of Packet flag */
579610Sgdamore@opensolaris.org #define	HMETMD_SOP	(1 << 30)	/* 30 : Start Of Packet flag */
589610Sgdamore@opensolaris.org #define	HMETMD_OWN	(0x80000000)	/* 31 : Ownership flag */
599610Sgdamore@opensolaris.org 					/* 0 - owned by software */
609610Sgdamore@opensolaris.org 					/* 1 - owned by hardware */
619610Sgdamore@opensolaris.org 
62*12981SZeeshanul.Huq@Sun.COM #define	HMETMD_CSSTART_MAX	0x3f	/* Maximum checksum start offset */
63*12981SZeeshanul.Huq@Sun.COM #define	HMETMD_CSSTUFF_MAX	0xff	/* Maximum checksum stuff offset */
649610Sgdamore@opensolaris.org #define	HMETMD_CSSTART_SHIFT 14	/* checksum start bit position */
659610Sgdamore@opensolaris.org #define	HMETMD_CSSTUFF_SHIFT 20	/* checksum stuff bit position */
669610Sgdamore@opensolaris.org 
679610Sgdamore@opensolaris.org /*
689610Sgdamore@opensolaris.org  *	Programming Notes:
699610Sgdamore@opensolaris.org  *
709610Sgdamore@opensolaris.org  *	1. If a packet occupies more than one descriptor, the software must
719610Sgdamore@opensolaris.org  *	turn over the ownership of the descriptors to the hardware
729610Sgdamore@opensolaris.org  *	"last-to-first", in order to avoid race conditions.
739610Sgdamore@opensolaris.org  *
749610Sgdamore@opensolaris.org  *	2. If a packet resides in more than one buffer, the Checksum_Enable,
759610Sgdamore@opensolaris.org  *	Checksum_Stuff_Offset and Checksum_Start_Offset fields must have the
769610Sgdamore@opensolaris.org  *	same values in all the descriptors that were allocated to the packet.
779610Sgdamore@opensolaris.org  *
789610Sgdamore@opensolaris.org  *	3. The hardware implementation relies on the fact that if a buffer
799610Sgdamore@opensolaris.org  *	starts at an "odd" boundary, the DMA state machine can "rewind"
809610Sgdamore@opensolaris.org  *	to the nearest burst boundary and execute a full DVMA burst Read.
819610Sgdamore@opensolaris.org  *
829610Sgdamore@opensolaris.org  *	There is no other alignment restriction for the transmit data buffer.
839610Sgdamore@opensolaris.org  */
849610Sgdamore@opensolaris.org 
859610Sgdamore@opensolaris.org /* Receive Descriptor structure */
869610Sgdamore@opensolaris.org 
879610Sgdamore@opensolaris.org struct hme_rmd {
889610Sgdamore@opensolaris.org 	uint_t	rmd_flags;	/* OWN, OVFLOW, buf/data size, cksum */
899610Sgdamore@opensolaris.org 	uint_t	rmd_addr;	/* 8-byte aligned buffer address */
909610Sgdamore@opensolaris.org };
919610Sgdamore@opensolaris.org 
929610Sgdamore@opensolaris.org /* fields in the rmd_flags */
939610Sgdamore@opensolaris.org 
949610Sgdamore@opensolaris.org #define	HMERMD_CKSUM	(0xffff << 0)	/* 0-15 : checksum computed */
959610Sgdamore@opensolaris.org #define	HMERMD_BUFSIZE	(0x3fff << 16)	/* 16-29 : buffer/data size */
969610Sgdamore@opensolaris.org #define	HMERMD_OVFLOW	(1 << 30)	/* 30 : Rx buffer overflow */
979610Sgdamore@opensolaris.org #define	HMERMD_OWN	(0x80000000)	/* 31 : Ownership flag */
989610Sgdamore@opensolaris.org 					/* 0 - owned by software */
999610Sgdamore@opensolaris.org 					/* 1 - owned by hardware */
1009610Sgdamore@opensolaris.org 
1019610Sgdamore@opensolaris.org #define	HMERMD_BUFSIZE_SHIFT 16	/* buffer/data size bit position */
1029610Sgdamore@opensolaris.org 
1039610Sgdamore@opensolaris.org /* ************************************************************************* */
1049610Sgdamore@opensolaris.org 
1059610Sgdamore@opensolaris.org /* Global Register set in SEB (Shared Ethernet Block) */
1069610Sgdamore@opensolaris.org 
1079610Sgdamore@opensolaris.org struct hme_global {
1089610Sgdamore@opensolaris.org     uint_t reset;		/* Global Software Reset Command */
1099610Sgdamore@opensolaris.org     uint_t config;		/* Global Configuration Register */
1109610Sgdamore@opensolaris.org     uint_t reserved[62];
1119610Sgdamore@opensolaris.org     uint_t status;		/* Global Status Register */
1129610Sgdamore@opensolaris.org     uint_t intmask;		/* Global Interrupt Mask Register */
1139610Sgdamore@opensolaris.org };
1149610Sgdamore@opensolaris.org 
1159610Sgdamore@opensolaris.org 
1169610Sgdamore@opensolaris.org /*
1179610Sgdamore@opensolaris.org  * Global Software Reset Command Register - RW
1189610Sgdamore@opensolaris.org  * These bits become "self cleared" after the corresponding reset command
1199610Sgdamore@opensolaris.org  * has been executed. After a reset, the software must poll this register
1209610Sgdamore@opensolaris.org  * till both the bits are read as 0's.
1219610Sgdamore@opensolaris.org  */
1229610Sgdamore@opensolaris.org 
1239610Sgdamore@opensolaris.org #define	HMEG_RESET_ETX	(1 << 0)	/* Reset ETX */
1249610Sgdamore@opensolaris.org #define	HMEG_RESET_ERX	(1 << 1)	/* Reset ERX */
1259610Sgdamore@opensolaris.org 
1269610Sgdamore@opensolaris.org #define	HMEG_RESET_GLOBAL HMEG_RESET_ETX | HMEG_RESET_ERX
1279610Sgdamore@opensolaris.org 
1289610Sgdamore@opensolaris.org 
1299610Sgdamore@opensolaris.org /* Global Configuration Register - RW */
1309610Sgdamore@opensolaris.org 
1319610Sgdamore@opensolaris.org #define	HMEG_CONFIG_BURSTSZ	(0x3 << 0)	/* sbus max burst size */
1329610Sgdamore@opensolaris.org #define	HMEG_CONFIG_64BIT_XFER	(1 << 2)	/* Extended transfer mode */
1339610Sgdamore@opensolaris.org #define	HMEG_CONFIG_PARITY	(1 << 3)	/* sbus parity enable */
1349610Sgdamore@opensolaris.org #define	HMEG_CONFIG_RES1	(1 << 4)	/* reserved, should be 0 */
1359610Sgdamore@opensolaris.org 
1369610Sgdamore@opensolaris.org #define	HMEG_CONFIG_BURST16	0x00	/* sbus max burst size 16 */
1379610Sgdamore@opensolaris.org #define	HMEG_CONFIG_BURST32	0x01	/* sbus max burst size 32 */
1389610Sgdamore@opensolaris.org #define	HMEG_CONFIG_BURST64	0x02	/* sbus max burst size 64 */
1399610Sgdamore@opensolaris.org #define	HMEG_CONFIG_BURST_RES	0x03	/* sbus max burst size - reserved */
1409610Sgdamore@opensolaris.org 
1419610Sgdamore@opensolaris.org #define	HMEG_CONFIG_64BIT_SHIFT	2
1429610Sgdamore@opensolaris.org /*
1439610Sgdamore@opensolaris.org  * Global Status Register - R-AC
1449610Sgdamore@opensolaris.org  *
1459610Sgdamore@opensolaris.org  * All the bits in the Global Status Register are automatically cleared when
1469610Sgdamore@opensolaris.org  * read with the exception of bit 23. The MIF status bit will be cleared after
1479610Sgdamore@opensolaris.org  * the MIF Status Register is read.
1489610Sgdamore@opensolaris.org  */
1499610Sgdamore@opensolaris.org 
1509610Sgdamore@opensolaris.org 
1519610Sgdamore@opensolaris.org #define	HMEG_STATUS_FRAME_RCVD	(1 << 0)	/* from RX_MAC to RxFIFO */
1529610Sgdamore@opensolaris.org #define	HMEG_STATUS_RXF_CNT_EXP	(1 << 1)	/* Rx_frame_counter expired */
1539610Sgdamore@opensolaris.org #define	HMEG_STATUS_ALN_CNT_EXP	(1 << 2)	/* Alignment_Error_cntr exp */
1549610Sgdamore@opensolaris.org #define	HMEG_STATUS_CRC_CNT_EXP	(1 << 3)	/* CRC_Error_counter expired */
1559610Sgdamore@opensolaris.org #define	HMEG_STATUS_LEN_CNT_EXP	(1 << 4)	/* Length_Error_counter exp */
1569610Sgdamore@opensolaris.org #define	HMEG_STATUS_RXFIFO_OVFL	(1 << 5)	/* RxFIFO_Overflow in RX_MAC */
1579610Sgdamore@opensolaris.org #define	HMEG_STATUS_RCV_CNT_EXP	(1 << 6)	/* Code_Violation_counter exp */
1589610Sgdamore@opensolaris.org #define	HMEG_STATUS_SQE_TST_ERR	(1 << 7)	/* SQE Test error in XIF */
1599610Sgdamore@opensolaris.org 
1609610Sgdamore@opensolaris.org #define	HMEG_STATUS_FRAME_SENT	(1 << 8)	/* Frame sent from TX_MAC */
1619610Sgdamore@opensolaris.org #define	HMEG_STATUS_TXFIFO_UNDR	(1 << 9)	/* TxFIFO Underrun in TX_MAC */
1629610Sgdamore@opensolaris.org #define	HMEG_STATUS_MXPKTSZ_ERR	(1 << 10)	/* Maximum_Packet_Size error */
1639610Sgdamore@opensolaris.org #define	HMEG_STATUS_NRMCOLC_EXP	(1 << 11)	/* Normal_collision_cntr exp */
1649610Sgdamore@opensolaris.org #define	HMEG_STATUS_EXCOLC_EXP	(1 << 12)	/* Excessive_coll_cntr exp */
1659610Sgdamore@opensolaris.org #define	HMEG_STATUS_LATCOLC_EXP	(1 << 13)	/* Late_Collision_cntr exp */
1669610Sgdamore@opensolaris.org #define	HMEG_STATUS_FSTCOLC_EXP	(1 << 14)	/* First_Coll_cntr expired */
1679610Sgdamore@opensolaris.org #define	HMEG_STATUS_DEFTIMR_EXP	(1 << 15)	/* Defer_Timer expired */
1689610Sgdamore@opensolaris.org 
1699610Sgdamore@opensolaris.org #define	HMEG_STATUS_RINT	(1 << 16)	/* from RxFIFO to host memory */
1709610Sgdamore@opensolaris.org #define	HMEG_STATUS_RX_DROP	(1 << 17)	/* No free Rx descriptors */
1719610Sgdamore@opensolaris.org #define	HMEG_STATUS_RX_ERR_ACK	(1 << 18)	/* Error Ack in Rx DMA cycle */
1729610Sgdamore@opensolaris.org #define	HMEG_STATUS_RX_LATE_ERR	(1 << 19)	/* Late Error in Rx DMA cycle */
1739610Sgdamore@opensolaris.org #define	HMEG_STATUS_RX_PAR_ERR	(1 << 20)	/* Parity error in Rx DMA */
1749610Sgdamore@opensolaris.org #define	HMEG_STATUS_RX_TAG_ERR	(1 << 21)	/* No two consecutiv tag bits */
1759610Sgdamore@opensolaris.org #define	HMEG_STATUS_EOP_ERR	(1 << 22)	/* EOP not set in Tx desc */
1769610Sgdamore@opensolaris.org #define	HMEG_STATUS_MIF_INTR	(1 << 23)	/* MIF interrupt */
1779610Sgdamore@opensolaris.org 
1789610Sgdamore@opensolaris.org #define	HMEG_STATUS_TINT	(1 << 24)	/* from host mem to TxFIFO */
1799610Sgdamore@opensolaris.org #define	HMEG_STATUS_TX_ALL	(1 << 25)	/* TxFIFO empty */
1809610Sgdamore@opensolaris.org #define	HMEG_STATUS_TX_ERR_ACK	(1 << 26)	/* Error Ack in Tx DMA cycle */
1819610Sgdamore@opensolaris.org #define	HMEG_STATUS_TX_LATE_ERR	(1 << 27)	/* Late error in Tx DMA cycle */
1829610Sgdamore@opensolaris.org #define	HMEG_STATUS_TX_PAR_ERR	(1 << 28)	/* Parity error in Tx DMA */
1839610Sgdamore@opensolaris.org #define	HMEG_STATUS_TX_TAG_ERR	(1 << 29)	/* No two consecutiv tag bits */
1849610Sgdamore@opensolaris.org #define	HMEG_STATUS_SLV_ERR_ACK	(1 << 30)	/* Error Ack in PIO cycle */
1859610Sgdamore@opensolaris.org #define	HMEG_STATUS_SLV_PAR_ERR	(0x80000000)	/* Parity error in PIO write */
1869610Sgdamore@opensolaris.org 
1879610Sgdamore@opensolaris.org #define	HMEG_STATUS_FATAL_ERR	 0xfc7c0000	/* all fatal errors */
1889610Sgdamore@opensolaris.org #define	HMEG_STATUS_NONFATAL_ERR 0x0002fefc	/* all non-fatal errors */
1899610Sgdamore@opensolaris.org #define	HMEG_STATUS_NORMAL_INT	 0x01810000	/* normal interrupts */
1909610Sgdamore@opensolaris.org 
1919610Sgdamore@opensolaris.org #define	HMEG_STATUS_INTR	 0xfefffefc 	/* All interesting interrupts */
1929610Sgdamore@opensolaris.org 
1939610Sgdamore@opensolaris.org /*
1949610Sgdamore@opensolaris.org  * Global Interrupt Mask register
1959610Sgdamore@opensolaris.org  *
1969610Sgdamore@opensolaris.org  * There is one-to-one correspondence between the bits in this register and
1979610Sgdamore@opensolaris.org  * the Global Status register.
1989610Sgdamore@opensolaris.org  *
1999610Sgdamore@opensolaris.org  * The MIF interrupt [bit 23] is not maskable here. It should be masked at the
2009610Sgdamore@opensolaris.org  * source of the interrupt in the MIF.
2019610Sgdamore@opensolaris.org  *
2029610Sgdamore@opensolaris.org  * Default value of the Global Interrupt Mask register is 0xFF7FFFFF.
2039610Sgdamore@opensolaris.org  */
2049610Sgdamore@opensolaris.org 
2059610Sgdamore@opensolaris.org #define	HMEG_MASK_FRAME_RCVD	(1 << 0)	/* from RX_MAC to RxFIFO */
2069610Sgdamore@opensolaris.org #define	HMEG_MASK_RXF_CNT_EXP	(1 << 1)	/* Rx_frame_counter expired */
2079610Sgdamore@opensolaris.org #define	HMEG_MASK_ALN_CNT_EXP	(1 << 2)	/* Alignment_Error_cntr exp */
2089610Sgdamore@opensolaris.org #define	HMEG_MASK_CRC_CNT_EXP	(1 << 3)	/* CRC_Error_counter expired */
2099610Sgdamore@opensolaris.org #define	HMEG_MASK_LEN_CNT_EXP	(1 << 4)	/* Length_Error_counter exp */
2109610Sgdamore@opensolaris.org #define	HMEG_MASK_RXFIFO_OVFL	(1 << 5)	/* RxFIFO_Overflow in RX_MAC */
2119610Sgdamore@opensolaris.org #define	HMEG_MASK_RCV_CNT_EXP	(1 << 6)	/* Code_Violation_counter exp */
2129610Sgdamore@opensolaris.org #define	HMEG_MASK_SQE_TST_ERR	(1 << 7)	/* SQE Test error in XIF */
2139610Sgdamore@opensolaris.org 
2149610Sgdamore@opensolaris.org #define	HMEG_MASK_FRAME_SENT	(1 << 8)	/* Frame sent from TX_MAC */
2159610Sgdamore@opensolaris.org #define	HMEG_MASK_TXFIFO_UNDR	(1 << 9)	/* TxFIFO Underrun in TX_MAC */
2169610Sgdamore@opensolaris.org #define	HMEG_MASK_MXPKTSZ_ERR	(1 << 10)	/* Maximum_Packet_Size error */
2179610Sgdamore@opensolaris.org #define	HMEG_MASK_NRMCOLC_EXP	(1 << 11)	/* Normal_collision_cntr exp */
2189610Sgdamore@opensolaris.org #define	HMEG_MASK_EXECOLC_EXP	(1 << 12)	/* Excessive_coll_cntr exp */
2199610Sgdamore@opensolaris.org #define	HMEG_MASK_LATCOLC_EXP	(1 << 13)	/* Late_Collision_cntr exp */
2209610Sgdamore@opensolaris.org #define	HMEG_MASK_FSTCOLC_EXP	(1 << 14)	/* First_Coll_cntr expired */
2219610Sgdamore@opensolaris.org #define	HMEG_MASK_DEFTIMR_EXP	(1 << 15)	/* Defer_Timer expired */
2229610Sgdamore@opensolaris.org 
2239610Sgdamore@opensolaris.org #define	HMEG_MASK_RINT		(1 << 16)	/* from RxFIFO to host memory */
2249610Sgdamore@opensolaris.org #define	HMEG_MASK_RX_DROP	(1 << 17)	/* No free Rx descriptors */
2259610Sgdamore@opensolaris.org #define	HMEG_MASK_RX_ERR_ACK	(1 << 18)	/* Error Ack in Rx DMA cycle */
2269610Sgdamore@opensolaris.org #define	HMEG_MASK_RX_LATE_ERR	(1 << 19)	/* Late Error in Rx DMA cycle */
2279610Sgdamore@opensolaris.org #define	HMEG_MASK_RX_PAR_ERR	(1 << 20)	/* Parity error in Rx DMA */
2289610Sgdamore@opensolaris.org #define	HMEG_MASK_RX_TAG_ERR	(1 << 21)	/* No two consecutiv tag bits */
2299610Sgdamore@opensolaris.org #define	HMEG_MASK_EOP_ERR	(1 << 22)	/* EOP not set in Tx desc */
2309610Sgdamore@opensolaris.org #define	HMEG_MASK_MIF_INTR	(1 << 23)	/* MIF interrupt */
2319610Sgdamore@opensolaris.org 
2329610Sgdamore@opensolaris.org #define	HMEG_MASK_TINT		(1 << 24)	/* from host mem to TxFIFO */
2339610Sgdamore@opensolaris.org #define	HMEG_MASK_TX_ALL	(1 << 25)	/* TxFIFO empty */
2349610Sgdamore@opensolaris.org #define	HMEG_MASK_TX_ERR_ACK	(1 << 26)	/* Error Ack in Tx DMA cycle */
2359610Sgdamore@opensolaris.org #define	HMEG_MASK_TX_LATE_ERR	(1 << 27)	/* Late error in Tx DMA cycle */
2369610Sgdamore@opensolaris.org #define	HMEG_MASK_TX_PAR_ERR	(1 << 28)	/* Parity error in Tx DMA */
2379610Sgdamore@opensolaris.org #define	HMEG_MASK_TX_TAG_ERR	(1 << 29)	/* No two consecutiv tag bits */
2389610Sgdamore@opensolaris.org #define	HMEG_MASK_SLV_ERR_ACK	(1 << 30)	/* Error Ack in PIO cycle */
2399610Sgdamore@opensolaris.org #define	HMEG_MASK_SLV_PAR_ERR	(0x80000000)	/* Parity error in PIO write */
2409610Sgdamore@opensolaris.org 
2419610Sgdamore@opensolaris.org #define	HMEG_MASK_INTR		(~HMEG_STATUS_INTR)
2429610Sgdamore@opensolaris.org 						/* uninteresting interrupts */
2439610Sgdamore@opensolaris.org 
2449610Sgdamore@opensolaris.org /*
2459610Sgdamore@opensolaris.org  *	Interrupts which are not interesting are:
2469610Sgdamore@opensolaris.org  *	HMEG_MASK_FRAME_SENT
2479610Sgdamore@opensolaris.org  *	HMEG_MASK_RXF_CNT_EXP
2489610Sgdamore@opensolaris.org  *	HMEG_MASK_FRAME_RCVD
2499610Sgdamore@opensolaris.org  */
2509610Sgdamore@opensolaris.org 
2519610Sgdamore@opensolaris.org /* ************************************************************************* */
2529610Sgdamore@opensolaris.org 
2539610Sgdamore@opensolaris.org /* ETX Register set */
2549610Sgdamore@opensolaris.org 
2559610Sgdamore@opensolaris.org struct hme_etx {
2569610Sgdamore@opensolaris.org     uint_t txpend;		/* Transmit Pending Command */
2579610Sgdamore@opensolaris.org     uint_t config;		/* ETX Configuration Register */
2589610Sgdamore@opensolaris.org     uint_t txring;		/* Transmit Descriptor Ring Pointer */
2599610Sgdamore@opensolaris.org     uint_t txbuf_base;		/* Transmit Data Buffer Base Address */
2609610Sgdamore@opensolaris.org     uint_t txbuf_disp;		/* Transmit Data Buffer Displacement */
2619610Sgdamore@opensolaris.org     uint_t txfifo_wr_ptr;	/* TxFIFO Write Pointer */
2629610Sgdamore@opensolaris.org     uint_t txfifo_sdwr_ptr;	/* TxFIFO Shadow Write Pointer */
2639610Sgdamore@opensolaris.org     uint_t txfifo_rd_ptr;	/* TxFIFO Read pointer */
2649610Sgdamore@opensolaris.org     uint_t txfifo_sdrd_ptr;	/* TxFIFO Shadow Read pointer */
2659610Sgdamore@opensolaris.org     uint_t txfifo_pkt_cnt;	/* TxFIFO Packet Counter */
2669610Sgdamore@opensolaris.org     uint_t state_mach;		/* ETX State Machine Register */
2679610Sgdamore@opensolaris.org     uint_t txring_size;		/* Descriptor Ring Size */
2689610Sgdamore@opensolaris.org     uint_t txbuf_ptr;		/* Transmit Data Buffer Pointer */
2699610Sgdamore@opensolaris.org };
2709610Sgdamore@opensolaris.org 
2719610Sgdamore@opensolaris.org /*
2729610Sgdamore@opensolaris.org  * ETX Transmit Pending Command Register - RW
2739610Sgdamore@opensolaris.org  * This 1-bit command must be issued by the software for every packet that the
2749610Sgdamore@opensolaris.org  * driver posts to the hardware.
2759610Sgdamore@opensolaris.org  * This bit becomes "self-cleared" after the command is executed.
2769610Sgdamore@opensolaris.org  */
2779610Sgdamore@opensolaris.org 
2789610Sgdamore@opensolaris.org #define	HMET_TXPEND_TDMD	(1 << 0)	/* wake up Tx DMA engine */
2799610Sgdamore@opensolaris.org 
2809610Sgdamore@opensolaris.org /*
2819610Sgdamore@opensolaris.org  * ETX Configuration Register
2829610Sgdamore@opensolaris.org  * If the desire is to buffer an entire standard Ethernet frame before its
2839610Sgdamore@opensolaris.org  * transmission is enabled, the Tx-FIFO-Threshold field has to be proframmed
2849610Sgdamore@opensolaris.org  * to "0x1ff".
2859610Sgdamore@opensolaris.org  * The default value for the register is 0x3fe.
2869610Sgdamore@opensolaris.org  * Bit 10 is used to modify the functionality of the Tx_All interrupt.
2879610Sgdamore@opensolaris.org  * If it is 0, Tx_All interrupt is generated after processing the last
2889610Sgdamore@opensolaris.org  * transmit descriptor with the OWN bit set. This only implies that the
2899610Sgdamore@opensolaris.org  * data has been copied to the FIFO.
2909610Sgdamore@opensolaris.org  * If it is 1, Tx_All interrupt is generated only after the entire
2919610Sgdamore@opensolaris.org  * Transmit FIFO has been drained.
2929610Sgdamore@opensolaris.org  */
2939610Sgdamore@opensolaris.org 
2949610Sgdamore@opensolaris.org #define	HMET_CONFIG_TXDMA_EN	(1 << 0)	/* Enable Tx DMA */
2959610Sgdamore@opensolaris.org #define	HMET_CONFIG_TXFIFOTH	(0x1ff << 1)	/* 1-9 : TX FIFO Threshold */
2969610Sgdamore@opensolaris.org #define	HMET_CONFIG_DRAIN_INT	(1 << 10)	/* TX_all_int modifier */
2979610Sgdamore@opensolaris.org 
2989610Sgdamore@opensolaris.org /*
2999610Sgdamore@opensolaris.org  * Transmit Descriptor Pointer
3009610Sgdamore@opensolaris.org  *
3019610Sgdamore@opensolaris.org  * This 29-bit register points to the next descriptor in the ring. The 21 most
3029610Sgdamore@opensolaris.org  * significant bits are used as the base address for the desriptor ring,
3039610Sgdamore@opensolaris.org  * and the 8 least significant bits are used as a displacement for the current
3049610Sgdamore@opensolaris.org  * descriptor.
3059610Sgdamore@opensolaris.org  *
3069610Sgdamore@opensolaris.org  * This register should be initialized to a 2KByte-aligned value after power-on
3079610Sgdamore@opensolaris.org  * or Software Reset.
3089610Sgdamore@opensolaris.org  *
3099610Sgdamore@opensolaris.org  */
3109610Sgdamore@opensolaris.org 
3119610Sgdamore@opensolaris.org /*
3129610Sgdamore@opensolaris.org  * ETX TX ring size register
3139610Sgdamore@opensolaris.org  * This is a 4-bit register to determine the no. of descriptor entries in the
3149610Sgdamore@opensolaris.org  * TX-ring. The number of entries can vary from 16 through 256 in increments of
3159610Sgdamore@opensolaris.org  * 16.
3169610Sgdamore@opensolaris.org  */
3179610Sgdamore@opensolaris.org 
3189610Sgdamore@opensolaris.org #define	HMET_RINGSZ_SHIFT	4
3199610Sgdamore@opensolaris.org 
3209610Sgdamore@opensolaris.org /* ************************************************************************* */
3219610Sgdamore@opensolaris.org 
3229610Sgdamore@opensolaris.org /* ERX Register Set */
3239610Sgdamore@opensolaris.org 
3249610Sgdamore@opensolaris.org struct hme_erx {
3259610Sgdamore@opensolaris.org     uint_t config;		/* ERX Configuration Register */
3269610Sgdamore@opensolaris.org     uint_t rxring;		/* Receive Descriptor Ring Pointer */
3279610Sgdamore@opensolaris.org     uint_t rxbuf_ptr;		/* Receive Data Buffer Pointer */
3289610Sgdamore@opensolaris.org     uint_t rxfifo_wr_ptr;	/* RxFIFO Write Pointer */
3299610Sgdamore@opensolaris.org     uint_t rxfifo_sdwr_ptr;	/* RxFIFO Shadow Write Pointer */
3309610Sgdamore@opensolaris.org     uint_t rxfifo_rd_ptr;	/* RxFIFO Read pointer */
3319610Sgdamore@opensolaris.org     uint_t rxfifo_pkt_cnt;	/* RxFIFO Packet Counter */
3329610Sgdamore@opensolaris.org     uint_t state_mach;		/* ERX State Machine Register */
3339610Sgdamore@opensolaris.org };
3349610Sgdamore@opensolaris.org 
3359610Sgdamore@opensolaris.org /*
3369610Sgdamore@opensolaris.org  * ERX Configuration Register - RW
3379610Sgdamore@opensolaris.org  * This 23-bit register determines the ERX-specific parameters that control the
3389610Sgdamore@opensolaris.org  * operation of the receive DMA channel.
3399610Sgdamore@opensolaris.org  */
3409610Sgdamore@opensolaris.org 
3419610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXDMA_EN	(1 << 0)	/* 0 : Enable Rx DMA */
3429610Sgdamore@opensolaris.org #define	HMER_CONFIG_RES1	(0x3 << 1)	/* 1,2 : reserverd */
3439610Sgdamore@opensolaris.org #define	HMER_CONFIG_FBOFFSET	(0x7 << 3)	/* 3-5 : First Byte Offset */
3449610Sgdamore@opensolaris.org #define	HMER_CONFIG_RES2	(0x7 << 6)	/* 6-8 : reserverd */
3459610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXRINGSZ	(0x3 << 9)	/* 9,10 : RX desc. ring size */
3469610Sgdamore@opensolaris.org #define	HMER_CONFIG_RES3	(0x1f << 11)	/* 11-15 : reserverd */
3479610Sgdamore@opensolaris.org #define	HMER_CONFIG_RX_CSSTART	(0x7f << 16)	/* 16-22 : cksum start offset */
3489610Sgdamore@opensolaris.org 
3499610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXRINGSZ32	(0x0 << 9)	/* Rx descr. ring size 32 */
3509610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXRINGSZ64	(0x1 << 9)	/* Rx descr. ring size 64 */
3519610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXRINGSZ128	(0x2 << 9)	/* Rx descr. ring size 128 */
3529610Sgdamore@opensolaris.org #define	HMER_CONFIG_RXRINGSZ256	(0x3 << 9)	/* Rx descr. ring size 256 */
3539610Sgdamore@opensolaris.org 
3549610Sgdamore@opensolaris.org #define	HMER_CONFIG_FBO_SHIFT	3
3559610Sgdamore@opensolaris.org #define	HMER_RXRINGSZ_SHIFT 	9
3569610Sgdamore@opensolaris.org #define	HMER_RX_CSSTART_SHIFT	16
3579610Sgdamore@opensolaris.org 
3589610Sgdamore@opensolaris.org /*
3599610Sgdamore@opensolaris.org  * Receive Descriptor Pointer
3609610Sgdamore@opensolaris.org  *
3619610Sgdamore@opensolaris.org  * This 29-bit register points to the next descriptor in the ring. The 21 most
3629610Sgdamore@opensolaris.org  * significant bits are used as the base address for the desriptor ring,
3639610Sgdamore@opensolaris.org  * and the 8 least significant bits are used as a displacement for the current
3649610Sgdamore@opensolaris.org  * descriptor.
3659610Sgdamore@opensolaris.org  *
3669610Sgdamore@opensolaris.org  * This register should be initialized to a 2KByte-aligned value after power-on
3679610Sgdamore@opensolaris.org  * or Software Reset.
3689610Sgdamore@opensolaris.org  *
3699610Sgdamore@opensolaris.org  */
3709610Sgdamore@opensolaris.org 
3719610Sgdamore@opensolaris.org /* ************************************************************************* */
3729610Sgdamore@opensolaris.org 
3739610Sgdamore@opensolaris.org 
3749610Sgdamore@opensolaris.org 
3759610Sgdamore@opensolaris.org /*
3769610Sgdamore@opensolaris.org  * Declarations and definitions specific to the BigMAC functional block.
3779610Sgdamore@opensolaris.org  *
3789610Sgdamore@opensolaris.org  * The BigMAC block will provide the MAC functons for 10 or 100 Mbps CSMA/CD
3799610Sgdamore@opensolaris.org  * protocol based interface.
3809610Sgdamore@opensolaris.org  *
3819610Sgdamore@opensolaris.org  */
3829610Sgdamore@opensolaris.org 
3839610Sgdamore@opensolaris.org /*
3849610Sgdamore@opensolaris.org  * BigMAC Register Set.
3859610Sgdamore@opensolaris.org  * BigMAC addresses map on a SBus word boundry. So all registers are
3869610Sgdamore@opensolaris.org  * declared for a size of 32 bits. Registers that use fewer than 32
3879610Sgdamore@opensolaris.org  * bits will return 0 in the bits not used.
3889610Sgdamore@opensolaris.org  */
3899610Sgdamore@opensolaris.org struct	hme_bmac {
3909610Sgdamore@opensolaris.org 	uint_t	xifc;		/* XIF Configuration register [9-0] (RW) */
3919610Sgdamore@opensolaris.org 	uint_t	pad1[129];	/* XXX unused */
3929610Sgdamore@opensolaris.org 	uint_t	txrst;		/* tx software reset (RW) */
3939610Sgdamore@opensolaris.org 	uint_t	txcfg;		/* tx configuration register [9-0] (RW) */
3949610Sgdamore@opensolaris.org 	uint_t	ipg1;		/* Inter Packet Gap 1 [7-0] (RW) */
3959610Sgdamore@opensolaris.org 	uint_t	ipg2;		/* Inter Packet Gap 2 [7-0] (RW) */
3969610Sgdamore@opensolaris.org 	uint_t	alimit;		/* attempt limit register [7-0] (RW) */
3979610Sgdamore@opensolaris.org 	uint_t	slot;		/* slot time register [7-0] (RW) */
3989610Sgdamore@opensolaris.org 	uint_t	palen;		/* preamble length register [7-0] (RW) */
3999610Sgdamore@opensolaris.org 	uint_t	papat;		/* preamble pattern register [7-0] (RW) */
4009610Sgdamore@opensolaris.org 	uint_t	txsfd;		/* tx start frame delimiter [7-0] (RW) */
4019610Sgdamore@opensolaris.org 	uint_t	jam;		/* jam size register [7-0] (RW) */
4029610Sgdamore@opensolaris.org 	uint_t	txmax;		/* tx maximum packet size [12-0] (RW) */
4039610Sgdamore@opensolaris.org 	uint_t	txmin;		/* tx minimum frame size [7-0] (RW) */
4049610Sgdamore@opensolaris.org 	uint_t	parg;		/* peak attempt count [7-0] (RW) */
4059610Sgdamore@opensolaris.org 	uint_t	dcnt;		/* defer timer counter [15-0] (RW) */
4069610Sgdamore@opensolaris.org 	uint_t	nccnt;		/* normal collision counter [15-0] (RW) */
4079610Sgdamore@opensolaris.org 	uint_t	fccnt;		/* first succesful coll. counter [15-0] (RW) */
4089610Sgdamore@opensolaris.org 	uint_t	excnt;		/* excess collision counter [7-0] (RW) */
4099610Sgdamore@opensolaris.org 	uint_t	ltcnt;		/* late collision counter [7-0] (RW) */
4109610Sgdamore@opensolaris.org 	uint_t	rseed;		/* random number seed [9-0] (RW) */
4119610Sgdamore@opensolaris.org 	uint_t	txsm;		/* tx state machine register [8-0] (R) */
4129610Sgdamore@opensolaris.org 	uint_t	pad2[44];	/* XXX Unused */
4139610Sgdamore@opensolaris.org 	uint_t	rxrst;		/* rx software reset register (RW) */
4149610Sgdamore@opensolaris.org 	uint_t	rxcfg;		/* rx configuration register [12-0] (RW) */
4159610Sgdamore@opensolaris.org 	uint_t	rxmax;		/* rx maximum packet size [12-0] (RW) */
4169610Sgdamore@opensolaris.org 	uint_t	rxmin;		/* rx minimum frame size [7-0] (RW) */
4179610Sgdamore@opensolaris.org 	uint_t	madd2;		/* mac address register 2 [47-32] (RW) */
4189610Sgdamore@opensolaris.org 	uint_t	madd1;		/* mac address register 1 [31-16] (RW) */
4199610Sgdamore@opensolaris.org 	uint_t	madd0;		/* mac address register 0 [15-0] (RW) */
4209610Sgdamore@opensolaris.org 	uint_t	frcnt;		/* receive frame count [15-0] (RW) */
4219610Sgdamore@opensolaris.org 	uint_t	lecnt;		/* rx giant length error count [7-0] (RW) */
4229610Sgdamore@opensolaris.org 	uint_t	aecnt;		/* rx alignment error count [7-0] (RW) */
4239610Sgdamore@opensolaris.org 	uint_t	fecnt;		/* receive crc error count [7-0] (RW) */
4249610Sgdamore@opensolaris.org 	uint_t	rxsm;		/* rx state machine register (R) */
4259610Sgdamore@opensolaris.org 	uint_t	rxcv;		/* rx code voilation register (R) */
4269610Sgdamore@opensolaris.org 	uchar_t	pad3[4];
4279610Sgdamore@opensolaris.org 	uint_t	hash3;		/* hash table 3 [63-48] (RW) */
4289610Sgdamore@opensolaris.org 	uint_t	hash2;		/* hash table 2 [47-32] (RW) */
4299610Sgdamore@opensolaris.org 	uint_t	hash1;		/* hash table 1 [31-16] (RW) */
4309610Sgdamore@opensolaris.org 	uint_t	hash0;		/* hash table 0 [15-0] (RW) */
4319610Sgdamore@opensolaris.org 	uint_t	afr2;		/* addr filter register 0_2 [15-0] (RW) */
4329610Sgdamore@opensolaris.org 	uint_t	afr1;		/* addr filter register 0_1 [15-0] (RW) */
4339610Sgdamore@opensolaris.org 	uint_t	afr0;		/* addr filter register 0_0 [15-0] (RW) */
4349610Sgdamore@opensolaris.org 	uint_t	afmr;		/* addr filter mask reg 0 [15-0] (RW) */
4359610Sgdamore@opensolaris.org };
4369610Sgdamore@opensolaris.org 
4379610Sgdamore@opensolaris.org /*
4389610Sgdamore@opensolaris.org  * BigMAC Register Bit Masks.
4399610Sgdamore@opensolaris.org  */
4409610Sgdamore@opensolaris.org 
4419610Sgdamore@opensolaris.org /* XIF Configuration Register */
4429610Sgdamore@opensolaris.org 
4439610Sgdamore@opensolaris.org #define	BMAC_XIFC_ENAB		(1 << 0)	/* Enable XIF output drivers */
4449610Sgdamore@opensolaris.org #define	BMAC_XIFC_XIFLPBK	(1 << 1)	/* Enable XIF Loopback mode */
4459610Sgdamore@opensolaris.org #define	BMAC_XIFC_MIILPBK	(1 << 2)	/* Enable MII Loopback mode */
4469610Sgdamore@opensolaris.org #define	BMAC_XIFC_MIIBUFDIS	(1 << 3)	/* Disable MII Recv Buffers */
4479610Sgdamore@opensolaris.org 
4489610Sgdamore@opensolaris.org /* IN FEPS 2.1 or earlier rev */
4499610Sgdamore@opensolaris.org #define	BMAC_XIFC_SQETSTENB	(1 << 4)	/* Enable SQE Test */
4509610Sgdamore@opensolaris.org #define	BMAC_XIFC_SQETSTWIN	(0x1f << 5)	/* SQE Test time window */
4519610Sgdamore@opensolaris.org 
4529610Sgdamore@opensolaris.org /* IN FEPS 2.2 or later rev */
4539610Sgdamore@opensolaris.org #define	BMAC_XIFC_LANCE_ENAB	(1 << 4)	/* Enable  LANCE mode */
4549610Sgdamore@opensolaris.org #define	BMAC_XIFC_LANCE_IPG0	(0x1f << 5)	/* IPG0 for LANCE mode */
4559610Sgdamore@opensolaris.org 
4569610Sgdamore@opensolaris.org #define	BMAC_XIFC_IPG0_SHIFT	5
4579610Sgdamore@opensolaris.org 
4589610Sgdamore@opensolaris.org /*
4599610Sgdamore@opensolaris.org  * TX_MAC Software Reset Command Register
4609610Sgdamore@opensolaris.org  * This bit is set to 1 when a PIO write is done. This bit becomes self-cleared.
4619610Sgdamore@opensolaris.org  * after the command has been executed.
4629610Sgdamore@opensolaris.org  */
4639610Sgdamore@opensolaris.org 
4649610Sgdamore@opensolaris.org #define	BMAC_TX_RESET		(1 << 0)	/* TX_MAC Reset Command */
4659610Sgdamore@opensolaris.org 
4669610Sgdamore@opensolaris.org /*
4679610Sgdamore@opensolaris.org  * TX_MAC Configuration Register
4689610Sgdamore@opensolaris.org  * To Ensure proper operation of the TX_MAC, the TX_MAC_Enable bit must always
4699610Sgdamore@opensolaris.org  * be cleared to 0 and a delay imposed before a PIO write to any of the other
4709610Sgdamore@opensolaris.org  * bits in the TX_MAC Configuration register or any of the MAC parameter
4719610Sgdamore@opensolaris.org  * registers is done.
4729610Sgdamore@opensolaris.org  *
4739610Sgdamore@opensolaris.org  * The amount of delay required depends on the time required to transmit a max.
4749610Sgdamore@opensolaris.org  * size frame.
4759610Sgdamore@opensolaris.org  */
4769610Sgdamore@opensolaris.org 
4779610Sgdamore@opensolaris.org #define	BMACTXRSTDELAY		(125)		/* 125 us wait period */
4789610Sgdamore@opensolaris.org 
4799610Sgdamore@opensolaris.org #define	BMAC_TXCFG_ENAB		(1 << 0)	/* tx enable */
4809610Sgdamore@opensolaris.org #define	BMAC_TXCFG_RES1		(0xf << 1)	/* 1-4 : reserved */
4819610Sgdamore@opensolaris.org #define	BMAC_TXCFG_SLOW		(1 << 5)	/* carrier detect before tx */
4829610Sgdamore@opensolaris.org #define	BMAC_TXCFG_IGCOLL	(1 << 6)	/* tx ignore collision */
4839610Sgdamore@opensolaris.org #define	BMAC_TXCFG_NFCS		(1 << 7)	/* no FCS will be generated */
4849610Sgdamore@opensolaris.org #define	BMAC_TXCFG_NBKOFF	(1 << 8)	/* No Backoff */
4859610Sgdamore@opensolaris.org #define	BMAC_TXCFG_FDX		(1 << 9)	/* Full Duplex */
4869610Sgdamore@opensolaris.org #define	BMAC_TXCFG_NGU		(1 << 10)	/* Never Give Up */
4879610Sgdamore@opensolaris.org 
4889610Sgdamore@opensolaris.org /*
4899610Sgdamore@opensolaris.org  * RX_MAC Configuration Register
4909610Sgdamore@opensolaris.org  * A delay of 3.2 us should be allowed after clearing Rx_MAC_Enable or
4919610Sgdamore@opensolaris.org  * Hash_Filter_enable or Address_Filter_Enable bits.
4929610Sgdamore@opensolaris.org  */
4939610Sgdamore@opensolaris.org 
4949610Sgdamore@opensolaris.org #define	BMACRXRSTDELAY		(40)		/* 3.2 us wait period */
4959610Sgdamore@opensolaris.org 
4969610Sgdamore@opensolaris.org #define	BMAC_RXCFG_ENAB		(1 << 0)	/* rx enable */
4979610Sgdamore@opensolaris.org #define	BMAC_RXCFG_RES1		(0xf << 1)	/* 1-4 : reserved */
4989610Sgdamore@opensolaris.org #define	BMAC_RXCFG_STRIP	(1 << 5)	/* rx strip pad bytes */
4999610Sgdamore@opensolaris.org #define	BMAC_RXCFG_PROMIS	(1 << 6)	/* rx enable promiscous */
5009610Sgdamore@opensolaris.org #define	BMAC_RXCFG_ERR		(1 << 7)	/* rx disable error checking */
5019610Sgdamore@opensolaris.org #define	BMAC_RXCFG_CRC		(1 << 8)	/* rx disable CRC stripping */
5029610Sgdamore@opensolaris.org #define	BMAC_RXCFG_MYOWN	(1 << 9)	/* rx filter own packets */
5039610Sgdamore@opensolaris.org #define	BMAC_RXCFG_GRPROM	(1 << 10)	/* rx promiscuous group mode */
5049610Sgdamore@opensolaris.org #define	BMAC_RXCFG_HASH		(1 << 11)	/* rx enable hash filter */
5059610Sgdamore@opensolaris.org #define	BMAC_RXCFG_ADDR		(1 << 12)	/* rx enable address filter */
5069610Sgdamore@opensolaris.org 
5079610Sgdamore@opensolaris.org 
5089610Sgdamore@opensolaris.org 
5099610Sgdamore@opensolaris.org /* ************************************************************************* */
5109610Sgdamore@opensolaris.org 
5119610Sgdamore@opensolaris.org /*
5129610Sgdamore@opensolaris.org  * MII Transceiver Interface
5139610Sgdamore@opensolaris.org  *
5149610Sgdamore@opensolaris.org  * The Management Interface (MIF) allows the host to program and collect status
5159610Sgdamore@opensolaris.org  * from two transceivers connected to the MII. MIF supports three modes of
5169610Sgdamore@opensolaris.org  * operation:
5179610Sgdamore@opensolaris.org  *	1. Bit-Bang Mode
5189610Sgdamore@opensolaris.org  *	   This mode is imlemented using three 1-bit registers: data, clock,
5199610Sgdamore@opensolaris.org  *	   and output_enable.
5209610Sgdamore@opensolaris.org  *
5219610Sgdamore@opensolaris.org  *	2. Frame Mode
5229610Sgdamore@opensolaris.org  *	   This mode is supported using one 32-bit register: Frame register.
5239610Sgdamore@opensolaris.org  *	   The software loads the Frame Register with avalid instaruction
5249610Sgdamore@opensolaris.org  *	   ("frame"), and polls the Valid Bit for completion.
5259610Sgdamore@opensolaris.org  *
5269610Sgdamore@opensolaris.org  *	3. Polling Mode
5279610Sgdamore@opensolaris.org  *	   The Polling mechanism is used for detecting a status change in the
5289610Sgdamore@opensolaris.org  *	   transceiver. When this mode is enabled, the MIF will continuously
5299610Sgdamore@opensolaris.org  *	   poll a specified transceiver register and generate a maskable
5309610Sgdamore@opensolaris.org  *	   interrupt when a status change is detected. This mode of operation
5319610Sgdamore@opensolaris.org  *	   can only be used when the MIF is in the "Frame mode".
5329610Sgdamore@opensolaris.org  *
5339610Sgdamore@opensolaris.org  */
5349610Sgdamore@opensolaris.org 
5359610Sgdamore@opensolaris.org struct hme_mif {
5369610Sgdamore@opensolaris.org 	uint_t mif_bbclk;	/* MIF Bit Bang Clock */
5379610Sgdamore@opensolaris.org 	uint_t mif_bbdata;	/* MIF Bit Bang Data */
5389610Sgdamore@opensolaris.org 	uint_t mif_bbopenb;	/* MIF Bit Bang Output Enable */
5399610Sgdamore@opensolaris.org 	uint_t mif_frame;	/* MIF Frame - ctl and data */
5409610Sgdamore@opensolaris.org 	uint_t mif_cfg;		/* MIF Configuration */
5419610Sgdamore@opensolaris.org 	uint_t mif_imask;	/* MIF Interrupt mask */
5429610Sgdamore@opensolaris.org 	uint_t mif_bsts;	/* MIF Basic/Status register */
5439610Sgdamore@opensolaris.org 	uint_t mif_fsm;		/* MIF State machine register */
5449610Sgdamore@opensolaris.org };
5459610Sgdamore@opensolaris.org 
5469610Sgdamore@opensolaris.org /* mif_bbc - Bit Bang Clock register */
5479610Sgdamore@opensolaris.org #define	HME_MIF_BBCLK	(1 << 0);	/* Bit Babg Clock */
5489610Sgdamore@opensolaris.org 
5499610Sgdamore@opensolaris.org #define	HME_BBCLK_LOW 0
5509610Sgdamore@opensolaris.org #define	HME_BBCLK_HIGH 1
5519610Sgdamore@opensolaris.org 
5529610Sgdamore@opensolaris.org /* mif_bbdata - bit Bang Data register */
5539610Sgdamore@opensolaris.org #define	HME_MIF_BBDATA	(1 << 0);	/* Bit Bang Data */
5549610Sgdamore@opensolaris.org 
5559610Sgdamore@opensolaris.org /* mif_bbopenb - Bit Bang oOutput Enable register */
5569610Sgdamore@opensolaris.org #define	HME_MIF_BBOPENB	(1 << 0);	/* Bit Bang output Enable */
5579610Sgdamore@opensolaris.org 
5589610Sgdamore@opensolaris.org /*
5599610Sgdamore@opensolaris.org  * Management Frame Structure:
5609610Sgdamore@opensolaris.org  * <IDLE> <ST><OP><PHYAD><REGAD><TA>	 <DATA>		   <IDLE>
5619610Sgdamore@opensolaris.org  * READ:  <01><10><AAAAA><RRRRR><Z0><DDDDDDDDDDDDDDDD>
5629610Sgdamore@opensolaris.org  * WRITE: <01><01><AAAAA><RRRRR><10><DDDDDDDDDDDDDDDD>
5639610Sgdamore@opensolaris.org  */
5649610Sgdamore@opensolaris.org 
5659610Sgdamore@opensolaris.org /* mif_frame - MIF control and data register */
5669610Sgdamore@opensolaris.org 
5679610Sgdamore@opensolaris.org #define	HME_MIF_FRDATA	(0xffff << 0)	/* 0-15 : data bits */
5689610Sgdamore@opensolaris.org #define	HME_MIF_FRTA0	(0x1 << 16)	/* 16 : TA bit, 1 for completion */
5699610Sgdamore@opensolaris.org #define	HME_MIF_FRTA1	(0x1 << 17)	/* 16-17 : TA bits */
5709610Sgdamore@opensolaris.org #define	HME_MIF_FRREGAD	(0x1f << 18)	/* 18-22 : register address bits */
5719610Sgdamore@opensolaris.org #define	HME_MIF_FRPHYAD	(0x1f << 23)	/* 23-27 : PHY ad, should be 0 */
5729610Sgdamore@opensolaris.org #define	HME_MIF_FROP	(0x3 << 28)	/* 28-29 : Operation - Write/Read */
5739610Sgdamore@opensolaris.org #define	HME_MIF_FRST	(0xc0000000)	/* 30-31 : START bits */
5749610Sgdamore@opensolaris.org 
5759610Sgdamore@opensolaris.org #define	HME_MIF_FRREGAD_SHIFT	18
5769610Sgdamore@opensolaris.org #define	HME_MIF_FRPHYAD_SHIFT	23
5779610Sgdamore@opensolaris.org #define	HME_MIF_FRREAD		0x60020000
5789610Sgdamore@opensolaris.org #define	HME_MIF_FRWRITE		0x50020000
5799610Sgdamore@opensolaris.org 
5809610Sgdamore@opensolaris.org /* maximum delay for MIF Register Read/Write operation */
5819610Sgdamore@opensolaris.org #define	HMEMAXMIFDELAY	(100)
5829610Sgdamore@opensolaris.org 
5839610Sgdamore@opensolaris.org /* maximum delay for Transceiver Reset */
5849610Sgdamore@opensolaris.org #define	HME_PHYRST_MAXDELAY	(500)
5859610Sgdamore@opensolaris.org 
5869610Sgdamore@opensolaris.org /* mif_cfg - MIF Configuration Register */
5879610Sgdamore@opensolaris.org 
5889610Sgdamore@opensolaris.org #define	HME_MIF_CFGPS	(1 << 0)	/* PHY Select */
5899610Sgdamore@opensolaris.org #define	HME_MIF_CFGPE	(1 << 1)	/* Poll Enable */
5909610Sgdamore@opensolaris.org #define	HME_MIF_CFGBB	(1 << 2)	/* Bit Bang Enable */
5919610Sgdamore@opensolaris.org #define	HME_MIF_CFGPR	(0x1f << 3)	/* Poll Register address */
5929610Sgdamore@opensolaris.org #define	HME_MIF_CFGM0	(1 << 8)	/* MDIO_0 Data / MDIO_0 attached */
5939610Sgdamore@opensolaris.org #define	HME_MIF_CFGM1	(1 << 9)	/* MDIO_1 Data / MDIO_1 attached */
5949610Sgdamore@opensolaris.org #define	HME_MIF_CFGPD	(0x1f << 10)	/* Poll Device PHY address */
5959610Sgdamore@opensolaris.org 
5969610Sgdamore@opensolaris.org #define	HME_MIF_CFGPR_SHIFT	3
5979610Sgdamore@opensolaris.org #define	HME_MIF_CFGPD_SHIFT	10
5989610Sgdamore@opensolaris.org #define	HME_MIF_POLL_DELAY	200
5999610Sgdamore@opensolaris.org 
6009610Sgdamore@opensolaris.org /*
6019610Sgdamore@opensolaris.org  * MDIO_0 corresponds to the On Board Transceiver.
6029610Sgdamore@opensolaris.org  * MDIO_1 corresponds to the External Transceiver.
6039610Sgdamore@opensolaris.org  * The PHYAD for both is 0.
6049610Sgdamore@opensolaris.org  */
6059610Sgdamore@opensolaris.org 
6069610Sgdamore@opensolaris.org #define	HME_INTERNAL_PHYAD	1	/* PHY address for int. transceiver */
6079610Sgdamore@opensolaris.org #define	HME_EXTERNAL_PHYAD	0	/* PHY address for ext. transceiver */
6089610Sgdamore@opensolaris.org 
6099610Sgdamore@opensolaris.org 
6109610Sgdamore@opensolaris.org /* mif_imask - MIF Interrupt Mask Register */
6119610Sgdamore@opensolaris.org /*
6129610Sgdamore@opensolaris.org  * This register is bit-to-bit same as Basic/Status Register
6139610Sgdamore@opensolaris.org  */
6149610Sgdamore@opensolaris.org #define	HME_MIF_INTMASK	(0xffff << 0)	/* 0-15 : Interrupt mask */
6159610Sgdamore@opensolaris.org 
6169610Sgdamore@opensolaris.org /* mif_bassts - MIF Basic / Status register */
6179610Sgdamore@opensolaris.org /*
6189610Sgdamore@opensolaris.org  * The Basic portion of this register indicates the last value of the register
6199610Sgdamore@opensolaris.org  * read indicated in the POLL REG field of the Configuration Register.
6209610Sgdamore@opensolaris.org  * The Status portion indicates bit(s) that have changed.
6219610Sgdamore@opensolaris.org  * The MIF Mask register is corresponding to this register in terms of the
6229610Sgdamore@opensolaris.org  * bit(s) that need to be masked for generating interrupt on the MIF Interrupt
6239610Sgdamore@opensolaris.org  * Bit of the Global Status Rgister.
6249610Sgdamore@opensolaris.org  */
6259610Sgdamore@opensolaris.org 
6269610Sgdamore@opensolaris.org #define	HME_MIF_STATUS	(0xffff << 0)	/* 0-15 : Status */
6279610Sgdamore@opensolaris.org #define	HME_MIF_BASIC	(0xffff << 16)	/* 16-31 : Basic register */
6289610Sgdamore@opensolaris.org 
6299610Sgdamore@opensolaris.org /* mif_fsm - MIF State Machine register */
6309610Sgdamore@opensolaris.org 
6319610Sgdamore@opensolaris.org #define	HME_MIF_FSM	(0x3ff << 0)	/* 0-9 : MIF state */
6329610Sgdamore@opensolaris.org 
6339610Sgdamore@opensolaris.org /* ************************************************************************ */
6349610Sgdamore@opensolaris.org 
6359610Sgdamore@opensolaris.org 
6369610Sgdamore@opensolaris.org /*
6379610Sgdamore@opensolaris.org  * Definition for the time required to wait after a software
6389610Sgdamore@opensolaris.org  * reset has been issued.
6399610Sgdamore@opensolaris.org  */
6409610Sgdamore@opensolaris.org #define	HMEMAXRSTDELAY	(200)
6419610Sgdamore@opensolaris.org #define	HMEPERIOD	(20)	/* period to wait */
6429610Sgdamore@opensolaris.org #define	HMEWAITPERIOD	HMEPERIOD
6439610Sgdamore@opensolaris.org 
6449610Sgdamore@opensolaris.org #define	HMEDELAY(c, n) \
6459610Sgdamore@opensolaris.org 	{ \
6469610Sgdamore@opensolaris.org 		register int N = n / HMEWAITPERIOD; \
6479610Sgdamore@opensolaris.org 		while (--N > 0) { \
6489610Sgdamore@opensolaris.org 			if (c) \
6499610Sgdamore@opensolaris.org 				break; \
6509610Sgdamore@opensolaris.org 			drv_usecwait(HMEWAITPERIOD); \
6519610Sgdamore@opensolaris.org 		} \
6529610Sgdamore@opensolaris.org 	}
6539610Sgdamore@opensolaris.org 
6549610Sgdamore@opensolaris.org #endif	/* HME_MAC_H */
655