e1000_phy.h revision 247064
1228753Smm/****************************************************************************** 2228753Smm 3228753Smm Copyright (c) 2001-2013, Intel Corporation 4228753Smm All rights reserved. 5228753Smm 6228753Smm Redistribution and use in source and binary forms, with or without 7228753Smm modification, are permitted provided that the following conditions are met: 8228753Smm 9228753Smm 1. Redistributions of source code must retain the above copyright notice, 10228753Smm this list of conditions and the following disclaimer. 11228753Smm 12228753Smm 2. Redistributions in binary form must reproduce the above copyright 13228753Smm notice, this list of conditions and the following disclaimer in the 14228753Smm documentation and/or other materials provided with the distribution. 15228753Smm 16228753Smm 3. Neither the name of the Intel Corporation nor the names of its 17228753Smm contributors may be used to endorse or promote products derived from 18228753Smm this software without specific prior written permission. 19228753Smm 20228753Smm THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21228753Smm AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22228753Smm IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23228753Smm ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24228753Smm LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25228753Smm CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26228753Smm SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27228763Smm INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28228753Smm CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29228753Smm ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30228753Smm POSSIBILITY OF SUCH DAMAGE. 31228753Smm 32228753Smm******************************************************************************/ 33228753Smm/*$FreeBSD: head/sys/dev/e1000/e1000_phy.h 247064 2013-02-21 00:25:45Z jfv $*/ 34228753Smm 35228753Smm#ifndef _E1000_PHY_H_ 36228753Smm#define _E1000_PHY_H_ 37228753Smm 38228753Smmvoid e1000_init_phy_ops_generic(struct e1000_hw *hw); 39228753Smms32 e1000_null_read_reg(struct e1000_hw *hw, u32 offset, u16 *data); 40228753Smmvoid e1000_null_phy_generic(struct e1000_hw *hw); 41228753Smms32 e1000_null_lplu_state(struct e1000_hw *hw, bool active); 42228753Smms32 e1000_null_write_reg(struct e1000_hw *hw, u32 offset, u16 data); 43228753Smms32 e1000_null_set_page(struct e1000_hw *hw, u16 data); 44228753Smms32 e1000_read_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset, 45228753Smm u8 dev_addr, u8 *data); 46228753Smms32 e1000_write_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset, 47228753Smm u8 dev_addr, u8 data); 48228753Smms32 e1000_check_downshift_generic(struct e1000_hw *hw); 49228753Smms32 e1000_check_polarity_m88(struct e1000_hw *hw); 50228753Smms32 e1000_check_polarity_igp(struct e1000_hw *hw); 51228753Smms32 e1000_check_polarity_ife(struct e1000_hw *hw); 52228753Smms32 e1000_check_reset_block_generic(struct e1000_hw *hw); 53228753Smms32 e1000_phy_setup_autoneg(struct e1000_hw *hw); 54228753Smms32 e1000_copper_link_autoneg(struct e1000_hw *hw); 55228753Smms32 e1000_copper_link_setup_igp(struct e1000_hw *hw); 56228753Smms32 e1000_copper_link_setup_m88(struct e1000_hw *hw); 57228753Smms32 e1000_copper_link_setup_m88_gen2(struct e1000_hw *hw); 58228753Smms32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw); 59228753Smms32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw); 60228753Smms32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw); 61232153Smms32 e1000_get_cable_length_m88(struct e1000_hw *hw); 62232153Smms32 e1000_get_cable_length_m88_gen2(struct e1000_hw *hw); 63228753Smms32 e1000_get_cable_length_igp_2(struct e1000_hw *hw); 64228753Smms32 e1000_get_cfg_done_generic(struct e1000_hw *hw); 65228753Smms32 e1000_get_phy_id(struct e1000_hw *hw); 66228753Smms32 e1000_get_phy_info_igp(struct e1000_hw *hw); 67228753Smms32 e1000_get_phy_info_m88(struct e1000_hw *hw); 68228753Smms32 e1000_get_phy_info_ife(struct e1000_hw *hw); 69228753Smms32 e1000_phy_sw_reset_generic(struct e1000_hw *hw); 70299529Smmvoid e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); 71228753Smms32 e1000_phy_hw_reset_generic(struct e1000_hw *hw); 72228753Smms32 e1000_phy_reset_dsp_generic(struct e1000_hw *hw); 73228753Smms32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data); 74228753Smms32 e1000_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data); 75228753Smms32 e1000_set_page_igp(struct e1000_hw *hw, u16 page); 76228753Smms32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); 77228753Smms32 e1000_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data); 78228753Smms32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); 79228753Smms32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active); 80228753Smms32 e1000_setup_copper_link_generic(struct e1000_hw *hw); 81228753Smms32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data); 82228753Smms32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data); 83228753Smms32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); 84228753Smms32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data); 85228753Smms32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); 86228753Smms32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, 87311041Smm u32 usec_interval, bool *success); 88311041Smms32 e1000_phy_init_script_igp3(struct e1000_hw *hw); 89299529Smmenum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id); 90299529Smms32 e1000_determine_phy_address(struct e1000_hw *hw); 91299529Smms32 e1000_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data); 92299529Smms32 e1000_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data); 93299529Smms32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg); 94228753Smms32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg); 95228753Smms32 e1000_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data); 96228753Smms32 e1000_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); 97228753Smmvoid e1000_power_up_phy_copper(struct e1000_hw *hw); 98228753Smmvoid e1000_power_down_phy_copper(struct e1000_hw *hw); 99232153Smms32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); 100232153Smms32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); 101228753Smms32 e1000_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data); 102228753Smms32 e1000_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data); 103228753Smms32 e1000_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data); 104228753Smms32 e1000_write_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 data); 105228753Smms32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); 106228753Smms32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data); 107228753Smms32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data); 108228753Smms32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); 109228753Smms32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data); 110228753Smms32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 data); 111228753Smms32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); 112228753Smms32 e1000_copper_link_setup_82577(struct e1000_hw *hw); 113228753Smms32 e1000_check_polarity_82577(struct e1000_hw *hw); 114228753Smms32 e1000_get_phy_info_82577(struct e1000_hw *hw); 115228753Smms32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw); 116228753Smms32 e1000_get_cable_length_82577(struct e1000_hw *hw); 117344673Smms32 e1000_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data); 118228753Smms32 e1000_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data); 119228753Smm 120228753Smm#define E1000_MAX_PHY_ADDR 8 121228753Smm 122228753Smm/* IGP01E1000 Specific Registers */ 123228753Smm#define IGP01E1000_PHY_PORT_CONFIG 0x10 /* Port Config */ 124228753Smm#define IGP01E1000_PHY_PORT_STATUS 0x11 /* Status */ 125228753Smm#define IGP01E1000_PHY_PORT_CTRL 0x12 /* Control */ 126228753Smm#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */ 127238856Smm#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO */ 128228753Smm#define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */ 129228753Smm#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */ 130228753Smm#define BM_PHY_PAGE_SELECT 22 /* Page Select for BM */ 131228753Smm#define IGP_PAGE_SHIFT 5 132228753Smm#define PHY_REG_MASK 0x1F 133228753Smm 134228753Smm/* GS40G - I210 PHY defines */ 135228753Smm#define GS40G_PAGE_SELECT 0x16 136228753Smm#define GS40G_PAGE_SHIFT 16 137228753Smm#define GS40G_OFFSET_MASK 0xFFFF 138228753Smm#define GS40G_PAGE_2 0x20000 139238856Smm#define GS40G_MAC_REG2 0x15 140238856Smm#define GS40G_MAC_LB 0x4140 141238856Smm#define GS40G_MAC_SPEED_1G 0X0006 142228753Smm#define GS40G_COPPER_SPEC 0x0010 143238856Smm#define GS40G_CS_POWER_DOWN 0x0002 144228753Smm 145228753Smm/* BM/HV Specific Registers */ 146228753Smm#define BM_PORT_CTRL_PAGE 769 147238856Smm#define BM_WUC_PAGE 800 148228753Smm#define BM_WUC_ADDRESS_OPCODE 0x11 149228753Smm#define BM_WUC_DATA_OPCODE 0x12 150228753Smm#define BM_WUC_ENABLE_PAGE BM_PORT_CTRL_PAGE 151228753Smm#define BM_WUC_ENABLE_REG 17 152228753Smm#define BM_WUC_ENABLE_BIT (1 << 2) 153228753Smm#define BM_WUC_HOST_WU_BIT (1 << 4) 154228753Smm#define BM_WUC_ME_WU_BIT (1 << 5) 155228753Smm 156228753Smm#define PHY_UPPER_SHIFT 21 157228753Smm#define BM_PHY_REG(page, reg) \ 158228753Smm (((reg) & MAX_PHY_REG_ADDRESS) |\ 159228753Smm (((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\ 160228753Smm (((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT))) 161228753Smm#define BM_PHY_REG_PAGE(offset) \ 162228753Smm ((u16)(((offset) >> PHY_PAGE_SHIFT) & 0xFFFF)) 163238856Smm#define BM_PHY_REG_NUM(offset) \ 164228753Smm ((u16)(((offset) & MAX_PHY_REG_ADDRESS) |\ 165228753Smm (((offset) >> (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)) &\ 166228753Smm ~MAX_PHY_REG_ADDRESS))) 167228753Smm 168232153Smm#define HV_INTC_FC_PAGE_START 768 169232153Smm#define I82578_ADDR_REG 29 170228753Smm#define I82577_ADDR_REG 16 171228753Smm#define I82577_CFG_REG 22 172228753Smm#define I82577_CFG_ASSERT_CRS_ON_TX (1 << 15) 173228753Smm#define I82577_CFG_ENABLE_DOWNSHIFT (3 << 10) /* auto downshift 100/10 */ 174228753Smm#define I82577_CTRL_REG 23 175228753Smm 176228753Smm/* 82577 specific PHY registers */ 177228753Smm#define I82577_PHY_CTRL_2 18 178228753Smm#define I82577_PHY_LBK_CTRL 19 179228753Smm#define I82577_PHY_STATUS_2 26 180228753Smm#define I82577_PHY_DIAG_STATUS 31 181228753Smm 182228753Smm/* I82577 PHY Status 2 */ 183228753Smm#define I82577_PHY_STATUS2_REV_POLARITY 0x0400 184228753Smm#define I82577_PHY_STATUS2_MDIX 0x0800 185228753Smm#define I82577_PHY_STATUS2_SPEED_MASK 0x0300 186344673Smm#define I82577_PHY_STATUS2_SPEED_1000MBPS 0x0200 187228753Smm 188228753Smm/* I82577 PHY Control 2 */ 189228753Smm#define I82577_PHY_CTRL2_MANUAL_MDIX 0x0200 190228753Smm#define I82577_PHY_CTRL2_AUTO_MDI_MDIX 0x0400 191228753Smm#define I82577_PHY_CTRL2_MDIX_CFG_MASK 0x0600 192228753Smm 193228753Smm/* I82577 PHY Diagnostics Status */ 194228753Smm#define I82577_DSTATUS_CABLE_LENGTH 0x03FC 195228753Smm#define I82577_DSTATUS_CABLE_LENGTH_SHIFT 2 196238856Smm 197228753Smm/* 82580 PHY Power Management */ 198228753Smm#define E1000_82580_PHY_POWER_MGMT 0xE14 199228753Smm#define E1000_82580_PM_SPD 0x0001 /* Smart Power Down */ 200228753Smm#define E1000_82580_PM_D0_LPLU 0x0002 /* For D0a states */ 201228753Smm#define E1000_82580_PM_D3_LPLU 0x0004 /* For all other states */ 202228753Smm#define E1000_82580_PM_GO_LINKD 0x0020 /* Go Link Disconnect */ 203228753Smm 204228753Smm/* BM PHY Copper Specific Control 1 */ 205228753Smm#define BM_CS_CTRL1 16 206228753Smm 207228753Smm/* BM PHY Copper Specific Status */ 208238856Smm#define BM_CS_STATUS 17 209238856Smm#define BM_CS_STATUS_LINK_UP 0x0400 210238856Smm#define BM_CS_STATUS_RESOLVED 0x0800 211228753Smm#define BM_CS_STATUS_SPEED_MASK 0xC000 212238856Smm#define BM_CS_STATUS_SPEED_1000 0x8000 213228753Smm 214228753Smm/* 82577 Mobile Phy Status Register */ 215228753Smm#define HV_M_STATUS 26 216238856Smm#define HV_M_STATUS_AUTONEG_COMPLETE 0x1000 217228753Smm#define HV_M_STATUS_SPEED_MASK 0x0300 218228753Smm#define HV_M_STATUS_SPEED_1000 0x0200 219228753Smm#define HV_M_STATUS_LINK_UP 0x0040 220228753Smm 221228753Smm#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 222228753Smm#define IGP01E1000_PHY_POLARITY_MASK 0x0078 223228753Smm 224228753Smm#define IGP01E1000_PSCR_AUTO_MDIX 0x1000 225228753Smm#define IGP01E1000_PSCR_FORCE_MDI_MDIX 0x2000 /* 0=MDI, 1=MDIX */ 226228753Smm 227228753Smm#define IGP01E1000_PSCFR_SMART_SPEED 0x0080 228228753Smm 229228753Smm/* Enable flexible speed on link-up */ 230228753Smm#define IGP01E1000_GMII_FLEX_SPD 0x0010 231228753Smm#define IGP01E1000_GMII_SPD 0x0020 /* Enable SPD */ 232238856Smm 233228753Smm#define IGP02E1000_PM_SPD 0x0001 /* Smart Power Down */ 234228753Smm#define IGP02E1000_PM_D0_LPLU 0x0002 /* For D0a states */ 235228753Smm#define IGP02E1000_PM_D3_LPLU 0x0004 /* For all other states */ 236228753Smm 237228753Smm#define IGP01E1000_PLHR_SS_DOWNGRADE 0x8000 238228753Smm 239228753Smm#define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002 240228753Smm#define IGP01E1000_PSSR_MDIX 0x0800 241228753Smm#define IGP01E1000_PSSR_SPEED_MASK 0xC000 242228753Smm#define IGP01E1000_PSSR_SPEED_1000MBPS 0xC000 243228753Smm 244228753Smm#define IGP02E1000_PHY_CHANNEL_NUM 4 245228753Smm#define IGP02E1000_PHY_AGC_A 0x11B1 246228753Smm#define IGP02E1000_PHY_AGC_B 0x12B1 247228753Smm#define IGP02E1000_PHY_AGC_C 0x14B1 248228753Smm#define IGP02E1000_PHY_AGC_D 0x18B1 249228753Smm 250228753Smm#define IGP02E1000_AGC_LENGTH_SHIFT 9 /* Course - 15:13, Fine - 12:9 */ 251228753Smm#define IGP02E1000_AGC_LENGTH_MASK 0x7F 252228753Smm#define IGP02E1000_AGC_RANGE 15 253228753Smm 254228753Smm#define E1000_CABLE_LENGTH_UNDEFINED 0xFF 255228753Smm 256228753Smm#define E1000_KMRNCTRLSTA_OFFSET 0x001F0000 257228753Smm#define E1000_KMRNCTRLSTA_OFFSET_SHIFT 16 258228753Smm#define E1000_KMRNCTRLSTA_REN 0x00200000 259228753Smm#define E1000_KMRNCTRLSTA_CTRL_OFFSET 0x1 /* Kumeran Control */ 260228753Smm#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */ 261228753Smm#define E1000_KMRNCTRLSTA_TIMEOUTS 0x4 /* Kumeran Timeouts */ 262228753Smm#define E1000_KMRNCTRLSTA_INBAND_PARAM 0x9 /* Kumeran InBand Parameters */ 263228753Smm#define E1000_KMRNCTRLSTA_IBIST_DISABLE 0x0200 /* Kumeran IBIST Disable */ 264#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */ 265#define E1000_KMRNCTRLSTA_K1_CONFIG 0x7 266#define E1000_KMRNCTRLSTA_K1_ENABLE 0x0002 /* enable K1 */ 267#define E1000_KMRNCTRLSTA_HD_CTRL 0x10 /* Kumeran HD Control */ 268 269#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10 270#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */ 271#define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY Special and LED Control */ 272#define IFE_PHY_MDIX_CONTROL 0x1C /* MDI/MDI-X Control */ 273 274/* IFE PHY Extended Status Control */ 275#define IFE_PESC_POLARITY_REVERSED 0x0100 276 277/* IFE PHY Special Control */ 278#define IFE_PSC_AUTO_POLARITY_DISABLE 0x0010 279#define IFE_PSC_FORCE_POLARITY 0x0020 280 281/* IFE PHY Special Control and LED Control */ 282#define IFE_PSCL_PROBE_MODE 0x0020 283#define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */ 284#define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */ 285 286/* IFE PHY MDIX Control */ 287#define IFE_PMC_MDIX_STATUS 0x0020 /* 1=MDI-X, 0=MDI */ 288#define IFE_PMC_FORCE_MDIX 0x0040 /* 1=force MDI-X, 0=force MDI */ 289#define IFE_PMC_AUTO_MDIX 0x0080 /* 1=enable auto, 0=disable */ 290 291/* SFP modules ID memory locations */ 292#define E1000_SFF_IDENTIFIER_OFFSET 0x00 293#define E1000_SFF_IDENTIFIER_SFF 0x02 294#define E1000_SFF_IDENTIFIER_SFP 0x03 295 296#define E1000_SFF_ETH_FLAGS_OFFSET 0x06 297/* Flags for SFP modules compatible with ETH up to 1Gb */ 298struct sfp_e1000_flags { 299 u8 e1000_base_sx:1; 300 u8 e1000_base_lx:1; 301 u8 e1000_base_cx:1; 302 u8 e1000_base_t:1; 303 u8 e100_base_lx:1; 304 u8 e100_base_fx:1; 305 u8 e10_base_bx10:1; 306 u8 e10_base_px:1; 307}; 308 309/* Vendor OUIs: format of OUI is 0x[byte0][byte1][byte2][00] */ 310#define E1000_SFF_VENDOR_OUI_TYCO 0x00407600 311#define E1000_SFF_VENDOR_OUI_FTL 0x00906500 312#define E1000_SFF_VENDOR_OUI_AVAGO 0x00176A00 313#define E1000_SFF_VENDOR_OUI_INTEL 0x001B2100 314 315#endif 316