38 static u32 e1000_get_phy_addr_for_hv_page(
u32 page);
43 static const u16 e1000_m88_cable_length_table[] = {
45 #define M88E1000_CABLE_LENGTH_TABLE_SIZE \
46 ARRAY_SIZE(e1000_m88_cable_length_table)
48 static const u16 e1000_igp_2_cable_length_table[] = {
49 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3,
50 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41, 6, 10, 14, 18, 22,
51 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61, 21, 26, 31, 35, 40,
52 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82, 40, 45, 51, 56, 61,
53 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104, 60, 66, 72, 77, 82,
54 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121, 83, 89, 95,
55 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121,
57 #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
58 ARRAY_SIZE(e1000_igp_2_cable_length_table)
60 #define BM_PHY_REG_PAGE(offset) \
61 ((u16)(((offset) >> PHY_PAGE_SHIFT) & 0xFFFF))
62 #define BM_PHY_REG_NUM(offset) \
63 ((u16)(((offset) & MAX_PHY_REG_ADDRESS) |\
64 (((offset) >> (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)) &\
65 ~MAX_PHY_REG_ADDRESS)))
67 #define HV_INTC_FC_PAGE_START 768
68 #define I82578_ADDR_REG 29
69 #define I82577_ADDR_REG 16
70 #define I82577_CFG_REG 22
71 #define I82577_CFG_ASSERT_CRS_ON_TX (1 << 15)
72 #define I82577_CFG_ENABLE_DOWNSHIFT (3 << 10)
73 #define I82577_CTRL_REG 23
76 #define I82577_PHY_CTRL_2 18
77 #define I82577_PHY_STATUS_2 26
78 #define I82577_PHY_DIAG_STATUS 31
81 #define I82577_PHY_STATUS2_REV_POLARITY 0x0400
82 #define I82577_PHY_STATUS2_MDIX 0x0800
83 #define I82577_PHY_STATUS2_SPEED_MASK 0x0300
84 #define I82577_PHY_STATUS2_SPEED_1000MBPS 0x0200
87 #define I82577_PHY_CTRL2_MANUAL_MDIX 0x0200
88 #define I82577_PHY_CTRL2_AUTO_MDI_MDIX 0x0400
89 #define I82577_PHY_CTRL2_MDIX_CFG_MASK 0x0600
92 #define I82577_DSTATUS_CABLE_LENGTH 0x03FC
93 #define I82577_DSTATUS_CABLE_LENGTH_SHIFT 2
96 #define BM_CS_CTRL1 16
98 #define HV_MUX_DATA_CTRL PHY_REG(776, 16)
99 #define HV_MUX_DATA_CTRL_GEN_TO_MAC 0x0400
100 #define HV_MUX_DATA_CTRL_FORCE_SPEED 0x0004
134 if (!phy->
ops.read_reg)
137 while (retry_count < 2) {
138 ret_val = e1e_rphy(hw,
PHY_ID1, &phy_id);
142 phy->
id = (
u32)(phy_id << 16);
144 ret_val = e1e_rphy(hw,
PHY_ID2, &phy_id);
149 phy->
revision = (
u32)(phy_id & ~PHY_REVISION_MASK);
151 if (phy->
id != 0 && phy->
id != PHY_REVISION_MASK)
192 e_dbg(
"PHY Address %d is out of range\n", offset);
219 e_dbg(
"MDI Read did not complete\n");
223 e_dbg(
"MDI Error\n");
252 e_dbg(
"PHY Address %d is out of range\n", offset);
261 mdic = (((
u32)data) |
280 e_dbg(
"MDI Write did not complete\n");
284 e_dbg(
"MDI Error\n");
312 ret_val = hw->
phy.ops.acquire(hw);
319 hw->
phy.ops.release(hw);
337 ret_val = hw->
phy.ops.acquire(hw);
344 hw->
phy.ops.release(hw);
360 e_dbg(
"Setting page 0x%x\n", page);
384 if (!hw->
phy.ops.acquire)
387 ret_val = hw->
phy.ops.acquire(hw);
401 hw->
phy.ops.release(hw);
418 return __e1000e_read_phy_reg_igp(hw, offset, data,
false);
432 return __e1000e_read_phy_reg_igp(hw, offset, data,
true);
451 if (!hw->
phy.ops.acquire)
454 ret_val = hw->
phy.ops.acquire(hw);
468 hw->
phy.ops.release(hw);
484 return __e1000e_write_phy_reg_igp(hw, offset, data,
false);
498 return __e1000e_write_phy_reg_igp(hw, offset, data,
true);
520 if (!hw->
phy.ops.acquire)
523 ret_val = hw->
phy.ops.acquire(hw);
530 ew32(KMRNCTRLSTA, kmrnctrlsta);
535 kmrnctrlsta =
er32(KMRNCTRLSTA);
536 *data = (
u16)kmrnctrlsta;
539 hw->
phy.ops.release(hw);
556 return __e1000_read_kmrn_reg(hw, offset, data,
false);
571 return __e1000_read_kmrn_reg(hw, offset, data,
true);
593 if (!hw->
phy.ops.acquire)
596 ret_val = hw->
phy.ops.acquire(hw);
603 ew32(KMRNCTRLSTA, kmrnctrlsta);
609 hw->
phy.ops.release(hw);
625 return __e1000_write_kmrn_reg(hw, offset, data,
false);
639 return __e1000_write_kmrn_reg(hw, offset, data,
true);
648 static s32 e1000_set_master_slave_mode(
struct e1000_hw *hw)
663 switch (hw->
phy.ms_type) {
717 switch (hw->
phy.mdix) {
732 return e1000_set_master_slave_mode(hw);
806 e_dbg(
"Error committing the PHY changes\n");
850 ret_val = e1e_wphy(hw, 29, 0x0003);
855 ret_val = e1e_wphy(hw, 30, 0x0000);
863 e_dbg(
"Error committing the PHY changes\n");
898 e_dbg(
"Error resetting the PHY.\n");
909 ret_val = e1000_set_d0_lplu_state(hw,
false);
911 e_dbg(
"Error Disabling LPLU D0\n");
938 if (hw->
mac.autoneg) {
968 ret_val = e1000_set_master_slave_mode(hw);
987 u16 mii_autoneg_adv_reg;
988 u16 mii_1000t_ctrl_reg = 0;
1027 e_dbg(
"Advertise 10mb Half duplex\n");
1033 e_dbg(
"Advertise 10mb Full duplex\n");
1039 e_dbg(
"Advertise 100mb Half duplex\n");
1045 e_dbg(
"Advertise 100mb Full duplex\n");
1051 e_dbg(
"Advertise 1000mb Half duplex request denied!\n");
1055 e_dbg(
"Advertise 1000mb Full duplex\n");
1077 switch (hw->
fc.current_mode) {
1114 e_dbg(
"Flow control param set incorrectly\n");
1122 e_dbg(
"Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
1139 static s32 e1000_copper_link_autoneg(
struct e1000_hw *hw)
1158 e_dbg(
"Reconfiguring auto-neg advertisement params\n");
1161 e_dbg(
"Error Setting up Auto-Negotiation\n");
1164 e_dbg(
"Restarting Auto-Neg\n");
1184 ret_val = e1000_wait_autoneg(hw);
1186 e_dbg(
"Error while waiting for autoneg to complete\n");
1191 hw->
mac.get_link_status =
true;
1210 if (hw->
mac.autoneg) {
1215 ret_val = e1000_copper_link_autoneg(hw);
1223 e_dbg(
"Forcing Speed and Duplex\n");
1224 ret_val = e1000_phy_force_speed_duplex(hw);
1226 e_dbg(
"Error Forcing Speed and Duplex\n");
1241 e_dbg(
"Valid link established!!!\n");
1242 hw->
mac.ops.config_collision_dist(hw);
1245 e_dbg(
"Unable to establish link!!!\n");
1291 e_dbg(
"IGP PSCR: %X\n", phy_data);
1296 e_dbg(
"Waiting for forced speed/duplex link on IGP phy.\n");
1304 e_dbg(
"Link taking longer than expected.\n");
1344 e_dbg(
"M88E1000 PSCR: %X\n", phy_data);
1362 e_dbg(
"Waiting for forced speed/duplex link on M88 phy.\n");
1371 e_dbg(
"Link taking longer than expected.\n");
1462 e_dbg(
"IFE PMC: %X\n", data);
1467 e_dbg(
"Waiting for forced speed/duplex link on IFE phy.\n");
1475 e_dbg(
"Link taking longer than expected.\n");
1522 e_dbg(
"Half Duplex\n");
1526 e_dbg(
"Full Duplex\n");
1534 e_dbg(
"Forcing 100mb\n");
1539 e_dbg(
"Forcing 10mb\n");
1542 hw->
mac.ops.config_collision_dist(hw);
1639 switch (phy->
type) {
1658 ret_val = e1e_rphy(hw, offset, &phy_data);
1726 ret_val = e1e_rphy(hw, offset, &data);
1759 ret_val = e1e_rphy(hw, offset, &phy_data);
1776 static s32 e1000_wait_autoneg(
struct e1000_hw *hw)
1783 ret_val = e1e_rphy(hw,
PHY_STATUS, &phy_status);
1786 ret_val = e1e_rphy(hw,
PHY_STATUS, &phy_status);
1811 u32 usec_interval,
bool *success)
1816 for (i = 0; i < iterations; i++) {
1822 ret_val = e1e_rphy(hw,
PHY_STATUS, &phy_status);
1830 ret_val = e1e_rphy(hw,
PHY_STATUS, &phy_status);
1835 if (usec_interval >= 1000)
1836 mdelay(usec_interval/1000);
1841 *success = (i < iterations);
1900 u16 phy_data,
i, agc_value = 0;
1901 u16 cur_agc_index, max_agc_index = 0;
1912 ret_val = e1e_rphy(hw, agc_reg_array[i], &phy_data);
1927 (cur_agc_index == 0))
1931 if (e1000_igp_2_cable_length_table[min_agc_index] >
1932 e1000_igp_2_cable_length_table[cur_agc_index])
1933 min_agc_index = cur_agc_index;
1934 if (e1000_igp_2_cable_length_table[max_agc_index] <
1935 e1000_igp_2_cable_length_table[cur_agc_index])
1936 max_agc_index = cur_agc_index;
1938 agc_value += e1000_igp_2_cable_length_table[cur_agc_index];
1941 agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
1942 e1000_igp_2_cable_length_table[max_agc_index]);
1943 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
1973 e_dbg(
"Phy info is only valid for copper media\n");
1982 e_dbg(
"Phy info is only valid if link is up\n");
2004 ret_val = e1000_get_cable_length(hw);
2050 e_dbg(
"Phy info is only valid if link is up\n");
2068 ret_val = e1000_get_cable_length(hw);
2110 e_dbg(
"Phy info is only valid if link is up\n");
2185 if (phy->
ops.check_reset_block) {
2186 ret_val = phy->
ops.check_reset_block(hw);
2191 ret_val = phy->
ops.acquire(hw);
2206 phy->
ops.release(hw);
2208 return e1000_get_phy_cfg_done(hw);
2233 e_dbg(
"Running IGP 3 PHY init script\n");
2237 e1e_wphy(hw, 0x2F5B, 0x9018);
2239 e1e_wphy(hw, 0x2F52, 0x0000);
2241 e1e_wphy(hw, 0x2FB1, 0x8B24);
2243 e1e_wphy(hw, 0x2FB2, 0xF8F0);
2245 e1e_wphy(hw, 0x2010, 0x10B0);
2247 e1e_wphy(hw, 0x2011, 0x0000);
2249 e1e_wphy(hw, 0x20DD, 0x249A);
2251 e1e_wphy(hw, 0x20DE, 0x00D3);
2253 e1e_wphy(hw, 0x28B4, 0x04CE);
2255 e1e_wphy(hw, 0x2F70, 0x29E4);
2257 e1e_wphy(hw, 0x0000, 0x0140);
2259 e1e_wphy(hw, 0x1F30, 0x1606);
2261 e1e_wphy(hw, 0x1F31, 0xB814);
2263 e1e_wphy(hw, 0x1F35, 0x002A);
2265 e1e_wphy(hw, 0x1F3E, 0x0067);
2267 e1e_wphy(hw, 0x1F54, 0x0065);
2269 e1e_wphy(hw, 0x1F55, 0x002A);
2271 e1e_wphy(hw, 0x1F56, 0x002A);
2273 e1e_wphy(hw, 0x1F72, 0x3FB0);
2275 e1e_wphy(hw, 0x1F76, 0xC0FF);
2277 e1e_wphy(hw, 0x1F77, 0x1DEC);
2279 e1e_wphy(hw, 0x1F78, 0xF9EF);
2281 e1e_wphy(hw, 0x1F79, 0x0210);
2283 e1e_wphy(hw, 0x1895, 0x0003);
2285 e1e_wphy(hw, 0x1796, 0x0008);
2287 e1e_wphy(hw, 0x1798, 0xD008);
2292 e1e_wphy(hw, 0x1898, 0xD918);
2294 e1e_wphy(hw, 0x187A, 0x0800);
2299 e1e_wphy(hw, 0x0019, 0x008D);
2301 e1e_wphy(hw, 0x001B, 0x2080);
2303 e1e_wphy(hw, 0x0014, 0x0045);
2305 e1e_wphy(hw, 0x0000, 0x1340);
2319 static s32 e1000_get_phy_cfg_done(
struct e1000_hw *hw)
2321 if (hw->
phy.ops.get_cfg_done)
2322 return hw->
phy.ops.get_cfg_done(hw);
2334 static s32 e1000_phy_force_speed_duplex(
struct e1000_hw *hw)
2336 if (hw->
phy.ops.force_speed_duplex)
2337 return hw->
phy.ops.force_speed_duplex(hw);
2410 hw->
phy.id = phy_type;
2413 hw->
phy.addr = phy_addr;
2445 if ((page >= 768) || (page == 0 && reg == 25) || (reg == 31))
2465 ret_val = hw->
phy.ops.acquire(hw);
2471 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2476 hw->
phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2479 u32 page_shift, page_select;
2486 if (hw->
phy.addr == 1) {
2496 (page << page_shift));
2505 hw->
phy.ops.release(hw);
2524 ret_val = hw->
phy.ops.acquire(hw);
2530 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2535 hw->
phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2538 u32 page_shift, page_select;
2545 if (hw->
phy.addr == 1) {
2555 (page << page_shift));
2563 hw->
phy.ops.release(hw);
2582 ret_val = hw->
phy.ops.acquire(hw);
2588 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2608 hw->
phy.ops.release(hw);
2626 ret_val = hw->
phy.ops.acquire(hw);
2632 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2652 hw->
phy.ops.release(hw);
2675 e_dbg(
"Could not set Port Control page\n");
2681 e_dbg(
"Could not read PHY register %d.%d\n",
2696 e_dbg(
"Could not write PHY register %d.%d\n",
2726 e_dbg(
"Could not set Port Control page\n");
2733 e_dbg(
"Could not restore PHY register %d.%d\n",
2764 static s32 e1000_access_phy_wakeup_reg_bm(
struct e1000_hw *hw,
u32 offset,
2765 u16 *data,
bool read,
bool page_set)
2775 e_dbg(
"Attempting to access page %d while gig enabled.\n",
2782 e_dbg(
"Could not enable PHY wakeup reg access\n");
2787 e_dbg(
"Accessing PHY page %d reg 0x%x\n", page, reg);
2792 e_dbg(
"Could not write address opcode to page %d\n", page);
2807 e_dbg(
"Could not access PHY reg %d.%d\n", page, reg);
2863 if (hw->
phy.ops.commit)
2864 return hw->
phy.ops.commit(hw);
2885 if (hw->
phy.ops.set_d0_lplu_state)
2886 return hw->
phy.ops.set_d0_lplu_state(hw, active);
2903 bool locked,
bool page_set)
2908 u32 phy_addr = hw->
phy.addr = e1000_get_phy_addr_for_hv_page(page);
2911 ret_val = hw->
phy.ops.acquire(hw);
2918 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2924 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
2938 hw->
phy.addr = phy_addr;
2945 e_dbg(
"reading PHY page %d (or 0x%x shifted) reg 0x%x\n", page,
2952 hw->
phy.ops.release(hw);
2969 return __e1000_read_phy_reg_hv(hw, offset, data,
false,
false);
2983 return __e1000_read_phy_reg_hv(hw, offset, data,
true,
false);
2997 return __e1000_read_phy_reg_hv(hw, offset, data,
true,
true);
3011 bool locked,
bool page_set)
3016 u32 phy_addr = hw->
phy.addr = e1000_get_phy_addr_for_hv_page(page);
3019 ret_val = hw->
phy.ops.acquire(hw);
3026 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
3032 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
3046 (hw->
phy.revision >= 1) &&
3047 (hw->
phy.addr == 2) &&
3050 ret_val = e1000_access_phy_debug_regs_hv(hw,
3062 hw->
phy.addr = phy_addr;
3069 e_dbg(
"writing PHY page %d (or 0x%x shifted) reg 0x%x\n", page,
3077 hw->
phy.ops.release(hw);
3093 return __e1000_write_phy_reg_hv(hw, offset, data,
false,
false);
3107 return __e1000_write_phy_reg_hv(hw, offset, data,
true,
false);
3121 return __e1000_write_phy_reg_hv(hw, offset, data,
true,
true);
3128 static u32 e1000_get_phy_addr_for_hv_page(
u32 page)
3150 static s32 e1000_access_phy_debug_regs_hv(
struct e1000_hw *hw,
u32 offset,
3151 u16 *data,
bool read)
3160 data_reg = addr_reg + 1;
3168 e_dbg(
"Could not write the Address Offset port register\n");
3179 e_dbg(
"Could not access the Data port register\n");
3281 e_dbg(
"Waiting for forced speed/duplex link on 82577 phy\n");
3289 e_dbg(
"Link taking longer than expected.\n");
3320 e_dbg(
"Phy info is only valid if link is up\n");
3338 ret_val = hw->
phy.ops.get_cable_length(hw);