From: Sasha Neftin <sasha.nef...@intel.com>

It is expected that PHY power management control should provide a reliable
and accurate indication of PHY reset completion and decrease the delay time
after a PHY reset.

Signed-off-by: Sasha Neftin <sasha.nef...@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 drivers/net/intel/e1000/base/e1000_defines.h |  2 ++
 drivers/net/intel/e1000/base/e1000_phy.c     | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/intel/e1000/base/e1000_defines.h 
b/drivers/net/intel/e1000/base/e1000_defines.h
index b1e616781e..8dfdce7dad 100644
--- a/drivers/net/intel/e1000/base/e1000_defines.h
+++ b/drivers/net/intel/e1000/base/e1000_defines.h
@@ -1099,6 +1099,8 @@
 
 #define PHY_CONTROL_LB         0x4000 /* PHY Loopback bit */
 
+#define E1000_PHY_RST_COMP     0x0100 /* Internal PHY reset completion */
+
 /* NVM Control */
 #define E1000_EECD_SK          0x00000001 /* NVM Clock */
 #define E1000_EECD_CS          0x00000002 /* NVM Chip Select */
diff --git a/drivers/net/intel/e1000/base/e1000_phy.c 
b/drivers/net/intel/e1000/base/e1000_phy.c
index ff37a54b6b..6e8f4ff4ea 100644
--- a/drivers/net/intel/e1000/base/e1000_phy.c
+++ b/drivers/net/intel/e1000/base/e1000_phy.c
@@ -2917,6 +2917,10 @@ s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw)
        if (ret_val)
                return ret_val;
 
+       if (hw->mac.type == e1000_i225) {
+               E1000_READ_REG(hw, E1000_I225_PHPM);
+       }
+
        ctrl = E1000_READ_REG(hw, E1000_CTRL);
        E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PHY_RST);
        E1000_WRITE_FLUSH(hw);
@@ -2926,7 +2930,17 @@ s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw)
        E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
        E1000_WRITE_FLUSH(hw);
 
-       usec_delay(150);
+       if (hw->mac.type == e1000_i225) {
+               u32 phpm = 0, timeout = 10000;
+               /* SW should guarantee 100us for the completion of the PHY 
reset */
+               usec_delay(100);
+               do {
+                       phpm = E1000_READ_REG(hw, E1000_I225_PHPM);
+                       timeout--;
+                       usec_delay(1);
+               } while (!(phpm & E1000_PHY_RST_COMP) && timeout);
+       }
+       usec_delay(100);
 
        phy->ops.release(hw);
 
-- 
2.43.5

Reply via email to