Deleted Added
full compact
e1000_phy.c (194865) e1000_phy.c (200243)
1/******************************************************************************
2
3 Copyright (c) 2001-2009, 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

--- 16 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******************************************************************************/
1/******************************************************************************
2
3 Copyright (c) 2001-2009, 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

--- 16 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: head/sys/dev/e1000/e1000_phy.c 194865 2009-06-24 17:41:29Z jfv $*/
33/*$FreeBSD: head/sys/dev/e1000/e1000_phy.c 200243 2009-12-08 01:07:44Z 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);
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,

--- 36 unchanged lines hidden (view full) ---

78 phy->ops.check_polarity = e1000_null_ops_generic;
79 phy->ops.check_reset_block = e1000_null_ops_generic;
80 phy->ops.commit = e1000_null_ops_generic;
81 phy->ops.force_speed_duplex = e1000_null_ops_generic;
82 phy->ops.get_cfg_done = e1000_null_ops_generic;
83 phy->ops.get_cable_length = e1000_null_ops_generic;
84 phy->ops.get_info = e1000_null_ops_generic;
85 phy->ops.read_reg = e1000_null_read_reg;
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);
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,

--- 36 unchanged lines hidden (view full) ---

78 phy->ops.check_polarity = e1000_null_ops_generic;
79 phy->ops.check_reset_block = e1000_null_ops_generic;
80 phy->ops.commit = e1000_null_ops_generic;
81 phy->ops.force_speed_duplex = e1000_null_ops_generic;
82 phy->ops.get_cfg_done = e1000_null_ops_generic;
83 phy->ops.get_cable_length = e1000_null_ops_generic;
84 phy->ops.get_info = e1000_null_ops_generic;
85 phy->ops.read_reg = e1000_null_read_reg;
86 phy->ops.read_reg_locked = e1000_null_read_reg;
86 phy->ops.release = e1000_null_phy_generic;
87 phy->ops.reset = e1000_null_ops_generic;
88 phy->ops.set_d0_lplu_state = e1000_null_lplu_state;
89 phy->ops.set_d3_lplu_state = e1000_null_lplu_state;
90 phy->ops.write_reg = e1000_null_write_reg;
87 phy->ops.release = e1000_null_phy_generic;
88 phy->ops.reset = e1000_null_ops_generic;
89 phy->ops.set_d0_lplu_state = e1000_null_lplu_state;
90 phy->ops.set_d3_lplu_state = e1000_null_lplu_state;
91 phy->ops.write_reg = e1000_null_write_reg;
92 phy->ops.write_reg_locked = e1000_null_write_reg;
91 phy->ops.power_up = e1000_null_phy_generic;
92 phy->ops.power_down = e1000_null_phy_generic;
93 phy->ops.cfg_on_link_up = e1000_null_ops_generic;
94}
95
96/**
97 * e1000_null_read_reg - No-op function, return 0
98 * @hw: pointer to the HW structure

--- 86 unchanged lines hidden (view full) ---

185
186 phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
187 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
188
189 if (phy->id != 0 && phy->id != PHY_REVISION_MASK)
190 goto out;
191
192 /*
93 phy->ops.power_up = e1000_null_phy_generic;
94 phy->ops.power_down = e1000_null_phy_generic;
95 phy->ops.cfg_on_link_up = e1000_null_ops_generic;
96}
97
98/**
99 * e1000_null_read_reg - No-op function, return 0
100 * @hw: pointer to the HW structure

--- 86 unchanged lines hidden (view full) ---

187
188 phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
189 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
190
191 if (phy->id != 0 && phy->id != PHY_REVISION_MASK)
192 goto out;
193
194 /*
193 * If the PHY ID is still unknown, we may have an 82577 without link.
194 * We will try again after setting Slow MDIC mode. No harm in trying
195 * again in this case since the PHY ID is unknown at this point anyway
195 * If the PHY ID is still unknown, we may have an 82577
196 * without link. We will try again after setting Slow MDIC
197 * mode. No harm in trying again in this case since the PHY
198 * ID is unknown at this point anyway.
196 */
199 */
200 ret_val = phy->ops.acquire(hw);
201 if (ret_val)
202 goto out;
197 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
198 if (ret_val)
199 goto out;
203 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
204 if (ret_val)
205 goto out;
206 phy->ops.release(hw);
200
201 retry_count++;
202 }
203out:
204 /* Revert to MDIO fast mode, if applicable */
207
208 retry_count++;
209 }
210out:
211 /* Revert to MDIO fast mode, if applicable */
205 if (retry_count)
212 if (retry_count) {
213 ret_val = phy->ops.acquire(hw);
214 if (ret_val)
215 return ret_val;
206 ret_val = e1000_set_mdio_slow_mode_hv(hw, FALSE);
216 ret_val = e1000_set_mdio_slow_mode_hv(hw, FALSE);
217 phy->ops.release(hw);
218 }
207
208 return ret_val;
209}
210
211/**
212 * e1000_phy_reset_dsp_generic - Reset PHY DSP
213 * @hw: pointer to the HW structure
214 *

--- 131 unchanged lines hidden (view full) ---

346 goto out;
347 }
348
349out:
350 return ret_val;
351}
352
353/**
219
220 return ret_val;
221}
222
223/**
224 * e1000_phy_reset_dsp_generic - Reset PHY DSP
225 * @hw: pointer to the HW structure
226 *

--- 131 unchanged lines hidden (view full) ---

358 goto out;
359 }
360
361out:
362 return ret_val;
363}
364
365/**
366 * e1000_read_phy_reg_i2c - Read PHY register using i2c
367 * @hw: pointer to the HW structure
368 * @offset: register offset to be read
369 * @data: pointer to the read data
370 *
371 * Reads the PHY register at offset using the i2c interface and stores the
372 * retrieved information in data.
373 **/
374s32 e1000_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data)
375{
376 struct e1000_phy_info *phy = &hw->phy;
377 u32 i, i2ccmd = 0;
378
379 DEBUGFUNC("e1000_read_phy_reg_i2c");
380
381 /*
382 * Set up Op-code, Phy Address, and register address in the I2CCMD
383 * register. The MAC will take care of interfacing with the
384 * PHY to retrieve the desired data.
385 */
386 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
387 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
388 (E1000_I2CCMD_OPCODE_READ));
389
390 E1000_WRITE_REG(hw, E1000_I2CCMD, i2ccmd);
391
392 /* Poll the ready bit to see if the I2C read completed */
393 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
394 usec_delay(50);
395 i2ccmd = E1000_READ_REG(hw, E1000_I2CCMD);
396 if (i2ccmd & E1000_I2CCMD_READY)
397 break;
398 }
399 if (!(i2ccmd & E1000_I2CCMD_READY)) {
400 DEBUGOUT("I2CCMD Read did not complete\n");
401 return -E1000_ERR_PHY;
402 }
403 if (i2ccmd & E1000_I2CCMD_ERROR) {
404 DEBUGOUT("I2CCMD Error bit set\n");
405 return -E1000_ERR_PHY;
406 }
407
408 /* Need to byte-swap the 16-bit value. */
409 *data = ((i2ccmd >> 8) & 0x00FF) | ((i2ccmd << 8) & 0xFF00);
410
411 return E1000_SUCCESS;
412}
413
414/**
415 * e1000_write_phy_reg_i2c - Write PHY register using i2c
416 * @hw: pointer to the HW structure
417 * @offset: register offset to write to
418 * @data: data to write at register offset
419 *
420 * Writes the data to PHY register at the offset using the i2c interface.
421 **/
422s32 e1000_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data)
423{
424 struct e1000_phy_info *phy = &hw->phy;
425 u32 i, i2ccmd = 0;
426 u16 phy_data_swapped;
427
428 DEBUGFUNC("e1000_write_phy_reg_i2c");
429
430 /* Swap the data bytes for the I2C interface */
431 phy_data_swapped = ((data >> 8) & 0x00FF) | ((data << 8) & 0xFF00);
432
433 /*
434 * Set up Op-code, Phy Address, and register address in the I2CCMD
435 * register. The MAC will take care of interfacing with the
436 * PHY to retrieve the desired data.
437 */
438 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
439 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
440 E1000_I2CCMD_OPCODE_WRITE |
441 phy_data_swapped);
442
443 E1000_WRITE_REG(hw, E1000_I2CCMD, i2ccmd);
444
445 /* Poll the ready bit to see if the I2C read completed */
446 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
447 usec_delay(50);
448 i2ccmd = E1000_READ_REG(hw, E1000_I2CCMD);
449 if (i2ccmd & E1000_I2CCMD_READY)
450 break;
451 }
452 if (!(i2ccmd & E1000_I2CCMD_READY)) {
453 DEBUGOUT("I2CCMD Write did not complete\n");
454 return -E1000_ERR_PHY;
455 }
456 if (i2ccmd & E1000_I2CCMD_ERROR) {
457 DEBUGOUT("I2CCMD Error bit set\n");
458 return -E1000_ERR_PHY;
459 }
460
461 return E1000_SUCCESS;
462}
463
464/**
354 * e1000_read_phy_reg_m88 - Read m88 PHY register
355 * @hw: pointer to the HW structure
356 * @offset: register offset to be read
357 * @data: pointer to the read data
358 *
359 * Acquires semaphore, if necessary, then reads the PHY register at offset
360 * and storing the retrieved information in data. Release any acquired
361 * semaphores before exiting.

--- 47 unchanged lines hidden (view full) ---

409
410 hw->phy.ops.release(hw);
411
412out:
413 return ret_val;
414}
415
416/**
465 * e1000_read_phy_reg_m88 - Read m88 PHY register
466 * @hw: pointer to the HW structure
467 * @offset: register offset to be read
468 * @data: pointer to the read data
469 *
470 * Acquires semaphore, if necessary, then reads the PHY register at offset
471 * and storing the retrieved information in data. Release any acquired
472 * semaphores before exiting.

--- 47 unchanged lines hidden (view full) ---

520
521 hw->phy.ops.release(hw);
522
523out:
524 return ret_val;
525}
526
527/**
417 * e1000_read_phy_reg_igp - Read igp PHY register
528 * __e1000_read_phy_reg_igp - Read igp PHY register
418 * @hw: pointer to the HW structure
419 * @offset: register offset to be read
420 * @data: pointer to the read data
529 * @hw: pointer to the HW structure
530 * @offset: register offset to be read
531 * @data: pointer to the read data
532 * @locked: semaphore has already been acquired or not
421 *
422 * Acquires semaphore, if necessary, then reads the PHY register at offset
533 *
534 * Acquires semaphore, if necessary, then reads the PHY register at offset
423 * and storing the retrieved information in data. Release any acquired
535 * and stores the retrieved information in data. Release any acquired
424 * semaphores before exiting.
425 **/
536 * semaphores before exiting.
537 **/
426s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
538static s32 __e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data,
539 bool locked)
427{
428 s32 ret_val = E1000_SUCCESS;
429
540{
541 s32 ret_val = E1000_SUCCESS;
542
430 DEBUGFUNC("e1000_read_phy_reg_igp");
543 DEBUGFUNC("__e1000_read_phy_reg_igp");
431
544
432 if (!(hw->phy.ops.acquire))
433 goto out;
545 if (!locked) {
546 if (!(hw->phy.ops.acquire))
547 goto out;
434
548
435 ret_val = hw->phy.ops.acquire(hw);
436 if (ret_val)
437 goto out;
549 ret_val = hw->phy.ops.acquire(hw);
550 if (ret_val)
551 goto out;
552 }
438
439 if (offset > MAX_PHY_MULTI_PAGE_REG) {
440 ret_val = e1000_write_phy_reg_mdic(hw,
441 IGP01E1000_PHY_PAGE_SELECT,
442 (u16)offset);
553
554 if (offset > MAX_PHY_MULTI_PAGE_REG) {
555 ret_val = e1000_write_phy_reg_mdic(hw,
556 IGP01E1000_PHY_PAGE_SELECT,
557 (u16)offset);
443 if (ret_val) {
444 hw->phy.ops.release(hw);
445 goto out;
446 }
558 if (ret_val)
559 goto release;
447 }
448
449 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
450 data);
451
560 }
561
562 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
563 data);
564
452 hw->phy.ops.release(hw);
453
565release:
566 if (!locked)
567 hw->phy.ops.release(hw);
454out:
455 return ret_val;
456}
457
458/**
568out:
569 return ret_val;
570}
571
572/**
573 * e1000_read_phy_reg_igp - Read igp PHY register
574 * @hw: pointer to the HW structure
575 * @offset: register offset to be read
576 * @data: pointer to the read data
577 *
578 * Acquires semaphore then reads the PHY register at offset and stores the
579 * retrieved information in data.
580 * Release the acquired semaphore before exiting.
581 **/
582s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
583{
584 return __e1000_read_phy_reg_igp(hw, offset, data, FALSE);
585}
586
587/**
588 * e1000_read_phy_reg_igp_locked - Read igp PHY register
589 * @hw: pointer to the HW structure
590 * @offset: register offset to be read
591 * @data: pointer to the read data
592 *
593 * Reads the PHY register at offset and stores the retrieved information
594 * in data. Assumes semaphore already acquired.
595 **/
596s32 e1000_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data)
597{
598 return __e1000_read_phy_reg_igp(hw, offset, data, TRUE);
599}
600
601/**
459 * e1000_write_phy_reg_igp - Write igp PHY register
460 * @hw: pointer to the HW structure
461 * @offset: register offset to write to
462 * @data: data to write at register offset
602 * e1000_write_phy_reg_igp - Write igp PHY register
603 * @hw: pointer to the HW structure
604 * @offset: register offset to write to
605 * @data: data to write at register offset
606 * @locked: semaphore has already been acquired or not
463 *
464 * Acquires semaphore, if necessary, then writes the data to PHY register
465 * at the offset. Release any acquired semaphores before exiting.
466 **/
607 *
608 * Acquires semaphore, if necessary, then writes the data to PHY register
609 * at the offset. Release any acquired semaphores before exiting.
610 **/
467s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
611static s32 __e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data,
612 bool locked)
468{
469 s32 ret_val = E1000_SUCCESS;
470
471 DEBUGFUNC("e1000_write_phy_reg_igp");
472
613{
614 s32 ret_val = E1000_SUCCESS;
615
616 DEBUGFUNC("e1000_write_phy_reg_igp");
617
473 if (!(hw->phy.ops.acquire))
474 goto out;
618 if (!locked) {
619 if (!(hw->phy.ops.acquire))
620 goto out;
475
621
476 ret_val = hw->phy.ops.acquire(hw);
477 if (ret_val)
478 goto out;
622 ret_val = hw->phy.ops.acquire(hw);
623 if (ret_val)
624 goto out;
625 }
479
480 if (offset > MAX_PHY_MULTI_PAGE_REG) {
481 ret_val = e1000_write_phy_reg_mdic(hw,
482 IGP01E1000_PHY_PAGE_SELECT,
483 (u16)offset);
626
627 if (offset > MAX_PHY_MULTI_PAGE_REG) {
628 ret_val = e1000_write_phy_reg_mdic(hw,
629 IGP01E1000_PHY_PAGE_SELECT,
630 (u16)offset);
484 if (ret_val) {
485 hw->phy.ops.release(hw);
486 goto out;
487 }
631 if (ret_val)
632 goto release;
488 }
489
490 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
491 data);
492
633 }
634
635 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
636 data);
637
493 hw->phy.ops.release(hw);
638release:
639 if (!locked)
640 hw->phy.ops.release(hw);
494
495out:
496 return ret_val;
497}
498
499/**
641
642out:
643 return ret_val;
644}
645
646/**
500 * e1000_read_kmrn_reg_generic - Read kumeran register
647 * e1000_write_phy_reg_igp - Write igp PHY register
501 * @hw: pointer to the HW structure
648 * @hw: pointer to the HW structure
649 * @offset: register offset to write to
650 * @data: data to write at register offset
651 *
652 * Acquires semaphore then writes the data to PHY register
653 * at the offset. Release any acquired semaphores before exiting.
654 **/
655s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
656{
657 return __e1000_write_phy_reg_igp(hw, offset, data, FALSE);
658}
659
660/**
661 * e1000_write_phy_reg_igp_locked - Write igp PHY register
662 * @hw: pointer to the HW structure
663 * @offset: register offset to write to
664 * @data: data to write at register offset
665 *
666 * Writes the data to PHY register at the offset.
667 * Assumes semaphore already acquired.
668 **/
669s32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data)
670{
671 return __e1000_write_phy_reg_igp(hw, offset, data, TRUE);
672}
673
674/**
675 * __e1000_read_kmrn_reg - Read kumeran register
676 * @hw: pointer to the HW structure
502 * @offset: register offset to be read
503 * @data: pointer to the read data
677 * @offset: register offset to be read
678 * @data: pointer to the read data
679 * @locked: semaphore has already been acquired or not
504 *
505 * Acquires semaphore, if necessary. Then reads the PHY register at offset
506 * using the kumeran interface. The information retrieved is stored in data.
507 * Release any acquired semaphores before exiting.
508 **/
680 *
681 * Acquires semaphore, if necessary. Then reads the PHY register at offset
682 * using the kumeran interface. The information retrieved is stored in data.
683 * Release any acquired semaphores before exiting.
684 **/
509s32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data)
685static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data,
686 bool locked)
510{
511 u32 kmrnctrlsta;
512 s32 ret_val = E1000_SUCCESS;
513
687{
688 u32 kmrnctrlsta;
689 s32 ret_val = E1000_SUCCESS;
690
514 DEBUGFUNC("e1000_read_kmrn_reg_generic");
691 DEBUGFUNC("__e1000_read_kmrn_reg");
515
692
516 if (!(hw->phy.ops.acquire))
517 goto out;
693 if (!locked) {
694 if (!(hw->phy.ops.acquire))
695 goto out;
518
696
519 ret_val = hw->phy.ops.acquire(hw);
520 if (ret_val)
521 goto out;
697 ret_val = hw->phy.ops.acquire(hw);
698 if (ret_val)
699 goto out;
700 }
522
523 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
524 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
525 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
526
527 usec_delay(2);
528
529 kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA);
530 *data = (u16)kmrnctrlsta;
531
701
702 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
703 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
704 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
705
706 usec_delay(2);
707
708 kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA);
709 *data = (u16)kmrnctrlsta;
710
532 hw->phy.ops.release(hw);
711 if (!locked)
712 hw->phy.ops.release(hw);
533
534out:
535 return ret_val;
536}
537
538/**
713
714out:
715 return ret_val;
716}
717
718/**
539 * e1000_write_kmrn_reg_generic - Write kumeran register
719 * e1000_read_kmrn_reg_generic - Read kumeran register
540 * @hw: pointer to the HW structure
720 * @hw: pointer to the HW structure
721 * @offset: register offset to be read
722 * @data: pointer to the read data
723 *
724 * Acquires semaphore then reads the PHY register at offset using the
725 * kumeran interface. The information retrieved is stored in data.
726 * Release the acquired semaphore before exiting.
727 **/
728s32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data)
729{
730 return __e1000_read_kmrn_reg(hw, offset, data, FALSE);
731}
732
733/**
734 * e1000_read_kmrn_reg_locked - Read kumeran register
735 * @hw: pointer to the HW structure
736 * @offset: register offset to be read
737 * @data: pointer to the read data
738 *
739 * Reads the PHY register at offset using the kumeran interface. The
740 * information retrieved is stored in data.
741 * Assumes semaphore already acquired.
742 **/
743s32 e1000_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data)
744{
745 return __e1000_read_kmrn_reg(hw, offset, data, TRUE);
746}
747
748/**
749 * __e1000_write_kmrn_reg - Write kumeran register
750 * @hw: pointer to the HW structure
541 * @offset: register offset to write to
542 * @data: data to write at register offset
751 * @offset: register offset to write to
752 * @data: data to write at register offset
753 * @locked: semaphore has already been acquired or not
543 *
544 * Acquires semaphore, if necessary. Then write the data to PHY register
545 * at the offset using the kumeran interface. Release any acquired semaphores
546 * before exiting.
547 **/
754 *
755 * Acquires semaphore, if necessary. Then write the data to PHY register
756 * at the offset using the kumeran interface. Release any acquired semaphores
757 * before exiting.
758 **/
548s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data)
759static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data,
760 bool locked)
549{
550 u32 kmrnctrlsta;
551 s32 ret_val = E1000_SUCCESS;
552
553 DEBUGFUNC("e1000_write_kmrn_reg_generic");
554
761{
762 u32 kmrnctrlsta;
763 s32 ret_val = E1000_SUCCESS;
764
765 DEBUGFUNC("e1000_write_kmrn_reg_generic");
766
555 if (!(hw->phy.ops.acquire))
556 goto out;
767 if (!locked) {
768 if (!(hw->phy.ops.acquire))
769 goto out;
557
770
558 ret_val = hw->phy.ops.acquire(hw);
559 if (ret_val)
560 goto out;
771 ret_val = hw->phy.ops.acquire(hw);
772 if (ret_val)
773 goto out;
774 }
561
562 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
563 E1000_KMRNCTRLSTA_OFFSET) | data;
564 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
565
566 usec_delay(2);
775
776 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
777 E1000_KMRNCTRLSTA_OFFSET) | data;
778 E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
779
780 usec_delay(2);
567 hw->phy.ops.release(hw);
568
781
782 if (!locked)
783 hw->phy.ops.release(hw);
784
569out:
570 return ret_val;
571}
572
573/**
785out:
786 return ret_val;
787}
788
789/**
790 * e1000_write_kmrn_reg_generic - Write kumeran register
791 * @hw: pointer to the HW structure
792 * @offset: register offset to write to
793 * @data: data to write at register offset
794 *
795 * Acquires semaphore then writes the data to the PHY register at the offset
796 * using the kumeran interface. Release the acquired semaphore before exiting.
797 **/
798s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data)
799{
800 return __e1000_write_kmrn_reg(hw, offset, data, FALSE);
801}
802
803/**
804 * e1000_write_kmrn_reg_locked - Write kumeran register
805 * @hw: pointer to the HW structure
806 * @offset: register offset to write to
807 * @data: data to write at register offset
808 *
809 * Write the data to PHY register at the offset using the kumeran interface.
810 * Assumes semaphore already acquired.
811 **/
812s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data)
813{
814 return __e1000_write_kmrn_reg(hw, offset, data, TRUE);
815}
816
817/**
574 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
575 * @hw: pointer to the HW structure
576 *
577 * Sets up Carrier-sense on Transmit and downshift values.
578 **/
579s32 e1000_copper_link_setup_82577(struct e1000_hw *hw)
580{
581 struct e1000_phy_info *phy = &hw->phy;
582 s32 ret_val;
583 u16 phy_data;
584
585 DEBUGFUNC("e1000_copper_link_setup_82577");
586
587 if (phy->reset_disable) {
588 ret_val = E1000_SUCCESS;
589 goto out;
590 }
591
818 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
819 * @hw: pointer to the HW structure
820 *
821 * Sets up Carrier-sense on Transmit and downshift values.
822 **/
823s32 e1000_copper_link_setup_82577(struct e1000_hw *hw)
824{
825 struct e1000_phy_info *phy = &hw->phy;
826 s32 ret_val;
827 u16 phy_data;
828
829 DEBUGFUNC("e1000_copper_link_setup_82577");
830
831 if (phy->reset_disable) {
832 ret_val = E1000_SUCCESS;
833 goto out;
834 }
835
836 if (phy->type == e1000_phy_82580) {
837 ret_val = hw->phy.ops.reset(hw);
838 if (ret_val) {
839 DEBUGOUT("Error resetting the PHY.\n");
840 goto out;
841 }
842 }
843
592 /* Enable CRS on TX. This must be set for half-duplex operation. */
593 ret_val = phy->ops.read_reg(hw, I82577_CFG_REG, &phy_data);
594 if (ret_val)
595 goto out;
596
597 phy_data |= I82577_CFG_ASSERT_CRS_ON_TX;
598
599 /* Enable downshift */
600 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT;
601
602 ret_val = phy->ops.write_reg(hw, I82577_CFG_REG, phy_data);
844 /* Enable CRS on TX. This must be set for half-duplex operation. */
845 ret_val = phy->ops.read_reg(hw, I82577_CFG_REG, &phy_data);
846 if (ret_val)
847 goto out;
848
849 phy_data |= I82577_CFG_ASSERT_CRS_ON_TX;
850
851 /* Enable downshift */
852 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT;
853
854 ret_val = phy->ops.write_reg(hw, I82577_CFG_REG, phy_data);
603 if (ret_val)
604 goto out;
605
855
606 /* Set number of link attempts before downshift */
607 ret_val = phy->ops.read_reg(hw, I82577_CTRL_REG, &phy_data);
608 if (ret_val)
609 goto out;
610 phy_data &= ~I82577_CTRL_DOWNSHIFT_MASK;
611 ret_val = phy->ops.write_reg(hw, I82577_CTRL_REG, phy_data);
612
613out:
614 return ret_val;
615}
616
617/**
618 * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link
619 * @hw: pointer to the HW structure
620 *

--- 700 unchanged lines hidden (view full) ---

1321 DEBUGOUT("Waiting for forced speed/duplex link on M88 phy.\n");
1322
1323 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
1324 100000, &link);
1325 if (ret_val)
1326 goto out;
1327
1328 if (!link) {
856out:
857 return ret_val;
858}
859
860/**
861 * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link
862 * @hw: pointer to the HW structure
863 *

--- 700 unchanged lines hidden (view full) ---

1564 DEBUGOUT("Waiting for forced speed/duplex link on M88 phy.\n");
1565
1566 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
1567 100000, &link);
1568 if (ret_val)
1569 goto out;
1570
1571 if (!link) {
1329 /*
1330 * We didn't get link.
1331 * Reset the DSP and cross our fingers.
1332 */
1333 ret_val = phy->ops.write_reg(hw,
1334 M88E1000_PHY_PAGE_SELECT,
1335 0x001d);
1336 if (ret_val)
1337 goto out;
1338 ret_val = e1000_phy_reset_dsp_generic(hw);
1339 if (ret_val)
1340 goto out;
1572 if (hw->phy.type != e1000_phy_m88) {
1573 DEBUGOUT("Link taking longer than expected.\n");
1574 } else {
1575 /*
1576 * We didn't get link.
1577 * Reset the DSP and cross our fingers.
1578 */
1579 ret_val = phy->ops.write_reg(hw,
1580 M88E1000_PHY_PAGE_SELECT,
1581 0x001d);
1582 if (ret_val)
1583 goto out;
1584 ret_val = e1000_phy_reset_dsp_generic(hw);
1585 if (ret_val)
1586 goto out;
1587 }
1341 }
1342
1343 /* Try once more */
1344 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
1345 100000, &link);
1346 if (ret_val)
1347 goto out;
1348 }
1349
1588 }
1589
1590 /* Try once more */
1591 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
1592 100000, &link);
1593 if (ret_val)
1594 goto out;
1595 }
1596
1597 if (hw->phy.type != e1000_phy_m88)
1598 goto out;
1599
1350 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
1351 if (ret_val)
1352 goto out;
1353
1354 /*
1355 * Resetting the phy means we need to re-force TX_CLK in the
1356 * Extended PHY Specific Control Register to 25MHz clock from
1357 * the reset value of 2.5MHz.

--- 30 unchanged lines hidden (view full) ---

1388{
1389 struct e1000_phy_info *phy = &hw->phy;
1390 s32 ret_val;
1391 u16 data;
1392 bool link;
1393
1394 DEBUGFUNC("e1000_phy_force_speed_duplex_ife");
1395
1600 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
1601 if (ret_val)
1602 goto out;
1603
1604 /*
1605 * Resetting the phy means we need to re-force TX_CLK in the
1606 * Extended PHY Specific Control Register to 25MHz clock from
1607 * the reset value of 2.5MHz.

--- 30 unchanged lines hidden (view full) ---

1638{
1639 struct e1000_phy_info *phy = &hw->phy;
1640 s32 ret_val;
1641 u16 data;
1642 bool link;
1643
1644 DEBUGFUNC("e1000_phy_force_speed_duplex_ife");
1645
1396 if (phy->type != e1000_phy_ife) {
1397 ret_val = e1000_phy_force_speed_duplex_igp(hw);
1398 goto out;
1399 }
1400
1401 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data);
1402 if (ret_val)
1403 goto out;
1404
1405 e1000_phy_force_speed_duplex_setup(hw, &data);
1406
1407 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data);
1408 if (ret_val)

--- 211 unchanged lines hidden (view full) ---

1620
1621 DEBUGFUNC("e1000_check_downshift_generic");
1622
1623 switch (phy->type) {
1624 case e1000_phy_m88:
1625 case e1000_phy_gg82563:
1626 case e1000_phy_bm:
1627 case e1000_phy_82578:
1646 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data);
1647 if (ret_val)
1648 goto out;
1649
1650 e1000_phy_force_speed_duplex_setup(hw, &data);
1651
1652 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data);
1653 if (ret_val)

--- 211 unchanged lines hidden (view full) ---

1865
1866 DEBUGFUNC("e1000_check_downshift_generic");
1867
1868 switch (phy->type) {
1869 case e1000_phy_m88:
1870 case e1000_phy_gg82563:
1871 case e1000_phy_bm:
1872 case e1000_phy_82578:
1628 case e1000_phy_82577:
1629 offset = M88E1000_PHY_SPEC_STATUS;
1630 mask = M88E1000_PSSR_DOWNSHIFT;
1631 break;
1873 offset = M88E1000_PHY_SPEC_STATUS;
1874 mask = M88E1000_PSSR_DOWNSHIFT;
1875 break;
1632 case e1000_phy_igp_2:
1633 case e1000_phy_igp:
1876 case e1000_phy_igp:
1877 case e1000_phy_igp_2:
1634 case e1000_phy_igp_3:
1635 offset = IGP01E1000_PHY_LINK_HEALTH;
1636 mask = IGP01E1000_PLHR_SS_DOWNGRADE;
1637 break;
1638 default:
1639 /* speed downshift not supported */
1640 phy->speed_downgraded = FALSE;
1641 ret_val = E1000_SUCCESS;

