xref: /onnv-gate/usr/src/uts/common/io/e1000g/e1000_phy.h (revision 11020:e0feef27b61a)
14919Sxy150489 /*
24919Sxy150489  * This file is provided under a CDDLv1 license.  When using or
34919Sxy150489  * redistributing this file, you may do so under this license.
44919Sxy150489  * In redistributing this file this license must be included
54919Sxy150489  * and no other modification of this header file is permitted.
64919Sxy150489  *
74919Sxy150489  * CDDL LICENSE SUMMARY
84919Sxy150489  *
98479SChenlu.Chen@Sun.COM  * Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved.
104919Sxy150489  *
114919Sxy150489  * The contents of this file are subject to the terms of Version
124919Sxy150489  * 1.0 of the Common Development and Distribution License (the "License").
134919Sxy150489  *
144919Sxy150489  * You should have received a copy of the License with this software.
154919Sxy150489  * You can obtain a copy of the License at
164919Sxy150489  *	http://www.opensolaris.org/os/licensing.
174919Sxy150489  * See the License for the specific language governing permissions
184919Sxy150489  * and limitations under the License.
194919Sxy150489  */
204919Sxy150489 
214919Sxy150489 /*
228479SChenlu.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
234919Sxy150489  * Use is subject to license terms of the CDDLv1.
244919Sxy150489  */
254919Sxy150489 
264919Sxy150489 /*
27*11020SMin.Xu@Sun.COM  * IntelVersion: 1.74 v3-1-10-1_2009-9-18_Release14-6
284919Sxy150489  */
294919Sxy150489 #ifndef _E1000_PHY_H_
304919Sxy150489 #define	_E1000_PHY_H_
314919Sxy150489 
324919Sxy150489 #ifdef __cplusplus
334919Sxy150489 extern "C" {
344919Sxy150489 #endif
354919Sxy150489 
366735Scc210113 void e1000_init_phy_ops_generic(struct e1000_hw *hw);
376735Scc210113 s32 e1000_null_read_reg(struct e1000_hw *hw, u32 offset, u16 *data);
386735Scc210113 void e1000_null_phy_generic(struct e1000_hw *hw);
396735Scc210113 s32 e1000_null_lplu_state(struct e1000_hw *hw, bool active);
406735Scc210113 s32 e1000_null_write_reg(struct e1000_hw *hw, u32 offset, u16 data);
414919Sxy150489 s32 e1000_check_downshift_generic(struct e1000_hw *hw);
424919Sxy150489 s32 e1000_check_polarity_m88(struct e1000_hw *hw);
434919Sxy150489 s32 e1000_check_polarity_igp(struct e1000_hw *hw);
4410680SMin.Xu@Sun.COM s32 e1000_check_polarity_ife(struct e1000_hw *hw);
454919Sxy150489 s32 e1000_check_reset_block_generic(struct e1000_hw *hw);
464919Sxy150489 s32 e1000_copper_link_autoneg(struct e1000_hw *hw);
474919Sxy150489 s32 e1000_copper_link_setup_igp(struct e1000_hw *hw);
484919Sxy150489 s32 e1000_copper_link_setup_m88(struct e1000_hw *hw);
494919Sxy150489 s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw);
504919Sxy150489 s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw);
5110680SMin.Xu@Sun.COM s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw);
524919Sxy150489 s32 e1000_get_cable_length_m88(struct e1000_hw *hw);
534919Sxy150489 s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw);
544919Sxy150489 s32 e1000_get_cfg_done_generic(struct e1000_hw *hw);
554919Sxy150489 s32 e1000_get_phy_id(struct e1000_hw *hw);
564919Sxy150489 s32 e1000_get_phy_info_igp(struct e1000_hw *hw);
574919Sxy150489 s32 e1000_get_phy_info_m88(struct e1000_hw *hw);
584919Sxy150489 s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw);
594919Sxy150489 void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl);
604919Sxy150489 s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw);
614919Sxy150489 s32 e1000_phy_reset_dsp_generic(struct e1000_hw *hw);
624919Sxy150489 s32 e1000_phy_setup_autoneg(struct e1000_hw *hw);
634919Sxy150489 s32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data);
64*11020SMin.Xu@Sun.COM s32 e1000_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data);
654919Sxy150489 s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data);
66*11020SMin.Xu@Sun.COM s32 e1000_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data);
674919Sxy150489 s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data);
686735Scc210113 s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active);
694919Sxy150489 s32 e1000_setup_copper_link_generic(struct e1000_hw *hw);
704919Sxy150489 s32 e1000_wait_autoneg_generic(struct e1000_hw *hw);
714919Sxy150489 s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data);
72*11020SMin.Xu@Sun.COM s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data);
734919Sxy150489 s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
74*11020SMin.Xu@Sun.COM s32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data);
754919Sxy150489 s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data);
764919Sxy150489 s32 e1000_phy_reset_dsp(struct e1000_hw *hw);
774919Sxy150489 s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
786735Scc210113     u32 usec_interval, bool *success);
794919Sxy150489 s32 e1000_phy_init_script_igp3(struct e1000_hw *hw);
808479SChenlu.Chen@Sun.COM enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id);
814919Sxy150489 s32 e1000_determine_phy_address(struct e1000_hw *hw);
824919Sxy150489 s32 e1000_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data);
834919Sxy150489 s32 e1000_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data);
847607STed.You@Sun.COM s32 e1000_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data);
857607STed.You@Sun.COM s32 e1000_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data);
866735Scc210113 void e1000_power_up_phy_copper(struct e1000_hw *hw);
876735Scc210113 void e1000_power_down_phy_copper(struct e1000_hw *hw);
886735Scc210113 s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data);
896735Scc210113 s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
9010680SMin.Xu@Sun.COM s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data);
91*11020SMin.Xu@Sun.COM s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data);
9210680SMin.Xu@Sun.COM s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data);
93*11020SMin.Xu@Sun.COM s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data);
9410680SMin.Xu@Sun.COM s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow);
9510680SMin.Xu@Sun.COM s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw);
9610680SMin.Xu@Sun.COM s32 e1000_copper_link_setup_82577(struct e1000_hw *hw);
9710680SMin.Xu@Sun.COM s32 e1000_check_polarity_82577(struct e1000_hw *hw);
9810680SMin.Xu@Sun.COM s32 e1000_get_phy_info_82577(struct e1000_hw *hw);
9910680SMin.Xu@Sun.COM s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw);
10010680SMin.Xu@Sun.COM s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
1014919Sxy150489 
1024919Sxy150489 #define	E1000_MAX_PHY_ADDR		4
1034919Sxy150489 
1044919Sxy150489 /* IGP01E1000 Specific Registers */
1054919Sxy150489 #define	IGP01E1000_PHY_PORT_CONFIG	0x10 /* Port Config */
1064919Sxy150489 #define	IGP01E1000_PHY_PORT_STATUS	0x11 /* Status */
1074919Sxy150489 #define	IGP01E1000_PHY_PORT_CTRL	0x12 /* Control */
1084919Sxy150489 #define	IGP01E1000_PHY_LINK_HEALTH	0x13 /* PHY Link Health */
1094919Sxy150489 #define	IGP01E1000_GMII_FIFO		0x14 /* GMII FIFO */
1104919Sxy150489 #define	IGP01E1000_PHY_CHANNEL_QUALITY	0x15 /* PHY Channel Quality */
1114919Sxy150489 #define	IGP02E1000_PHY_POWER_MGMT	0x19 /* Power Management */
1124919Sxy150489 #define	IGP01E1000_PHY_PAGE_SELECT	0x1F /* Page Select */
1136735Scc210113 #define	BM_PHY_PAGE_SELECT		22   /* Page Select for BM */
1144919Sxy150489 #define	IGP_PAGE_SHIFT			5
1154919Sxy150489 #define	PHY_REG_MASK			0x1F
1164919Sxy150489 
11710680SMin.Xu@Sun.COM /* BM/HV Specific Registers */
11810680SMin.Xu@Sun.COM #define	BM_PORT_CTRL_PAGE		769
11910680SMin.Xu@Sun.COM #define	BM_PCIE_PAGE			770
1204919Sxy150489 #define	BM_WUC_PAGE			800
1214919Sxy150489 #define	BM_WUC_ADDRESS_OPCODE		0x11
1224919Sxy150489 #define	BM_WUC_DATA_OPCODE		0x12
12310680SMin.Xu@Sun.COM #define	BM_WUC_ENABLE_PAGE		BM_PORT_CTRL_PAGE
1244919Sxy150489 #define	BM_WUC_ENABLE_REG		17
1254919Sxy150489 #define	BM_WUC_ENABLE_BIT		(1 << 2)
1264919Sxy150489 #define	BM_WUC_HOST_WU_BIT		(1 << 4)
1274919Sxy150489 
12810680SMin.Xu@Sun.COM #define	PHY_UPPER_SHIFT			21
12910680SMin.Xu@Sun.COM #define	BM_PHY_REG(page, reg) \
13010680SMin.Xu@Sun.COM 	(((reg) & MAX_PHY_REG_ADDRESS) |\
13110680SMin.Xu@Sun.COM 	(((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\
13210680SMin.Xu@Sun.COM 	(((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)))
13310680SMin.Xu@Sun.COM #define	BM_PHY_REG_PAGE(offset) \
13410680SMin.Xu@Sun.COM 	((u16)(((offset) >> PHY_PAGE_SHIFT) & 0xFFFF))
13510680SMin.Xu@Sun.COM #define	BM_PHY_REG_NUM(offset) \
13610680SMin.Xu@Sun.COM 	((u16)(((offset) & MAX_PHY_REG_ADDRESS) |\
13710680SMin.Xu@Sun.COM 	(((offset) >> (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)) &\
13810680SMin.Xu@Sun.COM 	~MAX_PHY_REG_ADDRESS)))
13910680SMin.Xu@Sun.COM 
14010680SMin.Xu@Sun.COM #define	HV_INTC_FC_PAGE_START		768
14110680SMin.Xu@Sun.COM #define	I82578_ADDR_REG			29
14210680SMin.Xu@Sun.COM #define	I82577_ADDR_REG			16
14310680SMin.Xu@Sun.COM #define	I82577_CFG_REG			22
14410680SMin.Xu@Sun.COM #define	I82577_CFG_ASSERT_CRS_ON_TX	(1 << 15)
14510680SMin.Xu@Sun.COM #define	I82577_CFG_ENABLE_DOWNSHIFT	(3 << 10) /* auto downshift 100/10 */
14610680SMin.Xu@Sun.COM #define	I82577_CTRL_REG			23
14710680SMin.Xu@Sun.COM #define	I82577_CTRL_DOWNSHIFT_MASK	(7 << 10)
14810680SMin.Xu@Sun.COM 
14910680SMin.Xu@Sun.COM /* 82577 specific PHY registers */
15010680SMin.Xu@Sun.COM #define	I82577_PHY_CTRL_2		18
15110680SMin.Xu@Sun.COM #define	I82577_PHY_LBK_CTRL		19
15210680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS_2		26
15310680SMin.Xu@Sun.COM #define	I82577_PHY_DIAG_STATUS		31
15410680SMin.Xu@Sun.COM 
15510680SMin.Xu@Sun.COM /* I82577 PHY Status 2 */
15610680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS2_REV_POLARITY		0x0400
15710680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS2_MDIX			0x0800
15810680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS2_SPEED_MASK		0x0300
15910680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS2_SPEED_1000MBPS	0x0200
16010680SMin.Xu@Sun.COM #define	I82577_PHY_STATUS2_SPEED_100MBPS	0x0100
16110680SMin.Xu@Sun.COM 
16210680SMin.Xu@Sun.COM /* I82577 PHY Control 2 */
16310680SMin.Xu@Sun.COM #define	I82577_PHY_CTRL2_AUTO_MDIX		0x0400
16410680SMin.Xu@Sun.COM #define	I82577_PHY_CTRL2_FORCE_MDI_MDIX		0x0200
16510680SMin.Xu@Sun.COM 
16610680SMin.Xu@Sun.COM /* I82577 PHY Diagnostics Status */
16710680SMin.Xu@Sun.COM #define	I82577_DSTATUS_CABLE_LENGTH		0x03FC
16810680SMin.Xu@Sun.COM #define	I82577_DSTATUS_CABLE_LENGTH_SHIFT	2
16910680SMin.Xu@Sun.COM 
1706735Scc210113 /* BM PHY Copper Specific Control 1 */
1716735Scc210113 #define	BM_CS_CTRL1			16
1726735Scc210113 #define	BM_CS_CTRL1_ENERGY_DETECT	0x0300	/* Enable Energy Detect */
1736735Scc210113 
17410680SMin.Xu@Sun.COM /* BM PHY Copper Specific Status */
1756735Scc210113 #define	BM_CS_STATUS			17
1766735Scc210113 #define	BM_CS_STATUS_ENERGY_DETECT	0x0010	/* Energy Detect Status */
17710680SMin.Xu@Sun.COM #define	BM_CS_STATUS_LINK_UP		0x0400
17810680SMin.Xu@Sun.COM #define	BM_CS_STATUS_RESOLVED		0x0800
17910680SMin.Xu@Sun.COM #define	BM_CS_STATUS_SPEED_MASK		0xC000
18010680SMin.Xu@Sun.COM #define	BM_CS_STATUS_SPEED_1000		0x8000
1816735Scc210113 
182*11020SMin.Xu@Sun.COM /* 82577 Mobile Phy Status Register */
183*11020SMin.Xu@Sun.COM #define	HV_M_STATUS			26
184*11020SMin.Xu@Sun.COM #define	HV_M_STATUS_AUTONEG_COMPLETE	0x1000
185*11020SMin.Xu@Sun.COM #define	HV_M_STATUS_SPEED_MASK		0x0300
186*11020SMin.Xu@Sun.COM #define	HV_M_STATUS_SPEED_1000		0x0200
187*11020SMin.Xu@Sun.COM #define	HV_M_STATUS_LINK_UP		0x0040
188*11020SMin.Xu@Sun.COM 
1894919Sxy150489 #define	IGP01E1000_PHY_PCS_INIT_REG	0x00B4
1904919Sxy150489 #define	IGP01E1000_PHY_POLARITY_MASK	0x0078
1914919Sxy150489 
1924919Sxy150489 #define	IGP01E1000_PSCR_AUTO_MDIX	0x1000
1934919Sxy150489 #define	IGP01E1000_PSCR_FORCE_MDI_MDIX	0x2000	/* 0=MDI, 1=MDIX */
1944919Sxy150489 
1954919Sxy150489 #define	IGP01E1000_PSCFR_SMART_SPEED	0x0080
1964919Sxy150489 
1974919Sxy150489 /* Enable flexible speed on link-up */
1984919Sxy150489 #define	IGP01E1000_GMII_FLEX_SPD	0x0010
1994919Sxy150489 #define	IGP01E1000_GMII_SPD		0x0020	/* Enable SPD */
2004919Sxy150489 
2014919Sxy150489 #define	IGP02E1000_PM_SPD		0x0001	/* Smart Power Down */
2024919Sxy150489 #define	IGP02E1000_PM_D0_LPLU		0x0002	/* For D0a states */
2034919Sxy150489 #define	IGP02E1000_PM_D3_LPLU		0x0004	/* For all other states */
2044919Sxy150489 
2054919Sxy150489 #define	IGP01E1000_PLHR_SS_DOWNGRADE	0x8000
2064919Sxy150489 
2074919Sxy150489 #define	IGP01E1000_PSSR_POLARITY_REVERSED 0x0002
20810680SMin.Xu@Sun.COM #define	IGP01E1000_PSSR_MDIX		0x0800
2094919Sxy150489 #define	IGP01E1000_PSSR_SPEED_MASK	0xC000
2104919Sxy150489 #define	IGP01E1000_PSSR_SPEED_1000MBPS	0xC000
2114919Sxy150489 
2124919Sxy150489 #define	IGP02E1000_PHY_CHANNEL_NUM	4
2134919Sxy150489 #define	IGP02E1000_PHY_AGC_A		0x11B1
2144919Sxy150489 #define	IGP02E1000_PHY_AGC_B		0x12B1
2154919Sxy150489 #define	IGP02E1000_PHY_AGC_C		0x14B1
2164919Sxy150489 #define	IGP02E1000_PHY_AGC_D		0x18B1
2174919Sxy150489 
2184919Sxy150489 #define	IGP02E1000_AGC_LENGTH_SHIFT	9 /* Course - 15:13, Fine - 12:9 */
2194919Sxy150489 #define	IGP02E1000_AGC_LENGTH_MASK	0x7F
2204919Sxy150489 #define	IGP02E1000_AGC_RANGE		15
2214919Sxy150489 
2224919Sxy150489 #define	IGP03E1000_PHY_MISC_CTRL	0x1B
2234919Sxy150489 #define	IGP03E1000_PHY_MISC_DUPLEX_MANUAL_SET 0x1000 /* Manually Set Duplex */
2244919Sxy150489 
2254919Sxy150489 #define	E1000_CABLE_LENGTH_UNDEFINED	0xFF
2264919Sxy150489 
2274919Sxy150489 #define	E1000_KMRNCTRLSTA_OFFSET	0x001F0000
2284919Sxy150489 #define	E1000_KMRNCTRLSTA_OFFSET_SHIFT	16
2294919Sxy150489 #define	E1000_KMRNCTRLSTA_REN		0x00200000
2304919Sxy150489 #define	E1000_KMRNCTRLSTA_DIAG_OFFSET	0x3	/* Kumeran Diagnostic */
23110680SMin.Xu@Sun.COM #define	E1000_KMRNCTRLSTA_TIMEOUTS	0x4	/* Kumeran Timeouts */
23210680SMin.Xu@Sun.COM #define	E1000_KMRNCTRLSTA_INBAND_PARAM	0x9	/* Kumeran InBand Parameters */
2334919Sxy150489 #define	E1000_KMRNCTRLSTA_DIAG_NELPBK	0x1000	/* Nearend Loopback mode */
23410680SMin.Xu@Sun.COM #define	E1000_KMRNCTRLSTA_K1_CONFIG	0x7
235*11020SMin.Xu@Sun.COM #define	E1000_KMRNCTRLSTA_K1_ENABLE	0x0002
2364919Sxy150489 
2374919Sxy150489 #define	IFE_PHY_EXTENDED_STATUS_CONTROL	0x10
2384919Sxy150489 #define	IFE_PHY_SPECIAL_CONTROL		0x11 /* 100BaseTx PHY Special Control */
2394919Sxy150489 #define	IFE_PHY_SPECIAL_CONTROL_LED	0x1B /* PHY Special and LED Control */
2404919Sxy150489 #define	IFE_PHY_MDIX_CONTROL		0x1C /* MDI/MDI-X Control */
2414919Sxy150489 
2424919Sxy150489 /* IFE PHY Extended Status Control */
2434919Sxy150489 #define	IFE_PESC_POLARITY_REVERSED	0x0100
2444919Sxy150489 
2454919Sxy150489 /* IFE PHY Special Control */
2464919Sxy150489 #define	IFE_PSC_AUTO_POLARITY_DISABLE	0x0010
2474919Sxy150489 #define	IFE_PSC_FORCE_POLARITY		0x0020
2484919Sxy150489 #define	IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN 0x0100
2494919Sxy150489 
2504919Sxy150489 /* IFE PHY Special Control and LED Control */
2514919Sxy150489 #define	IFE_PSCL_PROBE_MODE		0x0020
2524919Sxy150489 #define	IFE_PSCL_PROBE_LEDS_OFF		0x0006 /* Force LEDs 0 and 2 off */
2534919Sxy150489 #define	IFE_PSCL_PROBE_LEDS_ON		0x0007 /* Force LEDs 0 and 2 on */
2544919Sxy150489 
2554919Sxy150489 /* IFE PHY MDIX Control */
2564919Sxy150489 #define	IFE_PMC_MDIX_STATUS	0x0020 /* 1=MDI-X, 0=MDI */
2574919Sxy150489 #define	IFE_PMC_FORCE_MDIX	0x0040 /* 1=force MDI-X, 0=force MDI */
2584919Sxy150489 #define	IFE_PMC_AUTO_MDIX	0x0080 /* 1=enable auto MDI/MDI-X, 0=disable */
2594919Sxy150489 
2604919Sxy150489 #ifdef __cplusplus
2614919Sxy150489 }
2624919Sxy150489 #endif
2634919Sxy150489 
2644919Sxy150489 #endif	/* _E1000_PHY_H_ */
265