1ae06c70bSJeff Kirsher /* SPDX-License-Identifier: GPL-2.0 */ 2*51dce24bSJeff Kirsher /* Copyright(c) 2007 - 2018 Intel Corporation. */ 3dee1ad47SJeff Kirsher 4dee1ad47SJeff Kirsher #ifndef _E1000_PHY_H_ 5dee1ad47SJeff Kirsher #define _E1000_PHY_H_ 6dee1ad47SJeff Kirsher 7dee1ad47SJeff Kirsher enum e1000_ms_type { 8dee1ad47SJeff Kirsher e1000_ms_hw_default = 0, 9dee1ad47SJeff Kirsher e1000_ms_force_master, 10dee1ad47SJeff Kirsher e1000_ms_force_slave, 11dee1ad47SJeff Kirsher e1000_ms_auto 12dee1ad47SJeff Kirsher }; 13dee1ad47SJeff Kirsher 14dee1ad47SJeff Kirsher enum e1000_smart_speed { 15dee1ad47SJeff Kirsher e1000_smart_speed_default = 0, 16dee1ad47SJeff Kirsher e1000_smart_speed_on, 17dee1ad47SJeff Kirsher e1000_smart_speed_off 18dee1ad47SJeff Kirsher }; 19dee1ad47SJeff Kirsher 20dee1ad47SJeff Kirsher s32 igb_check_downshift(struct e1000_hw *hw); 21dee1ad47SJeff Kirsher s32 igb_check_reset_block(struct e1000_hw *hw); 22dee1ad47SJeff Kirsher s32 igb_copper_link_setup_igp(struct e1000_hw *hw); 23dee1ad47SJeff Kirsher s32 igb_copper_link_setup_m88(struct e1000_hw *hw); 24dee1ad47SJeff Kirsher s32 igb_copper_link_setup_m88_gen2(struct e1000_hw *hw); 25dee1ad47SJeff Kirsher s32 igb_phy_force_speed_duplex_igp(struct e1000_hw *hw); 26dee1ad47SJeff Kirsher s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw); 27dee1ad47SJeff Kirsher s32 igb_get_cable_length_m88(struct e1000_hw *hw); 28dee1ad47SJeff Kirsher s32 igb_get_cable_length_m88_gen2(struct e1000_hw *hw); 29dee1ad47SJeff Kirsher s32 igb_get_cable_length_igp_2(struct e1000_hw *hw); 30dee1ad47SJeff Kirsher s32 igb_get_phy_id(struct e1000_hw *hw); 31dee1ad47SJeff Kirsher s32 igb_get_phy_info_igp(struct e1000_hw *hw); 32dee1ad47SJeff Kirsher s32 igb_get_phy_info_m88(struct e1000_hw *hw); 33dee1ad47SJeff Kirsher s32 igb_phy_sw_reset(struct e1000_hw *hw); 34dee1ad47SJeff Kirsher s32 igb_phy_hw_reset(struct e1000_hw *hw); 35dee1ad47SJeff Kirsher s32 igb_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); 36dee1ad47SJeff Kirsher s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active); 37dee1ad47SJeff Kirsher s32 igb_setup_copper_link(struct e1000_hw *hw); 38dee1ad47SJeff Kirsher s32 igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); 39dee1ad47SJeff Kirsher s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations, 40dee1ad47SJeff Kirsher u32 usec_interval, bool *success); 41dee1ad47SJeff Kirsher void igb_power_up_phy_copper(struct e1000_hw *hw); 42dee1ad47SJeff Kirsher void igb_power_down_phy_copper(struct e1000_hw *hw); 43dee1ad47SJeff Kirsher s32 igb_phy_init_script_igp3(struct e1000_hw *hw); 4451045ecfSTodd Fujinaka s32 igb_initialize_M88E1512_phy(struct e1000_hw *hw); 4518f7ce54STodd Fujinaka s32 igb_initialize_M88E1543_phy(struct e1000_hw *hw); 46dee1ad47SJeff Kirsher s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); 47dee1ad47SJeff Kirsher s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); 48dee1ad47SJeff Kirsher s32 igb_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data); 49dee1ad47SJeff Kirsher s32 igb_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data); 50641ac5c0SAkeem G. Abodunrin s32 igb_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data); 51dee1ad47SJeff Kirsher s32 igb_copper_link_setup_82580(struct e1000_hw *hw); 52dee1ad47SJeff Kirsher s32 igb_get_phy_info_82580(struct e1000_hw *hw); 53dee1ad47SJeff Kirsher s32 igb_phy_force_speed_duplex_82580(struct e1000_hw *hw); 54dee1ad47SJeff Kirsher s32 igb_get_cable_length_82580(struct e1000_hw *hw); 552a3cdeadSAaron Sierra s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data); 562a3cdeadSAaron Sierra s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data); 57f96a8a0bSCarolyn Wyborny s32 igb_check_polarity_m88(struct e1000_hw *hw); 58dee1ad47SJeff Kirsher 59dee1ad47SJeff Kirsher /* IGP01E1000 Specific Registers */ 60dee1ad47SJeff Kirsher #define IGP01E1000_PHY_PORT_CONFIG 0x10 /* Port Config */ 61dee1ad47SJeff Kirsher #define IGP01E1000_PHY_PORT_STATUS 0x11 /* Status */ 62dee1ad47SJeff Kirsher #define IGP01E1000_PHY_PORT_CTRL 0x12 /* Control */ 63dee1ad47SJeff Kirsher #define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */ 64dee1ad47SJeff Kirsher #define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */ 65dee1ad47SJeff Kirsher #define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */ 66dee1ad47SJeff Kirsher #define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 67dee1ad47SJeff Kirsher #define IGP01E1000_PHY_POLARITY_MASK 0x0078 68dee1ad47SJeff Kirsher #define IGP01E1000_PSCR_AUTO_MDIX 0x1000 69dee1ad47SJeff Kirsher #define IGP01E1000_PSCR_FORCE_MDI_MDIX 0x2000 /* 0=MDI, 1=MDIX */ 70dee1ad47SJeff Kirsher #define IGP01E1000_PSCFR_SMART_SPEED 0x0080 71dee1ad47SJeff Kirsher 72dee1ad47SJeff Kirsher #define I82580_ADDR_REG 16 73dee1ad47SJeff Kirsher #define I82580_CFG_REG 22 74a51d8c21SJacob Keller #define I82580_CFG_ASSERT_CRS_ON_TX BIT(15) 75a51d8c21SJacob Keller #define I82580_CFG_ENABLE_DOWNSHIFT (3u << 10) /* auto downshift 100/10 */ 76dee1ad47SJeff Kirsher #define I82580_CTRL_REG 23 77a51d8c21SJacob Keller #define I82580_CTRL_DOWNSHIFT_MASK (7u << 10) 78dee1ad47SJeff Kirsher 79dee1ad47SJeff Kirsher /* 82580 specific PHY registers */ 80dee1ad47SJeff Kirsher #define I82580_PHY_CTRL_2 18 81dee1ad47SJeff Kirsher #define I82580_PHY_LBK_CTRL 19 82dee1ad47SJeff Kirsher #define I82580_PHY_STATUS_2 26 83dee1ad47SJeff Kirsher #define I82580_PHY_DIAG_STATUS 31 84dee1ad47SJeff Kirsher 85dee1ad47SJeff Kirsher /* I82580 PHY Status 2 */ 86dee1ad47SJeff Kirsher #define I82580_PHY_STATUS2_REV_POLARITY 0x0400 87dee1ad47SJeff Kirsher #define I82580_PHY_STATUS2_MDIX 0x0800 88dee1ad47SJeff Kirsher #define I82580_PHY_STATUS2_SPEED_MASK 0x0300 89dee1ad47SJeff Kirsher #define I82580_PHY_STATUS2_SPEED_1000MBPS 0x0200 90dee1ad47SJeff Kirsher #define I82580_PHY_STATUS2_SPEED_100MBPS 0x0100 91dee1ad47SJeff Kirsher 92dee1ad47SJeff Kirsher /* I82580 PHY Control 2 */ 931b556783SJesse Brandeburg #define I82580_PHY_CTRL2_MANUAL_MDIX 0x0200 941b556783SJesse Brandeburg #define I82580_PHY_CTRL2_AUTO_MDI_MDIX 0x0400 951b556783SJesse Brandeburg #define I82580_PHY_CTRL2_MDIX_CFG_MASK 0x0600 96dee1ad47SJeff Kirsher 97dee1ad47SJeff Kirsher /* I82580 PHY Diagnostics Status */ 98dee1ad47SJeff Kirsher #define I82580_DSTATUS_CABLE_LENGTH 0x03FC 99dee1ad47SJeff Kirsher #define I82580_DSTATUS_CABLE_LENGTH_SHIFT 2 100da02cde1SCarolyn Wyborny 101da02cde1SCarolyn Wyborny /* 82580 PHY Power Management */ 102da02cde1SCarolyn Wyborny #define E1000_82580_PHY_POWER_MGMT 0xE14 103da02cde1SCarolyn Wyborny #define E1000_82580_PM_SPD 0x0001 /* Smart Power Down */ 104da02cde1SCarolyn Wyborny #define E1000_82580_PM_D0_LPLU 0x0002 /* For D0a states */ 105da02cde1SCarolyn Wyborny #define E1000_82580_PM_D3_LPLU 0x0004 /* For all other states */ 106867eb39eSCarolyn Wyborny #define E1000_82580_PM_GO_LINKD 0x0020 /* Go Link Disconnect */ 107da02cde1SCarolyn Wyborny 108dee1ad47SJeff Kirsher /* Enable flexible speed on link-up */ 109dee1ad47SJeff Kirsher #define IGP02E1000_PM_D0_LPLU 0x0002 /* For D0a states */ 110dee1ad47SJeff Kirsher #define IGP02E1000_PM_D3_LPLU 0x0004 /* For all other states */ 111dee1ad47SJeff Kirsher #define IGP01E1000_PLHR_SS_DOWNGRADE 0x8000 112dee1ad47SJeff Kirsher #define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002 113dee1ad47SJeff Kirsher #define IGP01E1000_PSSR_MDIX 0x0800 114dee1ad47SJeff Kirsher #define IGP01E1000_PSSR_SPEED_MASK 0xC000 115dee1ad47SJeff Kirsher #define IGP01E1000_PSSR_SPEED_1000MBPS 0xC000 116dee1ad47SJeff Kirsher #define IGP02E1000_PHY_CHANNEL_NUM 4 117dee1ad47SJeff Kirsher #define IGP02E1000_PHY_AGC_A 0x11B1 118dee1ad47SJeff Kirsher #define IGP02E1000_PHY_AGC_B 0x12B1 119dee1ad47SJeff Kirsher #define IGP02E1000_PHY_AGC_C 0x14B1 120dee1ad47SJeff Kirsher #define IGP02E1000_PHY_AGC_D 0x18B1 121dee1ad47SJeff Kirsher #define IGP02E1000_AGC_LENGTH_SHIFT 9 /* Course - 15:13, Fine - 12:9 */ 122dee1ad47SJeff Kirsher #define IGP02E1000_AGC_LENGTH_MASK 0x7F 123dee1ad47SJeff Kirsher #define IGP02E1000_AGC_RANGE 15 124dee1ad47SJeff Kirsher 125dee1ad47SJeff Kirsher #define E1000_CABLE_LENGTH_UNDEFINED 0xFF 126dee1ad47SJeff Kirsher 127641ac5c0SAkeem G. Abodunrin /* SFP modules ID memory locations */ 128641ac5c0SAkeem G. Abodunrin #define E1000_SFF_IDENTIFIER_OFFSET 0x00 129641ac5c0SAkeem G. Abodunrin #define E1000_SFF_IDENTIFIER_SFF 0x02 130641ac5c0SAkeem G. Abodunrin #define E1000_SFF_IDENTIFIER_SFP 0x03 131641ac5c0SAkeem G. Abodunrin 132641ac5c0SAkeem G. Abodunrin #define E1000_SFF_ETH_FLAGS_OFFSET 0x06 133641ac5c0SAkeem G. Abodunrin /* Flags for SFP modules compatible with ETH up to 1Gb */ 134641ac5c0SAkeem G. Abodunrin struct e1000_sfp_flags { 135641ac5c0SAkeem G. Abodunrin u8 e1000_base_sx:1; 136641ac5c0SAkeem G. Abodunrin u8 e1000_base_lx:1; 137641ac5c0SAkeem G. Abodunrin u8 e1000_base_cx:1; 138641ac5c0SAkeem G. Abodunrin u8 e1000_base_t:1; 139641ac5c0SAkeem G. Abodunrin u8 e100_base_lx:1; 140641ac5c0SAkeem G. Abodunrin u8 e100_base_fx:1; 141641ac5c0SAkeem G. Abodunrin u8 e10_base_bx10:1; 142641ac5c0SAkeem G. Abodunrin u8 e10_base_px:1; 143641ac5c0SAkeem G. Abodunrin }; 144641ac5c0SAkeem G. Abodunrin 145dee1ad47SJeff Kirsher #endif 146