--- 178 unchanged lines hidden (view full) ---

1820
1821 for (i = 0; i < iterations; i++) {
1822 /*
1823 * Some PHYs require the PHY_STATUS register to be read
1824 * twice due to the link bit being sticky. No harm doing
1825 * it across the board.
1826 */
1827 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
1878 case e1000_phy_igp_3:
1879 offset = IGP01E1000_PHY_LINK_HEALTH;
1880 mask = IGP01E1000_PLHR_SS_DOWNGRADE;
1881 break;
1882 default:
1883 /* speed downshift not supported */
1884 phy->speed_downgraded = FALSE;
1885 ret_val = E1000_SUCCESS;

--- 178 unchanged lines hidden (view full) ---

2064
2065 for (i = 0; i < iterations; i++) {
2066 /*
2067 * Some PHYs require the PHY_STATUS register to be read
2068 * twice due to the link bit being sticky. No harm doing
2069 * it across the board.
2070 */
2071 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
1828 if (ret_val) {
2072 if (ret_val)
1829 /*
1830 * If the first read fails, another entity may have
1831 * ownership of the resources, wait and try again to
1832 * see if they have relinquished the resources yet.
1833 */
1834 usec_delay(usec_interval);
2073 /*
2074 * If the first read fails, another entity may have
2075 * ownership of the resources, wait and try again to
2076 * see if they have relinquished the resources yet.
2077 */
2078 usec_delay(usec_interval);
1835 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS,
1836 &phy_status);
1837 }
2079 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
1838 if (ret_val)
1839 break;
1840 if (phy_status & MII_SR_LINK_STATUS)
1841 break;
1842 if (usec_interval >= 1000)
1843 msec_delay_irq(usec_interval/1000);
1844 else
1845 usec_delay(usec_interval);

--- 28 unchanged lines hidden (view full) ---

1874 DEBUGFUNC("e1000_get_cable_length_m88");
1875
1876 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
1877 if (ret_val)
1878 goto out;
1879
1880 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
1881 M88E1000_PSSR_CABLE_LENGTH_SHIFT;
2080 if (ret_val)
2081 break;
2082 if (phy_status & MII_SR_LINK_STATUS)
2083 break;
2084 if (usec_interval >= 1000)
2085 msec_delay_irq(usec_interval/1000);
2086 else
2087 usec_delay(usec_interval);

--- 28 unchanged lines hidden (view full) ---

2116 DEBUGFUNC("e1000_get_cable_length_m88");
2117
2118 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
2119 if (ret_val)
2120 goto out;
2121
2122 index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
2123 M88E1000_PSSR_CABLE_LENGTH_SHIFT;
1882 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE + 1) {
1883 ret_val = E1000_ERR_PHY;
2124 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) {
2125 ret_val = -E1000_ERR_PHY;
1884 goto out;
1885 }
1886
1887 phy->min_cable_length = e1000_m88_cable_length_table[index];
2126 goto out;
2127 }
2128
2129 phy->min_cable_length = e1000_m88_cable_length_table[index];
1888 phy->max_cable_length = e1000_m88_cable_length_table[index+1];
2130 phy->max_cable_length = e1000_m88_cable_length_table[index + 1];
1889
1890 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
1891
1892out:
1893 return ret_val;
1894}
1895
1896/**

--- 84 unchanged lines hidden (view full) ---

1981{
1982 struct e1000_phy_info *phy = &hw->phy;
1983 s32 ret_val;
1984 u16 phy_data;
1985 bool link;
1986
1987 DEBUGFUNC("e1000_get_phy_info_m88");
1988
2131
2132 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
2133
2134out:
2135 return ret_val;
2136}
2137
2138/**

--- 84 unchanged lines hidden (view full) ---

2223{
2224 struct e1000_phy_info *phy = &hw->phy;
2225 s32 ret_val;
2226 u16 phy_data;
2227 bool link;
2228
2229 DEBUGFUNC("e1000_get_phy_info_m88");
2230
1989 if (hw->phy.media_type != e1000_media_type_copper) {
2231 if (phy->media_type != e1000_media_type_copper) {
1990 DEBUGOUT("Phy info is only valid for copper media\n");
1991 ret_val = -E1000_ERR_CONFIG;
1992 goto out;
1993 }
1994
1995 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1996 if (ret_val)
1997 goto out;

--- 85 unchanged lines hidden (view full) ---

2083 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data);
2084 if (ret_val)
2085 goto out;
2086
2087 phy->is_mdix = (data & IGP01E1000_PSSR_MDIX) ? TRUE : FALSE;
2088
2089 if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
2090 IGP01E1000_PSSR_SPEED_1000MBPS) {
2232 DEBUGOUT("Phy info is only valid for copper media\n");
2233 ret_val = -E1000_ERR_CONFIG;
2234 goto out;
2235 }
2236
2237 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
2238 if (ret_val)
2239 goto out;

--- 85 unchanged lines hidden (view full) ---

2325 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data);
2326 if (ret_val)
2327 goto out;
2328
2329 phy->is_mdix = (data & IGP01E1000_PSSR_MDIX) ? TRUE : FALSE;
2330
2331 if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
2332 IGP01E1000_PSSR_SPEED_1000MBPS) {
2091 ret_val = hw->phy.ops.get_cable_length(hw);
2333 ret_val = phy->ops.get_cable_length(hw);
2092 if (ret_val)
2093 goto out;
2094
2095 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data);
2096 if (ret_val)
2097 goto out;
2098
2099 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS)

--- 9 unchanged lines hidden (view full) ---

2109 phy->remote_rx = e1000_1000t_rx_status_undefined;
2110 }
2111
2112out:
2113 return ret_val;
2114}
2115
2116/**
2334 if (ret_val)
2335 goto out;
2336
2337 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data);
2338 if (ret_val)
2339 goto out;
2340
2341 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS)

--- 9 unchanged lines hidden (view full) ---

2351 phy->remote_rx = e1000_1000t_rx_status_undefined;
2352 }
2353
2354out:
2355 return ret_val;
2356}
2357
2358/**
2359 * e1000_get_phy_info_ife - Retrieves various IFE PHY states
2360 * @hw: pointer to the HW structure
2361 *
2362 * Populates "phy" structure with various feature states.
2363 **/
2364s32 e1000_get_phy_info_ife(struct e1000_hw *hw)
2365{
2366 struct e1000_phy_info *phy = &hw->phy;
2367 s32 ret_val;
2368 u16 data;
2369 bool link;
2370
2371 DEBUGFUNC("e1000_get_phy_info_ife");
2372
2373 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
2374 if (ret_val)
2375 goto out;
2376
2377 if (!link) {
2378 DEBUGOUT("Phy info is only valid if link is up\n");
2379 ret_val = -E1000_ERR_CONFIG;
2380 goto out;
2381 }
2382
2383 ret_val = phy->ops.read_reg(hw, IFE_PHY_SPECIAL_CONTROL, &data);
2384 if (ret_val)
2385 goto out;
2386 phy->polarity_correction = (data & IFE_PSC_AUTO_POLARITY_DISABLE)
2387 ? FALSE : TRUE;
2388
2389 if (phy->polarity_correction) {
2390 ret_val = e1000_check_polarity_ife(hw);
2391 if (ret_val)
2392 goto out;
2393 } else {
2394 /* Polarity is forced */
2395 phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY)
2396 ? e1000_rev_polarity_reversed
2397 : e1000_rev_polarity_normal;
2398 }
2399
2400 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data);
2401 if (ret_val)
2402 goto out;
2403
2404 phy->is_mdix = (data & IFE_PMC_MDIX_STATUS) ? TRUE : FALSE;
2405
2406 /* The following parameters are undefined for 10/100 operation. */
2407 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
2408 phy->local_rx = e1000_1000t_rx_status_undefined;
2409 phy->remote_rx = e1000_1000t_rx_status_undefined;
2410
2411out:
2412 return ret_val;
2413}
2414
2415/**
2117 * e1000_phy_sw_reset_generic - PHY software reset
2118 * @hw: pointer to the HW structure
2119 *
2120 * Does a software reset of the PHY by reading the PHY control register and
2121 * setting/write the control register reset bit to the PHY.
2122 **/
2123s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw)
2124{

--- 172 unchanged lines hidden (view full) ---

2297 * @phy_id: phy_id read from the phy
2298 *
2299 * Returns the phy type from the id.
2300 **/
2301enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id)
2302{
2303 enum e1000_phy_type phy_type = e1000_phy_unknown;
2304
2416 * e1000_phy_sw_reset_generic - PHY software reset
2417 * @hw: pointer to the HW structure
2418 *
2419 * Does a software reset of the PHY by reading the PHY control register and
2420 * setting/write the control register reset bit to the PHY.
2421 **/
2422s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw)
2423{

--- 172 unchanged lines hidden (view full) ---

2596 * @phy_id: phy_id read from the phy
2597 *
2598 * Returns the phy type from the id.
2599 **/
2600enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id)
2601{
2602 enum e1000_phy_type phy_type = e1000_phy_unknown;
2603
2305 switch (phy_id) {
2604 switch (phy_id) {
2306 case M88E1000_I_PHY_ID:
2307 case M88E1000_E_PHY_ID:
2308 case M88E1111_I_PHY_ID:
2309 case M88E1011_I_PHY_ID:
2310 phy_type = e1000_phy_m88;
2311 break;
2312 case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
2313 phy_type = e1000_phy_igp_2;

--- 14 unchanged lines hidden (view full) ---

2328 phy_type = e1000_phy_bm;
2329 break;
2330 case I82578_E_PHY_ID:
2331 phy_type = e1000_phy_82578;
2332 break;
2333 case I82577_E_PHY_ID:
2334 phy_type = e1000_phy_82577;
2335 break;
2605 case M88E1000_I_PHY_ID:
2606 case M88E1000_E_PHY_ID:
2607 case M88E1111_I_PHY_ID:
2608 case M88E1011_I_PHY_ID:
2609 phy_type = e1000_phy_m88;
2610 break;
2611 case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
2612 phy_type = e1000_phy_igp_2;

--- 14 unchanged lines hidden (view full) ---

2627 phy_type = e1000_phy_bm;
2628 break;
2629 case I82578_E_PHY_ID:
2630 phy_type = e1000_phy_82578;
2631 break;
2632 case I82577_E_PHY_ID:
2633 phy_type = e1000_phy_82577;
2634 break;
2635 case I82580_I_PHY_ID:
2636 phy_type = e1000_phy_82580;
2637 break;
2336 default:
2337 phy_type = e1000_phy_unknown;
2338 break;
2339 }
2340 return phy_type;
2341}
2342
2343/**

--- 67 unchanged lines hidden (view full) ---

2411{
2412 s32 ret_val;
2413 u32 page_select = 0;
2414 u32 page = offset >> IGP_PAGE_SHIFT;
2415 u32 page_shift = 0;
2416
2417 DEBUGFUNC("e1000_write_phy_reg_bm");
2418
2638 default:
2639 phy_type = e1000_phy_unknown;
2640 break;
2641 }
2642 return phy_type;
2643}
2644
2645/**

--- 67 unchanged lines hidden (view full) ---

2713{
2714 s32 ret_val;
2715 u32 page_select = 0;
2716 u32 page = offset >> IGP_PAGE_SHIFT;
2717 u32 page_shift = 0;
2718
2719 DEBUGFUNC("e1000_write_phy_reg_bm");
2720
2721 ret_val = hw->phy.ops.acquire(hw);
2722 if (ret_val)
2723 return ret_val;
2724
2419 /* Page 800 works differently than the rest so it has its own func */
2420 if (page == BM_WUC_PAGE) {
2421 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2422 FALSE);
2423 goto out;
2424 }
2425
2725 /* Page 800 works differently than the rest so it has its own func */
2726 if (page == BM_WUC_PAGE) {
2727 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2728 FALSE);
2729 goto out;
2730 }
2731
2426 ret_val = hw->phy.ops.acquire(hw);
2427 if (ret_val)
2428 goto out;
2429
2430 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2431
2432 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2433 /*
2434 * Page select is register 31 for phy address 1 and 22 for
2435 * phy address 2 and 3. Page select is shifted only for
2436 * phy address 1.
2437 */
2438 if (hw->phy.addr == 1) {
2439 page_shift = IGP_PAGE_SHIFT;
2440 page_select = IGP01E1000_PHY_PAGE_SELECT;
2441 } else {
2442 page_shift = 0;
2443 page_select = BM_PHY_PAGE_SELECT;
2444 }
2445
2446 /* Page is shifted left, PHY expects (page x 32) */
2447 ret_val = e1000_write_phy_reg_mdic(hw, page_select,
2448 (page << page_shift));
2732 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2733
2734 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2735 /*
2736 * Page select is register 31 for phy address 1 and 22 for
2737 * phy address 2 and 3. Page select is shifted only for
2738 * phy address 1.
2739 */
2740 if (hw->phy.addr == 1) {
2741 page_shift = IGP_PAGE_SHIFT;
2742 page_select = IGP01E1000_PHY_PAGE_SELECT;
2743 } else {
2744 page_shift = 0;
2745 page_select = BM_PHY_PAGE_SELECT;
2746 }
2747
2748 /* Page is shifted left, PHY expects (page x 32) */
2749 ret_val = e1000_write_phy_reg_mdic(hw, page_select,
2750 (page << page_shift));
2449 if (ret_val) {
2450 hw->phy.ops.release(hw);
2751 if (ret_val)
2451 goto out;
2752 goto out;
2452 }
2453 }
2454
2455 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2456 data);
2457
2753 }
2754
2755 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2756 data);
2757
2458 hw->phy.ops.release(hw);
2459
2460out:
2758out:
2759 hw->phy.ops.release(hw);
2461 return ret_val;
2462}
2463
2464/**
2465 * e1000_read_phy_reg_bm - Read BM PHY register
2466 * @hw: pointer to the HW structure
2467 * @offset: register offset to be read
2468 * @data: pointer to the read data

--- 6 unchanged lines hidden (view full) ---

2475{
2476 s32 ret_val;
2477 u32 page_select = 0;
2478 u32 page = offset >> IGP_PAGE_SHIFT;
2479 u32 page_shift = 0;
2480
2481 DEBUGFUNC("e1000_read_phy_reg_bm");
2482
2760 return ret_val;
2761}
2762
2763/**
2764 * e1000_read_phy_reg_bm - Read BM PHY register
2765 * @hw: pointer to the HW structure
2766 * @offset: register offset to be read
2767 * @data: pointer to the read data

--- 6 unchanged lines hidden (view full) ---

2774{
2775 s32 ret_val;
2776 u32 page_select = 0;
2777 u32 page = offset >> IGP_PAGE_SHIFT;
2778 u32 page_shift = 0;
2779
2780 DEBUGFUNC("e1000_read_phy_reg_bm");
2781
2782 ret_val = hw->phy.ops.acquire(hw);
2783 if (ret_val)
2784 return ret_val;
2785
2483 /* Page 800 works differently than the rest so it has its own func */
2484 if (page == BM_WUC_PAGE) {
2485 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2486 TRUE);
2487 goto out;
2488 }
2489
2786 /* Page 800 works differently than the rest so it has its own func */
2787 if (page == BM_WUC_PAGE) {
2788 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2789 TRUE);
2790 goto out;
2791 }
2792
2490 ret_val = hw->phy.ops.acquire(hw);
2491 if (ret_val)
2492 goto out;
2493
2494 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2495
2496 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2497 /*
2498 * Page select is register 31 for phy address 1 and 22 for
2499 * phy address 2 and 3. Page select is shifted only for
2500 * phy address 1.
2501 */
2502 if (hw->phy.addr == 1) {
2503 page_shift = IGP_PAGE_SHIFT;
2504 page_select = IGP01E1000_PHY_PAGE_SELECT;
2505 } else {
2506 page_shift = 0;
2507 page_select = BM_PHY_PAGE_SELECT;
2508 }
2509
2510 /* Page is shifted left, PHY expects (page x 32) */
2511 ret_val = e1000_write_phy_reg_mdic(hw, page_select,
2512 (page << page_shift));
2793 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2794
2795 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2796 /*
2797 * Page select is register 31 for phy address 1 and 22 for
2798 * phy address 2 and 3. Page select is shifted only for
2799 * phy address 1.
2800 */
2801 if (hw->phy.addr == 1) {
2802 page_shift = IGP_PAGE_SHIFT;
2803 page_select = IGP01E1000_PHY_PAGE_SELECT;
2804 } else {
2805 page_shift = 0;
2806 page_select = BM_PHY_PAGE_SELECT;
2807 }
2808
2809 /* Page is shifted left, PHY expects (page x 32) */
2810 ret_val = e1000_write_phy_reg_mdic(hw, page_select,
2811 (page << page_shift));
2513 if (ret_val) {
2514 hw->phy.ops.release(hw);
2812 if (ret_val)
2515 goto out;
2813 goto out;
2516 }
2517 }
2518
2519 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2520 data);
2814 }
2815
2816 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2817 data);
2521 hw->phy.ops.release(hw);
2522
2523out:
2818out:
2819 hw->phy.ops.release(hw);
2524 return ret_val;
2525}
2526
2527/**
2528 * e1000_read_phy_reg_bm2 - Read BM PHY register
2529 * @hw: pointer to the HW structure
2530 * @offset: register offset to be read
2531 * @data: pointer to the read data

--- 4 unchanged lines hidden (view full) ---

2536 **/
2537s32 e1000_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data)
2538{
2539 s32 ret_val;
2540 u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
2541
2542 DEBUGFUNC("e1000_write_phy_reg_bm2");
2543
2820 return ret_val;
2821}
2822
2823/**
2824 * e1000_read_phy_reg_bm2 - Read BM PHY register
2825 * @hw: pointer to the HW structure
2826 * @offset: register offset to be read
2827 * @data: pointer to the read data

--- 4 unchanged lines hidden (view full) ---

2832 **/
2833s32 e1000_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data)
2834{
2835 s32 ret_val;
2836 u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
2837
2838 DEBUGFUNC("e1000_write_phy_reg_bm2");
2839
2840 ret_val = hw->phy.ops.acquire(hw);
2841 if (ret_val)
2842 return ret_val;
2843
2544 /* Page 800 works differently than the rest so it has its own func */
2545 if (page == BM_WUC_PAGE) {
2546 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2547 TRUE);
2548 goto out;
2549 }
2550
2844 /* Page 800 works differently than the rest so it has its own func */
2845 if (page == BM_WUC_PAGE) {
2846 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
2847 TRUE);
2848 goto out;
2849 }
2850
2551 ret_val = hw->phy.ops.acquire(hw);
2552 if (ret_val)
2553 goto out;
2554
2555 hw->phy.addr = 1;
2556
2557 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2558
2559 /* Page is shifted left, PHY expects (page x 32) */
2560 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
2561 page);
2562
2851 hw->phy.addr = 1;
2852
2853 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2854
2855 /* Page is shifted left, PHY expects (page x 32) */
2856 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
2857 page);
2858
2563 if (ret_val) {
2564 hw->phy.ops.release(hw);
2859 if (ret_val)
2565 goto out;
2860 goto out;
2566 }
2567 }
2568
2569 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2570 data);
2861 }
2862
2863 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2864 data);
2571 hw->phy.ops.release(hw);
2572
2573out:
2865out:
2866 hw->phy.ops.release(hw);
2574 return ret_val;
2575}
2576
2577/**
2578 * e1000_write_phy_reg_bm2 - Write BM PHY register
2579 * @hw: pointer to the HW structure
2580 * @offset: register offset to write to
2581 * @data: data to write at register offset
2582 *
2583 * Acquires semaphore, if necessary, then writes the data to PHY register
2584 * at the offset. Release any acquired semaphores before exiting.
2585 **/
2586s32 e1000_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data)
2587{
2588 s32 ret_val;
2589 u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
2590
2591 DEBUGFUNC("e1000_write_phy_reg_bm2");
2592
2867 return ret_val;
2868}
2869
2870/**
2871 * e1000_write_phy_reg_bm2 - Write BM PHY register
2872 * @hw: pointer to the HW structure
2873 * @offset: register offset to write to
2874 * @data: data to write at register offset
2875 *
2876 * Acquires semaphore, if necessary, then writes the data to PHY register
2877 * at the offset. Release any acquired semaphores before exiting.
2878 **/
2879s32 e1000_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data)
2880{
2881 s32 ret_val;
2882 u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
2883
2884 DEBUGFUNC("e1000_write_phy_reg_bm2");
2885
2886 ret_val = hw->phy.ops.acquire(hw);
2887 if (ret_val)
2888 return ret_val;
2889
2593 /* Page 800 works differently than the rest so it has its own func */
2594 if (page == BM_WUC_PAGE) {
2595 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2596 FALSE);
2597 goto out;
2598 }
2599
2890 /* Page 800 works differently than the rest so it has its own func */
2891 if (page == BM_WUC_PAGE) {
2892 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
2893 FALSE);
2894 goto out;
2895 }
2896
2600 ret_val = hw->phy.ops.acquire(hw);
2601 if (ret_val)
2602 goto out;
2603
2604 hw->phy.addr = 1;
2605
2606 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2607 /* Page is shifted left, PHY expects (page x 32) */
2608 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
2609 page);
2610
2897 hw->phy.addr = 1;
2898
2899 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2900 /* Page is shifted left, PHY expects (page x 32) */
2901 ret_val = e1000_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
2902 page);
2903
2611 if (ret_val) {
2612 hw->phy.ops.release(hw);
2904 if (ret_val)
2613 goto out;
2905 goto out;
2614 }
2615 }
2616
2617 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2618 data);
2619
2906 }
2907
2908 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
2909 data);
2910
2620 hw->phy.ops.release(hw);
2621
2622out:
2911out:
2912 hw->phy.ops.release(hw);
2623 return ret_val;
2624}
2625
2626/**
2627 * e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
2628 * @hw: pointer to the HW structure
2629 * @offset: register offset to be read or written
2630 * @data: pointer to the data to read or write
2631 * @read: determines if operation is read or write
2632 *
2633 * Acquires semaphore, if necessary, then reads the PHY register at offset
2634 * and storing the retrieved information in data. Release any acquired
2635 * semaphores before exiting. Note that procedure to read the wakeup
2636 * registers are different. It works as such:
2637 * 1) Set page 769, register 17, bit 2 = 1
2638 * 2) Set page to 800 for host (801 if we were manageability)
2639 * 3) Write the address using the address opcode (0x11)
2640 * 4) Read or write the data using the data opcode (0x12)
2641 * 5) Restore 769_17.2 to its original value
2913 return ret_val;
2914}
2915
2916/**
2917 * e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
2918 * @hw: pointer to the HW structure
2919 * @offset: register offset to be read or written
2920 * @data: pointer to the data to read or write
2921 * @read: determines if operation is read or write
2922 *
2923 * Acquires semaphore, if necessary, then reads the PHY register at offset
2924 * and storing the retrieved information in data. Release any acquired
2925 * semaphores before exiting. Note that procedure to read the wakeup
2926 * registers are different. It works as such:
2927 * 1) Set page 769, register 17, bit 2 = 1
2928 * 2) Set page to 800 for host (801 if we were manageability)
2929 * 3) Write the address using the address opcode (0x11)
2930 * 4) Read or write the data using the data opcode (0x12)
2931 * 5) Restore 769_17.2 to its original value
2932 *
2933 * Assumes semaphore already acquired.
2642 **/
2643static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
2644 u16 *data, bool read)
2645{
2646 s32 ret_val;
2647 u16 reg = BM_PHY_REG_NUM(offset);
2648 u16 phy_reg = 0;
2934 **/
2935static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
2936 u16 *data, bool read)
2937{
2938 s32 ret_val;
2939 u16 reg = BM_PHY_REG_NUM(offset);
2940 u16 phy_reg = 0;
2649 u8 phy_acquired = 1;
2650
2651 DEBUGFUNC("e1000_access_phy_wakeup_reg_bm");
2652
2653 /* Gig must be disabled for MDIO accesses to page 800 */
2654 if ((hw->mac.type == e1000_pchlan) &&
2655 (!(E1000_READ_REG(hw, E1000_PHY_CTRL) & E1000_PHY_CTRL_GBE_DISABLE)))
2656 DEBUGOUT("Attempting to access page 800 while gig enabled.\n");
2657
2941
2942 DEBUGFUNC("e1000_access_phy_wakeup_reg_bm");
2943
2944 /* Gig must be disabled for MDIO accesses to page 800 */
2945 if ((hw->mac.type == e1000_pchlan) &&
2946 (!(E1000_READ_REG(hw, E1000_PHY_CTRL) & E1000_PHY_CTRL_GBE_DISABLE)))
2947 DEBUGOUT("Attempting to access page 800 while gig enabled.\n");
2948
2658 ret_val = hw->phy.ops.acquire(hw);
2659 if (ret_val) {
2660 DEBUGOUT("Could not acquire PHY\n");
2661 phy_acquired = 0;
2662 goto out;
2663 }
2664
2665 /* All operations in this function are phy address 1 */
2666 hw->phy.addr = 1;
2667
2668 /* Set page 769 */
2669 e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2670 (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
2671
2672 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, &phy_reg);

--- 55 unchanged lines hidden (view full) ---

2728 /* Clear 769_17.2 */
2729 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
2730 if (ret_val) {
2731 DEBUGOUT("Could not clear PHY page 769 bit 2\n");
2732 goto out;
2733 }
2734
2735out:
2949 /* All operations in this function are phy address 1 */
2950 hw->phy.addr = 1;
2951
2952 /* Set page 769 */
2953 e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2954 (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
2955
2956 ret_val = e1000_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, &phy_reg);

--- 55 unchanged lines hidden (view full) ---

3012 /* Clear 769_17.2 */
3013 ret_val = e1000_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
3014 if (ret_val) {
3015 DEBUGOUT("Could not clear PHY page 769 bit 2\n");
3016 goto out;
3017 }
3018
3019out:
2736 if (phy_acquired == 1)
2737 hw->phy.ops.release(hw);
2738 return ret_val;
2739}
2740
2741/**
2742 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
2743 * @hw: pointer to the HW structure
2744 *
2745 * In the case of a PHY power down to save power, or to turn off link during a

--- 24 unchanged lines hidden (view full) ---

2770
2771 /* The PHY will retain its settings across a power down/up cycle */
2772 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
2773 mii_reg |= MII_CR_POWER_DOWN;
2774 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
2775 msec_delay(1);
2776}
2777
3020 return ret_val;
3021}
3022
3023/**
3024 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
3025 * @hw: pointer to the HW structure
3026 *
3027 * In the case of a PHY power down to save power, or to turn off link during a

--- 24 unchanged lines hidden (view full) ---

3052
3053 /* The PHY will retain its settings across a power down/up cycle */
3054 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
3055 mii_reg |= MII_CR_POWER_DOWN;
3056 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
3057 msec_delay(1);
3058}
3059
3060/**
3061 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
3062 * @hw: pointer to the HW structure
3063 * @slow: TRUE for slow mode, FALSE for normal mode
3064 *
3065 * Assumes semaphore already acquired.
3066 **/
2778s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow)
2779{
2780 s32 ret_val = E1000_SUCCESS;
2781 u16 data = 0;
2782
3067s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow)
3068{
3069 s32 ret_val = E1000_SUCCESS;
3070 u16 data = 0;
3071
2783 ret_val = hw->phy.ops.acquire(hw);
2784 if (ret_val)
2785 return ret_val;
2786
2787 /* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */
2788 hw->phy.addr = 1;
2789 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2790 (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT));
3072 /* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */
3073 hw->phy.addr = 1;
3074 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
3075 (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT));
2791 if (ret_val) {
2792 hw->phy.ops.release(hw);
2793 return ret_val;
2794 }
3076 if (ret_val)
3077 goto out;
3078
2795 ret_val = e1000_write_phy_reg_mdic(hw, BM_CS_CTRL1,
2796 (0x2180 | (slow << 10)));
3079 ret_val = e1000_write_phy_reg_mdic(hw, BM_CS_CTRL1,
3080 (0x2180 | (slow << 10)));
3081 if (ret_val)
3082 goto out;
2797
2798 /* dummy read when reverting to fast mode - throw away result */
2799 if (!slow)
3083
3084 /* dummy read when reverting to fast mode - throw away result */
3085 if (!slow)
2800 e1000_read_phy_reg_mdic(hw, BM_CS_CTRL1, &data);
3086 ret_val = e1000_read_phy_reg_mdic(hw, BM_CS_CTRL1, &data);
2801
3087
2802 hw->phy.ops.release(hw);
2803
3088out:
2804 return ret_val;
2805}
2806
2807/**
3089 return ret_val;
3090}
3091
3092/**
2808 * e1000_read_phy_reg_hv - Read HV PHY register
3093 * __e1000_read_phy_reg_hv - Read HV PHY register
2809 * @hw: pointer to the HW structure
2810 * @offset: register offset to be read
2811 * @data: pointer to the read data
3094 * @hw: pointer to the HW structure
3095 * @offset: register offset to be read
3096 * @data: pointer to the read data
3097 * @locked: semaphore has already been acquired or not
2812 *
2813 * Acquires semaphore, if necessary, then reads the PHY register at offset
3098 *
3099 * Acquires semaphore, if necessary, then reads the PHY register at offset
2814 * and storing the retrieved information in data. Release any acquired
3100 * and stores the retrieved information in data. Release any acquired
2815 * semaphore before exiting.
2816 **/
3101 * semaphore before exiting.
3102 **/
2817s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data)
3103static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data,
3104 bool locked)
2818{
2819 s32 ret_val;
2820 u16 page = BM_PHY_REG_PAGE(offset);
2821 u16 reg = BM_PHY_REG_NUM(offset);
2822 bool in_slow_mode = FALSE;
2823
2824 DEBUGFUNC("e1000_read_phy_reg_hv");
2825
3105{
3106 s32 ret_val;
3107 u16 page = BM_PHY_REG_PAGE(offset);
3108 u16 reg = BM_PHY_REG_NUM(offset);
3109 bool in_slow_mode = FALSE;
3110
3111 DEBUGFUNC("e1000_read_phy_reg_hv");
3112
3113 if (!locked) {
3114 ret_val = hw->phy.ops.acquire(hw);
3115 if (ret_val)
3116 return ret_val;
3117 }
3118
2826 /* Workaround failure in MDIO access while cable is disconnected */
2827 if ((hw->phy.type == e1000_phy_82577) &&
2828 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
2829 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
2830 if (ret_val)
2831 goto out;
2832
2833 in_slow_mode = TRUE;

--- 7 unchanged lines hidden (view full) ---

2841 }
2842
2843 if (page > 0 && page < HV_INTC_FC_PAGE_START) {
2844 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
2845 data, TRUE);
2846 goto out;
2847 }
2848
3119 /* Workaround failure in MDIO access while cable is disconnected */
3120 if ((hw->phy.type == e1000_phy_82577) &&
3121 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
3122 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
3123 if (ret_val)
3124 goto out;
3125
3126 in_slow_mode = TRUE;

--- 7 unchanged lines hidden (view full) ---

3134 }
3135
3136 if (page > 0 && page < HV_INTC_FC_PAGE_START) {
3137 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
3138 data, TRUE);
3139 goto out;
3140 }
3141
2849 ret_val = hw->phy.ops.acquire(hw);
2850 if (ret_val)
2851 goto out;
2852
2853 hw->phy.addr = e1000_get_phy_addr_for_hv_page(page);
2854
2855 if (page == HV_INTC_FC_PAGE_START)
2856 page = 0;
2857
2858 if (reg > MAX_PHY_MULTI_PAGE_REG) {
3142 hw->phy.addr = e1000_get_phy_addr_for_hv_page(page);
3143
3144 if (page == HV_INTC_FC_PAGE_START)
3145 page = 0;
3146
3147 if (reg > MAX_PHY_MULTI_PAGE_REG) {
2859 if ((hw->phy.type != e1000_phy_82578) ||
2860 ((reg != I82578_ADDR_REG) &&
2861 (reg != I82578_ADDR_REG + 1))) {
2862 u32 phy_addr = hw->phy.addr;
3148 u32 phy_addr = hw->phy.addr;
2863
3149
2864 hw->phy.addr = 1;
3150 hw->phy.addr = 1;
2865
3151
2866 /* Page is shifted left, PHY expects (page x 32) */
2867 ret_val = e1000_write_phy_reg_mdic(hw,
2868 IGP01E1000_PHY_PAGE_SELECT,
2869 (page << IGP_PAGE_SHIFT));
2870 if (ret_val) {
2871 hw->phy.ops.release(hw);
2872 goto out;
2873 }
2874 hw->phy.addr = phy_addr;
2875 }
3152 /* Page is shifted left, PHY expects (page x 32) */
3153 ret_val = e1000_write_phy_reg_mdic(hw,
3154 IGP01E1000_PHY_PAGE_SELECT,
3155 (page << IGP_PAGE_SHIFT));
3156 hw->phy.addr = phy_addr;
3157
3158 if (ret_val)
3159 goto out;
2876 }
2877
2878 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg,
2879 data);
3160 }
3161
3162 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg,
3163 data);
2880 hw->phy.ops.release(hw);
2881
2882out:
2883 /* Revert to MDIO fast mode, if applicable */
2884 if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
3164out:
3165 /* Revert to MDIO fast mode, if applicable */
3166 if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
2885 ret_val = e1000_set_mdio_slow_mode_hv(hw, FALSE);
3167 ret_val |= e1000_set_mdio_slow_mode_hv(hw, FALSE);
2886
3168
3169 if (!locked)
3170 hw->phy.ops.release(hw);
3171
2887 return ret_val;
2888}
2889
2890/**
3172 return ret_val;
3173}
3174
3175/**
2891 * e1000_write_phy_reg_hv - Write HV PHY register
3176 * e1000_read_phy_reg_hv - Read HV PHY register
2892 * @hw: pointer to the HW structure
3177 * @hw: pointer to the HW structure
3178 * @offset: register offset to be read
3179 * @data: pointer to the read data
3180 *
3181 * Acquires semaphore then reads the PHY register at offset and stores
3182 * the retrieved information in data. Release the acquired semaphore
3183 * before exiting.
3184 **/
3185s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data)
3186{
3187 return __e1000_read_phy_reg_hv(hw, offset, data, FALSE);
3188}
3189
3190/**
3191 * e1000_read_phy_reg_hv_locked - Read HV PHY register
3192 * @hw: pointer to the HW structure
3193 * @offset: register offset to be read
3194 * @data: pointer to the read data
3195 *
3196 * Reads the PHY register at offset and stores the retrieved information
3197 * in data. Assumes semaphore already acquired.
3198 **/
3199s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data)
3200{
3201 return __e1000_read_phy_reg_hv(hw, offset, data, TRUE);
3202}
3203
3204/**
3205 * __e1000_write_phy_reg_hv - Write HV PHY register
3206 * @hw: pointer to the HW structure
2893 * @offset: register offset to write to
2894 * @data: data to write at register offset
3207 * @offset: register offset to write to
3208 * @data: data to write at register offset
3209 * @locked: semaphore has already been acquired or not
2895 *
2896 * Acquires semaphore, if necessary, then writes the data to PHY register
2897 * at the offset. Release any acquired semaphores before exiting.
2898 **/
3210 *
3211 * Acquires semaphore, if necessary, then writes the data to PHY register
3212 * at the offset. Release any acquired semaphores before exiting.
3213 **/
2899s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data)
3214static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data,
3215 bool locked)
2900{
2901 s32 ret_val;
2902 u16 page = BM_PHY_REG_PAGE(offset);
2903 u16 reg = BM_PHY_REG_NUM(offset);
2904 bool in_slow_mode = FALSE;
2905
2906 DEBUGFUNC("e1000_write_phy_reg_hv");
2907
3216{
3217 s32 ret_val;
3218 u16 page = BM_PHY_REG_PAGE(offset);
3219 u16 reg = BM_PHY_REG_NUM(offset);
3220 bool in_slow_mode = FALSE;
3221
3222 DEBUGFUNC("e1000_write_phy_reg_hv");
3223
3224 if (!locked) {
3225 ret_val = hw->phy.ops.acquire(hw);
3226 if (ret_val)
3227 return ret_val;
3228 }
3229
2908 /* Workaround failure in MDIO access while cable is disconnected */
2909 if ((hw->phy.type == e1000_phy_82577) &&
2910 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
2911 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
2912 if (ret_val)
2913 goto out;
2914
2915 in_slow_mode = TRUE;

--- 7 unchanged lines hidden (view full) ---

2923 }
2924
2925 if (page > 0 && page < HV_INTC_FC_PAGE_START) {
2926 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
2927 &data, FALSE);
2928 goto out;
2929 }
2930
3230 /* Workaround failure in MDIO access while cable is disconnected */
3231 if ((hw->phy.type == e1000_phy_82577) &&
3232 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
3233 ret_val = e1000_set_mdio_slow_mode_hv(hw, TRUE);
3234 if (ret_val)
3235 goto out;
3236
3237 in_slow_mode = TRUE;

--- 7 unchanged lines hidden (view full) ---

3245 }
3246
3247 if (page > 0 && page < HV_INTC_FC_PAGE_START) {
3248 ret_val = e1000_access_phy_debug_regs_hv(hw, offset,
3249 &data, FALSE);
3250 goto out;
3251 }
3252
2931 ret_val = hw->phy.ops.acquire(hw);
2932 if (ret_val)
2933 goto out;
2934
2935 hw->phy.addr = e1000_get_phy_addr_for_hv_page(page);
2936
2937 if (page == HV_INTC_FC_PAGE_START)
2938 page = 0;
2939
2940 /*
2941 * Workaround MDIO accesses being disabled after entering IEEE Power
2942 * Down (whenever bit 11 of the PHY Control register is set)
2943 */
2944 if ((hw->phy.type == e1000_phy_82578) &&
2945 (hw->phy.revision >= 1) &&
2946 (hw->phy.addr == 2) &&
2947 ((MAX_PHY_REG_ADDRESS & reg) == 0) &&
2948 (data & (1 << 11))) {
2949 u16 data2 = 0x7EFF;
3253 hw->phy.addr = e1000_get_phy_addr_for_hv_page(page);
3254
3255 if (page == HV_INTC_FC_PAGE_START)
3256 page = 0;
3257
3258 /*
3259 * Workaround MDIO accesses being disabled after entering IEEE Power
3260 * Down (whenever bit 11 of the PHY Control register is set)
3261 */
3262 if ((hw->phy.type == e1000_phy_82578) &&
3263 (hw->phy.revision >= 1) &&
3264 (hw->phy.addr == 2) &&
3265 ((MAX_PHY_REG_ADDRESS & reg) == 0) &&
3266 (data & (1 << 11))) {
3267 u16 data2 = 0x7EFF;
2950 hw->phy.ops.release(hw);
2951 ret_val = e1000_access_phy_debug_regs_hv(hw, (1 << 6) | 0x3,
2952 &data2, FALSE);
2953 if (ret_val)
2954 goto out;
3268 ret_val = e1000_access_phy_debug_regs_hv(hw, (1 << 6) | 0x3,
3269 &data2, FALSE);
3270 if (ret_val)
3271 goto out;
2955
2956 ret_val = hw->phy.ops.acquire(hw);
2957 if (ret_val)
2958 goto out;
2959 }
2960
2961 if (reg > MAX_PHY_MULTI_PAGE_REG) {
3272 }
3273
3274 if (reg > MAX_PHY_MULTI_PAGE_REG) {
2962 if ((hw->phy.type != e1000_phy_82578) ||
2963 ((reg != I82578_ADDR_REG) &&
2964 (reg != I82578_ADDR_REG + 1))) {
2965 u32 phy_addr = hw->phy.addr;
3275 u32 phy_addr = hw->phy.addr;
2966
3276
2967 hw->phy.addr = 1;
3277 hw->phy.addr = 1;
2968
3278
2969 /* Page is shifted left, PHY expects (page x 32) */
2970 ret_val = e1000_write_phy_reg_mdic(hw,
2971 IGP01E1000_PHY_PAGE_SELECT,
2972 (page << IGP_PAGE_SHIFT));
2973 if (ret_val) {
2974 hw->phy.ops.release(hw);
2975 goto out;
2976 }
2977 hw->phy.addr = phy_addr;
2978 }
3279 /* Page is shifted left, PHY expects (page x 32) */
3280 ret_val = e1000_write_phy_reg_mdic(hw,
3281 IGP01E1000_PHY_PAGE_SELECT,
3282 (page << IGP_PAGE_SHIFT));
3283 hw->phy.addr = phy_addr;
3284
3285 if (ret_val)
3286 goto out;
2979 }
2980
2981 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg,
2982 data);
3287 }
3288
3289 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg,
3290 data);
2983 hw->phy.ops.release(hw);
2984
2985out:
2986 /* Revert to MDIO fast mode, if applicable */
2987 if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
3291
3292out:
3293 /* Revert to MDIO fast mode, if applicable */
3294 if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
2988 ret_val = e1000_set_mdio_slow_mode_hv(hw, FALSE);
3295 ret_val |= e1000_set_mdio_slow_mode_hv(hw, FALSE);
2989
3296
3297 if (!locked)
3298 hw->phy.ops.release(hw);
3299
2990 return ret_val;
2991}
2992
2993/**
3300 return ret_val;
3301}
3302
3303/**
3304 * e1000_write_phy_reg_hv - Write HV PHY register
3305 * @hw: pointer to the HW structure
3306 * @offset: register offset to write to
3307 * @data: data to write at register offset
3308 *
3309 * Acquires semaphore then writes the data to PHY register at the offset.
3310 * Release the acquired semaphores before exiting.
3311 **/
3312s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data)
3313{
3314 return __e1000_write_phy_reg_hv(hw, offset, data, FALSE);
3315}
3316
3317/**
3318 * e1000_write_phy_reg_hv_locked - Write HV PHY register
3319 * @hw: pointer to the HW structure
3320 * @offset: register offset to write to
3321 * @data: data to write at register offset
3322 *
3323 * Writes the data to PHY register at the offset. Assumes semaphore
3324 * already acquired.
3325 **/
3326s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data)
3327{
3328 return __e1000_write_phy_reg_hv(hw, offset, data, TRUE);
3329}
3330
3331/**
2994 * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page
2995 * @page: page to be accessed
2996 **/
2997static u32 e1000_get_phy_addr_for_hv_page(u32 page)
2998{
2999 u32 phy_addr = 2;
3000
3001 if (page >= HV_INTC_FC_PAGE_START)

--- 4 unchanged lines hidden (view full) ---

3006
3007/**
3008 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
3009 * @hw: pointer to the HW structure
3010 * @offset: register offset to be read or written
3011 * @data: pointer to the data to be read or written
3012 * @read: determines if operation is read or written
3013 *
3332 * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page
3333 * @page: page to be accessed
3334 **/
3335static u32 e1000_get_phy_addr_for_hv_page(u32 page)
3336{
3337 u32 phy_addr = 2;
3338
3339 if (page >= HV_INTC_FC_PAGE_START)

--- 4 unchanged lines hidden (view full) ---

3344
3345/**
3346 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
3347 * @hw: pointer to the HW structure
3348 * @offset: register offset to be read or written
3349 * @data: pointer to the data to be read or written
3350 * @read: determines if operation is read or written
3351 *
3014 * Acquires semaphore, if necessary, then reads the PHY register at offset
3015 * and storing the retreived information in data. Release any acquired
3016 * semaphores before exiting. Note that the procedure to read these regs
3017 * uses the address port and data port to read/write.
3352 * Reads the PHY register at offset and stores the retreived information
3353 * in data. Assumes semaphore already acquired. Note that the procedure
3354 * to read these regs uses the address port and data port to read/write.
3018 **/
3019static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
3020 u16 *data, bool read)
3021{
3022 s32 ret_val;
3023 u32 addr_reg = 0;
3024 u32 data_reg = 0;
3355 **/
3356static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
3357 u16 *data, bool read)
3358{
3359 s32 ret_val;
3360 u32 addr_reg = 0;
3361 u32 data_reg = 0;
3025 u8 phy_acquired = 1;
3026
3027 DEBUGFUNC("e1000_access_phy_debug_regs_hv");
3028
3029 /* This takes care of the difference with desktop vs mobile phy */
3030 addr_reg = (hw->phy.type == e1000_phy_82578) ?
3031 I82578_ADDR_REG : I82577_ADDR_REG;
3032 data_reg = addr_reg + 1;
3033
3362
3363 DEBUGFUNC("e1000_access_phy_debug_regs_hv");
3364
3365 /* This takes care of the difference with desktop vs mobile phy */
3366 addr_reg = (hw->phy.type == e1000_phy_82578) ?
3367 I82578_ADDR_REG : I82577_ADDR_REG;
3368 data_reg = addr_reg + 1;
3369
3034 ret_val = hw->phy.ops.acquire(hw);
3035 if (ret_val) {
3036 DEBUGOUT("Could not acquire PHY\n");
3037 phy_acquired = 0;
3038 goto out;
3039 }
3040
3041 /* All operations in this function are phy address 2 */
3042 hw->phy.addr = 2;
3043
3044 /* masking with 0x3F to remove the page from offset */
3045 ret_val = e1000_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F);
3046 if (ret_val) {
3047 DEBUGOUT("Could not write PHY the HV address register\n");
3048 goto out;

--- 6 unchanged lines hidden (view full) ---

3055 ret_val = e1000_write_phy_reg_mdic(hw, data_reg, *data);
3056
3057 if (ret_val) {
3058 DEBUGOUT("Could not read data value from HV data register\n");
3059 goto out;
3060 }
3061
3062out:
3370 /* All operations in this function are phy address 2 */
3371 hw->phy.addr = 2;
3372
3373 /* masking with 0x3F to remove the page from offset */
3374 ret_val = e1000_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F);
3375 if (ret_val) {
3376 DEBUGOUT("Could not write PHY the HV address register\n");
3377 goto out;

--- 6 unchanged lines hidden (view full) ---

3384 ret_val = e1000_write_phy_reg_mdic(hw, data_reg, *data);
3385
3386 if (ret_val) {
3387 DEBUGOUT("Could not read data value from HV data register\n");
3388 goto out;
3389 }
3390
3391out:
3063 if (phy_acquired == 1)
3064 hw->phy.ops.release(hw);
3065 return ret_val;
3066}
3067
3068/**
3069 * e1000_link_stall_workaround_hv - Si workaround
3070 * @hw: pointer to the HW structure
3071 *
3072 * This function works around a Si bug where the link partner can get

--- 12 unchanged lines hidden (view full) ---

3085
3086 if (hw->phy.type != e1000_phy_82578)
3087 goto out;
3088
3089 /* Do not apply workaround if in PHY loopback bit 14 set */
3090 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data);
3091 if (data & PHY_CONTROL_LB)
3092 goto out;
3392 return ret_val;
3393}
3394
3395/**
3396 * e1000_link_stall_workaround_hv - Si workaround
3397 * @hw: pointer to the HW structure
3398 *
3399 * This function works around a Si bug where the link partner can get

--- 12 unchanged lines hidden (view full) ---

3412
3413 if (hw->phy.type != e1000_phy_82578)
3414 goto out;
3415
3416 /* Do not apply workaround if in PHY loopback bit 14 set */
3417 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data);
3418 if (data & PHY_CONTROL_LB)
3419 goto out;
3093
3420
3094 /* check if link is up and at 1Gbps */
3095 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data);
3096 if (ret_val)
3097 goto out;
3098
3099 data &= BM_CS_STATUS_LINK_UP |
3100 BM_CS_STATUS_RESOLVED |
3101 BM_CS_STATUS_SPEED_MASK;

