e1000_phy.c (235527) | e1000_phy.c (238262) |
---|---|
1/****************************************************************************** 2 | 1/****************************************************************************** 2 |
3 Copyright (c) 2001-2011, Intel Corporation | 3 Copyright (c) 2001-2012, Intel Corporation |
4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 13 unchanged lines hidden (view full) --- 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32******************************************************************************/ | 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 13 unchanged lines hidden (view full) --- 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32******************************************************************************/ |
33/*$FreeBSD: stable/9/sys/dev/e1000/e1000_phy.c 235527 2012-05-16 22:22:52Z jfv $*/ | 33/*$FreeBSD: stable/9/sys/dev/e1000/e1000_phy.c 238262 2012-07-08 20:35:56Z jfv $*/ |
34 35#include "e1000_api.h" 36 37static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg); 38static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, 39 u16 *data, bool read, bool page_set); 40static u32 e1000_get_phy_addr_for_hv_page(u32 page); 41static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, --- 48 unchanged lines hidden (view full) --- 90 phy->ops.reset = e1000_null_ops_generic; 91 phy->ops.set_d0_lplu_state = e1000_null_lplu_state; 92 phy->ops.set_d3_lplu_state = e1000_null_lplu_state; 93 phy->ops.write_reg = e1000_null_write_reg; 94 phy->ops.write_reg_locked = e1000_null_write_reg; 95 phy->ops.write_reg_page = e1000_null_write_reg; 96 phy->ops.power_up = e1000_null_phy_generic; 97 phy->ops.power_down = e1000_null_phy_generic; | 34 35#include "e1000_api.h" 36 37static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg); 38static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, 39 u16 *data, bool read, bool page_set); 40static u32 e1000_get_phy_addr_for_hv_page(u32 page); 41static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, --- 48 unchanged lines hidden (view full) --- 90 phy->ops.reset = e1000_null_ops_generic; 91 phy->ops.set_d0_lplu_state = e1000_null_lplu_state; 92 phy->ops.set_d3_lplu_state = e1000_null_lplu_state; 93 phy->ops.write_reg = e1000_null_write_reg; 94 phy->ops.write_reg_locked = e1000_null_write_reg; 95 phy->ops.write_reg_page = e1000_null_write_reg; 96 phy->ops.power_up = e1000_null_phy_generic; 97 phy->ops.power_down = e1000_null_phy_generic; |
98 phy->ops.read_i2c_byte = e1000_read_i2c_byte_generic; 99 phy->ops.write_i2c_byte = e1000_write_i2c_byte_generic; | 98 phy->ops.read_i2c_byte = e1000_read_i2c_byte_null; 99 phy->ops.write_i2c_byte = e1000_write_i2c_byte_null; |
100 phy->ops.cfg_on_link_up = e1000_null_ops_generic; 101} 102 103/** 104 * e1000_null_set_page - No-op function, return 0 105 * @hw: pointer to the HW structure 106 **/ 107s32 e1000_null_set_page(struct e1000_hw *hw, u16 data) --- 38 unchanged lines hidden (view full) --- 146 **/ 147s32 e1000_null_write_reg(struct e1000_hw *hw, u32 offset, u16 data) 148{ 149 DEBUGFUNC("e1000_null_write_reg"); 150 return E1000_SUCCESS; 151} 152 153/** | 100 phy->ops.cfg_on_link_up = e1000_null_ops_generic; 101} 102 103/** 104 * e1000_null_set_page - No-op function, return 0 105 * @hw: pointer to the HW structure 106 **/ 107s32 e1000_null_set_page(struct e1000_hw *hw, u16 data) --- 38 unchanged lines hidden (view full) --- 146 **/ 147s32 e1000_null_write_reg(struct e1000_hw *hw, u32 offset, u16 data) 148{ 149 DEBUGFUNC("e1000_null_write_reg"); 150 return E1000_SUCCESS; 151} 152 153/** |
154 * e1000_read_i2c_byte_null - No-op function, return 0 155 * @hw: pointer to hardware structure 156 * @byte_offset: byte offset to write 157 * @dev_addr: device address 158 * @data: data value read 159 * 160 **/ 161s32 e1000_read_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset, 162 u8 dev_addr, u8 *data) 163{ 164 DEBUGFUNC("e1000_read_i2c_byte_null"); 165 return E1000_SUCCESS; 166} 167 168/** 169 * e1000_write_i2c_byte_null - No-op function, return 0 170 * @hw: pointer to hardware structure 171 * @byte_offset: byte offset to write 172 * @dev_addr: device address 173 * @data: data value to write 174 * 175 **/ 176s32 e1000_write_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset, 177 u8 dev_addr, u8 data) 178{ 179 DEBUGFUNC("e1000_write_i2c_byte_null"); 180 return E1000_SUCCESS; 181} 182 183/** |
|
154 * e1000_check_reset_block_generic - Check if PHY reset is blocked 155 * @hw: pointer to the HW structure 156 * 157 * Read the PHY management control register and check whether a PHY reset 158 * is blocked. If a reset is not blocked return E1000_SUCCESS, otherwise 159 * return E1000_BLK_PHY_RESET (12). 160 **/ 161s32 e1000_check_reset_block_generic(struct e1000_hw *hw) --- 19 unchanged lines hidden (view full) --- 181{ 182 struct e1000_phy_info *phy = &hw->phy; 183 s32 ret_val = E1000_SUCCESS; 184 u16 phy_id; 185 u16 retry_count = 0; 186 187 DEBUGFUNC("e1000_get_phy_id"); 188 | 184 * e1000_check_reset_block_generic - Check if PHY reset is blocked 185 * @hw: pointer to the HW structure 186 * 187 * Read the PHY management control register and check whether a PHY reset 188 * is blocked. If a reset is not blocked return E1000_SUCCESS, otherwise 189 * return E1000_BLK_PHY_RESET (12). 190 **/ 191s32 e1000_check_reset_block_generic(struct e1000_hw *hw) --- 19 unchanged lines hidden (view full) --- 211{ 212 struct e1000_phy_info *phy = &hw->phy; 213 s32 ret_val = E1000_SUCCESS; 214 u16 phy_id; 215 u16 retry_count = 0; 216 217 DEBUGFUNC("e1000_get_phy_id"); 218 |
189 if (!(phy->ops.read_reg)) 190 goto out; | 219 if (!phy->ops.read_reg) 220 return E1000_SUCCESS; |
191 192 while (retry_count < 2) { 193 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id); 194 if (ret_val) | 221 222 while (retry_count < 2) { 223 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id); 224 if (ret_val) |
195 goto out; | 225 return ret_val; |
196 197 phy->id = (u32)(phy_id << 16); 198 usec_delay(20); 199 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); 200 if (ret_val) | 226 227 phy->id = (u32)(phy_id << 16); 228 usec_delay(20); 229 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); 230 if (ret_val) |
201 goto out; | 231 return ret_val; |
202 203 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); 204 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); 205 206 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) | 232 233 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); 234 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); 235 236 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) |
207 goto out; | 237 return E1000_SUCCESS; |
208 209 retry_count++; 210 } | 238 239 retry_count++; 240 } |
211out: 212 return ret_val; | 241 242 return E1000_SUCCESS; |
213} 214 215/** 216 * e1000_phy_reset_dsp_generic - Reset PHY DSP 217 * @hw: pointer to the HW structure 218 * 219 * Reset the digital signal processor. 220 **/ 221s32 e1000_phy_reset_dsp_generic(struct e1000_hw *hw) 222{ | 243} 244 245/** 246 * e1000_phy_reset_dsp_generic - Reset PHY DSP 247 * @hw: pointer to the HW structure 248 * 249 * Reset the digital signal processor. 250 **/ 251s32 e1000_phy_reset_dsp_generic(struct e1000_hw *hw) 252{ |
223 s32 ret_val = E1000_SUCCESS; | 253 s32 ret_val; |
224 225 DEBUGFUNC("e1000_phy_reset_dsp_generic"); 226 | 254 255 DEBUGFUNC("e1000_phy_reset_dsp_generic"); 256 |
227 if (!(hw->phy.ops.write_reg)) 228 goto out; | 257 if (!hw->phy.ops.write_reg) 258 return E1000_SUCCESS; |
229 230 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xC1); 231 if (ret_val) | 259 260 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xC1); 261 if (ret_val) |
232 goto out; | 262 return ret_val; |
233 | 263 |
234 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0); 235 236out: 237 return ret_val; | 264 return hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0); |
238} 239 240/** 241 * e1000_read_phy_reg_mdic - Read MDI control register 242 * @hw: pointer to the HW structure 243 * @offset: register offset to be read 244 * @data: pointer to the read data 245 * 246 * Reads the MDI control register in the PHY at offset and stores the 247 * information read to data. 248 **/ 249s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) 250{ 251 struct e1000_phy_info *phy = &hw->phy; 252 u32 i, mdic = 0; | 265} 266 267/** 268 * e1000_read_phy_reg_mdic - Read MDI control register 269 * @hw: pointer to the HW structure 270 * @offset: register offset to be read 271 * @data: pointer to the read data 272 * 273 * Reads the MDI control register in the PHY at offset and stores the 274 * information read to data. 275 **/ 276s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) 277{ 278 struct e1000_phy_info *phy = &hw->phy; 279 u32 i, mdic = 0; |
253 s32 ret_val = E1000_SUCCESS; | |
254 255 DEBUGFUNC("e1000_read_phy_reg_mdic"); 256 257 if (offset > MAX_PHY_REG_ADDRESS) { 258 DEBUGOUT1("PHY Address %d is out of range\n", offset); 259 return -E1000_ERR_PARAM; 260 } 261 --- 16 unchanged lines hidden (view full) --- 278 for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { 279 usec_delay(50); 280 mdic = E1000_READ_REG(hw, E1000_MDIC); 281 if (mdic & E1000_MDIC_READY) 282 break; 283 } 284 if (!(mdic & E1000_MDIC_READY)) { 285 DEBUGOUT("MDI Read did not complete\n"); | 280 281 DEBUGFUNC("e1000_read_phy_reg_mdic"); 282 283 if (offset > MAX_PHY_REG_ADDRESS) { 284 DEBUGOUT1("PHY Address %d is out of range\n", offset); 285 return -E1000_ERR_PARAM; 286 } 287 --- 16 unchanged lines hidden (view full) --- 304 for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { 305 usec_delay(50); 306 mdic = E1000_READ_REG(hw, E1000_MDIC); 307 if (mdic & E1000_MDIC_READY) 308 break; 309 } 310 if (!(mdic & E1000_MDIC_READY)) { 311 DEBUGOUT("MDI Read did not complete\n"); |
286 ret_val = -E1000_ERR_PHY; 287 goto out; | 312 return -E1000_ERR_PHY; |
288 } 289 if (mdic & E1000_MDIC_ERROR) { 290 DEBUGOUT("MDI Error\n"); | 313 } 314 if (mdic & E1000_MDIC_ERROR) { 315 DEBUGOUT("MDI Error\n"); |
291 ret_val = -E1000_ERR_PHY; 292 goto out; | 316 return -E1000_ERR_PHY; |
293 } 294 *data = (u16) mdic; 295 296 /* 297 * Allow some time after each MDIC transaction to avoid 298 * reading duplicate data in the next MDIC transaction. 299 */ 300 if (hw->mac.type == e1000_pch2lan) 301 usec_delay(100); 302 | 317 } 318 *data = (u16) mdic; 319 320 /* 321 * Allow some time after each MDIC transaction to avoid 322 * reading duplicate data in the next MDIC transaction. 323 */ 324 if (hw->mac.type == e1000_pch2lan) 325 usec_delay(100); 326 |
303out: 304 return ret_val; | 327 return E1000_SUCCESS; |
305} 306 307/** 308 * e1000_write_phy_reg_mdic - Write MDI control register 309 * @hw: pointer to the HW structure 310 * @offset: register offset to write to 311 * @data: data to write to register at offset 312 * 313 * Writes data to MDI control register in the PHY at offset. 314 **/ 315s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) 316{ 317 struct e1000_phy_info *phy = &hw->phy; 318 u32 i, mdic = 0; | 328} 329 330/** 331 * e1000_write_phy_reg_mdic - Write MDI control register 332 * @hw: pointer to the HW structure 333 * @offset: register offset to write to 334 * @data: data to write to register at offset 335 * 336 * Writes data to MDI control register in the PHY at offset. 337 **/ 338s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) 339{ 340 struct e1000_phy_info *phy = &hw->phy; 341 u32 i, mdic = 0; |
319 s32 ret_val = E1000_SUCCESS; | |
320 321 DEBUGFUNC("e1000_write_phy_reg_mdic"); 322 323 if (offset > MAX_PHY_REG_ADDRESS) { 324 DEBUGOUT1("PHY Address %d is out of range\n", offset); 325 return -E1000_ERR_PARAM; 326 } 327 --- 17 unchanged lines hidden (view full) --- 345 for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { 346 usec_delay(50); 347 mdic = E1000_READ_REG(hw, E1000_MDIC); 348 if (mdic & E1000_MDIC_READY) 349 break; 350 } 351 if (!(mdic & E1000_MDIC_READY)) { 352 DEBUGOUT("MDI Write did not complete\n"); | 342 343 DEBUGFUNC("e1000_write_phy_reg_mdic"); 344 345 if (offset > MAX_PHY_REG_ADDRESS) { 346 DEBUGOUT1("PHY Address %d is out of range\n", offset); 347 return -E1000_ERR_PARAM; 348 } 349 --- 17 unchanged lines hidden (view full) --- 367 for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { 368 usec_delay(50); 369 mdic = E1000_READ_REG(hw, E1000_MDIC); 370 if (mdic & E1000_MDIC_READY) 371 break; 372 } 373 if (!(mdic & E1000_MDIC_READY)) { 374 DEBUGOUT("MDI Write did not complete\n"); |
353 ret_val = -E1000_ERR_PHY; 354 goto out; | 375 return -E1000_ERR_PHY; |
355 } 356 if (mdic & E1000_MDIC_ERROR) { 357 DEBUGOUT("MDI Error\n"); | 376 } 377 if (mdic & E1000_MDIC_ERROR) { 378 DEBUGOUT("MDI Error\n"); |
358 ret_val = -E1000_ERR_PHY; 359 goto out; | 379 return -E1000_ERR_PHY; |
360 } 361 362 /* 363 * Allow some time after each MDIC transaction to avoid 364 * reading duplicate data in the next MDIC transaction. 365 */ 366 if (hw->mac.type == e1000_pch2lan) 367 usec_delay(100); 368 | 380 } 381 382 /* 383 * Allow some time after each MDIC transaction to avoid 384 * reading duplicate data in the next MDIC transaction. 385 */ 386 if (hw->mac.type == e1000_pch2lan) 387 usec_delay(100); 388 |
369out: 370 return ret_val; | 389 return E1000_SUCCESS; |
371} 372 373/** 374 * e1000_read_phy_reg_i2c - Read PHY register using i2c 375 * @hw: pointer to the HW structure 376 * @offset: register offset to be read 377 * @data: pointer to the read data 378 * --- 237 unchanged lines hidden (view full) --- 616 * @data: pointer to the read data 617 * 618 * Acquires semaphore, if necessary, then reads the PHY register at offset 619 * and storing the retrieved information in data. Release any acquired 620 * semaphores before exiting. 621 **/ 622s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) 623{ | 390} 391 392/** 393 * e1000_read_phy_reg_i2c - Read PHY register using i2c 394 * @hw: pointer to the HW structure 395 * @offset: register offset to be read 396 * @data: pointer to the read data 397 * --- 237 unchanged lines hidden (view full) --- 635 * @data: pointer to the read data 636 * 637 * Acquires semaphore, if necessary, then reads the PHY register at offset 638 * and storing the retrieved information in data. Release any acquired 639 * semaphores before exiting. 640 **/ 641s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) 642{ |
624 s32 ret_val = E1000_SUCCESS; | 643 s32 ret_val; |
625 626 DEBUGFUNC("e1000_read_phy_reg_m88"); 627 | 644 645 DEBUGFUNC("e1000_read_phy_reg_m88"); 646 |
628 if (!(hw->phy.ops.acquire)) 629 goto out; | 647 if (!hw->phy.ops.acquire) 648 return E1000_SUCCESS; |
630 631 ret_val = hw->phy.ops.acquire(hw); 632 if (ret_val) | 649 650 ret_val = hw->phy.ops.acquire(hw); 651 if (ret_val) |
633 goto out; | 652 return ret_val; |
634 635 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 636 data); 637 638 hw->phy.ops.release(hw); 639 | 653 654 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 655 data); 656 657 hw->phy.ops.release(hw); 658 |
640out: | |
641 return ret_val; 642} 643 644/** 645 * e1000_write_phy_reg_m88 - Write m88 PHY register 646 * @hw: pointer to the HW structure 647 * @offset: register offset to write to 648 * @data: data to write at register offset 649 * 650 * Acquires semaphore, if necessary, then writes the data to PHY register 651 * at the offset. Release any acquired semaphores before exiting. 652 **/ 653s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) 654{ | 659 return ret_val; 660} 661 662/** 663 * e1000_write_phy_reg_m88 - Write m88 PHY register 664 * @hw: pointer to the HW structure 665 * @offset: register offset to write to 666 * @data: data to write at register offset 667 * 668 * Acquires semaphore, if necessary, then writes the data to PHY register 669 * at the offset. Release any acquired semaphores before exiting. 670 **/ 671s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) 672{ |
655 s32 ret_val = E1000_SUCCESS; | 673 s32 ret_val; |
656 657 DEBUGFUNC("e1000_write_phy_reg_m88"); 658 | 674 675 DEBUGFUNC("e1000_write_phy_reg_m88"); 676 |
659 if (!(hw->phy.ops.acquire)) 660 goto out; | 677 if (!hw->phy.ops.acquire) 678 return E1000_SUCCESS; |
661 662 ret_val = hw->phy.ops.acquire(hw); 663 if (ret_val) | 679 680 ret_val = hw->phy.ops.acquire(hw); 681 if (ret_val) |
664 goto out; | 682 return ret_val; |
665 666 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 667 data); 668 669 hw->phy.ops.release(hw); 670 | 683 684 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 685 data); 686 687 hw->phy.ops.release(hw); 688 |
671out: | |
672 return ret_val; 673} 674 675/** 676 * e1000_set_page_igp - Set page as on IGP-like PHY(s) 677 * @hw: pointer to the HW structure 678 * @page: page to set (shifted left when necessary) 679 * --- 26 unchanged lines hidden (view full) --- 706static s32 __e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, 707 bool locked) 708{ 709 s32 ret_val = E1000_SUCCESS; 710 711 DEBUGFUNC("__e1000_read_phy_reg_igp"); 712 713 if (!locked) { | 689 return ret_val; 690} 691 692/** 693 * e1000_set_page_igp - Set page as on IGP-like PHY(s) 694 * @hw: pointer to the HW structure 695 * @page: page to set (shifted left when necessary) 696 * --- 26 unchanged lines hidden (view full) --- 723static s32 __e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, 724 bool locked) 725{ 726 s32 ret_val = E1000_SUCCESS; 727 728 DEBUGFUNC("__e1000_read_phy_reg_igp"); 729 730 if (!locked) { |
714 if (!(hw->phy.ops.acquire)) 715 goto out; | 731 if (!hw->phy.ops.acquire) 732 return E1000_SUCCESS; |
716 717 ret_val = hw->phy.ops.acquire(hw); 718 if (ret_val) | 733 734 ret_val = hw->phy.ops.acquire(hw); 735 if (ret_val) |
719 goto out; | 736 return ret_val; |
720 } 721 | 737 } 738 |
722 if (offset > MAX_PHY_MULTI_PAGE_REG) { | 739 if (offset > MAX_PHY_MULTI_PAGE_REG) |
723 ret_val = e1000_write_phy_reg_mdic(hw, 724 IGP01E1000_PHY_PAGE_SELECT, 725 (u16)offset); | 740 ret_val = e1000_write_phy_reg_mdic(hw, 741 IGP01E1000_PHY_PAGE_SELECT, 742 (u16)offset); |
726 if (ret_val) 727 goto release; 728 } 729 730 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 731 data); 732 733release: | 743 if (!ret_val) 744 ret_val = e1000_read_phy_reg_mdic(hw, 745 MAX_PHY_REG_ADDRESS & offset, 746 data); |
734 if (!locked) 735 hw->phy.ops.release(hw); | 747 if (!locked) 748 hw->phy.ops.release(hw); |
736out: | 749 |
737 return ret_val; 738} 739 740/** 741 * e1000_read_phy_reg_igp - Read igp PHY register 742 * @hw: pointer to the HW structure 743 * @offset: register offset to be read 744 * @data: pointer to the read data --- 34 unchanged lines hidden (view full) --- 779static s32 __e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, 780 bool locked) 781{ 782 s32 ret_val = E1000_SUCCESS; 783 784 DEBUGFUNC("e1000_write_phy_reg_igp"); 785 786 if (!locked) { | 750 return ret_val; 751} 752 753/** 754 * e1000_read_phy_reg_igp - Read igp PHY register 755 * @hw: pointer to the HW structure 756 * @offset: register offset to be read 757 * @data: pointer to the read data --- 34 unchanged lines hidden (view full) --- 792static s32 __e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, 793 bool locked) 794{ 795 s32 ret_val = E1000_SUCCESS; 796 797 DEBUGFUNC("e1000_write_phy_reg_igp"); 798 799 if (!locked) { |
787 if (!(hw->phy.ops.acquire)) 788 goto out; | 800 if (!hw->phy.ops.acquire) 801 return E1000_SUCCESS; |
789 790 ret_val = hw->phy.ops.acquire(hw); 791 if (ret_val) | 802 803 ret_val = hw->phy.ops.acquire(hw); 804 if (ret_val) |
792 goto out; | 805 return ret_val; |
793 } 794 | 806 } 807 |
795 if (offset > MAX_PHY_MULTI_PAGE_REG) { | 808 if (offset > MAX_PHY_MULTI_PAGE_REG) |
796 ret_val = e1000_write_phy_reg_mdic(hw, 797 IGP01E1000_PHY_PAGE_SELECT, 798 (u16)offset); | 809 ret_val = e1000_write_phy_reg_mdic(hw, 810 IGP01E1000_PHY_PAGE_SELECT, 811 (u16)offset); |
799 if (ret_val) 800 goto release; 801 } 802 803 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 804 data); 805 806release: | 812 if (!ret_val) 813 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & 814 offset, 815 data); |
807 if (!locked) 808 hw->phy.ops.release(hw); 809 | 816 if (!locked) 817 hw->phy.ops.release(hw); 818 |
810out: | |
811 return ret_val; 812} 813 814/** 815 * e1000_write_phy_reg_igp - Write igp PHY register 816 * @hw: pointer to the HW structure 817 * @offset: register offset to write to 818 * @data: data to write at register offset --- 30 unchanged lines hidden (view full) --- 849 * Acquires semaphore, if necessary. Then reads the PHY register at offset 850 * using the kumeran interface. The information retrieved is stored in data. 851 * Release any acquired semaphores before exiting. 852 **/ 853static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, 854 bool locked) 855{ 856 u32 kmrnctrlsta; | 819 return ret_val; 820} 821 822/** 823 * e1000_write_phy_reg_igp - Write igp PHY register 824 * @hw: pointer to the HW structure 825 * @offset: register offset to write to 826 * @data: data to write at register offset --- 30 unchanged lines hidden (view full) --- 857 * Acquires semaphore, if necessary. Then reads the PHY register at offset 858 * using the kumeran interface. The information retrieved is stored in data. 859 * Release any acquired semaphores before exiting. 860 **/ 861static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, 862 bool locked) 863{ 864 u32 kmrnctrlsta; |
857 s32 ret_val = E1000_SUCCESS; | |
858 859 DEBUGFUNC("__e1000_read_kmrn_reg"); 860 861 if (!locked) { | 865 866 DEBUGFUNC("__e1000_read_kmrn_reg"); 867 868 if (!locked) { |
862 if (!(hw->phy.ops.acquire)) 863 goto out; | 869 s32 ret_val = E1000_SUCCESS; |
864 | 870 |
871 if (!hw->phy.ops.acquire) 872 return E1000_SUCCESS; 873 |
|
865 ret_val = hw->phy.ops.acquire(hw); 866 if (ret_val) | 874 ret_val = hw->phy.ops.acquire(hw); 875 if (ret_val) |
867 goto out; | 876 return ret_val; |
868 } 869 870 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & 871 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; 872 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); 873 E1000_WRITE_FLUSH(hw); 874 875 usec_delay(2); 876 877 kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA); 878 *data = (u16)kmrnctrlsta; 879 880 if (!locked) 881 hw->phy.ops.release(hw); 882 | 877 } 878 879 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & 880 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; 881 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); 882 E1000_WRITE_FLUSH(hw); 883 884 usec_delay(2); 885 886 kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA); 887 *data = (u16)kmrnctrlsta; 888 889 if (!locked) 890 hw->phy.ops.release(hw); 891 |
883out: 884 return ret_val; | 892 return E1000_SUCCESS; |
885} 886 887/** 888 * e1000_read_kmrn_reg_generic - Read kumeran register 889 * @hw: pointer to the HW structure 890 * @offset: register offset to be read 891 * @data: pointer to the read data 892 * --- 31 unchanged lines hidden (view full) --- 924 * Acquires semaphore, if necessary. Then write the data to PHY register 925 * at the offset using the kumeran interface. Release any acquired semaphores 926 * before exiting. 927 **/ 928static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, 929 bool locked) 930{ 931 u32 kmrnctrlsta; | 893} 894 895/** 896 * e1000_read_kmrn_reg_generic - Read kumeran register 897 * @hw: pointer to the HW structure 898 * @offset: register offset to be read 899 * @data: pointer to the read data 900 * --- 31 unchanged lines hidden (view full) --- 932 * Acquires semaphore, if necessary. Then write the data to PHY register 933 * at the offset using the kumeran interface. Release any acquired semaphores 934 * before exiting. 935 **/ 936static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, 937 bool locked) 938{ 939 u32 kmrnctrlsta; |
932 s32 ret_val = E1000_SUCCESS; | |
933 934 DEBUGFUNC("e1000_write_kmrn_reg_generic"); 935 936 if (!locked) { | 940 941 DEBUGFUNC("e1000_write_kmrn_reg_generic"); 942 943 if (!locked) { |
937 if (!(hw->phy.ops.acquire)) 938 goto out; | 944 s32 ret_val = E1000_SUCCESS; |
939 | 945 |
946 if (!hw->phy.ops.acquire) 947 return E1000_SUCCESS; 948 |
|
940 ret_val = hw->phy.ops.acquire(hw); 941 if (ret_val) | 949 ret_val = hw->phy.ops.acquire(hw); 950 if (ret_val) |
942 goto out; | 951 return ret_val; |
943 } 944 945 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & 946 E1000_KMRNCTRLSTA_OFFSET) | data; 947 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); 948 E1000_WRITE_FLUSH(hw); 949 950 usec_delay(2); 951 952 if (!locked) 953 hw->phy.ops.release(hw); 954 | 952 } 953 954 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & 955 E1000_KMRNCTRLSTA_OFFSET) | data; 956 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); 957 E1000_WRITE_FLUSH(hw); 958 959 usec_delay(2); 960 961 if (!locked) 962 hw->phy.ops.release(hw); 963 |
955out: 956 return ret_val; | 964 return E1000_SUCCESS; |
957} 958 959/** 960 * e1000_write_kmrn_reg_generic - Write kumeran register 961 * @hw: pointer to the HW structure 962 * @offset: register offset to write to 963 * @data: data to write at register offset 964 * --- 15 unchanged lines hidden (view full) --- 980 * Assumes semaphore already acquired. 981 **/ 982s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) 983{ 984 return __e1000_write_kmrn_reg(hw, offset, data, TRUE); 985} 986 987/** | 965} 966 967/** 968 * e1000_write_kmrn_reg_generic - Write kumeran register 969 * @hw: pointer to the HW structure 970 * @offset: register offset to write to 971 * @data: data to write at register offset 972 * --- 15 unchanged lines hidden (view full) --- 988 * Assumes semaphore already acquired. 989 **/ 990s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) 991{ 992 return __e1000_write_kmrn_reg(hw, offset, data, TRUE); 993} 994 995/** |
996 * e1000_set_master_slave_mode - Setup PHY for Master/slave mode 997 * @hw: pointer to the HW structure 998 * 999 * Sets up Master/slave mode 1000 **/ 1001static s32 e1000_set_master_slave_mode(struct e1000_hw *hw) 1002{ 1003 s32 ret_val; 1004 u16 phy_data; 1005 1006 /* Resolve Master/Slave mode */ 1007 ret_val = hw->phy.ops.read_reg(hw, PHY_1000T_CTRL, &phy_data); 1008 if (ret_val) 1009 return ret_val; 1010 1011 /* load defaults for future use */ 1012 hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ? 1013 ((phy_data & CR_1000T_MS_VALUE) ? 1014 e1000_ms_force_master : 1015 e1000_ms_force_slave) : e1000_ms_auto; 1016 1017 switch (hw->phy.ms_type) { 1018 case e1000_ms_force_master: 1019 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE); 1020 break; 1021 case e1000_ms_force_slave: 1022 phy_data |= CR_1000T_MS_ENABLE; 1023 phy_data &= ~(CR_1000T_MS_VALUE); 1024 break; 1025 case e1000_ms_auto: 1026 phy_data &= ~CR_1000T_MS_ENABLE; 1027 /* fall-through */ 1028 default: 1029 break; 1030 } 1031 1032 return hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data); 1033} 1034 1035/** |
|
988 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link 989 * @hw: pointer to the HW structure 990 * 991 * Sets up Carrier-sense on Transmit and downshift values. 992 **/ 993s32 e1000_copper_link_setup_82577(struct e1000_hw *hw) 994{ 995 s32 ret_val; 996 u16 phy_data; 997 998 DEBUGFUNC("e1000_copper_link_setup_82577"); 999 1000 if (hw->phy.type == e1000_phy_82580) { 1001 ret_val = hw->phy.ops.reset(hw); 1002 if (ret_val) { 1003 DEBUGOUT("Error resetting the PHY.\n"); | 1036 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link 1037 * @hw: pointer to the HW structure 1038 * 1039 * Sets up Carrier-sense on Transmit and downshift values. 1040 **/ 1041s32 e1000_copper_link_setup_82577(struct e1000_hw *hw) 1042{ 1043 s32 ret_val; 1044 u16 phy_data; 1045 1046 DEBUGFUNC("e1000_copper_link_setup_82577"); 1047 1048 if (hw->phy.type == e1000_phy_82580) { 1049 ret_val = hw->phy.ops.reset(hw); 1050 if (ret_val) { 1051 DEBUGOUT("Error resetting the PHY.\n"); |
1004 goto out; | 1052 return ret_val; |
1005 } 1006 } 1007 1008 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1009 ret_val = hw->phy.ops.read_reg(hw, I82577_CFG_REG, &phy_data); 1010 if (ret_val) | 1053 } 1054 } 1055 1056 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1057 ret_val = hw->phy.ops.read_reg(hw, I82577_CFG_REG, &phy_data); 1058 if (ret_val) |
1011 goto out; | 1059 return ret_val; |
1012 1013 phy_data |= I82577_CFG_ASSERT_CRS_ON_TX; 1014 1015 /* Enable downshift */ 1016 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT; 1017 1018 ret_val = hw->phy.ops.write_reg(hw, I82577_CFG_REG, phy_data); 1019 if (ret_val) | 1060 1061 phy_data |= I82577_CFG_ASSERT_CRS_ON_TX; 1062 1063 /* Enable downshift */ 1064 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT; 1065 1066 ret_val = hw->phy.ops.write_reg(hw, I82577_CFG_REG, phy_data); 1067 if (ret_val) |
1020 goto out; | 1068 return ret_val; |
1021 | 1069 |
1022 /* Resolve Master/Slave mode */ 1023 ret_val = hw->phy.ops.read_reg(hw, PHY_1000T_CTRL, &phy_data); | 1070 /* Set MDI/MDIX mode */ 1071 ret_val = hw->phy.ops.read_reg(hw, I82577_PHY_CTRL_2, &phy_data); |
1024 if (ret_val) | 1072 if (ret_val) |
1025 goto out; 1026 1027 /* load defaults for future use */ 1028 hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ? 1029 ((phy_data & CR_1000T_MS_VALUE) ? 1030 e1000_ms_force_master : 1031 e1000_ms_force_slave) : e1000_ms_auto; 1032 1033 switch (hw->phy.ms_type) { 1034 case e1000_ms_force_master: 1035 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE); | 1073 return ret_val; 1074 phy_data &= ~I82577_PHY_CTRL2_MDIX_CFG_MASK; 1075 /* 1076 * Options: 1077 * 0 - Auto (default) 1078 * 1 - MDI mode 1079 * 2 - MDI-X mode 1080 */ 1081 switch (hw->phy.mdix) { 1082 case 1: |
1036 break; | 1083 break; |
1037 case e1000_ms_force_slave: 1038 phy_data |= CR_1000T_MS_ENABLE; 1039 phy_data &= ~(CR_1000T_MS_VALUE); | 1084 case 2: 1085 phy_data |= I82577_PHY_CTRL2_MANUAL_MDIX; |
1040 break; | 1086 break; |
1041 case e1000_ms_auto: 1042 phy_data &= ~CR_1000T_MS_ENABLE; | 1087 case 0: |
1043 default: | 1088 default: |
1089 phy_data |= I82577_PHY_CTRL2_AUTO_MDI_MDIX; |
|
1044 break; 1045 } | 1090 break; 1091 } |
1046 1047 ret_val = hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data); | 1092 ret_val = hw->phy.ops.write_reg(hw, I82577_PHY_CTRL_2, phy_data); |
1048 if (ret_val) | 1093 if (ret_val) |
1049 goto out; | 1094 return ret_val; |
1050 | 1095 |
1051out: 1052 return ret_val; | 1096 return e1000_set_master_slave_mode(hw); |
1053} 1054 1055/** 1056 * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link 1057 * @hw: pointer to the HW structure 1058 * 1059 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock 1060 * and downshift values are set also. --- 5 unchanged lines hidden (view full) --- 1066 u16 phy_data; 1067 1068 DEBUGFUNC("e1000_copper_link_setup_m88"); 1069 1070 1071 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1072 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1073 if (ret_val) | 1097} 1098 1099/** 1100 * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link 1101 * @hw: pointer to the HW structure 1102 * 1103 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock 1104 * and downshift values are set also. --- 5 unchanged lines hidden (view full) --- 1110 u16 phy_data; 1111 1112 DEBUGFUNC("e1000_copper_link_setup_m88"); 1113 1114 1115 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1116 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1117 if (ret_val) |
1074 goto out; | 1118 return ret_val; |
1075 1076 /* For BM PHY this bit is downshift enable */ 1077 if (phy->type != e1000_phy_bm) 1078 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1079 1080 /* 1081 * Options: 1082 * MDI/MDI-X = 0 (default) --- 23 unchanged lines hidden (view full) --- 1106 /* 1107 * Options: 1108 * disable_polarity_correction = 0 (default) 1109 * Automatic Correction for Reversed Cable Polarity 1110 * 0 - Disabled 1111 * 1 - Enabled 1112 */ 1113 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; | 1119 1120 /* For BM PHY this bit is downshift enable */ 1121 if (phy->type != e1000_phy_bm) 1122 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1123 1124 /* 1125 * Options: 1126 * MDI/MDI-X = 0 (default) --- 23 unchanged lines hidden (view full) --- 1150 /* 1151 * Options: 1152 * disable_polarity_correction = 0 (default) 1153 * Automatic Correction for Reversed Cable Polarity 1154 * 0 - Disabled 1155 * 1 - Enabled 1156 */ 1157 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; |
1114 if (phy->disable_polarity_correction == 1) | 1158 if (phy->disable_polarity_correction) |
1115 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 1116 1117 /* Enable downshift on BM (disabled by default) */ | 1159 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 1160 1161 /* Enable downshift on BM (disabled by default) */ |
1118 if (phy->type == e1000_phy_bm) | 1162 if (phy->type == e1000_phy_bm) { 1163 /* For 82574/82583, first disable then enable downshift */ 1164 if (phy->id == BME1000_E_PHY_ID_R2) { 1165 phy_data &= ~BME1000_PSCR_ENABLE_DOWNSHIFT; 1166 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, 1167 phy_data); 1168 if (ret_val) 1169 return ret_val; 1170 /* Commit the changes. */ 1171 ret_val = phy->ops.commit(hw); 1172 if (ret_val) { 1173 DEBUGOUT("Error committing the PHY changes\n"); 1174 return ret_val; 1175 } 1176 } 1177 |
1119 phy_data |= BME1000_PSCR_ENABLE_DOWNSHIFT; | 1178 phy_data |= BME1000_PSCR_ENABLE_DOWNSHIFT; |
1179 } |
|
1120 1121 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1122 if (ret_val) | 1180 1181 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1182 if (ret_val) |
1123 goto out; | 1183 return ret_val; |
1124 1125 if ((phy->type == e1000_phy_m88) && 1126 (phy->revision < E1000_REVISION_4) && 1127 (phy->id != BME1000_E_PHY_ID_R2)) { 1128 /* 1129 * Force TX_CLK in the Extended PHY Specific Control Register 1130 * to 25MHz clock. 1131 */ 1132 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1133 &phy_data); 1134 if (ret_val) | 1184 1185 if ((phy->type == e1000_phy_m88) && 1186 (phy->revision < E1000_REVISION_4) && 1187 (phy->id != BME1000_E_PHY_ID_R2)) { 1188 /* 1189 * Force TX_CLK in the Extended PHY Specific Control Register 1190 * to 25MHz clock. 1191 */ 1192 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1193 &phy_data); 1194 if (ret_val) |
1135 goto out; | 1195 return ret_val; |
1136 1137 phy_data |= M88E1000_EPSCR_TX_CLK_25; 1138 1139 if ((phy->revision == E1000_REVISION_2) && 1140 (phy->id == M88E1111_I_PHY_ID)) { 1141 /* 82573L PHY - set the downshift counter to 5x. */ 1142 phy_data &= ~M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK; 1143 phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X; 1144 } else { 1145 /* Configure Master and Slave downshift values */ 1146 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | 1147 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); 1148 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | 1149 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); 1150 } 1151 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1152 phy_data); 1153 if (ret_val) | 1196 1197 phy_data |= M88E1000_EPSCR_TX_CLK_25; 1198 1199 if ((phy->revision == E1000_REVISION_2) && 1200 (phy->id == M88E1111_I_PHY_ID)) { 1201 /* 82573L PHY - set the downshift counter to 5x. */ 1202 phy_data &= ~M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK; 1203 phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X; 1204 } else { 1205 /* Configure Master and Slave downshift values */ 1206 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | 1207 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); 1208 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | 1209 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); 1210 } 1211 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1212 phy_data); 1213 if (ret_val) |
1154 goto out; | 1214 return ret_val; |
1155 } 1156 1157 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { 1158 /* Set PHY page 0, register 29 to 0x0003 */ 1159 ret_val = phy->ops.write_reg(hw, 29, 0x0003); 1160 if (ret_val) | 1215 } 1216 1217 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { 1218 /* Set PHY page 0, register 29 to 0x0003 */ 1219 ret_val = phy->ops.write_reg(hw, 29, 0x0003); 1220 if (ret_val) |
1161 goto out; | 1221 return ret_val; |
1162 1163 /* Set PHY page 0, register 30 to 0x0000 */ 1164 ret_val = phy->ops.write_reg(hw, 30, 0x0000); 1165 if (ret_val) | 1222 1223 /* Set PHY page 0, register 30 to 0x0000 */ 1224 ret_val = phy->ops.write_reg(hw, 30, 0x0000); 1225 if (ret_val) |
1166 goto out; | 1226 return ret_val; |
1167 } 1168 1169 /* Commit the changes. */ 1170 ret_val = phy->ops.commit(hw); 1171 if (ret_val) { 1172 DEBUGOUT("Error committing the PHY changes\n"); | 1227 } 1228 1229 /* Commit the changes. */ 1230 ret_val = phy->ops.commit(hw); 1231 if (ret_val) { 1232 DEBUGOUT("Error committing the PHY changes\n"); |
1173 goto out; | 1233 return ret_val; |
1174 } 1175 1176 if (phy->type == e1000_phy_82578) { 1177 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1178 &phy_data); 1179 if (ret_val) | 1234 } 1235 1236 if (phy->type == e1000_phy_82578) { 1237 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1238 &phy_data); 1239 if (ret_val) |
1180 goto out; | 1240 return ret_val; |
1181 1182 /* 82578 PHY - set the downshift count to 1x. */ 1183 phy_data |= I82578_EPSCR_DOWNSHIFT_ENABLE; 1184 phy_data &= ~I82578_EPSCR_DOWNSHIFT_COUNTER_MASK; 1185 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1186 phy_data); 1187 if (ret_val) | 1241 1242 /* 82578 PHY - set the downshift count to 1x. */ 1243 phy_data |= I82578_EPSCR_DOWNSHIFT_ENABLE; 1244 phy_data &= ~I82578_EPSCR_DOWNSHIFT_COUNTER_MASK; 1245 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1246 phy_data); 1247 if (ret_val) |
1188 goto out; | 1248 return ret_val; |
1189 } 1190 | 1249 } 1250 |
1191out: 1192 return ret_val; | 1251 if (phy->type == e1000_phy_i210) { 1252 ret_val = e1000_set_master_slave_mode(hw); 1253 if (ret_val) 1254 return ret_val; 1255 } 1256 1257 return E1000_SUCCESS; |
1193} 1194 1195/** 1196 * e1000_copper_link_setup_m88_gen2 - Setup m88 PHY's for copper link 1197 * @hw: pointer to the HW structure 1198 * 1199 * Sets up MDI/MDI-X and polarity for i347-AT4, m88e1322 and m88e1112 PHY's. 1200 * Also enables and sets the downshift parameters. --- 5 unchanged lines hidden (view full) --- 1206 u16 phy_data; 1207 1208 DEBUGFUNC("e1000_copper_link_setup_m88_gen2"); 1209 1210 1211 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1212 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1213 if (ret_val) | 1258} 1259 1260/** 1261 * e1000_copper_link_setup_m88_gen2 - Setup m88 PHY's for copper link 1262 * @hw: pointer to the HW structure 1263 * 1264 * Sets up MDI/MDI-X and polarity for i347-AT4, m88e1322 and m88e1112 PHY's. 1265 * Also enables and sets the downshift parameters. --- 5 unchanged lines hidden (view full) --- 1271 u16 phy_data; 1272 1273 DEBUGFUNC("e1000_copper_link_setup_m88_gen2"); 1274 1275 1276 /* Enable CRS on Tx. This must be set for half-duplex operation. */ 1277 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1278 if (ret_val) |
1214 goto out; | 1279 return ret_val; |
1215 1216 /* 1217 * Options: 1218 * MDI/MDI-X = 0 (default) 1219 * 0 - Auto for all speeds 1220 * 1 - MDI mode 1221 * 2 - MDI-X mode 1222 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) --- 22 unchanged lines hidden (view full) --- 1245 /* 1246 * Options: 1247 * disable_polarity_correction = 0 (default) 1248 * Automatic Correction for Reversed Cable Polarity 1249 * 0 - Disabled 1250 * 1 - Enabled 1251 */ 1252 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; | 1280 1281 /* 1282 * Options: 1283 * MDI/MDI-X = 0 (default) 1284 * 0 - Auto for all speeds 1285 * 1 - MDI mode 1286 * 2 - MDI-X mode 1287 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) --- 22 unchanged lines hidden (view full) --- 1310 /* 1311 * Options: 1312 * disable_polarity_correction = 0 (default) 1313 * Automatic Correction for Reversed Cable Polarity 1314 * 0 - Disabled 1315 * 1 - Enabled 1316 */ 1317 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; |
1253 if (phy->disable_polarity_correction == 1) | 1318 if (phy->disable_polarity_correction) |
1254 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 1255 1256 /* Enable downshift and setting it to X6 */ 1257 phy_data &= ~I347AT4_PSCR_DOWNSHIFT_MASK; 1258 phy_data |= I347AT4_PSCR_DOWNSHIFT_6X; 1259 phy_data |= I347AT4_PSCR_DOWNSHIFT_ENABLE; 1260 1261 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1262 if (ret_val) | 1319 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 1320 1321 /* Enable downshift and setting it to X6 */ 1322 phy_data &= ~I347AT4_PSCR_DOWNSHIFT_MASK; 1323 phy_data |= I347AT4_PSCR_DOWNSHIFT_6X; 1324 phy_data |= I347AT4_PSCR_DOWNSHIFT_ENABLE; 1325 1326 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1327 if (ret_val) |
1263 goto out; | 1328 return ret_val; |
1264 1265 /* Commit the changes. */ 1266 ret_val = phy->ops.commit(hw); 1267 if (ret_val) { 1268 DEBUGOUT("Error committing the PHY changes\n"); | 1329 1330 /* Commit the changes. */ 1331 ret_val = phy->ops.commit(hw); 1332 if (ret_val) { 1333 DEBUGOUT("Error committing the PHY changes\n"); |
1269 goto out; | 1334 return ret_val; |
1270 } 1271 | 1335 } 1336 |
1272out: 1273 return ret_val; | 1337 return E1000_SUCCESS; |
1274} 1275 1276/** 1277 * e1000_copper_link_setup_igp - Setup igp PHY's for copper link 1278 * @hw: pointer to the HW structure 1279 * 1280 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for 1281 * igp PHY's. --- 5 unchanged lines hidden (view full) --- 1287 u16 data; 1288 1289 DEBUGFUNC("e1000_copper_link_setup_igp"); 1290 1291 1292 ret_val = hw->phy.ops.reset(hw); 1293 if (ret_val) { 1294 DEBUGOUT("Error resetting the PHY.\n"); | 1338} 1339 1340/** 1341 * e1000_copper_link_setup_igp - Setup igp PHY's for copper link 1342 * @hw: pointer to the HW structure 1343 * 1344 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for 1345 * igp PHY's. --- 5 unchanged lines hidden (view full) --- 1351 u16 data; 1352 1353 DEBUGFUNC("e1000_copper_link_setup_igp"); 1354 1355 1356 ret_val = hw->phy.ops.reset(hw); 1357 if (ret_val) { 1358 DEBUGOUT("Error resetting the PHY.\n"); |
1295 goto out; | 1359 return ret_val; |
1296 } 1297 1298 /* 1299 * Wait 100ms for MAC to configure PHY from NVM settings, to avoid 1300 * timeout issues when LFS is enabled. 1301 */ 1302 msec_delay(100); 1303 1304 /* 1305 * The NVM settings will configure LPLU in D3 for 1306 * non-IGP1 PHYs. 1307 */ 1308 if (phy->type == e1000_phy_igp) { 1309 /* disable lplu d3 during driver init */ 1310 ret_val = hw->phy.ops.set_d3_lplu_state(hw, FALSE); 1311 if (ret_val) { 1312 DEBUGOUT("Error Disabling LPLU D3\n"); | 1360 } 1361 1362 /* 1363 * Wait 100ms for MAC to configure PHY from NVM settings, to avoid 1364 * timeout issues when LFS is enabled. 1365 */ 1366 msec_delay(100); 1367 1368 /* 1369 * The NVM settings will configure LPLU in D3 for 1370 * non-IGP1 PHYs. 1371 */ 1372 if (phy->type == e1000_phy_igp) { 1373 /* disable lplu d3 during driver init */ 1374 ret_val = hw->phy.ops.set_d3_lplu_state(hw, FALSE); 1375 if (ret_val) { 1376 DEBUGOUT("Error Disabling LPLU D3\n"); |
1313 goto out; | 1377 return ret_val; |
1314 } 1315 } 1316 1317 /* disable lplu d0 during driver init */ 1318 if (hw->phy.ops.set_d0_lplu_state) { 1319 ret_val = hw->phy.ops.set_d0_lplu_state(hw, FALSE); 1320 if (ret_val) { 1321 DEBUGOUT("Error Disabling LPLU D0\n"); | 1378 } 1379 } 1380 1381 /* disable lplu d0 during driver init */ 1382 if (hw->phy.ops.set_d0_lplu_state) { 1383 ret_val = hw->phy.ops.set_d0_lplu_state(hw, FALSE); 1384 if (ret_val) { 1385 DEBUGOUT("Error Disabling LPLU D0\n"); |
1322 goto out; | 1386 return ret_val; |
1323 } 1324 } 1325 /* Configure mdi-mdix settings */ 1326 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &data); 1327 if (ret_val) | 1387 } 1388 } 1389 /* Configure mdi-mdix settings */ 1390 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &data); 1391 if (ret_val) |
1328 goto out; | 1392 return ret_val; |
1329 1330 data &= ~IGP01E1000_PSCR_AUTO_MDIX; 1331 1332 switch (phy->mdix) { 1333 case 1: 1334 data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX; 1335 break; 1336 case 2: 1337 data |= IGP01E1000_PSCR_FORCE_MDI_MDIX; 1338 break; 1339 case 0: 1340 default: 1341 data |= IGP01E1000_PSCR_AUTO_MDIX; 1342 break; 1343 } 1344 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, data); 1345 if (ret_val) | 1393 1394 data &= ~IGP01E1000_PSCR_AUTO_MDIX; 1395 1396 switch (phy->mdix) { 1397 case 1: 1398 data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX; 1399 break; 1400 case 2: 1401 data |= IGP01E1000_PSCR_FORCE_MDI_MDIX; 1402 break; 1403 case 0: 1404 default: 1405 data |= IGP01E1000_PSCR_AUTO_MDIX; 1406 break; 1407 } 1408 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, data); 1409 if (ret_val) |
1346 goto out; | 1410 return ret_val; |
1347 1348 /* set auto-master slave resolution settings */ 1349 if (hw->mac.autoneg) { 1350 /* 1351 * when autonegotiation advertisement is only 1000Mbps then we 1352 * should disable SmartSpeed and enable Auto MasterSlave 1353 * resolution as hardware default. 1354 */ 1355 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { 1356 /* Disable SmartSpeed */ 1357 ret_val = phy->ops.read_reg(hw, 1358 IGP01E1000_PHY_PORT_CONFIG, 1359 &data); 1360 if (ret_val) | 1411 1412 /* set auto-master slave resolution settings */ 1413 if (hw->mac.autoneg) { 1414 /* 1415 * when autonegotiation advertisement is only 1000Mbps then we 1416 * should disable SmartSpeed and enable Auto MasterSlave 1417 * resolution as hardware default. 1418 */ 1419 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { 1420 /* Disable SmartSpeed */ 1421 ret_val = phy->ops.read_reg(hw, 1422 IGP01E1000_PHY_PORT_CONFIG, 1423 &data); 1424 if (ret_val) |
1361 goto out; | 1425 return ret_val; |
1362 1363 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 1364 ret_val = phy->ops.write_reg(hw, 1365 IGP01E1000_PHY_PORT_CONFIG, 1366 data); 1367 if (ret_val) | 1426 1427 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 1428 ret_val = phy->ops.write_reg(hw, 1429 IGP01E1000_PHY_PORT_CONFIG, 1430 data); 1431 if (ret_val) |
1368 goto out; | 1432 return ret_val; |
1369 1370 /* Set auto Master/Slave resolution process */ 1371 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data); 1372 if (ret_val) | 1433 1434 /* Set auto Master/Slave resolution process */ 1435 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data); 1436 if (ret_val) |
1373 goto out; | 1437 return ret_val; |
1374 1375 data &= ~CR_1000T_MS_ENABLE; 1376 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data); 1377 if (ret_val) | 1438 1439 data &= ~CR_1000T_MS_ENABLE; 1440 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data); 1441 if (ret_val) |
1378 goto out; | 1442 return ret_val; |
1379 } 1380 | 1443 } 1444 |
1381 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data); 1382 if (ret_val) 1383 goto out; 1384 1385 /* load defaults for future use */ 1386 phy->original_ms_type = (data & CR_1000T_MS_ENABLE) ? 1387 ((data & CR_1000T_MS_VALUE) ? 1388 e1000_ms_force_master : 1389 e1000_ms_force_slave) : 1390 e1000_ms_auto; 1391 1392 switch (phy->ms_type) { 1393 case e1000_ms_force_master: 1394 data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE); 1395 break; 1396 case e1000_ms_force_slave: 1397 data |= CR_1000T_MS_ENABLE; 1398 data &= ~(CR_1000T_MS_VALUE); 1399 break; 1400 case e1000_ms_auto: 1401 data &= ~CR_1000T_MS_ENABLE; 1402 default: 1403 break; 1404 } 1405 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data); 1406 if (ret_val) 1407 goto out; | 1445 ret_val = e1000_set_master_slave_mode(hw); |
1408 } 1409 | 1446 } 1447 |
1410out: | |
1411 return ret_val; 1412} 1413 1414/** | 1448 return ret_val; 1449} 1450 1451/** |
1415 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link 1416 * @hw: pointer to the HW structure 1417 * 1418 * Performs initial bounds checking on autoneg advertisement parameter, then 1419 * configure to advertise the full capability. Setup the PHY to autoneg 1420 * and restart the negotiation process between the link partner. If 1421 * autoneg_wait_to_complete, then wait for autoneg to complete before exiting. 1422 **/ 1423s32 e1000_copper_link_autoneg(struct e1000_hw *hw) 1424{ 1425 struct e1000_phy_info *phy = &hw->phy; 1426 s32 ret_val; 1427 u16 phy_ctrl; 1428 1429 DEBUGFUNC("e1000_copper_link_autoneg"); 1430 1431 /* 1432 * Perform some bounds checking on the autoneg advertisement 1433 * parameter. 1434 */ 1435 phy->autoneg_advertised &= phy->autoneg_mask; 1436 1437 /* 1438 * If autoneg_advertised is zero, we assume it was not defaulted 1439 * by the calling code so we set to advertise full capability. 1440 */ 1441 if (phy->autoneg_advertised == 0) 1442 phy->autoneg_advertised = phy->autoneg_mask; 1443 1444 DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); 1445 ret_val = e1000_phy_setup_autoneg(hw); 1446 if (ret_val) { 1447 DEBUGOUT("Error Setting up Auto-Negotiation\n"); 1448 goto out; 1449 } 1450 DEBUGOUT("Restarting Auto-Neg\n"); 1451 1452 /* 1453 * Restart auto-negotiation by setting the Auto Neg Enable bit and 1454 * the Auto Neg Restart bit in the PHY control register. 1455 */ 1456 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); 1457 if (ret_val) 1458 goto out; 1459 1460 phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); 1461 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl); 1462 if (ret_val) 1463 goto out; 1464 1465 /* 1466 * Does the user want to wait for Auto-Neg to complete here, or 1467 * check at a later time (for example, callback routine). 1468 */ 1469 if (phy->autoneg_wait_to_complete) { 1470 ret_val = hw->mac.ops.wait_autoneg(hw); 1471 if (ret_val) { 1472 DEBUGOUT("Error while waiting for autoneg to complete\n"); 1473 goto out; 1474 } 1475 } 1476 1477 hw->mac.get_link_status = TRUE; 1478 1479out: 1480 return ret_val; 1481} 1482 1483/** | |
1484 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation 1485 * @hw: pointer to the HW structure 1486 * 1487 * Reads the MII auto-neg advertisement register and/or the 1000T control 1488 * register and if the PHY is already setup for auto-negotiation, then 1489 * return successful. Otherwise, setup advertisement and flow control to 1490 * the appropriate values for the wanted auto-negotiation. 1491 **/ --- 6 unchanged lines hidden (view full) --- 1498 1499 DEBUGFUNC("e1000_phy_setup_autoneg"); 1500 1501 phy->autoneg_advertised &= phy->autoneg_mask; 1502 1503 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ 1504 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); 1505 if (ret_val) | 1452 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation 1453 * @hw: pointer to the HW structure 1454 * 1455 * Reads the MII auto-neg advertisement register and/or the 1000T control 1456 * register and if the PHY is already setup for auto-negotiation, then 1457 * return successful. Otherwise, setup advertisement and flow control to 1458 * the appropriate values for the wanted auto-negotiation. 1459 **/ --- 6 unchanged lines hidden (view full) --- 1466 1467 DEBUGFUNC("e1000_phy_setup_autoneg"); 1468 1469 phy->autoneg_advertised &= phy->autoneg_mask; 1470 1471 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ 1472 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); 1473 if (ret_val) |
1506 goto out; | 1474 return ret_val; |
1507 1508 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { 1509 /* Read the MII 1000Base-T Control Register (Address 9). */ 1510 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, 1511 &mii_1000t_ctrl_reg); 1512 if (ret_val) | 1475 1476 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { 1477 /* Read the MII 1000Base-T Control Register (Address 9). */ 1478 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, 1479 &mii_1000t_ctrl_reg); 1480 if (ret_val) |
1513 goto out; | 1481 return ret_val; |
1514 } 1515 1516 /* 1517 * Need to parse both autoneg_advertised and fc and set up 1518 * the appropriate PHY registers. First we will parse for 1519 * autoneg_advertised software override. Since we can advertise 1520 * a plethora of combinations, we need to check each bit 1521 * individually. --- 97 unchanged lines hidden (view full) --- 1619 /* 1620 * Flow control (both Rx and Tx) is enabled by a software 1621 * over-ride. 1622 */ 1623 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); 1624 break; 1625 default: 1626 DEBUGOUT("Flow control param set incorrectly\n"); | 1482 } 1483 1484 /* 1485 * Need to parse both autoneg_advertised and fc and set up 1486 * the appropriate PHY registers. First we will parse for 1487 * autoneg_advertised software override. Since we can advertise 1488 * a plethora of combinations, we need to check each bit 1489 * individually. --- 97 unchanged lines hidden (view full) --- 1587 /* 1588 * Flow control (both Rx and Tx) is enabled by a software 1589 * over-ride. 1590 */ 1591 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); 1592 break; 1593 default: 1594 DEBUGOUT("Flow control param set incorrectly\n"); |
1627 ret_val = -E1000_ERR_CONFIG; 1628 goto out; | 1595 return -E1000_ERR_CONFIG; |
1629 } 1630 1631 ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); 1632 if (ret_val) | 1596 } 1597 1598 ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); 1599 if (ret_val) |
1633 goto out; | 1600 return ret_val; |
1634 1635 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 1636 | 1601 1602 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 1603 |
1637 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { | 1604 if (phy->autoneg_mask & ADVERTISE_1000_FULL) |
1638 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, 1639 mii_1000t_ctrl_reg); | 1605 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, 1606 mii_1000t_ctrl_reg); |
1640 if (ret_val) 1641 goto out; | 1607 1608 return ret_val; 1609} 1610 1611/** 1612 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link 1613 * @hw: pointer to the HW structure 1614 * 1615 * Performs initial bounds checking on autoneg advertisement parameter, then 1616 * configure to advertise the full capability. Setup the PHY to autoneg 1617 * and restart the negotiation process between the link partner. If 1618 * autoneg_wait_to_complete, then wait for autoneg to complete before exiting. 1619 **/ 1620s32 e1000_copper_link_autoneg(struct e1000_hw *hw) 1621{ 1622 struct e1000_phy_info *phy = &hw->phy; 1623 s32 ret_val; 1624 u16 phy_ctrl; 1625 1626 DEBUGFUNC("e1000_copper_link_autoneg"); 1627 1628 /* 1629 * Perform some bounds checking on the autoneg advertisement 1630 * parameter. 1631 */ 1632 phy->autoneg_advertised &= phy->autoneg_mask; 1633 1634 /* 1635 * If autoneg_advertised is zero, we assume it was not defaulted 1636 * by the calling code so we set to advertise full capability. 1637 */ 1638 if (!phy->autoneg_advertised) 1639 phy->autoneg_advertised = phy->autoneg_mask; 1640 1641 DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); 1642 ret_val = e1000_phy_setup_autoneg(hw); 1643 if (ret_val) { 1644 DEBUGOUT("Error Setting up Auto-Negotiation\n"); 1645 return ret_val; |
1642 } | 1646 } |
1647 DEBUGOUT("Restarting Auto-Neg\n"); |
|
1643 | 1648 |
1644out: | 1649 /* 1650 * Restart auto-negotiation by setting the Auto Neg Enable bit and 1651 * the Auto Neg Restart bit in the PHY control register. 1652 */ 1653 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); 1654 if (ret_val) 1655 return ret_val; 1656 1657 phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); 1658 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl); 1659 if (ret_val) 1660 return ret_val; 1661 1662 /* 1663 * Does the user want to wait for Auto-Neg to complete here, or 1664 * check at a later time (for example, callback routine). 1665 */ 1666 if (phy->autoneg_wait_to_complete) { 1667 ret_val = hw->mac.ops.wait_autoneg(hw); 1668 if (ret_val) { 1669 DEBUGOUT("Error while waiting for autoneg to complete\n"); 1670 return ret_val; 1671 } 1672 } 1673 1674 hw->mac.get_link_status = TRUE; 1675 |
1645 return ret_val; 1646} 1647 1648/** 1649 * e1000_setup_copper_link_generic - Configure copper link settings 1650 * @hw: pointer to the HW structure 1651 * 1652 * Calls the appropriate function to configure the link for auto-neg or forced --- 10 unchanged lines hidden (view full) --- 1663 1664 if (hw->mac.autoneg) { 1665 /* 1666 * Setup autoneg and flow control advertisement and perform 1667 * autonegotiation. 1668 */ 1669 ret_val = e1000_copper_link_autoneg(hw); 1670 if (ret_val) | 1676 return ret_val; 1677} 1678 1679/** 1680 * e1000_setup_copper_link_generic - Configure copper link settings 1681 * @hw: pointer to the HW structure 1682 * 1683 * Calls the appropriate function to configure the link for auto-neg or forced --- 10 unchanged lines hidden (view full) --- 1694 1695 if (hw->mac.autoneg) { 1696 /* 1697 * Setup autoneg and flow control advertisement and perform 1698 * autonegotiation. 1699 */ 1700 ret_val = e1000_copper_link_autoneg(hw); 1701 if (ret_val) |
1671 goto out; | 1702 return ret_val; |
1672 } else { 1673 /* 1674 * PHY will be set to 10H, 10F, 100H or 100F 1675 * depending on user settings. 1676 */ 1677 DEBUGOUT("Forcing Speed and Duplex\n"); 1678 ret_val = hw->phy.ops.force_speed_duplex(hw); 1679 if (ret_val) { 1680 DEBUGOUT("Error Forcing Speed and Duplex\n"); | 1703 } else { 1704 /* 1705 * PHY will be set to 10H, 10F, 100H or 100F 1706 * depending on user settings. 1707 */ 1708 DEBUGOUT("Forcing Speed and Duplex\n"); 1709 ret_val = hw->phy.ops.force_speed_duplex(hw); 1710 if (ret_val) { 1711 DEBUGOUT("Error Forcing Speed and Duplex\n"); |
1681 goto out; | 1712 return ret_val; |
1682 } 1683 } 1684 1685 /* 1686 * Check link status. Wait up to 100 microseconds for link to become 1687 * valid. 1688 */ 1689 ret_val = e1000_phy_has_link_generic(hw, COPPER_LINK_UP_LIMIT, 10, 1690 &link); 1691 if (ret_val) | 1713 } 1714 } 1715 1716 /* 1717 * Check link status. Wait up to 100 microseconds for link to become 1718 * valid. 1719 */ 1720 ret_val = e1000_phy_has_link_generic(hw, COPPER_LINK_UP_LIMIT, 10, 1721 &link); 1722 if (ret_val) |
1692 goto out; | 1723 return ret_val; |
1693 1694 if (link) { 1695 DEBUGOUT("Valid link established!!!\n"); | 1724 1725 if (link) { 1726 DEBUGOUT("Valid link established!!!\n"); |
1696 e1000_config_collision_dist_generic(hw); | 1727 hw->mac.ops.config_collision_dist(hw); |
1697 ret_val = e1000_config_fc_after_link_up_generic(hw); 1698 } else { 1699 DEBUGOUT("Unable to establish link!!!\n"); 1700 } 1701 | 1728 ret_val = e1000_config_fc_after_link_up_generic(hw); 1729 } else { 1730 DEBUGOUT("Unable to establish link!!!\n"); 1731 } 1732 |
1702out: | |
1703 return ret_val; 1704} 1705 1706/** 1707 * e1000_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY 1708 * @hw: pointer to the HW structure 1709 * 1710 * Calls the PHY setup function to force speed and duplex. Clears the --- 6 unchanged lines hidden (view full) --- 1717 s32 ret_val; 1718 u16 phy_data; 1719 bool link; 1720 1721 DEBUGFUNC("e1000_phy_force_speed_duplex_igp"); 1722 1723 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 1724 if (ret_val) | 1733 return ret_val; 1734} 1735 1736/** 1737 * e1000_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY 1738 * @hw: pointer to the HW structure 1739 * 1740 * Calls the PHY setup function to force speed and duplex. Clears the --- 6 unchanged lines hidden (view full) --- 1747 s32 ret_val; 1748 u16 phy_data; 1749 bool link; 1750 1751 DEBUGFUNC("e1000_phy_force_speed_duplex_igp"); 1752 1753 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 1754 if (ret_val) |
1725 goto out; | 1755 return ret_val; |
1726 1727 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 1728 1729 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 1730 if (ret_val) | 1756 1757 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 1758 1759 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 1760 if (ret_val) |
1731 goto out; | 1761 return ret_val; |
1732 1733 /* 1734 * Clear Auto-Crossover to force MDI manually. IGP requires MDI 1735 * forced whenever speed and duplex are forced. 1736 */ 1737 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data); 1738 if (ret_val) | 1762 1763 /* 1764 * Clear Auto-Crossover to force MDI manually. IGP requires MDI 1765 * forced whenever speed and duplex are forced. 1766 */ 1767 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data); 1768 if (ret_val) |
1739 goto out; | 1769 return ret_val; |
1740 1741 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX; 1742 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX; 1743 1744 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data); 1745 if (ret_val) | 1770 1771 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX; 1772 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX; 1773 1774 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data); 1775 if (ret_val) |
1746 goto out; | 1776 return ret_val; |
1747 1748 DEBUGOUT1("IGP PSCR: %X\n", phy_data); 1749 1750 usec_delay(1); 1751 1752 if (phy->autoneg_wait_to_complete) { 1753 DEBUGOUT("Waiting for forced speed/duplex link on IGP phy.\n"); 1754 1755 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1756 100000, &link); 1757 if (ret_val) | 1777 1778 DEBUGOUT1("IGP PSCR: %X\n", phy_data); 1779 1780 usec_delay(1); 1781 1782 if (phy->autoneg_wait_to_complete) { 1783 DEBUGOUT("Waiting for forced speed/duplex link on IGP phy.\n"); 1784 1785 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1786 100000, &link); 1787 if (ret_val) |
1758 goto out; | 1788 return ret_val; |
1759 1760 if (!link) 1761 DEBUGOUT("Link taking longer than expected.\n"); 1762 1763 /* Try once more */ 1764 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1765 100000, &link); | 1789 1790 if (!link) 1791 DEBUGOUT("Link taking longer than expected.\n"); 1792 1793 /* Try once more */ 1794 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1795 100000, &link); |
1766 if (ret_val) 1767 goto out; | |
1768 } 1769 | 1796 } 1797 |
1770out: | |
1771 return ret_val; 1772} 1773 1774/** 1775 * e1000_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY 1776 * @hw: pointer to the HW structure 1777 * 1778 * Calls the PHY setup function to force speed and duplex. Clears the --- 12 unchanged lines hidden (view full) --- 1791 DEBUGFUNC("e1000_phy_force_speed_duplex_m88"); 1792 1793 /* 1794 * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI 1795 * forced whenever speed and duplex are forced. 1796 */ 1797 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1798 if (ret_val) | 1798 return ret_val; 1799} 1800 1801/** 1802 * e1000_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY 1803 * @hw: pointer to the HW structure 1804 * 1805 * Calls the PHY setup function to force speed and duplex. Clears the --- 12 unchanged lines hidden (view full) --- 1818 DEBUGFUNC("e1000_phy_force_speed_duplex_m88"); 1819 1820 /* 1821 * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI 1822 * forced whenever speed and duplex are forced. 1823 */ 1824 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1825 if (ret_val) |
1799 goto out; | 1826 return ret_val; |
1800 1801 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; 1802 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1803 if (ret_val) | 1827 1828 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; 1829 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1830 if (ret_val) |
1804 goto out; | 1831 return ret_val; |
1805 1806 DEBUGOUT1("M88E1000 PSCR: %X\n", phy_data); 1807 1808 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 1809 if (ret_val) | 1832 1833 DEBUGOUT1("M88E1000 PSCR: %X\n", phy_data); 1834 1835 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 1836 if (ret_val) |
1810 goto out; | 1837 return ret_val; |
1811 1812 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 1813 1814 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 1815 if (ret_val) | 1838 1839 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 1840 1841 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 1842 if (ret_val) |
1816 goto out; | 1843 return ret_val; |
1817 1818 /* Reset the phy to commit changes. */ 1819 ret_val = hw->phy.ops.commit(hw); 1820 if (ret_val) | 1844 1845 /* Reset the phy to commit changes. */ 1846 ret_val = hw->phy.ops.commit(hw); 1847 if (ret_val) |
1821 goto out; | 1848 return ret_val; |
1822 1823 if (phy->autoneg_wait_to_complete) { 1824 DEBUGOUT("Waiting for forced speed/duplex link on M88 phy.\n"); 1825 1826 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1827 100000, &link); 1828 if (ret_val) | 1849 1850 if (phy->autoneg_wait_to_complete) { 1851 DEBUGOUT("Waiting for forced speed/duplex link on M88 phy.\n"); 1852 1853 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1854 100000, &link); 1855 if (ret_val) |
1829 goto out; | 1856 return ret_val; |
1830 1831 if (!link) { | 1857 1858 if (!link) { |
1832 if (hw->phy.type != e1000_phy_m88 || 1833 hw->phy.id == I347AT4_E_PHY_ID || 1834 hw->phy.id == M88E1340M_E_PHY_ID || 1835 hw->phy.id == M88E1112_E_PHY_ID) { | 1859 bool reset_dsp = TRUE; 1860 1861 switch (hw->phy.id) { 1862 case I347AT4_E_PHY_ID: 1863 case M88E1340M_E_PHY_ID: 1864 case M88E1112_E_PHY_ID: 1865 case I210_I_PHY_ID: 1866 reset_dsp = FALSE; 1867 break; 1868 default: 1869 if (hw->phy.type != e1000_phy_m88) 1870 reset_dsp = FALSE; 1871 break; 1872 } 1873 1874 if (!reset_dsp) { |
1836 DEBUGOUT("Link taking longer than expected.\n"); 1837 } else { 1838 /* 1839 * We didn't get link. 1840 * Reset the DSP and cross our fingers. 1841 */ 1842 ret_val = phy->ops.write_reg(hw, 1843 M88E1000_PHY_PAGE_SELECT, 1844 0x001d); 1845 if (ret_val) | 1875 DEBUGOUT("Link taking longer than expected.\n"); 1876 } else { 1877 /* 1878 * We didn't get link. 1879 * Reset the DSP and cross our fingers. 1880 */ 1881 ret_val = phy->ops.write_reg(hw, 1882 M88E1000_PHY_PAGE_SELECT, 1883 0x001d); 1884 if (ret_val) |
1846 goto out; | 1885 return ret_val; |
1847 ret_val = e1000_phy_reset_dsp_generic(hw); 1848 if (ret_val) | 1886 ret_val = e1000_phy_reset_dsp_generic(hw); 1887 if (ret_val) |
1849 goto out; | 1888 return ret_val; |
1850 } 1851 } 1852 1853 /* Try once more */ 1854 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1855 100000, &link); 1856 if (ret_val) | 1889 } 1890 } 1891 1892 /* Try once more */ 1893 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1894 100000, &link); 1895 if (ret_val) |
1857 goto out; | 1896 return ret_val; |
1858 } 1859 | 1897 } 1898 |
1860 if (hw->phy.type != e1000_phy_m88 || 1861 hw->phy.id == I347AT4_E_PHY_ID || 1862 hw->phy.id == M88E1340M_E_PHY_ID || 1863 hw->phy.id == M88E1112_E_PHY_ID) 1864 goto out; | 1899 if (hw->phy.type != e1000_phy_m88) 1900 return E1000_SUCCESS; |
1865 | 1901 |
1902 if (hw->phy.id == I347AT4_E_PHY_ID || 1903 hw->phy.id == M88E1340M_E_PHY_ID || 1904 hw->phy.id == M88E1112_E_PHY_ID) 1905 return E1000_SUCCESS; 1906 if (hw->phy.id == I210_I_PHY_ID) 1907 return E1000_SUCCESS; |
|
1866 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data); 1867 if (ret_val) | 1908 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data); 1909 if (ret_val) |
1868 goto out; | 1910 return ret_val; |
1869 1870 /* 1871 * Resetting the phy means we need to re-force TX_CLK in the 1872 * Extended PHY Specific Control Register to 25MHz clock from 1873 * the reset value of 2.5MHz. 1874 */ 1875 phy_data |= M88E1000_EPSCR_TX_CLK_25; 1876 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data); 1877 if (ret_val) | 1911 1912 /* 1913 * Resetting the phy means we need to re-force TX_CLK in the 1914 * Extended PHY Specific Control Register to 25MHz clock from 1915 * the reset value of 2.5MHz. 1916 */ 1917 phy_data |= M88E1000_EPSCR_TX_CLK_25; 1918 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data); 1919 if (ret_val) |
1878 goto out; | 1920 return ret_val; |
1879 1880 /* 1881 * In addition, we must re-enable CRS on Tx for both half and full 1882 * duplex. 1883 */ 1884 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1885 if (ret_val) | 1921 1922 /* 1923 * In addition, we must re-enable CRS on Tx for both half and full 1924 * duplex. 1925 */ 1926 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1927 if (ret_val) |
1886 goto out; | 1928 return ret_val; |
1887 1888 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1889 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1890 | 1929 1930 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1931 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1932 |
1891out: | |
1892 return ret_val; 1893} 1894 1895/** 1896 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex 1897 * @hw: pointer to the HW structure 1898 * 1899 * Forces the speed and duplex settings of the PHY. --- 6 unchanged lines hidden (view full) --- 1906 s32 ret_val; 1907 u16 data; 1908 bool link; 1909 1910 DEBUGFUNC("e1000_phy_force_speed_duplex_ife"); 1911 1912 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data); 1913 if (ret_val) | 1933 return ret_val; 1934} 1935 1936/** 1937 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex 1938 * @hw: pointer to the HW structure 1939 * 1940 * Forces the speed and duplex settings of the PHY. --- 6 unchanged lines hidden (view full) --- 1947 s32 ret_val; 1948 u16 data; 1949 bool link; 1950 1951 DEBUGFUNC("e1000_phy_force_speed_duplex_ife"); 1952 1953 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data); 1954 if (ret_val) |
1914 goto out; | 1955 return ret_val; |
1915 1916 e1000_phy_force_speed_duplex_setup(hw, &data); 1917 1918 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data); 1919 if (ret_val) | 1956 1957 e1000_phy_force_speed_duplex_setup(hw, &data); 1958 1959 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data); 1960 if (ret_val) |
1920 goto out; | 1961 return ret_val; |
1921 1922 /* Disable MDI-X support for 10/100 */ 1923 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 1924 if (ret_val) | 1962 1963 /* Disable MDI-X support for 10/100 */ 1964 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 1965 if (ret_val) |
1925 goto out; | 1966 return ret_val; |
1926 1927 data &= ~IFE_PMC_AUTO_MDIX; 1928 data &= ~IFE_PMC_FORCE_MDIX; 1929 1930 ret_val = phy->ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, data); 1931 if (ret_val) | 1967 1968 data &= ~IFE_PMC_AUTO_MDIX; 1969 data &= ~IFE_PMC_FORCE_MDIX; 1970 1971 ret_val = phy->ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, data); 1972 if (ret_val) |
1932 goto out; | 1973 return ret_val; |
1933 1934 DEBUGOUT1("IFE PMC: %X\n", data); 1935 1936 usec_delay(1); 1937 1938 if (phy->autoneg_wait_to_complete) { 1939 DEBUGOUT("Waiting for forced speed/duplex link on IFE phy.\n"); 1940 1941 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1942 100000, &link); 1943 if (ret_val) | 1974 1975 DEBUGOUT1("IFE PMC: %X\n", data); 1976 1977 usec_delay(1); 1978 1979 if (phy->autoneg_wait_to_complete) { 1980 DEBUGOUT("Waiting for forced speed/duplex link on IFE phy.\n"); 1981 1982 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1983 100000, &link); 1984 if (ret_val) |
1944 goto out; | 1985 return ret_val; |
1945 1946 if (!link) 1947 DEBUGOUT("Link taking longer than expected.\n"); 1948 1949 /* Try once more */ 1950 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1951 100000, &link); 1952 if (ret_val) | 1986 1987 if (!link) 1988 DEBUGOUT("Link taking longer than expected.\n"); 1989 1990 /* Try once more */ 1991 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 1992 100000, &link); 1993 if (ret_val) |
1953 goto out; | 1994 return ret_val; |
1954 } 1955 | 1995 } 1996 |
1956out: 1957 return ret_val; | 1997 return E1000_SUCCESS; |
1958} 1959 1960/** 1961 * e1000_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex 1962 * @hw: pointer to the HW structure 1963 * @phy_ctrl: pointer to current value of PHY_CONTROL 1964 * 1965 * Forces speed and duplex on the PHY by doing the following: disable flow --- 43 unchanged lines hidden (view full) --- 2009 DEBUGOUT("Forcing 100mb\n"); 2010 } else { 2011 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); 2012 *phy_ctrl |= MII_CR_SPEED_10; 2013 *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100); 2014 DEBUGOUT("Forcing 10mb\n"); 2015 } 2016 | 1998} 1999 2000/** 2001 * e1000_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex 2002 * @hw: pointer to the HW structure 2003 * @phy_ctrl: pointer to current value of PHY_CONTROL 2004 * 2005 * Forces speed and duplex on the PHY by doing the following: disable flow --- 43 unchanged lines hidden (view full) --- 2049 DEBUGOUT("Forcing 100mb\n"); 2050 } else { 2051 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); 2052 *phy_ctrl |= MII_CR_SPEED_10; 2053 *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100); 2054 DEBUGOUT("Forcing 10mb\n"); 2055 } 2056 |
2017 e1000_config_collision_dist_generic(hw); | 2057 hw->mac.ops.config_collision_dist(hw); |
2018 2019 E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 2020} 2021 2022/** 2023 * e1000_set_d3_lplu_state_generic - Sets low power link up state for D3 2024 * @hw: pointer to the HW structure 2025 * @active: boolean used to enable/disable lplu --- 5 unchanged lines hidden (view full) --- 2031 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 2032 * is used during Dx states where the power conservation is most important. 2033 * During driver activity, SmartSpeed should be enabled so performance is 2034 * maintained. 2035 **/ 2036s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active) 2037{ 2038 struct e1000_phy_info *phy = &hw->phy; | 2058 2059 E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 2060} 2061 2062/** 2063 * e1000_set_d3_lplu_state_generic - Sets low power link up state for D3 2064 * @hw: pointer to the HW structure 2065 * @active: boolean used to enable/disable lplu --- 5 unchanged lines hidden (view full) --- 2071 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 2072 * is used during Dx states where the power conservation is most important. 2073 * During driver activity, SmartSpeed should be enabled so performance is 2074 * maintained. 2075 **/ 2076s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active) 2077{ 2078 struct e1000_phy_info *phy = &hw->phy; |
2039 s32 ret_val = E1000_SUCCESS; | 2079 s32 ret_val; |
2040 u16 data; 2041 2042 DEBUGFUNC("e1000_set_d3_lplu_state_generic"); 2043 | 2080 u16 data; 2081 2082 DEBUGFUNC("e1000_set_d3_lplu_state_generic"); 2083 |
2044 if (!(hw->phy.ops.read_reg)) 2045 goto out; | 2084 if (!hw->phy.ops.read_reg) 2085 return E1000_SUCCESS; |
2046 2047 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data); 2048 if (ret_val) | 2086 2087 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data); 2088 if (ret_val) |
2049 goto out; | 2089 return ret_val; |
2050 2051 if (!active) { 2052 data &= ~IGP02E1000_PM_D3_LPLU; 2053 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 2054 data); 2055 if (ret_val) | 2090 2091 if (!active) { 2092 data &= ~IGP02E1000_PM_D3_LPLU; 2093 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 2094 data); 2095 if (ret_val) |
2056 goto out; | 2096 return ret_val; |
2057 /* 2058 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 2059 * during Dx states where the power conservation is most 2060 * important. During driver activity we should enable 2061 * SmartSpeed, so performance is maintained. 2062 */ 2063 if (phy->smart_speed == e1000_smart_speed_on) { 2064 ret_val = phy->ops.read_reg(hw, 2065 IGP01E1000_PHY_PORT_CONFIG, 2066 &data); 2067 if (ret_val) | 2097 /* 2098 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 2099 * during Dx states where the power conservation is most 2100 * important. During driver activity we should enable 2101 * SmartSpeed, so performance is maintained. 2102 */ 2103 if (phy->smart_speed == e1000_smart_speed_on) { 2104 ret_val = phy->ops.read_reg(hw, 2105 IGP01E1000_PHY_PORT_CONFIG, 2106 &data); 2107 if (ret_val) |
2068 goto out; | 2108 return ret_val; |
2069 2070 data |= IGP01E1000_PSCFR_SMART_SPEED; 2071 ret_val = phy->ops.write_reg(hw, 2072 IGP01E1000_PHY_PORT_CONFIG, 2073 data); 2074 if (ret_val) | 2109 2110 data |= IGP01E1000_PSCFR_SMART_SPEED; 2111 ret_val = phy->ops.write_reg(hw, 2112 IGP01E1000_PHY_PORT_CONFIG, 2113 data); 2114 if (ret_val) |
2075 goto out; | 2115 return ret_val; |
2076 } else if (phy->smart_speed == e1000_smart_speed_off) { 2077 ret_val = phy->ops.read_reg(hw, 2078 IGP01E1000_PHY_PORT_CONFIG, 2079 &data); 2080 if (ret_val) | 2116 } else if (phy->smart_speed == e1000_smart_speed_off) { 2117 ret_val = phy->ops.read_reg(hw, 2118 IGP01E1000_PHY_PORT_CONFIG, 2119 &data); 2120 if (ret_val) |
2081 goto out; | 2121 return ret_val; |
2082 2083 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 2084 ret_val = phy->ops.write_reg(hw, 2085 IGP01E1000_PHY_PORT_CONFIG, 2086 data); 2087 if (ret_val) | 2122 2123 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 2124 ret_val = phy->ops.write_reg(hw, 2125 IGP01E1000_PHY_PORT_CONFIG, 2126 data); 2127 if (ret_val) |
2088 goto out; | 2128 return ret_val; |
2089 } 2090 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || 2091 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || 2092 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { 2093 data |= IGP02E1000_PM_D3_LPLU; 2094 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 2095 data); 2096 if (ret_val) | 2129 } 2130 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || 2131 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || 2132 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { 2133 data |= IGP02E1000_PM_D3_LPLU; 2134 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 2135 data); 2136 if (ret_val) |
2097 goto out; | 2137 return ret_val; |
2098 2099 /* When LPLU is enabled, we should disable SmartSpeed */ 2100 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 2101 &data); 2102 if (ret_val) | 2138 2139 /* When LPLU is enabled, we should disable SmartSpeed */ 2140 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 2141 &data); 2142 if (ret_val) |
2103 goto out; | 2143 return ret_val; |
2104 2105 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 2106 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 2107 data); 2108 } 2109 | 2144 2145 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 2146 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 2147 data); 2148 } 2149 |
2110out: | |
2111 return ret_val; 2112} 2113 2114/** 2115 * e1000_check_downshift_generic - Checks whether a downshift in speed occurred 2116 * @hw: pointer to the HW structure 2117 * 2118 * Success returns 0, Failure returns 1 --- 4 unchanged lines hidden (view full) --- 2123{ 2124 struct e1000_phy_info *phy = &hw->phy; 2125 s32 ret_val; 2126 u16 phy_data, offset, mask; 2127 2128 DEBUGFUNC("e1000_check_downshift_generic"); 2129 2130 switch (phy->type) { | 2150 return ret_val; 2151} 2152 2153/** 2154 * e1000_check_downshift_generic - Checks whether a downshift in speed occurred 2155 * @hw: pointer to the HW structure 2156 * 2157 * Success returns 0, Failure returns 1 --- 4 unchanged lines hidden (view full) --- 2162{ 2163 struct e1000_phy_info *phy = &hw->phy; 2164 s32 ret_val; 2165 u16 phy_data, offset, mask; 2166 2167 DEBUGFUNC("e1000_check_downshift_generic"); 2168 2169 switch (phy->type) { |
2170 case e1000_phy_i210: |
|
2131 case e1000_phy_m88: 2132 case e1000_phy_gg82563: 2133 case e1000_phy_bm: 2134 case e1000_phy_82578: 2135 offset = M88E1000_PHY_SPEC_STATUS; 2136 mask = M88E1000_PSSR_DOWNSHIFT; 2137 break; 2138 case e1000_phy_igp: 2139 case e1000_phy_igp_2: 2140 case e1000_phy_igp_3: 2141 offset = IGP01E1000_PHY_LINK_HEALTH; 2142 mask = IGP01E1000_PLHR_SS_DOWNGRADE; 2143 break; 2144 default: 2145 /* speed downshift not supported */ 2146 phy->speed_downgraded = FALSE; | 2171 case e1000_phy_m88: 2172 case e1000_phy_gg82563: 2173 case e1000_phy_bm: 2174 case e1000_phy_82578: 2175 offset = M88E1000_PHY_SPEC_STATUS; 2176 mask = M88E1000_PSSR_DOWNSHIFT; 2177 break; 2178 case e1000_phy_igp: 2179 case e1000_phy_igp_2: 2180 case e1000_phy_igp_3: 2181 offset = IGP01E1000_PHY_LINK_HEALTH; 2182 mask = IGP01E1000_PLHR_SS_DOWNGRADE; 2183 break; 2184 default: 2185 /* speed downshift not supported */ 2186 phy->speed_downgraded = FALSE; |
2147 ret_val = E1000_SUCCESS; 2148 goto out; | 2187 return E1000_SUCCESS; |
2149 } 2150 2151 ret_val = phy->ops.read_reg(hw, offset, &phy_data); 2152 2153 if (!ret_val) | 2188 } 2189 2190 ret_val = phy->ops.read_reg(hw, offset, &phy_data); 2191 2192 if (!ret_val) |
2154 phy->speed_downgraded = (phy_data & mask) ? TRUE : FALSE; | 2193 phy->speed_downgraded = !!(phy_data & mask); |
2155 | 2194 |
2156out: | |
2157 return ret_val; 2158} 2159 2160/** 2161 * e1000_check_polarity_m88 - Checks the polarity. 2162 * @hw: pointer to the HW structure 2163 * 2164 * Success returns 0, Failure returns -E1000_ERR_PHY (-2) --- 36 unchanged lines hidden (view full) --- 2201 DEBUGFUNC("e1000_check_polarity_igp"); 2202 2203 /* 2204 * Polarity is determined based on the speed of 2205 * our connection. 2206 */ 2207 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); 2208 if (ret_val) | 2195 return ret_val; 2196} 2197 2198/** 2199 * e1000_check_polarity_m88 - Checks the polarity. 2200 * @hw: pointer to the HW structure 2201 * 2202 * Success returns 0, Failure returns -E1000_ERR_PHY (-2) --- 36 unchanged lines hidden (view full) --- 2239 DEBUGFUNC("e1000_check_polarity_igp"); 2240 2241 /* 2242 * Polarity is determined based on the speed of 2243 * our connection. 2244 */ 2245 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); 2246 if (ret_val) |
2209 goto out; | 2247 return ret_val; |
2210 2211 if ((data & IGP01E1000_PSSR_SPEED_MASK) == 2212 IGP01E1000_PSSR_SPEED_1000MBPS) { 2213 offset = IGP01E1000_PHY_PCS_INIT_REG; 2214 mask = IGP01E1000_PHY_POLARITY_MASK; 2215 } else { 2216 /* 2217 * This really only applies to 10Mbps since --- 5 unchanged lines hidden (view full) --- 2223 2224 ret_val = phy->ops.read_reg(hw, offset, &data); 2225 2226 if (!ret_val) 2227 phy->cable_polarity = (data & mask) 2228 ? e1000_rev_polarity_reversed 2229 : e1000_rev_polarity_normal; 2230 | 2248 2249 if ((data & IGP01E1000_PSSR_SPEED_MASK) == 2250 IGP01E1000_PSSR_SPEED_1000MBPS) { 2251 offset = IGP01E1000_PHY_PCS_INIT_REG; 2252 mask = IGP01E1000_PHY_POLARITY_MASK; 2253 } else { 2254 /* 2255 * This really only applies to 10Mbps since --- 5 unchanged lines hidden (view full) --- 2261 2262 ret_val = phy->ops.read_reg(hw, offset, &data); 2263 2264 if (!ret_val) 2265 phy->cable_polarity = (data & mask) 2266 ? e1000_rev_polarity_reversed 2267 : e1000_rev_polarity_normal; 2268 |
2231out: | |
2232 return ret_val; 2233} 2234 2235/** 2236 * e1000_check_polarity_ife - Check cable polarity for IFE PHY 2237 * @hw: pointer to the HW structure 2238 * 2239 * Polarity is determined on the polarity reversal feature being enabled. --- 36 unchanged lines hidden (view full) --- 2276 **/ 2277s32 e1000_wait_autoneg_generic(struct e1000_hw *hw) 2278{ 2279 s32 ret_val = E1000_SUCCESS; 2280 u16 i, phy_status; 2281 2282 DEBUGFUNC("e1000_wait_autoneg_generic"); 2283 | 2269 return ret_val; 2270} 2271 2272/** 2273 * e1000_check_polarity_ife - Check cable polarity for IFE PHY 2274 * @hw: pointer to the HW structure 2275 * 2276 * Polarity is determined on the polarity reversal feature being enabled. --- 36 unchanged lines hidden (view full) --- 2313 **/ 2314s32 e1000_wait_autoneg_generic(struct e1000_hw *hw) 2315{ 2316 s32 ret_val = E1000_SUCCESS; 2317 u16 i, phy_status; 2318 2319 DEBUGFUNC("e1000_wait_autoneg_generic"); 2320 |
2284 if (!(hw->phy.ops.read_reg)) | 2321 if (!hw->phy.ops.read_reg) |
2285 return E1000_SUCCESS; 2286 2287 /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */ 2288 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { 2289 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); 2290 if (ret_val) 2291 break; 2292 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); --- 23 unchanged lines hidden (view full) --- 2316s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, 2317 u32 usec_interval, bool *success) 2318{ 2319 s32 ret_val = E1000_SUCCESS; 2320 u16 i, phy_status; 2321 2322 DEBUGFUNC("e1000_phy_has_link_generic"); 2323 | 2322 return E1000_SUCCESS; 2323 2324 /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */ 2325 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { 2326 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); 2327 if (ret_val) 2328 break; 2329 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); --- 23 unchanged lines hidden (view full) --- 2353s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, 2354 u32 usec_interval, bool *success) 2355{ 2356 s32 ret_val = E1000_SUCCESS; 2357 u16 i, phy_status; 2358 2359 DEBUGFUNC("e1000_phy_has_link_generic"); 2360 |
2324 if (!(hw->phy.ops.read_reg)) | 2361 if (!hw->phy.ops.read_reg) |
2325 return E1000_SUCCESS; 2326 2327 for (i = 0; i < iterations; i++) { 2328 /* 2329 * Some PHYs require the PHY_STATUS register to be read 2330 * twice due to the link bit being sticky. No harm doing 2331 * it across the board. 2332 */ --- 11 unchanged lines hidden (view full) --- 2344 if (phy_status & MII_SR_LINK_STATUS) 2345 break; 2346 if (usec_interval >= 1000) 2347 msec_delay_irq(usec_interval/1000); 2348 else 2349 usec_delay(usec_interval); 2350 } 2351 | 2362 return E1000_SUCCESS; 2363 2364 for (i = 0; i < iterations; i++) { 2365 /* 2366 * Some PHYs require the PHY_STATUS register to be read 2367 * twice due to the link bit being sticky. No harm doing 2368 * it across the board. 2369 */ --- 11 unchanged lines hidden (view full) --- 2381 if (phy_status & MII_SR_LINK_STATUS) 2382 break; 2383 if (usec_interval >= 1000) 2384 msec_delay_irq(usec_interval/1000); 2385 else 2386 usec_delay(usec_interval); 2387 } 2388 |
2352 *success = (i < iterations) ? TRUE : FALSE; | 2389 *success = (i < iterations); |
2353 2354 return ret_val; 2355} 2356 2357/** 2358 * e1000_get_cable_length_m88 - Determine cable length for m88 PHY 2359 * @hw: pointer to the HW structure 2360 * --- 13 unchanged lines hidden (view full) --- 2374 struct e1000_phy_info *phy = &hw->phy; 2375 s32 ret_val; 2376 u16 phy_data, index; 2377 2378 DEBUGFUNC("e1000_get_cable_length_m88"); 2379 2380 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 2381 if (ret_val) | 2390 2391 return ret_val; 2392} 2393 2394/** 2395 * e1000_get_cable_length_m88 - Determine cable length for m88 PHY 2396 * @hw: pointer to the HW structure 2397 * --- 13 unchanged lines hidden (view full) --- 2411 struct e1000_phy_info *phy = &hw->phy; 2412 s32 ret_val; 2413 u16 phy_data, index; 2414 2415 DEBUGFUNC("e1000_get_cable_length_m88"); 2416 2417 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 2418 if (ret_val) |
2382 goto out; | 2419 return ret_val; |
2383 2384 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> 2385 M88E1000_PSSR_CABLE_LENGTH_SHIFT; | 2420 2421 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> 2422 M88E1000_PSSR_CABLE_LENGTH_SHIFT; |
2386 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) { 2387 ret_val = -E1000_ERR_PHY; 2388 goto out; 2389 } | |
2390 | 2423 |
2424 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) 2425 return -E1000_ERR_PHY; 2426 |
|
2391 phy->min_cable_length = e1000_m88_cable_length_table[index]; 2392 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; 2393 2394 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; 2395 | 2427 phy->min_cable_length = e1000_m88_cable_length_table[index]; 2428 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; 2429 2430 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; 2431 |
2396out: 2397 return ret_val; | 2432 return E1000_SUCCESS; |
2398} 2399 2400s32 e1000_get_cable_length_m88_gen2(struct e1000_hw *hw) 2401{ 2402 struct e1000_phy_info *phy = &hw->phy; 2403 s32 ret_val; 2404 u16 phy_data, phy_data2, index, default_page, is_cm; 2405 2406 DEBUGFUNC("e1000_get_cable_length_m88_gen2"); 2407 2408 switch (hw->phy.id) { | 2433} 2434 2435s32 e1000_get_cable_length_m88_gen2(struct e1000_hw *hw) 2436{ 2437 struct e1000_phy_info *phy = &hw->phy; 2438 s32 ret_val; 2439 u16 phy_data, phy_data2, index, default_page, is_cm; 2440 2441 DEBUGFUNC("e1000_get_cable_length_m88_gen2"); 2442 2443 switch (hw->phy.id) { |
2444 case I210_I_PHY_ID: 2445 /* Get cable length from PHY Cable Diagnostics Control Reg */ 2446 ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) + 2447 (I347AT4_PCDL + phy->addr), 2448 &phy_data); 2449 if (ret_val) 2450 return ret_val; 2451 2452 /* Check if the unit of cable length is meters or cm */ 2453 ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) + 2454 I347AT4_PCDC, &phy_data2); 2455 if (ret_val) 2456 return ret_val; 2457 2458 is_cm = !(phy_data2 & I347AT4_PCDC_CABLE_LENGTH_UNIT); 2459 2460 /* Populate the phy structure with cable length in meters */ 2461 phy->min_cable_length = phy_data / (is_cm ? 100 : 1); 2462 phy->max_cable_length = phy_data / (is_cm ? 100 : 1); 2463 phy->cable_length = phy_data / (is_cm ? 100 : 1); 2464 break; |
|
2409 case M88E1340M_E_PHY_ID: 2410 case I347AT4_E_PHY_ID: 2411 /* Remember the original page select and set it to 7 */ 2412 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, 2413 &default_page); 2414 if (ret_val) | 2465 case M88E1340M_E_PHY_ID: 2466 case I347AT4_E_PHY_ID: 2467 /* Remember the original page select and set it to 7 */ 2468 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, 2469 &default_page); 2470 if (ret_val) |
2415 goto out; | 2471 return ret_val; |
2416 2417 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x07); 2418 if (ret_val) | 2472 2473 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x07); 2474 if (ret_val) |
2419 goto out; | 2475 return ret_val; |
2420 2421 /* Get cable length from PHY Cable Diagnostics Control Reg */ 2422 ret_val = phy->ops.read_reg(hw, (I347AT4_PCDL + phy->addr), 2423 &phy_data); 2424 if (ret_val) | 2476 2477 /* Get cable length from PHY Cable Diagnostics Control Reg */ 2478 ret_val = phy->ops.read_reg(hw, (I347AT4_PCDL + phy->addr), 2479 &phy_data); 2480 if (ret_val) |
2425 goto out; | 2481 return ret_val; |
2426 2427 /* Check if the unit of cable length is meters or cm */ 2428 ret_val = phy->ops.read_reg(hw, I347AT4_PCDC, &phy_data2); 2429 if (ret_val) | 2482 2483 /* Check if the unit of cable length is meters or cm */ 2484 ret_val = phy->ops.read_reg(hw, I347AT4_PCDC, &phy_data2); 2485 if (ret_val) |
2430 goto out; | 2486 return ret_val; |
2431 2432 is_cm = !(phy_data2 & I347AT4_PCDC_CABLE_LENGTH_UNIT); 2433 2434 /* Populate the phy structure with cable length in meters */ 2435 phy->min_cable_length = phy_data / (is_cm ? 100 : 1); 2436 phy->max_cable_length = phy_data / (is_cm ? 100 : 1); 2437 phy->cable_length = phy_data / (is_cm ? 100 : 1); 2438 2439 /* Reset the page select to its original value */ 2440 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 2441 default_page); 2442 if (ret_val) | 2487 2488 is_cm = !(phy_data2 & I347AT4_PCDC_CABLE_LENGTH_UNIT); 2489 2490 /* Populate the phy structure with cable length in meters */ 2491 phy->min_cable_length = phy_data / (is_cm ? 100 : 1); 2492 phy->max_cable_length = phy_data / (is_cm ? 100 : 1); 2493 phy->cable_length = phy_data / (is_cm ? 100 : 1); 2494 2495 /* Reset the page select to its original value */ 2496 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 2497 default_page); 2498 if (ret_val) |
2443 goto out; | 2499 return ret_val; |
2444 break; | 2500 break; |
2501 |
|
2445 case M88E1112_E_PHY_ID: 2446 /* Remember the original page select and set it to 5 */ 2447 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, 2448 &default_page); 2449 if (ret_val) | 2502 case M88E1112_E_PHY_ID: 2503 /* Remember the original page select and set it to 5 */ 2504 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, 2505 &default_page); 2506 if (ret_val) |
2450 goto out; | 2507 return ret_val; |
2451 2452 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x05); 2453 if (ret_val) | 2508 2509 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x05); 2510 if (ret_val) |
2454 goto out; | 2511 return ret_val; |
2455 2456 ret_val = phy->ops.read_reg(hw, M88E1112_VCT_DSP_DISTANCE, 2457 &phy_data); 2458 if (ret_val) | 2512 2513 ret_val = phy->ops.read_reg(hw, M88E1112_VCT_DSP_DISTANCE, 2514 &phy_data); 2515 if (ret_val) |
2459 goto out; | 2516 return ret_val; |
2460 2461 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> 2462 M88E1000_PSSR_CABLE_LENGTH_SHIFT; | 2517 2518 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> 2519 M88E1000_PSSR_CABLE_LENGTH_SHIFT; |
2463 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) { 2464 ret_val = -E1000_ERR_PHY; 2465 goto out; 2466 } | |
2467 | 2520 |
2521 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) 2522 return -E1000_ERR_PHY; 2523 |
|
2468 phy->min_cable_length = e1000_m88_cable_length_table[index]; 2469 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; 2470 2471 phy->cable_length = (phy->min_cable_length + 2472 phy->max_cable_length) / 2; 2473 2474 /* Reset the page select to its original value */ 2475 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 2476 default_page); 2477 if (ret_val) | 2524 phy->min_cable_length = e1000_m88_cable_length_table[index]; 2525 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; 2526 2527 phy->cable_length = (phy->min_cable_length + 2528 phy->max_cable_length) / 2; 2529 2530 /* Reset the page select to its original value */ 2531 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 2532 default_page); 2533 if (ret_val) |
2478 goto out; | 2534 return ret_val; |
2479 2480 break; 2481 default: | 2535 2536 break; 2537 default: |
2482 ret_val = -E1000_ERR_PHY; 2483 goto out; | 2538 return -E1000_ERR_PHY; |
2484 } 2485 | 2539 } 2540 |
2486out: | |
2487 return ret_val; 2488} 2489 2490/** 2491 * e1000_get_cable_length_igp_2 - Determine cable length for igp2 PHY 2492 * @hw: pointer to the HW structure 2493 * 2494 * The automatic gain control (agc) normalizes the amplitude of the 2495 * received signal, adjusting for the attenuation produced by the 2496 * cable. By reading the AGC registers, which represent the 2497 * combination of coarse and fine gain value, the value can be put 2498 * into a lookup table to obtain the approximate cable length 2499 * for each channel. 2500 **/ 2501s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw) 2502{ 2503 struct e1000_phy_info *phy = &hw->phy; | 2541 return ret_val; 2542} 2543 2544/** 2545 * e1000_get_cable_length_igp_2 - Determine cable length for igp2 PHY 2546 * @hw: pointer to the HW structure 2547 * 2548 * The automatic gain control (agc) normalizes the amplitude of the 2549 * received signal, adjusting for the attenuation produced by the 2550 * cable. By reading the AGC registers, which represent the 2551 * combination of coarse and fine gain value, the value can be put 2552 * into a lookup table to obtain the approximate cable length 2553 * for each channel. 2554 **/ 2555s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw) 2556{ 2557 struct e1000_phy_info *phy = &hw->phy; |
2504 s32 ret_val = E1000_SUCCESS; | 2558 s32 ret_val; |
2505 u16 phy_data, i, agc_value = 0; 2506 u16 cur_agc_index, max_agc_index = 0; 2507 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; 2508 static const u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] = { 2509 IGP02E1000_PHY_AGC_A, 2510 IGP02E1000_PHY_AGC_B, 2511 IGP02E1000_PHY_AGC_C, 2512 IGP02E1000_PHY_AGC_D 2513 }; 2514 2515 DEBUGFUNC("e1000_get_cable_length_igp_2"); 2516 2517 /* Read the AGC registers for all channels */ 2518 for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) { 2519 ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &phy_data); 2520 if (ret_val) | 2559 u16 phy_data, i, agc_value = 0; 2560 u16 cur_agc_index, max_agc_index = 0; 2561 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; 2562 static const u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] = { 2563 IGP02E1000_PHY_AGC_A, 2564 IGP02E1000_PHY_AGC_B, 2565 IGP02E1000_PHY_AGC_C, 2566 IGP02E1000_PHY_AGC_D 2567 }; 2568 2569 DEBUGFUNC("e1000_get_cable_length_igp_2"); 2570 2571 /* Read the AGC registers for all channels */ 2572 for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) { 2573 ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &phy_data); 2574 if (ret_val) |
2521 goto out; | 2575 return ret_val; |
2522 2523 /* 2524 * Getting bits 15:9, which represent the combination of 2525 * coarse and fine gain values. The result is a number 2526 * that can be put into the lookup table to obtain the 2527 * approximate cable length. 2528 */ 2529 cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) & 2530 IGP02E1000_AGC_LENGTH_MASK; 2531 2532 /* Array index bound check. */ 2533 if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) || | 2576 2577 /* 2578 * Getting bits 15:9, which represent the combination of 2579 * coarse and fine gain values. The result is a number 2580 * that can be put into the lookup table to obtain the 2581 * approximate cable length. 2582 */ 2583 cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) & 2584 IGP02E1000_AGC_LENGTH_MASK; 2585 2586 /* Array index bound check. */ 2587 if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) || |
2534 (cur_agc_index == 0)) { 2535 ret_val = -E1000_ERR_PHY; 2536 goto out; 2537 } | 2588 (cur_agc_index == 0)) 2589 return -E1000_ERR_PHY; |
2538 2539 /* Remove min & max AGC values from calculation. */ 2540 if (e1000_igp_2_cable_length_table[min_agc_index] > 2541 e1000_igp_2_cable_length_table[cur_agc_index]) 2542 min_agc_index = cur_agc_index; 2543 if (e1000_igp_2_cable_length_table[max_agc_index] < 2544 e1000_igp_2_cable_length_table[cur_agc_index]) 2545 max_agc_index = cur_agc_index; --- 7 unchanged lines hidden (view full) --- 2553 2554 /* Calculate cable length with the error range of +/- 10 meters. */ 2555 phy->min_cable_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ? 2556 (agc_value - IGP02E1000_AGC_RANGE) : 0; 2557 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; 2558 2559 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; 2560 | 2590 2591 /* Remove min & max AGC values from calculation. */ 2592 if (e1000_igp_2_cable_length_table[min_agc_index] > 2593 e1000_igp_2_cable_length_table[cur_agc_index]) 2594 min_agc_index = cur_agc_index; 2595 if (e1000_igp_2_cable_length_table[max_agc_index] < 2596 e1000_igp_2_cable_length_table[cur_agc_index]) 2597 max_agc_index = cur_agc_index; --- 7 unchanged lines hidden (view full) --- 2605 2606 /* Calculate cable length with the error range of +/- 10 meters. */ 2607 phy->min_cable_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ? 2608 (agc_value - IGP02E1000_AGC_RANGE) : 0; 2609 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; 2610 2611 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; 2612 |
2561out: 2562 return ret_val; | 2613 return E1000_SUCCESS; |
2563} 2564 2565/** 2566 * e1000_get_phy_info_m88 - Retrieve PHY information 2567 * @hw: pointer to the HW structure 2568 * 2569 * Valid for only copper links. Read the PHY status register (sticky read) 2570 * to verify that link is up. Read the PHY special control register to --- 7 unchanged lines hidden (view full) --- 2578 s32 ret_val; 2579 u16 phy_data; 2580 bool link; 2581 2582 DEBUGFUNC("e1000_get_phy_info_m88"); 2583 2584 if (phy->media_type != e1000_media_type_copper) { 2585 DEBUGOUT("Phy info is only valid for copper media\n"); | 2614} 2615 2616/** 2617 * e1000_get_phy_info_m88 - Retrieve PHY information 2618 * @hw: pointer to the HW structure 2619 * 2620 * Valid for only copper links. Read the PHY status register (sticky read) 2621 * to verify that link is up. Read the PHY special control register to --- 7 unchanged lines hidden (view full) --- 2629 s32 ret_val; 2630 u16 phy_data; 2631 bool link; 2632 2633 DEBUGFUNC("e1000_get_phy_info_m88"); 2634 2635 if (phy->media_type != e1000_media_type_copper) { 2636 DEBUGOUT("Phy info is only valid for copper media\n"); |
2586 ret_val = -E1000_ERR_CONFIG; 2587 goto out; | 2637 return -E1000_ERR_CONFIG; |
2588 } 2589 2590 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2591 if (ret_val) | 2638 } 2639 2640 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2641 if (ret_val) |
2592 goto out; | 2642 return ret_val; |
2593 2594 if (!link) { 2595 DEBUGOUT("Phy info is only valid if link is up\n"); | 2643 2644 if (!link) { 2645 DEBUGOUT("Phy info is only valid if link is up\n"); |
2596 ret_val = -E1000_ERR_CONFIG; 2597 goto out; | 2646 return -E1000_ERR_CONFIG; |
2598 } 2599 2600 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 2601 if (ret_val) | 2647 } 2648 2649 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 2650 if (ret_val) |
2602 goto out; | 2651 return ret_val; |
2603 | 2652 |
2604 phy->polarity_correction = (phy_data & M88E1000_PSCR_POLARITY_REVERSAL) 2605 ? TRUE : FALSE; | 2653 phy->polarity_correction = !!(phy_data & 2654 M88E1000_PSCR_POLARITY_REVERSAL); |
2606 2607 ret_val = e1000_check_polarity_m88(hw); 2608 if (ret_val) | 2655 2656 ret_val = e1000_check_polarity_m88(hw); 2657 if (ret_val) |
2609 goto out; | 2658 return ret_val; |
2610 2611 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 2612 if (ret_val) | 2659 2660 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 2661 if (ret_val) |
2613 goto out; | 2662 return ret_val; |
2614 | 2663 |
2615 phy->is_mdix = (phy_data & M88E1000_PSSR_MDIX) ? TRUE : FALSE; | 2664 phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX); |
2616 2617 if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) { 2618 ret_val = hw->phy.ops.get_cable_length(hw); 2619 if (ret_val) | 2665 2666 if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) { 2667 ret_val = hw->phy.ops.get_cable_length(hw); 2668 if (ret_val) |
2620 goto out; | 2669 return ret_val; |
2621 2622 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data); 2623 if (ret_val) | 2670 2671 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data); 2672 if (ret_val) |
2624 goto out; | 2673 return ret_val; |
2625 2626 phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) 2627 ? e1000_1000t_rx_status_ok 2628 : e1000_1000t_rx_status_not_ok; 2629 2630 phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) 2631 ? e1000_1000t_rx_status_ok 2632 : e1000_1000t_rx_status_not_ok; 2633 } else { 2634 /* Set values to "undefined" */ 2635 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2636 phy->local_rx = e1000_1000t_rx_status_undefined; 2637 phy->remote_rx = e1000_1000t_rx_status_undefined; 2638 } 2639 | 2674 2675 phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) 2676 ? e1000_1000t_rx_status_ok 2677 : e1000_1000t_rx_status_not_ok; 2678 2679 phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) 2680 ? e1000_1000t_rx_status_ok 2681 : e1000_1000t_rx_status_not_ok; 2682 } else { 2683 /* Set values to "undefined" */ 2684 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2685 phy->local_rx = e1000_1000t_rx_status_undefined; 2686 phy->remote_rx = e1000_1000t_rx_status_undefined; 2687 } 2688 |
2640out: | |
2641 return ret_val; 2642} 2643 2644/** 2645 * e1000_get_phy_info_igp - Retrieve igp PHY information 2646 * @hw: pointer to the HW structure 2647 * 2648 * Read PHY status to determine if link is up. If link is up, then --- 7 unchanged lines hidden (view full) --- 2656 s32 ret_val; 2657 u16 data; 2658 bool link; 2659 2660 DEBUGFUNC("e1000_get_phy_info_igp"); 2661 2662 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2663 if (ret_val) | 2689 return ret_val; 2690} 2691 2692/** 2693 * e1000_get_phy_info_igp - Retrieve igp PHY information 2694 * @hw: pointer to the HW structure 2695 * 2696 * Read PHY status to determine if link is up. If link is up, then --- 7 unchanged lines hidden (view full) --- 2704 s32 ret_val; 2705 u16 data; 2706 bool link; 2707 2708 DEBUGFUNC("e1000_get_phy_info_igp"); 2709 2710 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2711 if (ret_val) |
2664 goto out; | 2712 return ret_val; |
2665 2666 if (!link) { 2667 DEBUGOUT("Phy info is only valid if link is up\n"); | 2713 2714 if (!link) { 2715 DEBUGOUT("Phy info is only valid if link is up\n"); |
2668 ret_val = -E1000_ERR_CONFIG; 2669 goto out; | 2716 return -E1000_ERR_CONFIG; |
2670 } 2671 2672 phy->polarity_correction = TRUE; 2673 2674 ret_val = e1000_check_polarity_igp(hw); 2675 if (ret_val) | 2717 } 2718 2719 phy->polarity_correction = TRUE; 2720 2721 ret_val = e1000_check_polarity_igp(hw); 2722 if (ret_val) |
2676 goto out; | 2723 return ret_val; |
2677 2678 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); 2679 if (ret_val) | 2724 2725 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); 2726 if (ret_val) |
2680 goto out; | 2727 return ret_val; |
2681 | 2728 |
2682 phy->is_mdix = (data & IGP01E1000_PSSR_MDIX) ? TRUE : FALSE; | 2729 phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX); |
2683 2684 if ((data & IGP01E1000_PSSR_SPEED_MASK) == 2685 IGP01E1000_PSSR_SPEED_1000MBPS) { 2686 ret_val = phy->ops.get_cable_length(hw); 2687 if (ret_val) | 2730 2731 if ((data & IGP01E1000_PSSR_SPEED_MASK) == 2732 IGP01E1000_PSSR_SPEED_1000MBPS) { 2733 ret_val = phy->ops.get_cable_length(hw); 2734 if (ret_val) |
2688 goto out; | 2735 return ret_val; |
2689 2690 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); 2691 if (ret_val) | 2736 2737 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); 2738 if (ret_val) |
2692 goto out; | 2739 return ret_val; |
2693 2694 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) 2695 ? e1000_1000t_rx_status_ok 2696 : e1000_1000t_rx_status_not_ok; 2697 2698 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) 2699 ? e1000_1000t_rx_status_ok 2700 : e1000_1000t_rx_status_not_ok; 2701 } else { 2702 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2703 phy->local_rx = e1000_1000t_rx_status_undefined; 2704 phy->remote_rx = e1000_1000t_rx_status_undefined; 2705 } 2706 | 2740 2741 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) 2742 ? e1000_1000t_rx_status_ok 2743 : e1000_1000t_rx_status_not_ok; 2744 2745 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) 2746 ? e1000_1000t_rx_status_ok 2747 : e1000_1000t_rx_status_not_ok; 2748 } else { 2749 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2750 phy->local_rx = e1000_1000t_rx_status_undefined; 2751 phy->remote_rx = e1000_1000t_rx_status_undefined; 2752 } 2753 |
2707out: | |
2708 return ret_val; 2709} 2710 2711/** 2712 * e1000_get_phy_info_ife - Retrieves various IFE PHY states 2713 * @hw: pointer to the HW structure 2714 * 2715 * Populates "phy" structure with various feature states. --- 4 unchanged lines hidden (view full) --- 2720 s32 ret_val; 2721 u16 data; 2722 bool link; 2723 2724 DEBUGFUNC("e1000_get_phy_info_ife"); 2725 2726 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2727 if (ret_val) | 2754 return ret_val; 2755} 2756 2757/** 2758 * e1000_get_phy_info_ife - Retrieves various IFE PHY states 2759 * @hw: pointer to the HW structure 2760 * 2761 * Populates "phy" structure with various feature states. --- 4 unchanged lines hidden (view full) --- 2766 s32 ret_val; 2767 u16 data; 2768 bool link; 2769 2770 DEBUGFUNC("e1000_get_phy_info_ife"); 2771 2772 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 2773 if (ret_val) |
2728 goto out; | 2774 return ret_val; |
2729 2730 if (!link) { 2731 DEBUGOUT("Phy info is only valid if link is up\n"); | 2775 2776 if (!link) { 2777 DEBUGOUT("Phy info is only valid if link is up\n"); |
2732 ret_val = -E1000_ERR_CONFIG; 2733 goto out; | 2778 return -E1000_ERR_CONFIG; |
2734 } 2735 2736 ret_val = phy->ops.read_reg(hw, IFE_PHY_SPECIAL_CONTROL, &data); 2737 if (ret_val) | 2779 } 2780 2781 ret_val = phy->ops.read_reg(hw, IFE_PHY_SPECIAL_CONTROL, &data); 2782 if (ret_val) |
2738 goto out; 2739 phy->polarity_correction = (data & IFE_PSC_AUTO_POLARITY_DISABLE) 2740 ? FALSE : TRUE; | 2783 return ret_val; 2784 phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE); |
2741 2742 if (phy->polarity_correction) { 2743 ret_val = e1000_check_polarity_ife(hw); 2744 if (ret_val) | 2785 2786 if (phy->polarity_correction) { 2787 ret_val = e1000_check_polarity_ife(hw); 2788 if (ret_val) |
2745 goto out; | 2789 return ret_val; |
2746 } else { 2747 /* Polarity is forced */ 2748 phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY) 2749 ? e1000_rev_polarity_reversed 2750 : e1000_rev_polarity_normal; 2751 } 2752 2753 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 2754 if (ret_val) | 2790 } else { 2791 /* Polarity is forced */ 2792 phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY) 2793 ? e1000_rev_polarity_reversed 2794 : e1000_rev_polarity_normal; 2795 } 2796 2797 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 2798 if (ret_val) |
2755 goto out; | 2799 return ret_val; |
2756 | 2800 |
2757 phy->is_mdix = (data & IFE_PMC_MDIX_STATUS) ? TRUE : FALSE; | 2801 phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS); |
2758 2759 /* The following parameters are undefined for 10/100 operation. */ 2760 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2761 phy->local_rx = e1000_1000t_rx_status_undefined; 2762 phy->remote_rx = e1000_1000t_rx_status_undefined; 2763 | 2802 2803 /* The following parameters are undefined for 10/100 operation. */ 2804 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 2805 phy->local_rx = e1000_1000t_rx_status_undefined; 2806 phy->remote_rx = e1000_1000t_rx_status_undefined; 2807 |
2764out: 2765 return ret_val; | 2808 return E1000_SUCCESS; |
2766} 2767 2768/** 2769 * e1000_phy_sw_reset_generic - PHY software reset 2770 * @hw: pointer to the HW structure 2771 * 2772 * Does a software reset of the PHY by reading the PHY control register and 2773 * setting/write the control register reset bit to the PHY. 2774 **/ 2775s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw) 2776{ | 2809} 2810 2811/** 2812 * e1000_phy_sw_reset_generic - PHY software reset 2813 * @hw: pointer to the HW structure 2814 * 2815 * Does a software reset of the PHY by reading the PHY control register and 2816 * setting/write the control register reset bit to the PHY. 2817 **/ 2818s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw) 2819{ |
2777 s32 ret_val = E1000_SUCCESS; | 2820 s32 ret_val; |
2778 u16 phy_ctrl; 2779 2780 DEBUGFUNC("e1000_phy_sw_reset_generic"); 2781 | 2821 u16 phy_ctrl; 2822 2823 DEBUGFUNC("e1000_phy_sw_reset_generic"); 2824 |
2782 if (!(hw->phy.ops.read_reg)) 2783 goto out; | 2825 if (!hw->phy.ops.read_reg) 2826 return E1000_SUCCESS; |
2784 2785 ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); 2786 if (ret_val) | 2827 2828 ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); 2829 if (ret_val) |
2787 goto out; | 2830 return ret_val; |
2788 2789 phy_ctrl |= MII_CR_RESET; 2790 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL, phy_ctrl); 2791 if (ret_val) | 2831 2832 phy_ctrl |= MII_CR_RESET; 2833 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL, phy_ctrl); 2834 if (ret_val) |
2792 goto out; | 2835 return ret_val; |
2793 2794 usec_delay(1); 2795 | 2836 2837 usec_delay(1); 2838 |
2796out: | |
2797 return ret_val; 2798} 2799 2800/** 2801 * e1000_phy_hw_reset_generic - PHY hardware reset 2802 * @hw: pointer to the HW structure 2803 * 2804 * Verify the reset block is not blocking us from resetting. Acquire 2805 * semaphore (if necessary) and read/set/write the device control reset 2806 * bit in the PHY. Wait the appropriate delay time for the device to 2807 * reset and release the semaphore (if necessary). 2808 **/ 2809s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw) 2810{ 2811 struct e1000_phy_info *phy = &hw->phy; | 2839 return ret_val; 2840} 2841 2842/** 2843 * e1000_phy_hw_reset_generic - PHY hardware reset 2844 * @hw: pointer to the HW structure 2845 * 2846 * Verify the reset block is not blocking us from resetting. Acquire 2847 * semaphore (if necessary) and read/set/write the device control reset 2848 * bit in the PHY. Wait the appropriate delay time for the device to 2849 * reset and release the semaphore (if necessary). 2850 **/ 2851s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw) 2852{ 2853 struct e1000_phy_info *phy = &hw->phy; |
2812 s32 ret_val = E1000_SUCCESS; | 2854 s32 ret_val; |
2813 u32 ctrl; 2814 2815 DEBUGFUNC("e1000_phy_hw_reset_generic"); 2816 | 2855 u32 ctrl; 2856 2857 DEBUGFUNC("e1000_phy_hw_reset_generic"); 2858 |
2817 ret_val = phy->ops.check_reset_block(hw); 2818 if (ret_val) { 2819 ret_val = E1000_SUCCESS; 2820 goto out; | 2859 if (phy->ops.check_reset_block) { 2860 ret_val = phy->ops.check_reset_block(hw); 2861 if (ret_val) 2862 return E1000_SUCCESS; |
2821 } 2822 2823 ret_val = phy->ops.acquire(hw); 2824 if (ret_val) | 2863 } 2864 2865 ret_val = phy->ops.acquire(hw); 2866 if (ret_val) |
2825 goto out; | 2867 return ret_val; |
2826 2827 ctrl = E1000_READ_REG(hw, E1000_CTRL); 2828 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PHY_RST); 2829 E1000_WRITE_FLUSH(hw); 2830 2831 usec_delay(phy->reset_delay_us); 2832 2833 E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 2834 E1000_WRITE_FLUSH(hw); 2835 2836 usec_delay(150); 2837 2838 phy->ops.release(hw); 2839 | 2868 2869 ctrl = E1000_READ_REG(hw, E1000_CTRL); 2870 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PHY_RST); 2871 E1000_WRITE_FLUSH(hw); 2872 2873 usec_delay(phy->reset_delay_us); 2874 2875 E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 2876 E1000_WRITE_FLUSH(hw); 2877 2878 usec_delay(150); 2879 2880 phy->ops.release(hw); 2881 |
2840 ret_val = phy->ops.get_cfg_done(hw); 2841 2842out: 2843 return ret_val; | 2882 return phy->ops.get_cfg_done(hw); |
2844} 2845 2846/** 2847 * e1000_get_cfg_done_generic - Generic configuration done 2848 * @hw: pointer to the HW structure 2849 * 2850 * Generic function to wait 10 milli-seconds for configuration to complete 2851 * and return success. --- 137 unchanged lines hidden (view full) --- 2989 phy_type = e1000_phy_82577; 2990 break; 2991 case I82579_E_PHY_ID: 2992 phy_type = e1000_phy_82579; 2993 break; 2994 case I82580_I_PHY_ID: 2995 phy_type = e1000_phy_82580; 2996 break; | 2883} 2884 2885/** 2886 * e1000_get_cfg_done_generic - Generic configuration done 2887 * @hw: pointer to the HW structure 2888 * 2889 * Generic function to wait 10 milli-seconds for configuration to complete 2890 * and return success. --- 137 unchanged lines hidden (view full) --- 3028 phy_type = e1000_phy_82577; 3029 break; 3030 case I82579_E_PHY_ID: 3031 phy_type = e1000_phy_82579; 3032 break; 3033 case I82580_I_PHY_ID: 3034 phy_type = e1000_phy_82580; 3035 break; |
3036 case I210_I_PHY_ID: 3037 phy_type = e1000_phy_i210; 3038 break; |
|
2997 default: 2998 phy_type = e1000_phy_unknown; 2999 break; 3000 } 3001 return phy_type; 3002} 3003 3004/** 3005 * e1000_determine_phy_address - Determines PHY address. 3006 * @hw: pointer to the HW structure 3007 * 3008 * This uses a trial and error method to loop through possible PHY 3009 * addresses. It tests each by reading the PHY ID registers and 3010 * checking for a match. 3011 **/ 3012s32 e1000_determine_phy_address(struct e1000_hw *hw) 3013{ | 3039 default: 3040 phy_type = e1000_phy_unknown; 3041 break; 3042 } 3043 return phy_type; 3044} 3045 3046/** 3047 * e1000_determine_phy_address - Determines PHY address. 3048 * @hw: pointer to the HW structure 3049 * 3050 * This uses a trial and error method to loop through possible PHY 3051 * addresses. It tests each by reading the PHY ID registers and 3052 * checking for a match. 3053 **/ 3054s32 e1000_determine_phy_address(struct e1000_hw *hw) 3055{ |
3014 s32 ret_val = -E1000_ERR_PHY_TYPE; | |
3015 u32 phy_addr = 0; 3016 u32 i; 3017 enum e1000_phy_type phy_type = e1000_phy_unknown; 3018 3019 hw->phy.id = phy_type; 3020 3021 for (phy_addr = 0; phy_addr < E1000_MAX_PHY_ADDR; phy_addr++) { 3022 hw->phy.addr = phy_addr; 3023 i = 0; 3024 3025 do { 3026 e1000_get_phy_id(hw); 3027 phy_type = e1000_get_phy_type_from_id(hw->phy.id); 3028 3029 /* 3030 * If phy_type is valid, break - we found our 3031 * PHY address 3032 */ | 3056 u32 phy_addr = 0; 3057 u32 i; 3058 enum e1000_phy_type phy_type = e1000_phy_unknown; 3059 3060 hw->phy.id = phy_type; 3061 3062 for (phy_addr = 0; phy_addr < E1000_MAX_PHY_ADDR; phy_addr++) { 3063 hw->phy.addr = phy_addr; 3064 i = 0; 3065 3066 do { 3067 e1000_get_phy_id(hw); 3068 phy_type = e1000_get_phy_type_from_id(hw->phy.id); 3069 3070 /* 3071 * If phy_type is valid, break - we found our 3072 * PHY address 3073 */ |
3033 if (phy_type != e1000_phy_unknown) { 3034 ret_val = E1000_SUCCESS; 3035 goto out; 3036 } | 3074 if (phy_type != e1000_phy_unknown) 3075 return E1000_SUCCESS; 3076 |
3037 msec_delay(1); 3038 i++; 3039 } while (i < 10); 3040 } 3041 | 3077 msec_delay(1); 3078 i++; 3079 } while (i < 10); 3080 } 3081 |
3042out: 3043 return ret_val; | 3082 return -E1000_ERR_PHY_TYPE; |
3044} 3045 3046/** 3047 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address 3048 * @page: page to access 3049 * 3050 * Returns the phy address for the page requested. 3051 **/ --- 26 unchanged lines hidden (view full) --- 3078 ret_val = hw->phy.ops.acquire(hw); 3079 if (ret_val) 3080 return ret_val; 3081 3082 /* Page 800 works differently than the rest so it has its own func */ 3083 if (page == BM_WUC_PAGE) { 3084 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, 3085 FALSE, FALSE); | 3083} 3084 3085/** 3086 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address 3087 * @page: page to access 3088 * 3089 * Returns the phy address for the page requested. 3090 **/ --- 26 unchanged lines hidden (view full) --- 3117 ret_val = hw->phy.ops.acquire(hw); 3118 if (ret_val) 3119 return ret_val; 3120 3121 /* Page 800 works differently than the rest so it has its own func */ 3122 if (page == BM_WUC_PAGE) { 3123 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, 3124 FALSE, FALSE); |
3086 goto out; | 3125 goto release; |
3087 } 3088 3089 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 3090 3091 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3092 u32 page_shift, page_select; 3093 3094 /* --- 8 unchanged lines hidden (view full) --- 3103 page_shift = 0; 3104 page_select = BM_PHY_PAGE_SELECT; 3105 } 3106 3107 /* Page is shifted left, PHY expects (page x 32) */ 3108 ret_val = e1000_write_phy_reg_mdic(hw, page_select, 3109 (page << page_shift)); 3110 if (ret_val) | 3126 } 3127 3128 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 3129 3130 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3131 u32 page_shift, page_select; 3132 3133 /* --- 8 unchanged lines hidden (view full) --- 3142 page_shift = 0; 3143 page_select = BM_PHY_PAGE_SELECT; 3144 } 3145 3146 /* Page is shifted left, PHY expects (page x 32) */ 3147 ret_val = e1000_write_phy_reg_mdic(hw, page_select, 3148 (page << page_shift)); 3149 if (ret_val) |
3111 goto out; | 3150 goto release; |
3112 } 3113 3114 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3115 data); 3116 | 3151 } 3152 3153 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3154 data); 3155 |
3117out: | 3156release: |
3118 hw->phy.ops.release(hw); 3119 return ret_val; 3120} 3121 3122/** 3123 * e1000_read_phy_reg_bm - Read BM PHY register 3124 * @hw: pointer to the HW structure 3125 * @offset: register offset to be read --- 13 unchanged lines hidden (view full) --- 3139 ret_val = hw->phy.ops.acquire(hw); 3140 if (ret_val) 3141 return ret_val; 3142 3143 /* Page 800 works differently than the rest so it has its own func */ 3144 if (page == BM_WUC_PAGE) { 3145 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, 3146 TRUE, FALSE); | 3157 hw->phy.ops.release(hw); 3158 return ret_val; 3159} 3160 3161/** 3162 * e1000_read_phy_reg_bm - Read BM PHY register 3163 * @hw: pointer to the HW structure 3164 * @offset: register offset to be read --- 13 unchanged lines hidden (view full) --- 3178 ret_val = hw->phy.ops.acquire(hw); 3179 if (ret_val) 3180 return ret_val; 3181 3182 /* Page 800 works differently than the rest so it has its own func */ 3183 if (page == BM_WUC_PAGE) { 3184 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, 3185 TRUE, FALSE); |
3147 goto out; | 3186 goto release; |
3148 } 3149 3150 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 3151 3152 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3153 u32 page_shift, page_select; 3154 3155 /* --- 8 unchanged lines hidden (view full) --- 3164 page_shift = 0; 3165 page_select = BM_PHY_PAGE_SELECT; 3166 } 3167 3168 /* Page is shifted left, PHY expects (page x 32) */ 3169 ret_val = e1000_write_phy_reg_mdic(hw, page_select, 3170 (page << page_shift)); 3171 if (ret_val) | 3187 } 3188 3189 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 3190 3191 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3192 u32 page_shift, page_select; 3193 3194 /* --- 8 unchanged lines hidden (view full) --- 3203 page_shift = 0; 3204 page_select = BM_PHY_PAGE_SELECT; 3205 } 3206 3207 /* Page is shifted left, PHY expects (page x 32) */ 3208 ret_val = e1000_write_phy_reg_mdic(hw, page_select, 3209 (page << page_shift)); 3210 if (ret_val) |
3172 goto out; | 3211 goto release; |
3173 } 3174 3175 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3176 data); | 3212 } 3213 3214 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3215 data); |
3177out: | 3216release: |
3178 hw->phy.ops.release(hw); 3179 return ret_val; 3180} 3181 3182/** 3183 * e1000_read_phy_reg_bm2 - Read BM PHY register 3184 * @hw: pointer to the HW structure 3185 * @offset: register offset to be read --- 13 unchanged lines hidden (view full) --- 3199 ret_val = hw->phy.ops.acquire(hw); 3200 if (ret_val) 3201 return ret_val; 3202 3203 /* Page 800 works differently than the rest so it has its own func */ 3204 if (page == BM_WUC_PAGE) { 3205 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, 3206 TRUE, FALSE); | 3217 hw->phy.ops.release(hw); 3218 return ret_val; 3219} 3220 3221/** 3222 * e1000_read_phy_reg_bm2 - Read BM PHY register 3223 * @hw: pointer to the HW structure 3224 * @offset: register offset to be read --- 13 unchanged lines hidden (view full) --- 3238 ret_val = hw->phy.ops.acquire(hw); 3239 if (ret_val) 3240 return ret_val; 3241 3242 /* Page 800 works differently than the rest so it has its own func */ 3243 if (page == BM_WUC_PAGE) { 3244 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, 3245 TRUE, FALSE); |
3207 goto out; | 3246 goto release; |
3208 } 3209 3210 hw->phy.addr = 1; 3211 3212 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3213 3214 /* Page is shifted left, PHY expects (page x 32) */ 3215 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, 3216 page); 3217 3218 if (ret_val) | 3247 } 3248 3249 hw->phy.addr = 1; 3250 3251 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3252 3253 /* Page is shifted left, PHY expects (page x 32) */ 3254 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, 3255 page); 3256 3257 if (ret_val) |
3219 goto out; | 3258 goto release; |
3220 } 3221 3222 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3223 data); | 3259 } 3260 3261 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3262 data); |
3224out: | 3263release: |
3225 hw->phy.ops.release(hw); 3226 return ret_val; 3227} 3228 3229/** 3230 * e1000_write_phy_reg_bm2 - Write BM PHY register 3231 * @hw: pointer to the HW structure 3232 * @offset: register offset to write to --- 12 unchanged lines hidden (view full) --- 3245 ret_val = hw->phy.ops.acquire(hw); 3246 if (ret_val) 3247 return ret_val; 3248 3249 /* Page 800 works differently than the rest so it has its own func */ 3250 if (page == BM_WUC_PAGE) { 3251 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, 3252 FALSE, FALSE); | 3264 hw->phy.ops.release(hw); 3265 return ret_val; 3266} 3267 3268/** 3269 * e1000_write_phy_reg_bm2 - Write BM PHY register 3270 * @hw: pointer to the HW structure 3271 * @offset: register offset to write to --- 12 unchanged lines hidden (view full) --- 3284 ret_val = hw->phy.ops.acquire(hw); 3285 if (ret_val) 3286 return ret_val; 3287 3288 /* Page 800 works differently than the rest so it has its own func */ 3289 if (page == BM_WUC_PAGE) { 3290 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, 3291 FALSE, FALSE); |
3253 goto out; | 3292 goto release; |
3254 } 3255 3256 hw->phy.addr = 1; 3257 3258 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3259 /* Page is shifted left, PHY expects (page x 32) */ 3260 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, 3261 page); 3262 3263 if (ret_val) | 3293 } 3294 3295 hw->phy.addr = 1; 3296 3297 if (offset > MAX_PHY_MULTI_PAGE_REG) { 3298 /* Page is shifted left, PHY expects (page x 32) */ 3299 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, 3300 page); 3301 3302 if (ret_val) |
3264 goto out; | 3303 goto release; |
3265 } 3266 3267 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3268 data); 3269 | 3304 } 3305 3306 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 3307 data); 3308 |
3270out: | 3309release: |
3271 hw->phy.ops.release(hw); 3272 return ret_val; 3273} 3274 3275/** 3276 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers 3277 * @hw: pointer to the HW structure 3278 * @phy_reg: pointer to store original contents of BM_WUC_ENABLE_REG 3279 * 3280 * Assumes semaphore already acquired and phy_reg points to a valid memory 3281 * address to store contents of the BM_WUC_ENABLE_REG register. 3282 **/ 3283s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) 3284{ 3285 s32 ret_val; 3286 u16 temp; 3287 3288 DEBUGFUNC("e1000_enable_phy_wakeup_reg_access_bm"); 3289 | 3310 hw->phy.ops.release(hw); 3311 return ret_val; 3312} 3313 3314/** 3315 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers 3316 * @hw: pointer to the HW structure 3317 * @phy_reg: pointer to store original contents of BM_WUC_ENABLE_REG 3318 * 3319 * Assumes semaphore already acquired and phy_reg points to a valid memory 3320 * address to store contents of the BM_WUC_ENABLE_REG register. 3321 **/ 3322s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) 3323{ 3324 s32 ret_val; 3325 u16 temp; 3326 3327 DEBUGFUNC("e1000_enable_phy_wakeup_reg_access_bm"); 3328 |
3290 if (!phy_reg) { 3291 ret_val = -E1000_ERR_PARAM; 3292 goto out; 3293 } | 3329 if (!phy_reg) 3330 return -E1000_ERR_PARAM; |
3294 3295 /* All page select, port ctrl and wakeup registers use phy address 1 */ 3296 hw->phy.addr = 1; 3297 3298 /* Select Port Control Registers page */ 3299 ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); 3300 if (ret_val) { 3301 DEBUGOUT("Could not set Port Control page\n"); | 3331 3332 /* All page select, port ctrl and wakeup registers use phy address 1 */ 3333 hw->phy.addr = 1; 3334 3335 /* Select Port Control Registers page */ 3336 ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); 3337 if (ret_val) { 3338 DEBUGOUT("Could not set Port Control page\n"); |
3302 goto out; | 3339 return ret_val; |
3303 } 3304 3305 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg); 3306 if (ret_val) { 3307 DEBUGOUT2("Could not read PHY register %d.%d\n", 3308 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); | 3340 } 3341 3342 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg); 3343 if (ret_val) { 3344 DEBUGOUT2("Could not read PHY register %d.%d\n", 3345 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); |
3309 goto out; | 3346 return ret_val; |
3310 } 3311 3312 /* 3313 * Enable both PHY wakeup mode and Wakeup register page writes. 3314 * Prevent a power state change by disabling ME and Host PHY wakeup. 3315 */ 3316 temp = *phy_reg; 3317 temp |= BM_WUC_ENABLE_BIT; 3318 temp &= ~(BM_WUC_ME_WU_BIT | BM_WUC_HOST_WU_BIT); 3319 3320 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, temp); 3321 if (ret_val) { 3322 DEBUGOUT2("Could not write PHY register %d.%d\n", 3323 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); | 3347 } 3348 3349 /* 3350 * Enable both PHY wakeup mode and Wakeup register page writes. 3351 * Prevent a power state change by disabling ME and Host PHY wakeup. 3352 */ 3353 temp = *phy_reg; 3354 temp |= BM_WUC_ENABLE_BIT; 3355 temp &= ~(BM_WUC_ME_WU_BIT | BM_WUC_HOST_WU_BIT); 3356 3357 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, temp); 3358 if (ret_val) { 3359 DEBUGOUT2("Could not write PHY register %d.%d\n", 3360 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); |
3324 goto out; | 3361 return ret_val; |
3325 } 3326 | 3362 } 3363 |
3327 /* Select Host Wakeup Registers page */ 3328 ret_val = e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT)); 3329 3330 /* caller now able to write registers on the Wakeup registers page */ 3331out: 3332 return ret_val; | 3364 /* 3365 * Select Host Wakeup Registers page - caller now able to write 3366 * registers on the Wakeup registers page 3367 */ 3368 return e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT)); |
3333} 3334 3335/** 3336 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs 3337 * @hw: pointer to the HW structure 3338 * @phy_reg: pointer to original contents of BM_WUC_ENABLE_REG 3339 * 3340 * Restore BM_WUC_ENABLE_REG to its original value. --- 10 unchanged lines hidden (view full) --- 3351 3352 if (!phy_reg) 3353 return -E1000_ERR_PARAM; 3354 3355 /* Select Port Control Registers page */ 3356 ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); 3357 if (ret_val) { 3358 DEBUGOUT("Could not set Port Control page\n"); | 3369} 3370 3371/** 3372 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs 3373 * @hw: pointer to the HW structure 3374 * @phy_reg: pointer to original contents of BM_WUC_ENABLE_REG 3375 * 3376 * Restore BM_WUC_ENABLE_REG to its original value. --- 10 unchanged lines hidden (view full) --- 3387 3388 if (!phy_reg) 3389 return -E1000_ERR_PARAM; 3390 3391 /* Select Port Control Registers page */ 3392 ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); 3393 if (ret_val) { 3394 DEBUGOUT("Could not set Port Control page\n"); |
3359 goto out; | 3395 return ret_val; |
3360 } 3361 3362 /* Restore 769.17 to its original value */ 3363 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, *phy_reg); 3364 if (ret_val) 3365 DEBUGOUT2("Could not restore PHY register %d.%d\n", 3366 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); | 3396 } 3397 3398 /* Restore 769.17 to its original value */ 3399 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, *phy_reg); 3400 if (ret_val) 3401 DEBUGOUT2("Could not restore PHY register %d.%d\n", 3402 BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); |
3367out: | 3403 |
3368 return ret_val; 3369} 3370 3371/** 3372 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register 3373 * @hw: pointer to the HW structure 3374 * @offset: register offset to be read or written 3375 * @data: pointer to the data to read or write --- 32 unchanged lines hidden (view full) --- 3408 DEBUGOUT1("Attempting to access page %d while gig enabled.\n", 3409 page); 3410 3411 if (!page_set) { 3412 /* Enable access to PHY wakeup registers */ 3413 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg); 3414 if (ret_val) { 3415 DEBUGOUT("Could not enable PHY wakeup reg access\n"); | 3404 return ret_val; 3405} 3406 3407/** 3408 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register 3409 * @hw: pointer to the HW structure 3410 * @offset: register offset to be read or written 3411 * @data: pointer to the data to read or write --- 32 unchanged lines hidden (view full) --- 3444 DEBUGOUT1("Attempting to access page %d while gig enabled.\n", 3445 page); 3446 3447 if (!page_set) { 3448 /* Enable access to PHY wakeup registers */ 3449 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg); 3450 if (ret_val) { 3451 DEBUGOUT("Could not enable PHY wakeup reg access\n"); |
3416 goto out; | 3452 return ret_val; |
3417 } 3418 } 3419 3420 DEBUGOUT2("Accessing PHY page %d reg 0x%x\n", page, reg); 3421 3422 /* Write the Wakeup register page offset value using opcode 0x11 */ 3423 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ADDRESS_OPCODE, reg); 3424 if (ret_val) { 3425 DEBUGOUT1("Could not write address opcode to page %d\n", page); | 3453 } 3454 } 3455 3456 DEBUGOUT2("Accessing PHY page %d reg 0x%x\n", page, reg); 3457 3458 /* Write the Wakeup register page offset value using opcode 0x11 */ 3459 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ADDRESS_OPCODE, reg); 3460 if (ret_val) { 3461 DEBUGOUT1("Could not write address opcode to page %d\n", page); |
3426 goto out; | 3462 return ret_val; |
3427 } 3428 3429 if (read) { 3430 /* Read the Wakeup register page value using opcode 0x12 */ 3431 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE, 3432 data); 3433 } else { 3434 /* Write the Wakeup register page value using opcode 0x12 */ 3435 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE, 3436 *data); 3437 } 3438 3439 if (ret_val) { 3440 DEBUGOUT2("Could not access PHY reg %d.%d\n", page, reg); | 3463 } 3464 3465 if (read) { 3466 /* Read the Wakeup register page value using opcode 0x12 */ 3467 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE, 3468 data); 3469 } else { 3470 /* Write the Wakeup register page value using opcode 0x12 */ 3471 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE, 3472 *data); 3473 } 3474 3475 if (ret_val) { 3476 DEBUGOUT2("Could not access PHY reg %d.%d\n", page, reg); |
3441 goto out; | 3477 return ret_val; |
3442 } 3443 3444 if (!page_set) 3445 ret_val = e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg); 3446 | 3478 } 3479 3480 if (!page_set) 3481 ret_val = e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg); 3482 |
3447out: | |
3448 return ret_val; 3449} 3450 3451/** 3452 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down 3453 * @hw: pointer to the HW structure 3454 * 3455 * In the case of a PHY power down to save power, or to turn off link during a 3456 * driver unload, or wake on lan is not enabled, restore the link to previous 3457 * settings. 3458 **/ 3459void e1000_power_up_phy_copper(struct e1000_hw *hw) 3460{ 3461 u16 mii_reg = 0; | 3483 return ret_val; 3484} 3485 3486/** 3487 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down 3488 * @hw: pointer to the HW structure 3489 * 3490 * In the case of a PHY power down to save power, or to turn off link during a 3491 * driver unload, or wake on lan is not enabled, restore the link to previous 3492 * settings. 3493 **/ 3494void e1000_power_up_phy_copper(struct e1000_hw *hw) 3495{ 3496 u16 mii_reg = 0; |
3497 u16 power_reg = 0; |
|
3462 3463 /* The PHY will retain its settings across a power down/up cycle */ 3464 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); 3465 mii_reg &= ~MII_CR_POWER_DOWN; | 3498 3499 /* The PHY will retain its settings across a power down/up cycle */ 3500 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); 3501 mii_reg &= ~MII_CR_POWER_DOWN; |
3502 if (hw->phy.type == e1000_phy_i210) { 3503 hw->phy.ops.read_reg(hw, GS40G_COPPER_SPEC, &power_reg); 3504 power_reg &= ~GS40G_CS_POWER_DOWN; 3505 hw->phy.ops.write_reg(hw, GS40G_COPPER_SPEC, power_reg); 3506 } |
|
3466 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); 3467} 3468 3469/** 3470 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down 3471 * @hw: pointer to the HW structure 3472 * 3473 * In the case of a PHY power down to save power, or to turn off link during a 3474 * driver unload, or wake on lan is not enabled, restore the link to previous 3475 * settings. 3476 **/ 3477void e1000_power_down_phy_copper(struct e1000_hw *hw) 3478{ 3479 u16 mii_reg = 0; | 3507 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); 3508} 3509 3510/** 3511 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down 3512 * @hw: pointer to the HW structure 3513 * 3514 * In the case of a PHY power down to save power, or to turn off link during a 3515 * driver unload, or wake on lan is not enabled, restore the link to previous 3516 * settings. 3517 **/ 3518void e1000_power_down_phy_copper(struct e1000_hw *hw) 3519{ 3520 u16 mii_reg = 0; |
3521 u16 power_reg = 0; |
|
3480 3481 /* The PHY will retain its settings across a power down/up cycle */ 3482 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); 3483 mii_reg |= MII_CR_POWER_DOWN; | 3522 3523 /* The PHY will retain its settings across a power down/up cycle */ 3524 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); 3525 mii_reg |= MII_CR_POWER_DOWN; |
3526 /* i210 Phy requires an additional bit for power up/down */ 3527 if (hw->phy.type == e1000_phy_i210) { 3528 hw->phy.ops.read_reg(hw, GS40G_COPPER_SPEC, &power_reg); 3529 power_reg |= GS40G_CS_POWER_DOWN; 3530 hw->phy.ops.write_reg(hw, GS40G_COPPER_SPEC, power_reg); 3531 } |
|
3484 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); 3485 msec_delay(1); 3486} 3487 3488/** 3489 * __e1000_read_phy_reg_hv - Read HV PHY register 3490 * @hw: pointer to the HW structure 3491 * @offset: register offset to be read --- 149 unchanged lines hidden (view full) --- 3641 3642 /* 3643 * Workaround MDIO accesses being disabled after entering IEEE 3644 * Power Down (when bit 11 of the PHY Control register is set) 3645 */ 3646 if ((hw->phy.type == e1000_phy_82578) && 3647 (hw->phy.revision >= 1) && 3648 (hw->phy.addr == 2) && | 3532 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); 3533 msec_delay(1); 3534} 3535 3536/** 3537 * __e1000_read_phy_reg_hv - Read HV PHY register 3538 * @hw: pointer to the HW structure 3539 * @offset: register offset to be read --- 149 unchanged lines hidden (view full) --- 3689 3690 /* 3691 * Workaround MDIO accesses being disabled after entering IEEE 3692 * Power Down (when bit 11 of the PHY Control register is set) 3693 */ 3694 if ((hw->phy.type == e1000_phy_82578) && 3695 (hw->phy.revision >= 1) && 3696 (hw->phy.addr == 2) && |
3649 ((MAX_PHY_REG_ADDRESS & reg) == 0) && | 3697 !(MAX_PHY_REG_ADDRESS & reg) && |
3650 (data & (1 << 11))) { 3651 u16 data2 = 0x7EFF; 3652 ret_val = e1000_access_phy_debug_regs_hv(hw, 3653 (1 << 6) | 0x3, 3654 &data2, FALSE); 3655 if (ret_val) 3656 goto out; 3657 } --- 107 unchanged lines hidden (view full) --- 3765 3766 /* All operations in this function are phy address 2 */ 3767 hw->phy.addr = 2; 3768 3769 /* masking with 0x3F to remove the page from offset */ 3770 ret_val = e1000_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); 3771 if (ret_val) { 3772 DEBUGOUT("Could not write the Address Offset port register\n"); | 3698 (data & (1 << 11))) { 3699 u16 data2 = 0x7EFF; 3700 ret_val = e1000_access_phy_debug_regs_hv(hw, 3701 (1 << 6) | 0x3, 3702 &data2, FALSE); 3703 if (ret_val) 3704 goto out; 3705 } --- 107 unchanged lines hidden (view full) --- 3813 3814 /* All operations in this function are phy address 2 */ 3815 hw->phy.addr = 2; 3816 3817 /* masking with 0x3F to remove the page from offset */ 3818 ret_val = e1000_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); 3819 if (ret_val) { 3820 DEBUGOUT("Could not write the Address Offset port register\n"); |
3773 goto out; | 3821 return ret_val; |
3774 } 3775 3776 /* Read or write the data value next */ 3777 if (read) 3778 ret_val = e1000_read_phy_reg_mdic(hw, data_reg, data); 3779 else 3780 ret_val = e1000_write_phy_reg_mdic(hw, data_reg, *data); 3781 | 3822 } 3823 3824 /* Read or write the data value next */ 3825 if (read) 3826 ret_val = e1000_read_phy_reg_mdic(hw, data_reg, data); 3827 else 3828 ret_val = e1000_write_phy_reg_mdic(hw, data_reg, *data); 3829 |
3782 if (ret_val) { | 3830 if (ret_val) |
3783 DEBUGOUT("Could not access the Data port register\n"); | 3831 DEBUGOUT("Could not access the Data port register\n"); |
3784 goto out; 3785 } | |
3786 | 3832 |
3787out: | |
3788 return ret_val; 3789} 3790 3791/** 3792 * e1000_link_stall_workaround_hv - Si workaround 3793 * @hw: pointer to the HW structure 3794 * 3795 * This function works around a Si bug where the link partner can get --- 6 unchanged lines hidden (view full) --- 3802s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) 3803{ 3804 s32 ret_val = E1000_SUCCESS; 3805 u16 data; 3806 3807 DEBUGFUNC("e1000_link_stall_workaround_hv"); 3808 3809 if (hw->phy.type != e1000_phy_82578) | 3833 return ret_val; 3834} 3835 3836/** 3837 * e1000_link_stall_workaround_hv - Si workaround 3838 * @hw: pointer to the HW structure 3839 * 3840 * This function works around a Si bug where the link partner can get --- 6 unchanged lines hidden (view full) --- 3847s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) 3848{ 3849 s32 ret_val = E1000_SUCCESS; 3850 u16 data; 3851 3852 DEBUGFUNC("e1000_link_stall_workaround_hv"); 3853 3854 if (hw->phy.type != e1000_phy_82578) |
3810 goto out; | 3855 return E1000_SUCCESS; |
3811 3812 /* Do not apply workaround if in PHY loopback bit 14 set */ 3813 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data); 3814 if (data & PHY_CONTROL_LB) | 3856 3857 /* Do not apply workaround if in PHY loopback bit 14 set */ 3858 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data); 3859 if (data & PHY_CONTROL_LB) |
3815 goto out; | 3860 return E1000_SUCCESS; |
3816 3817 /* check if link is up and at 1Gbps */ 3818 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data); 3819 if (ret_val) | 3861 3862 /* check if link is up and at 1Gbps */ 3863 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data); 3864 if (ret_val) |
3820 goto out; | 3865 return ret_val; |
3821 3822 data &= BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | 3823 BM_CS_STATUS_SPEED_MASK; 3824 3825 if (data != (BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | 3826 BM_CS_STATUS_SPEED_1000)) | 3866 3867 data &= BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | 3868 BM_CS_STATUS_SPEED_MASK; 3869 3870 if (data != (BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | 3871 BM_CS_STATUS_SPEED_1000)) |
3827 goto out; | 3872 return E1000_SUCCESS; |
3828 3829 msec_delay(200); 3830 3831 /* flush the packets in the fifo buffer */ 3832 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3833 HV_MUX_DATA_CTRL_GEN_TO_MAC | 3834 HV_MUX_DATA_CTRL_FORCE_SPEED); 3835 if (ret_val) | 3873 3874 msec_delay(200); 3875 3876 /* flush the packets in the fifo buffer */ 3877 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3878 HV_MUX_DATA_CTRL_GEN_TO_MAC | 3879 HV_MUX_DATA_CTRL_FORCE_SPEED); 3880 if (ret_val) |
3836 goto out; | 3881 return ret_val; |
3837 | 3882 |
3838 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3839 HV_MUX_DATA_CTRL_GEN_TO_MAC); 3840 3841out: 3842 return ret_val; | 3883 return hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3884 HV_MUX_DATA_CTRL_GEN_TO_MAC); |
3843} 3844 3845/** 3846 * e1000_check_polarity_82577 - Checks the polarity. 3847 * @hw: pointer to the HW structure 3848 * 3849 * Success returns 0, Failure returns -E1000_ERR_PHY (-2) 3850 * --- 29 unchanged lines hidden (view full) --- 3880 s32 ret_val; 3881 u16 phy_data; 3882 bool link; 3883 3884 DEBUGFUNC("e1000_phy_force_speed_duplex_82577"); 3885 3886 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 3887 if (ret_val) | 3885} 3886 3887/** 3888 * e1000_check_polarity_82577 - Checks the polarity. 3889 * @hw: pointer to the HW structure 3890 * 3891 * Success returns 0, Failure returns -E1000_ERR_PHY (-2) 3892 * --- 29 unchanged lines hidden (view full) --- 3922 s32 ret_val; 3923 u16 phy_data; 3924 bool link; 3925 3926 DEBUGFUNC("e1000_phy_force_speed_duplex_82577"); 3927 3928 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 3929 if (ret_val) |
3888 goto out; | 3930 return ret_val; |
3889 3890 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 3891 3892 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 3893 if (ret_val) | 3931 3932 e1000_phy_force_speed_duplex_setup(hw, &phy_data); 3933 3934 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 3935 if (ret_val) |
3894 goto out; | 3936 return ret_val; |
3895 3896 usec_delay(1); 3897 3898 if (phy->autoneg_wait_to_complete) { 3899 DEBUGOUT("Waiting for forced speed/duplex link on 82577 phy\n"); 3900 3901 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 3902 100000, &link); 3903 if (ret_val) | 3937 3938 usec_delay(1); 3939 3940 if (phy->autoneg_wait_to_complete) { 3941 DEBUGOUT("Waiting for forced speed/duplex link on 82577 phy\n"); 3942 3943 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 3944 100000, &link); 3945 if (ret_val) |
3904 goto out; | 3946 return ret_val; |
3905 3906 if (!link) 3907 DEBUGOUT("Link taking longer than expected.\n"); 3908 3909 /* Try once more */ 3910 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 3911 100000, &link); | 3947 3948 if (!link) 3949 DEBUGOUT("Link taking longer than expected.\n"); 3950 3951 /* Try once more */ 3952 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 3953 100000, &link); |
3912 if (ret_val) 3913 goto out; | |
3914 } 3915 | 3954 } 3955 |
3916out: | |
3917 return ret_val; 3918} 3919 3920/** 3921 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information 3922 * @hw: pointer to the HW structure 3923 * 3924 * Read PHY status to determine if link is up. If link is up, then --- 7 unchanged lines hidden (view full) --- 3932 s32 ret_val; 3933 u16 data; 3934 bool link; 3935 3936 DEBUGFUNC("e1000_get_phy_info_82577"); 3937 3938 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 3939 if (ret_val) | 3956 return ret_val; 3957} 3958 3959/** 3960 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information 3961 * @hw: pointer to the HW structure 3962 * 3963 * Read PHY status to determine if link is up. If link is up, then --- 7 unchanged lines hidden (view full) --- 3971 s32 ret_val; 3972 u16 data; 3973 bool link; 3974 3975 DEBUGFUNC("e1000_get_phy_info_82577"); 3976 3977 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 3978 if (ret_val) |
3940 goto out; | 3979 return ret_val; |
3941 3942 if (!link) { 3943 DEBUGOUT("Phy info is only valid if link is up\n"); | 3980 3981 if (!link) { 3982 DEBUGOUT("Phy info is only valid if link is up\n"); |
3944 ret_val = -E1000_ERR_CONFIG; 3945 goto out; | 3983 return -E1000_ERR_CONFIG; |
3946 } 3947 3948 phy->polarity_correction = TRUE; 3949 3950 ret_val = e1000_check_polarity_82577(hw); 3951 if (ret_val) | 3984 } 3985 3986 phy->polarity_correction = TRUE; 3987 3988 ret_val = e1000_check_polarity_82577(hw); 3989 if (ret_val) |
3952 goto out; | 3990 return ret_val; |
3953 3954 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); 3955 if (ret_val) | 3991 3992 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); 3993 if (ret_val) |
3956 goto out; | 3994 return ret_val; |
3957 | 3995 |
3958 phy->is_mdix = (data & I82577_PHY_STATUS2_MDIX) ? TRUE : FALSE; | 3996 phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX); |
3959 3960 if ((data & I82577_PHY_STATUS2_SPEED_MASK) == 3961 I82577_PHY_STATUS2_SPEED_1000MBPS) { 3962 ret_val = hw->phy.ops.get_cable_length(hw); 3963 if (ret_val) | 3997 3998 if ((data & I82577_PHY_STATUS2_SPEED_MASK) == 3999 I82577_PHY_STATUS2_SPEED_1000MBPS) { 4000 ret_val = hw->phy.ops.get_cable_length(hw); 4001 if (ret_val) |
3964 goto out; | 4002 return ret_val; |
3965 3966 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); 3967 if (ret_val) | 4003 4004 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); 4005 if (ret_val) |
3968 goto out; | 4006 return ret_val; |
3969 3970 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) 3971 ? e1000_1000t_rx_status_ok 3972 : e1000_1000t_rx_status_not_ok; 3973 3974 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) 3975 ? e1000_1000t_rx_status_ok 3976 : e1000_1000t_rx_status_not_ok; 3977 } else { 3978 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 3979 phy->local_rx = e1000_1000t_rx_status_undefined; 3980 phy->remote_rx = e1000_1000t_rx_status_undefined; 3981 } 3982 | 4007 4008 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) 4009 ? e1000_1000t_rx_status_ok 4010 : e1000_1000t_rx_status_not_ok; 4011 4012 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) 4013 ? e1000_1000t_rx_status_ok 4014 : e1000_1000t_rx_status_not_ok; 4015 } else { 4016 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 4017 phy->local_rx = e1000_1000t_rx_status_undefined; 4018 phy->remote_rx = e1000_1000t_rx_status_undefined; 4019 } 4020 |
3983out: 3984 return ret_val; | 4021 return E1000_SUCCESS; |
3985} 3986 3987/** 3988 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY 3989 * @hw: pointer to the HW structure 3990 * 3991 * Reads the diagnostic status register and verifies result is valid before 3992 * placing it in the phy_cable_length field. 3993 **/ 3994s32 e1000_get_cable_length_82577(struct e1000_hw *hw) 3995{ 3996 struct e1000_phy_info *phy = &hw->phy; 3997 s32 ret_val; 3998 u16 phy_data, length; 3999 4000 DEBUGFUNC("e1000_get_cable_length_82577"); 4001 4002 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data); 4003 if (ret_val) | 4022} 4023 4024/** 4025 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY 4026 * @hw: pointer to the HW structure 4027 * 4028 * Reads the diagnostic status register and verifies result is valid before 4029 * placing it in the phy_cable_length field. 4030 **/ 4031s32 e1000_get_cable_length_82577(struct e1000_hw *hw) 4032{ 4033 struct e1000_phy_info *phy = &hw->phy; 4034 s32 ret_val; 4035 u16 phy_data, length; 4036 4037 DEBUGFUNC("e1000_get_cable_length_82577"); 4038 4039 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data); 4040 if (ret_val) |
4004 goto out; | 4041 return ret_val; |
4005 4006 length = (phy_data & I82577_DSTATUS_CABLE_LENGTH) >> 4007 I82577_DSTATUS_CABLE_LENGTH_SHIFT; 4008 4009 if (length == E1000_CABLE_LENGTH_UNDEFINED) 4010 ret_val = -E1000_ERR_PHY; 4011 4012 phy->cable_length = length; 4013 | 4042 4043 length = (phy_data & I82577_DSTATUS_CABLE_LENGTH) >> 4044 I82577_DSTATUS_CABLE_LENGTH_SHIFT; 4045 4046 if (length == E1000_CABLE_LENGTH_UNDEFINED) 4047 ret_val = -E1000_ERR_PHY; 4048 4049 phy->cable_length = length; 4050 |
4014out: | 4051 return E1000_SUCCESS; 4052} 4053 4054/** 4055 * e1000_write_phy_reg_gs40g - Write GS40G PHY register 4056 * @hw: pointer to the HW structure 4057 * @offset: register offset to write to 4058 * @data: data to write at register offset 4059 * 4060 * Acquires semaphore, if necessary, then writes the data to PHY register 4061 * at the offset. Release any acquired semaphores before exiting. 4062 **/ 4063s32 e1000_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data) 4064{ 4065 s32 ret_val; 4066 u16 page = offset >> GS40G_PAGE_SHIFT; 4067 4068 DEBUGFUNC("e1000_write_phy_reg_gs40g"); 4069 4070 offset = offset & GS40G_OFFSET_MASK; 4071 ret_val = hw->phy.ops.acquire(hw); 4072 if (ret_val) 4073 return ret_val; 4074 4075 ret_val = e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page); 4076 if (ret_val) 4077 goto release; 4078 ret_val = e1000_write_phy_reg_mdic(hw, offset, data); 4079 4080release: 4081 hw->phy.ops.release(hw); |
4015 return ret_val; 4016} | 4082 return ret_val; 4083} |
4084 4085/** 4086 * e1000_read_phy_reg_gs40g - Read GS40G PHY register 4087 * @hw: pointer to the HW structure 4088 * @offset: lower half is register offset to read to 4089 * upper half is page to use. 4090 * @data: data to read at register offset 4091 * 4092 * Acquires semaphore, if necessary, then reads the data in the PHY register 4093 * at the offset. Release any acquired semaphores before exiting. 4094 **/ 4095s32 e1000_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data) 4096{ 4097 s32 ret_val; 4098 u16 page = offset >> GS40G_PAGE_SHIFT; 4099 4100 DEBUGFUNC("e1000_read_phy_reg_gs40g"); 4101 4102 offset = offset & GS40G_OFFSET_MASK; 4103 ret_val = hw->phy.ops.acquire(hw); 4104 if (ret_val) 4105 return ret_val; 4106 4107 ret_val = e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page); 4108 if (ret_val) 4109 goto release; 4110 ret_val = e1000_read_phy_reg_mdic(hw, offset, data); 4111 4112release: 4113 hw->phy.ops.release(hw); 4114 return ret_val; 4115} |
|