xref: /onnv-gate/usr/src/uts/common/sys/nxge/nxge_mii.h (revision 5203:59f5e8f20d30)
13859Sml29623 /*
23859Sml29623  * CDDL HEADER START
33859Sml29623  *
43859Sml29623  * The contents of this file are subject to the terms of the
53859Sml29623  * Common Development and Distribution License (the "License").
63859Sml29623  * You may not use this file except in compliance with the License.
73859Sml29623  *
83859Sml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93859Sml29623  * or http://www.opensolaris.org/os/licensing.
103859Sml29623  * See the License for the specific language governing permissions
113859Sml29623  * and limitations under the License.
123859Sml29623  *
133859Sml29623  * When distributing Covered Code, include this CDDL HEADER in each
143859Sml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153859Sml29623  * If applicable, add the following below this CDDL HEADER, with the
163859Sml29623  * fields enclosed by brackets "[]" replaced with your own identifying
173859Sml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
183859Sml29623  *
193859Sml29623  * CDDL HEADER END
203859Sml29623  */
213859Sml29623 /*
225196Ssbehera  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
233859Sml29623  * Use is subject to license terms.
243859Sml29623  */
253859Sml29623 
263859Sml29623 #ifndef _SYS_NXGE_NXGE_MII_H_
273859Sml29623 #define	_SYS_NXGE_NXGE_MII_H_
283859Sml29623 
293859Sml29623 #pragma ident	"%Z%%M%	%I%	%E% SMI"
303859Sml29623 
313859Sml29623 #ifdef __cplusplus
323859Sml29623 extern "C" {
333859Sml29623 #endif
343859Sml29623 
35*5203Ssbehera #include <sys/miiregs.h>
36*5203Ssbehera 
373859Sml29623 /*
383859Sml29623  * Configuration Register space.
393859Sml29623  */
403859Sml29623 
41*5203Ssbehera #define	NXGE_MII_LPRXNPR		8
42*5203Ssbehera #define	NXGE_MII_GCR			9
43*5203Ssbehera #define	NXGE_MII_GSR			10
44*5203Ssbehera #define	NXGE_MII_RES0			11
45*5203Ssbehera #define	NXGE_MII_RES1			12
46*5203Ssbehera #define	NXGE_MII_RES2			13
47*5203Ssbehera #define	NXGE_MII_RES3			14
48*5203Ssbehera #define	NXGE_MII_ESR			15
49*5203Ssbehera 
50*5203Ssbehera #define	NXGE_MII_SHADOW			MII_VENDOR(0xc)
515196Ssbehera /* Shadow register definition */
52*5203Ssbehera #define	NXGE_MII_MODE_CONTROL_REG	MII_VENDOR(0xf)
533859Sml29623 
54*5203Ssbehera #define	NXGE_MAX_MII_REGS		32
553859Sml29623 
563859Sml29623 /*
573859Sml29623  * Configuration Register space.
583859Sml29623  */
593859Sml29623 typedef struct _mii_regs {
603859Sml29623 	uchar_t bmcr;		/* Basic mode control register */
613859Sml29623 	uchar_t bmsr;		/* Basic mode status register */
623859Sml29623 	uchar_t idr1;		/* Phy identifier register 1 */
633859Sml29623 	uchar_t idr2;		/* Phy identifier register 2 */
643859Sml29623 	uchar_t anar;		/* Auto-Negotiation advertisement register */
653859Sml29623 	uchar_t anlpar;		/* Auto-Negotiation link Partner ability reg */
663859Sml29623 	uchar_t aner;		/* Auto-Negotiation expansion register */
673859Sml29623 	uchar_t nptxr;		/* Next page transmit register */
683859Sml29623 	uchar_t lprxnpr;	/* Link partner received next page register */
693859Sml29623 	uchar_t gcr;		/* Gigabit basic mode control register. */
703859Sml29623 	uchar_t gsr;		/* Gigabit basic mode status register */
713859Sml29623 	uchar_t mii_res1[4];	/* For future use by MII working group */
723859Sml29623 	uchar_t esr;		/* Extended status register. */
735196Ssbehera 	uchar_t vendor_res[12];	/* For future use by Phy Vendors */
745196Ssbehera 	uchar_t shadow;
755196Ssbehera 	uchar_t vendor_res2[3]; /* For future use by Phy Vendors */
763859Sml29623 } mii_regs_t, *p_mii_regs_t;
773859Sml29623 
783859Sml29623 /*
793859Sml29623  * MII Register 0: Basic mode control register.
803859Sml29623  */
813859Sml29623 typedef union _mii_bmcr {
823859Sml29623 	uint16_t value;
833859Sml29623 	struct {
843859Sml29623 #if defined(_BIT_FIELDS_HTOL)
853859Sml29623 		uint16_t reset:1;
863859Sml29623 		uint16_t loopback:1;
873859Sml29623 		uint16_t speed_sel:1;
883859Sml29623 		uint16_t enable_autoneg:1;
893859Sml29623 		uint16_t power_down:1;
903859Sml29623 		uint16_t isolate:1;
913859Sml29623 		uint16_t restart_autoneg:1;
923859Sml29623 		uint16_t duplex_mode:1;
933859Sml29623 		uint16_t col_test:1;
943859Sml29623 		uint16_t speed_1000_sel:1;
953859Sml29623 		uint16_t res1:6;
963859Sml29623 #elif defined(_BIT_FIELDS_LTOH)
973859Sml29623 		uint16_t res1:6;
983859Sml29623 		uint16_t speed_1000_sel:1;
993859Sml29623 		uint16_t col_test:1;
1003859Sml29623 		uint16_t duplex_mode:1;
1013859Sml29623 		uint16_t restart_autoneg:1;
1023859Sml29623 		uint16_t isolate:1;
1033859Sml29623 		uint16_t power_down:1;
1043859Sml29623 		uint16_t enable_autoneg:1;
1053859Sml29623 		uint16_t speed_sel:1;
1063859Sml29623 		uint16_t loopback:1;
1073859Sml29623 		uint16_t reset:1;
1083859Sml29623 #endif
1093859Sml29623 	} bits;
1103859Sml29623 } mii_bmcr_t, *p_mii_bmcr_t;
1113859Sml29623 
1123859Sml29623 /*
1133859Sml29623  * MII Register 1:  Basic mode status register.
1143859Sml29623  */
1153859Sml29623 typedef union _mii_bmsr {
1163859Sml29623 	uint16_t value;
1173859Sml29623 	struct {
1183859Sml29623 #if defined(_BIT_FIELDS_HTOL)
1193859Sml29623 		uint16_t link_100T4:1;
1203859Sml29623 		uint16_t link_100fdx:1;
1213859Sml29623 		uint16_t link_100hdx:1;
1223859Sml29623 		uint16_t link_10fdx:1;
1233859Sml29623 		uint16_t link_10hdx:1;
1243859Sml29623 		uint16_t res2:2;
1253859Sml29623 		uint16_t extend_status:1;
1263859Sml29623 		uint16_t res1:1;
1273859Sml29623 		uint16_t preamble_supress:1;
1283859Sml29623 		uint16_t auto_neg_complete:1;
1293859Sml29623 		uint16_t remote_fault:1;
1303859Sml29623 		uint16_t auto_neg_able:1;
1313859Sml29623 		uint16_t link_status:1;
1323859Sml29623 		uint16_t jabber_detect:1;
1333859Sml29623 		uint16_t ext_cap:1;
1343859Sml29623 #elif defined(_BIT_FIELDS_LTOH)
1353859Sml29623 		int16_t ext_cap:1;
1363859Sml29623 		uint16_t jabber_detect:1;
1373859Sml29623 		uint16_t link_status:1;
1383859Sml29623 		uint16_t auto_neg_able:1;
1393859Sml29623 		uint16_t remote_fault:1;
1403859Sml29623 		uint16_t auto_neg_complete:1;
1413859Sml29623 		uint16_t preamble_supress:1;
1423859Sml29623 		uint16_t res1:1;
1433859Sml29623 		uint16_t extend_status:1;
1443859Sml29623 		uint16_t res2:2;
1453859Sml29623 		uint16_t link_10hdx:1;
1463859Sml29623 		uint16_t link_10fdx:1;
1473859Sml29623 		uint16_t link_100hdx:1;
1483859Sml29623 		uint16_t link_100fdx:1;
1493859Sml29623 		uint16_t link_100T4:1;
1503859Sml29623 #endif
1513859Sml29623 	} bits;
1523859Sml29623 } mii_bmsr_t, *p_mii_bmsr_t;
1533859Sml29623 
1543859Sml29623 /*
1553859Sml29623  * MII Register 2: Physical Identifier 1.
1563859Sml29623  */
1573859Sml29623 /* contains BCM OUI bits [3:18] */
1583859Sml29623 typedef union _mii_idr1 {
1593859Sml29623 	uint16_t value;
1603859Sml29623 	struct {
1613859Sml29623 		uint16_t ieee_address:16;
1623859Sml29623 	} bits;
1633859Sml29623 } mii_idr1_t, *p_mii_idr1_t;
1643859Sml29623 
1653859Sml29623 /*
1663859Sml29623  * MII Register 3: Physical Identifier 2.
1673859Sml29623  */
1683859Sml29623 typedef union _mii_idr2 {
1693859Sml29623 	uint16_t value;
1703859Sml29623 	struct {
1713859Sml29623 #if defined(_BIT_FIELDS_HTOL)
1723859Sml29623 		uint16_t ieee_address:6;
1733859Sml29623 		uint16_t model_no:6;
1743859Sml29623 		uint16_t rev_no:4;
1753859Sml29623 #elif defined(_BIT_FIELDS_LTOH)
1763859Sml29623 		uint16_t rev_no:4;
1773859Sml29623 		uint16_t model_no:6;
1783859Sml29623 		uint16_t ieee_address:6;
1793859Sml29623 #endif
1803859Sml29623 	} bits;
1813859Sml29623 } mii_idr2_t, *p_mii_idr2_t;
1823859Sml29623 
1833859Sml29623 /*
1843859Sml29623  * MII Register 4: Auto-negotiation advertisement register.
1853859Sml29623  */
1863859Sml29623 typedef union _mii_anar {
1873859Sml29623 	uint16_t value;
1883859Sml29623 	struct {
1893859Sml29623 #if defined(_BIT_FIELDS_HTOL)
1903859Sml29623 		uint16_t np_indication:1;
1913859Sml29623 		uint16_t acknowledge:1;
1923859Sml29623 		uint16_t remote_fault:1;
1933859Sml29623 		uint16_t res1:1;
1943859Sml29623 		uint16_t cap_asmpause:1;
1953859Sml29623 		uint16_t cap_pause:1;
1963859Sml29623 		uint16_t cap_100T4:1;
1973859Sml29623 		uint16_t cap_100fdx:1;
1983859Sml29623 		uint16_t cap_100hdx:1;
1993859Sml29623 		uint16_t cap_10fdx:1;
2003859Sml29623 		uint16_t cap_10hdx:1;
2013859Sml29623 		uint16_t selector:5;
2023859Sml29623 #elif defined(_BIT_FIELDS_LTOH)
2033859Sml29623 		uint16_t selector:5;
2043859Sml29623 		uint16_t cap_10hdx:1;
2053859Sml29623 		uint16_t cap_10fdx:1;
2063859Sml29623 		uint16_t cap_100hdx:1;
2073859Sml29623 		uint16_t cap_100fdx:1;
2083859Sml29623 		uint16_t cap_100T4:1;
2093859Sml29623 		uint16_t cap_pause:1;
2103859Sml29623 		uint16_t cap_asmpause:1;
2113859Sml29623 		uint16_t res1:1;
2123859Sml29623 		uint16_t remote_fault:1;
2133859Sml29623 		uint16_t acknowledge:1;
2143859Sml29623 		uint16_t np_indication:1;
2153859Sml29623 #endif
2163859Sml29623 	} bits;
2173859Sml29623 } mii_anar_t, *p_mii_anar_t;
2183859Sml29623 
2193859Sml29623 /*
2203859Sml29623  * MII Register 5: Auto-negotiation link partner ability register.
2213859Sml29623  */
2223859Sml29623 typedef mii_anar_t mii_anlpar_t, *pmii_anlpar_t;
2233859Sml29623 
2243859Sml29623 /*
2253859Sml29623  * MII Register 6: Auto-negotiation expansion register.
2263859Sml29623  */
2273859Sml29623 typedef union _mii_aner {
2283859Sml29623 	uint16_t value;
2293859Sml29623 	struct {
2303859Sml29623 #if defined(_BIT_FIELDS_HTOL)
2313859Sml29623 		uint16_t res:11;
2323859Sml29623 		uint16_t mlf:1;
2333859Sml29623 		uint16_t lp_np_able:1;
2343859Sml29623 		uint16_t np_able:1;
2353859Sml29623 		uint16_t page_rx:1;
2363859Sml29623 		uint16_t lp_an_able:1;
2373859Sml29623 #else
2383859Sml29623 		uint16_t lp_an_able:1;
2393859Sml29623 		uint16_t page_rx:1;
2403859Sml29623 		uint16_t np_able:1;
2413859Sml29623 		uint16_t lp_np_able:1;
2423859Sml29623 		uint16_t mlf:1;
2433859Sml29623 		uint16_t res:11;
2443859Sml29623 #endif
2453859Sml29623 	} bits;
2463859Sml29623 } mii_aner_t, *p_mii_aner_t;
2473859Sml29623 
2483859Sml29623 /*
2493859Sml29623  * MII Register 7: Next page transmit register.
2503859Sml29623  */
2513859Sml29623 typedef	union _mii_nptxr {
2523859Sml29623 	uint16_t value;
2533859Sml29623 	struct {
2543859Sml29623 #if defined(_BIT_FIELDS_HTOL)
2553859Sml29623 		uint16_t np:1;
2563859Sml29623 		uint16_t res:1;
2573859Sml29623 		uint16_t msgp:1;
2583859Sml29623 		uint16_t ack2:1;
2593859Sml29623 		uint16_t toggle:1;
2603859Sml29623 		uint16_t res1:11;
2613859Sml29623 #else
2623859Sml29623 		uint16_t res1:11;
2633859Sml29623 		uint16_t toggle:1;
2643859Sml29623 		uint16_t ack2:1;
2653859Sml29623 		uint16_t msgp:1;
2663859Sml29623 		uint16_t res:1;
2673859Sml29623 		uint16_t np:1;
2683859Sml29623 #endif
2693859Sml29623 	} bits;
2703859Sml29623 } mii_nptxr_t, *p_mii_nptxr_t;
2713859Sml29623 
2723859Sml29623 /*
2733859Sml29623  * MII Register 8: Link partner received next page register.
2743859Sml29623  */
2753859Sml29623 typedef union _mii_lprxnpr {
2763859Sml29623 	uint16_t value;
2773859Sml29623 	struct {
2783859Sml29623 #if defined(_BIT_FIELDS_HTOL)
2793859Sml29623 		uint16_t np:1;
2803859Sml29623 			uint16_t ack:1;
2813859Sml29623 		uint16_t msgp:1;
2823859Sml29623 		uint16_t ack2:1;
2833859Sml29623 		uint16_t toggle:1;
2843859Sml29623 		uint16_t mcf:11;
2853859Sml29623 #else
2863859Sml29623 		uint16_t mcf:11;
2873859Sml29623 		uint16_t toggle:1;
2883859Sml29623 		uint16_t ack2:1;
2893859Sml29623 		uint16_t msgp:1;
2903859Sml29623 		uint16_t ack:1;
2913859Sml29623 		uint16_t np:1;
2923859Sml29623 #endif
2933859Sml29623 	} bits;
2943859Sml29623 } mii_lprxnpr_t, *p_mii_lprxnpr_t;
2953859Sml29623 
2963859Sml29623 /*
2973859Sml29623  * MII Register 9: 1000BaseT control register.
2983859Sml29623  */
2993859Sml29623 typedef union _mii_gcr {
3003859Sml29623 	uint16_t value;
3013859Sml29623 	struct {
3023859Sml29623 #if defined(_BIT_FIELDS_HTOL)
3033859Sml29623 		uint16_t test_mode:3;
3043859Sml29623 		uint16_t ms_mode_en:1;
3053859Sml29623 		uint16_t master:1;
3063859Sml29623 		uint16_t dte_or_repeater:1;
3073859Sml29623 		uint16_t link_1000fdx:1;
3083859Sml29623 		uint16_t link_1000hdx:1;
3093859Sml29623 		uint16_t res:8;
3103859Sml29623 #else
3113859Sml29623 		uint16_t res:8;
3123859Sml29623 		uint16_t link_1000hdx:1;
3133859Sml29623 		uint16_t link_1000fdx:1;
3143859Sml29623 		uint16_t dte_or_repeater:1;
3153859Sml29623 		uint16_t master:1;
3163859Sml29623 		uint16_t ms_mode_en:1;
3173859Sml29623 		uint16_t test_mode:3;
3183859Sml29623 #endif
3193859Sml29623 	} bits;
3203859Sml29623 } mii_gcr_t, *p_mii_gcr_t;
3213859Sml29623 
3223859Sml29623 /*
3233859Sml29623  * MII Register 10: 1000BaseT status register.
3243859Sml29623  */
3253859Sml29623 typedef union _mii_gsr {
3263859Sml29623 	uint16_t value;
3273859Sml29623 	struct {
3283859Sml29623 #if defined(_BIT_FIELDS_HTOL)
3293859Sml29623 		uint16_t ms_config_fault:1;
3303859Sml29623 		uint16_t ms_resolve:1;
3313859Sml29623 		uint16_t local_rx_status:1;
3323859Sml29623 		uint16_t remote_rx_status:1;
3333859Sml29623 		uint16_t link_1000fdx:1;
3343859Sml29623 		uint16_t link_1000hdx:1;
3353859Sml29623 		uint16_t res:2;
3363859Sml29623 		uint16_t idle_err_cnt:8;
3373859Sml29623 #else
3383859Sml29623 		uint16_t idle_err_cnt:8;
3393859Sml29623 		uint16_t res:2;
3403859Sml29623 		uint16_t link_1000hdx:1;
3413859Sml29623 		uint16_t link_1000fdx:1;
3423859Sml29623 		uint16_t remote_rx_status:1;
3433859Sml29623 		uint16_t local_rx_status:1;
3443859Sml29623 		uint16_t ms_resolve:1;
3453859Sml29623 		uint16_t ms_config_fault:1;
3463859Sml29623 #endif
3473859Sml29623 	} bits;
3483859Sml29623 } mii_gsr_t, *p_mii_gsr_t;
3493859Sml29623 
3503859Sml29623 /*
3513859Sml29623  * MII Register 15: Extended status register.
3523859Sml29623  */
3533859Sml29623 typedef union _mii_esr {
3543859Sml29623 	uint16_t value;
3553859Sml29623 	struct {
3563859Sml29623 #if defined(_BIT_FIELDS_HTOL)
3573859Sml29623 		uint16_t link_1000Xfdx:1;
3583859Sml29623 		uint16_t link_1000Xhdx:1;
3593859Sml29623 		uint16_t link_1000fdx:1;
3603859Sml29623 		uint16_t link_1000hdx:1;
3613859Sml29623 		uint16_t res:12;
3623859Sml29623 #else
3633859Sml29623 			uint16_t res:12;
3643859Sml29623 		uint16_t link_1000hdx:1;
3653859Sml29623 		uint16_t link_1000fdx:1;
3663859Sml29623 		uint16_t link_1000Xhdx:1;
3673859Sml29623 		uint16_t link_1000Xfdx:1;
3683859Sml29623 #endif
3693859Sml29623 	} bits;
3703859Sml29623 } mii_esr_t, *p_mii_esr_t;
3713859Sml29623 
3725196Ssbehera #define	NXGE_MODE_SELECT_FIBER	0x01
3735196Ssbehera /* Shadow regiser 0x11111 */
3745196Ssbehera typedef union _mii_mode_control_stat {
3755196Ssbehera 	uint16_t value;
3765196Ssbehera 	struct {
3775196Ssbehera #if defined(_BIT_FIELDS_HTOL)
3785196Ssbehera 		uint16_t write_enable:1;
3795196Ssbehera 		uint16_t shadow:5;
3805196Ssbehera 		uint16_t rsv:1;
3815196Ssbehera 		uint16_t change:1;
3825196Ssbehera 		uint16_t copper:1;
3835196Ssbehera 		uint16_t fiber:1;
3845196Ssbehera 		uint16_t copper_energy:1;
3855196Ssbehera 		uint16_t fiber_signal:1;
3865196Ssbehera 		uint16_t rsv1:1;
3875196Ssbehera 		uint16_t mode:2;
3885196Ssbehera 		uint16_t enable:1;
3895196Ssbehera #elif defined(_BIT_FIELDS_LTOH)
3905196Ssbehera 		uint16_t enable:1;
3915196Ssbehera 		uint16_t mode:2;
3925196Ssbehera 		uint16_t rsv1:1;
3935196Ssbehera 		uint16_t fiber_signal:1;
3945196Ssbehera 		uint16_t copper_energy:1;
3955196Ssbehera 		uint16_t fiber:1;
3965196Ssbehera 		uint16_t copper:1;
3975196Ssbehera 		uint16_t change:1;
3985196Ssbehera 		uint16_t rsv:1;
3995196Ssbehera 		uint16_t shadow:5;
4005196Ssbehera 		uint16_t write_enable:1;
4015196Ssbehera #endif
4025196Ssbehera 	} bits;
4035196Ssbehera } mii_mode_control_stat_t, *p_mode_control_stat_t;
4045196Ssbehera 
4053859Sml29623 #ifdef __cplusplus
4063859Sml29623 }
4073859Sml29623 #endif
4083859Sml29623 
4093859Sml29623 #endif /* _SYS_NXGE_NXGE_MII_H_ */
410