--- 202 unchanged lines hidden (view full) ---

3304 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data);
3305 if (ret_val)
3306 goto out;
3307
3308 length = (phy_data & I82577_DSTATUS_CABLE_LENGTH) >>
3309 I82577_DSTATUS_CABLE_LENGTH_SHIFT;
3310
3311 if (length == E1000_CABLE_LENGTH_UNDEFINED)
3421 /* check if link is up and at 1Gbps */
3422 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data);
3423 if (ret_val)
3424 goto out;
3425
3426 data &= BM_CS_STATUS_LINK_UP |
3427 BM_CS_STATUS_RESOLVED |
3428 BM_CS_STATUS_SPEED_MASK;

--- 202 unchanged lines hidden (view full) ---

3631 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data);
3632 if (ret_val)
3633 goto out;
3634
3635 length = (phy_data & I82577_DSTATUS_CABLE_LENGTH) >>
3636 I82577_DSTATUS_CABLE_LENGTH_SHIFT;
3637
3638 if (length == E1000_CABLE_LENGTH_UNDEFINED)
3312 ret_val = E1000_ERR_PHY;
3639 ret_val = -E1000_ERR_PHY;
3313
3314 phy->cable_length = length;
3315
3316out:
3317 return ret_val;
3318}
3640
3641 phy->cable_length = length;
3642
3643out:
3644 return ret_val;
3645}