202-net-igb-add-i210-i211-support-for-phy-read-write.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Author: Tim Harvey <tharvey@gateworks.com>
  2. Date: Thu May 15 00:12:26 2014 -0700
  3. net: igb: add i210/i211 support for phy read/write
  4. The i210/i211 uses the MDICNFG register for the phy address instead of the
  5. MDIC register.
  6. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
  7. --- a/drivers/net/ethernet/intel/igb/e1000_phy.c
  8. +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
  9. @@ -129,7 +129,7 @@ out:
  10. s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
  11. {
  12. struct e1000_phy_info *phy = &hw->phy;
  13. - u32 i, mdic = 0;
  14. + u32 i, mdicnfg, mdic = 0;
  15. s32 ret_val = 0;
  16. if (offset > MAX_PHY_REG_ADDRESS) {
  17. @@ -142,11 +142,25 @@ s32 igb_read_phy_reg_mdic(struct e1000_h
  18. * Control register. The MAC will take care of interfacing with the
  19. * PHY to retrieve the desired data.
  20. */
  21. - mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  22. - (phy->addr << E1000_MDIC_PHY_SHIFT) |
  23. - (E1000_MDIC_OP_READ));
  24. + switch (hw->mac.type) {
  25. + case e1000_i210:
  26. + case e1000_i211:
  27. + mdicnfg = rd32(E1000_MDICNFG);
  28. + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  29. + mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
  30. + wr32(E1000_MDICNFG, mdicnfg);
  31. + mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  32. + (E1000_MDIC_OP_READ));
  33. + break;
  34. + default:
  35. + mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  36. + (phy->addr << E1000_MDIC_PHY_SHIFT) |
  37. + (E1000_MDIC_OP_READ));
  38. + break;
  39. + }
  40. wr32(E1000_MDIC, mdic);
  41. + wrfl();
  42. /* Poll the ready bit to see if the MDI read completed
  43. * Increasing the time out as testing showed failures with
  44. @@ -171,6 +185,18 @@ s32 igb_read_phy_reg_mdic(struct e1000_h
  45. *data = (u16) mdic;
  46. out:
  47. + switch (hw->mac.type) {
  48. + /* restore MDICNFG to have phy's addr */
  49. + case e1000_i210:
  50. + case e1000_i211:
  51. + mdicnfg = rd32(E1000_MDICNFG);
  52. + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  53. + mdicnfg |= (hw->phy.addr << E1000_MDICNFG_PHY_SHIFT);
  54. + wr32(E1000_MDICNFG, mdicnfg);
  55. + break;
  56. + default:
  57. + break;
  58. + }
  59. return ret_val;
  60. }
  61. @@ -185,7 +211,7 @@ out:
  62. s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
  63. {
  64. struct e1000_phy_info *phy = &hw->phy;
  65. - u32 i, mdic = 0;
  66. + u32 i, mdicnfg, mdic = 0;
  67. s32 ret_val = 0;
  68. if (offset > MAX_PHY_REG_ADDRESS) {
  69. @@ -198,12 +224,27 @@ s32 igb_write_phy_reg_mdic(struct e1000_
  70. * Control register. The MAC will take care of interfacing with the
  71. * PHY to retrieve the desired data.
  72. */
  73. - mdic = (((u32)data) |
  74. - (offset << E1000_MDIC_REG_SHIFT) |
  75. - (phy->addr << E1000_MDIC_PHY_SHIFT) |
  76. - (E1000_MDIC_OP_WRITE));
  77. + switch (hw->mac.type) {
  78. + case e1000_i210:
  79. + case e1000_i211:
  80. + mdicnfg = rd32(E1000_MDICNFG);
  81. + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  82. + mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
  83. + wr32(E1000_MDICNFG, mdicnfg);
  84. + mdic = (((u32)data) |
  85. + (offset << E1000_MDIC_REG_SHIFT) |
  86. + (E1000_MDIC_OP_WRITE));
  87. + break;
  88. + default:
  89. + mdic = (((u32)data) |
  90. + (offset << E1000_MDIC_REG_SHIFT) |
  91. + (phy->addr << E1000_MDIC_PHY_SHIFT) |
  92. + (E1000_MDIC_OP_WRITE));
  93. + break;
  94. + }
  95. wr32(E1000_MDIC, mdic);
  96. + wrfl();
  97. /* Poll the ready bit to see if the MDI read completed
  98. * Increasing the time out as testing showed failures with
  99. @@ -227,6 +268,18 @@ s32 igb_write_phy_reg_mdic(struct e1000_
  100. }
  101. out:
  102. + switch (hw->mac.type) {
  103. + /* restore MDICNFG to have phy's addr */
  104. + case e1000_i210:
  105. + case e1000_i211:
  106. + mdicnfg = rd32(E1000_MDICNFG);
  107. + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  108. + mdicnfg |= (hw->phy.addr << E1000_MDICNFG_PHY_SHIFT);
  109. + wr32(E1000_MDICNFG, mdicnfg);
  110. + break;
  111. + default:
  112. + break;
  113. + }
  114. return ret_val;
  115. }