Skip to contentSkip to conversation

igc: Add PHY power management control

PATCH Superseded Sasha Neftin 3 participants 4 messages Dec 12, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igc: Add PHY power management control

PHY power management control should provide a reliable and accurate indication of PHY reset completion and decrease the delay time after a PHY reset

---
 drivers/net/ethernet/intel/igc/igc_defines.h | 1 +
 drivers/net/ethernet/intel/igc/igc_phy.c     | 9 +++++++++
 drivers/net/ethernet/intel/igc/igc_regs.h    | 1 +
 3 files changed, 11 insertions(+)
drivers/net/ethernet/intel/igc/igc_defines.h +1 -0
index 2121fc34e300..71a4b0281c03 100644
@@ -460,6 +460,7 @@
 /* PHY Status Register */
 #define MII_SR_LINK_STATUS	0x0004 /* Link Status 1 = link */
 #define MII_SR_AUTONEG_COMPLETE	0x0020 /* Auto Neg Complete */
+#define IGC_PHY_RST_COMP	0x0100 /* Internal PHY reset completion */
 
 /* PHY 1000 MII Register/Bit Definitions */
 /* PHY Registers defined by IEEE */
drivers/net/ethernet/intel/igc/igc_phy.c +9 -0
index f4b05af0dd2f..e19e861df719 100644
@@ -173,6 +173,7 @@ s32 igc_check_downshift(struct igc_hw *hw)
 s32 igc_phy_hw_reset(struct igc_hw *hw)
 {
 	struct igc_phy_info *phy = &hw->phy;
+	u32 phpm = 0, timeout = 10000;
 	s32  ret_val;
 	u32 ctrl;
 
@@ -186,6 +187,8 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 	if (ret_val)
 		goto out;
 
+	phpm = rd32(IGC_I225_PHPM);
+
 	ctrl = rd32(IGC_CTRL);
 	wr32(IGC_CTRL, ctrl | IGC_CTRL_PHY_RST);
 	wrfl();
@@ -195,6 +198,12 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 	wr32(IGC_CTRL, ctrl);
 	wrfl();
 
+	do {
+		phpm = rd32(IGC_I225_PHPM);
+		timeout--;
+		udelay(1);
+	} while (!(phpm & IGC_PHY_RST_COMP) && timeout);
+
 	usleep_range(1500, 2000);
 
 	phy->ops.release(hw);
drivers/net/ethernet/intel/igc/igc_regs.h +1 -0
index c82111051898..164c42b39dfa 100644
@@ -12,6 +12,7 @@
 #define IGC_MDIC		0x00020  /* MDI Control - RW */
 #define IGC_MDICNFG		0x00E04  /* MDC/MDIO Configuration - RW */
 #define IGC_CONNSW		0x00034  /* Copper/Fiber switch control - RW */
+#define IGC_I225_PHPM		0x00E14	 /* I225 PHY Power Management */
 
 /* Internal Packet Buffer Size Registers */
 #define IGC_RXPBS		0x02404  /* Rx Packet Buffer Size - RW */
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 igc: Add PHY power management control

Dear Sasha,

Quoted 28 lines · Sasha Neftin

PHY power management control should provide a reliable and accurate indication of PHY reset completion and decrease the delay time after a PHY reset

---
 drivers/net/ethernet/intel/igc/igc_defines.h | 1 +
 drivers/net/ethernet/intel/igc/igc_phy.c     | 9 +++++++++
 drivers/net/ethernet/intel/igc/igc_regs.h    | 1 +
 3 files changed, 11 insertions(+)
drivers/net/ethernet/intel/igc/igc_defines.h +1 -0
index 2121fc34e300..71a4b0281c03 100644
@@ -460,6 +460,7 @@
 /* PHY Status Register */
 #define MII_SR_LINK_STATUS	0x0004 /* Link Status 1 = link */
 #define MII_SR_AUTONEG_COMPLETE	0x0020 /* Auto Neg Complete */
+#define IGC_PHY_RST_COMP	0x0100 /* Internal PHY reset completion */
 
 /* PHY 1000 MII Register/Bit Definitions */
 /* PHY Registers defined by IEEE */
drivers/net/ethernet/intel/igc/igc_phy.c +0 -0
index f4b05af0dd2f..e19e861df719 100644

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_check_downshift(struct igc_hw *hw) · line 176

Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
@@ -173,6 +173,7 @@ s32 igc_check_downshift(struct igc_hw *hw)
 s32 igc_phy_hw_reset(struct igc_hw *hw)
 {
 	struct igc_phy_info *phy = &hw->phy;
+	u32 phpm = 0, timeout = 10000;

Just use unsigned int for timeout?

phpm does not need to be initialized to 0?

Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_phy.c +2 -0
 	s32  ret_val;
 	u32 ctrl;
 
@@ -186,6 +187,8 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 	if (ret_val)
 		goto out;
 
+	phpm = rd32(IGC_I225_PHPM);
+
 	ctrl = rd32(IGC_CTRL);
 	wr32(IGC_CTRL, ctrl | IGC_CTRL_PHY_RST);
 	wrfl();

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_phy_hw_reset(struct igc_hw *hw) · line 205

Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_phy.c +5 -0
@@ -195,6 +198,12 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 	wr32(IGC_CTRL, ctrl);
 	wrfl();
 
+	do {
+		phpm = rd32(IGC_I225_PHPM);
+		timeout--;
+		udelay(1);
+	} while (!(phpm & IGC_PHY_RST_COMP) && timeout);

Print an error, when the timeout is reached?

Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
+
 	usleep_range(1500, 2000);
 
 	phy->ops.release(hw);
drivers/net/ethernet/intel/igc/igc_regs.h +0 -0
index c82111051898..164c42b39dfa 100644

drivers/net/ethernet/intel/igc/igc_regs.h line 18

Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_regs.h +1 -0
@@ -12,6 +12,7 @@
 #define IGC_MDIC		0x00020  /* MDI Control - RW */
 #define IGC_MDICNFG		0x00E04  /* MDC/MDIO Configuration - RW */
 #define IGC_CONNSW		0x00034  /* Copper/Fiber switch control - RW */
+#define IGC_I225_PHPM		0x00E14	 /* I225 PHY Power Management */
 
 /* Internal Packet Buffer Size Registers */
 #define IGC_RXPBS		0x02404  /* Rx Packet Buffer Size - RW */

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5174 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20191212/7d592b74/attachment.p7s>

#2 lore raw

PATCH 1/1 igc: Add PHY power management control

Quoted 25 lines · Paul Menzel

Dear Sasha,

Quoted 21 lines · Sasha Neftin

PHY power management control should provide a reliable and accurate indication of PHY reset completion and decrease the delay time after a PHY reset

---
  drivers/net/ethernet/intel/igc/igc_defines.h | 1 +
  drivers/net/ethernet/intel/igc/igc_phy.c     | 9 +++++++++
  drivers/net/ethernet/intel/igc/igc_regs.h    | 1 +
  3 files changed, 11 insertions(+)
drivers/net/ethernet/intel/igc/igc_defines.h +1 -0
index 2121fc34e300..71a4b0281c03 100644
@@ -460,6 +460,7 @@
  /* PHY Status Register */
  #define MII_SR_LINK_STATUS	0x0004 /* Link Status 1 = link */
  #define MII_SR_AUTONEG_COMPLETE	0x0020 /* Auto Neg Complete */
+#define IGC_PHY_RST_COMP	0x0100 /* Internal PHY reset completion */
 
Quoted 14 lines

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_check_downshift(struct igc_hw *hw) · line 176

Quoted 11 lines
drivers/net/ethernet/intel/igc/igc_defines.h +0 -0
  /* PHY 1000 MII Register/Bit Definitions */
  /* PHY Registers defined by IEEE */
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
index f4b05af0dd2f..e19e861df719 100644
@@ -173,6 +173,7 @@ s32 igc_check_downshift(struct igc_hw *hw)
  s32 igc_phy_hw_reset(struct igc_hw *hw)
  {
  	struct igc_phy_info *phy = &hw->phy;
+	u32 phpm = 0, timeout = 10000;

Just use unsigned int for timeout?

u32 is unsigned int.

Quoted 1 line

phpm does not need to be initialized to 0?

RST_COMP indication in the PHPM register is clear on reading. I once 'read' the PHPM before polling and make sure zero value.

Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/igc/igc_phy.c +2 -0
  	s32  ret_val;
  	u32 ctrl;
 
@@ -186,6 +187,8 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
  	if (ret_val)
  		goto out;
 
+	phpm = rd32(IGC_I225_PHPM);
+
  	ctrl = rd32(IGC_CTRL);
  	wr32(IGC_CTRL, ctrl | IGC_CTRL_PHY_RST);
  	wrfl();
@@ -195,6 +198,12 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
  	wr32(IGC_CTRL, ctrl);
  	wrfl();
 
Quoted 7 lines

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_phy_hw_reset(struct igc_hw *hw) · line 205

Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_phy.c +5 -0
+	do {
+		phpm = rd32(IGC_I225_PHPM);
+		timeout--;
+		udelay(1);
+	} while (!(phpm & IGC_PHY_RST_COMP) && timeout);

Print an error, when the timeout is reached?

Good idea. I will add hw_dbg in v2. Thanks.

Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
+
  	usleep_range(1500, 2000);
 
  	phy->ops.release(hw);
drivers/net/ethernet/intel/igc/igc_regs.h +1 -0
index c82111051898..164c42b39dfa 100644
@@ -12,6 +12,7 @@
  #define IGC_MDIC		0x00020  /* MDI Control - RW */
  #define IGC_MDICNFG		0x00E04  /* MDC/MDIO Configuration - RW */
  #define IGC_CONNSW		0x00034  /* Copper/Fiber switch control - RW */
+#define IGC_I225_PHPM		0x00E14	 /* I225 PHY Power Management */
 
Quoted 4 lines

drivers/net/ethernet/intel/igc/igc_regs.h line 18

Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_regs.h +0 -0
  /* Internal Packet Buffer Size Registers */
  #define IGC_RXPBS		0x02404  /* Rx Packet Buffer Size - RW */

Hello Paul,
Thank you very much for your comments.
Sasha

#3 lore raw

PATCH 1/1 igc: Add PHY power management control

Dear Sasha,

Am 12.12.19 um 13:08 schrieb Neftin, Sasha:

Quoted 39 lines · Paul Menzel
Quoted 29 lines · Sasha Neftin
Quoted 27 lines

PHY power management control should provide a reliable and accurate indication of PHY reset completion and decrease the delay time after a PHY reset

---

? drivers/net/ethernet/intel/igc/igc_defines.h | 1 +
? drivers/net/ethernet/intel/igc/igc_phy.c???? | 9 +++++++++
? drivers/net/ethernet/intel/igc/igc_regs.h??? | 1 +

? 3 files changed, 11 insertions(+)

drivers/net/ethernet/intel/igc/igc_defines.h +0 -0
index 2121fc34e300..71a4b0281c03 100644
@@ -460,6 +460,7 @@

? /* PHY Status Register */
? #define MII_SR_LINK_STATUS??? 0x0004 /* Link Status 1 = link */ ? #define MII_SR_AUTONEG_COMPLETE??? 0x0020 /* Auto Neg Complete */ +#define IGC_PHY_RST_COMP??? 0x0100 /* Internal PHY reset completion */ ? /* PHY 1000 MII Register/Bit Definitions */
? /* PHY Registers defined by IEEE */

drivers/net/ethernet/intel/igc/igc_phy.c +0 -1
index f4b05af0dd2f..e19e861df719 100644
--- a/drivers/net/ethernet/intel/igc/igc_phy.c
Quoted 9 lines

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_check_downshift(struct igc_hw *hw) · line 176

Quoted 6 lines

+++ b/drivers/net/ethernet/intel/igc/igc_phy.c

drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
@@ -173,6 +173,7 @@ s32 igc_check_downshift(struct igc_hw *hw)
 ? s32 igc_phy_hw_reset(struct igc_hw *hw)
 ? {
 ????? struct igc_phy_info *phy = &hw->phy;
+??? u32 phpm = 0, timeout = 10000;

Just use unsigned int for timeout?

Quoted 1 line

u32 is unsigned int.

Yeah, but you constrain the size. Why not use the native type for the given architecture? It won?t be noticeable in size and speed, but it?s more cleaner.

Quoted 3 lines
Quoted 1 line

phpm does not need to be initialized to 0?

RST_COMP indication in the PHPM register is clear on reading. I once 'read' the PHPM before polling and make sure zero value.

Sorry, I do not understand. I suggest to just declare the variable.

     u32 phpm;
Quoted 6 lines
Quoted 6 lines

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_phy_hw_reset(struct igc_hw *hw) · line 189

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
 ????? s32? ret_val;
 ????? u32 ctrl;
@@ -186,6 +187,8 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 ????? if (ret_val)
 ????????? goto out;
+??? phpm = rd32(IGC_I225_PHPM);

Here you are making sure, that it?s set.

Quoted 27 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
+
 ????? ctrl = rd32(IGC_CTRL);
 ????? wr32(IGC_CTRL, ctrl | IGC_CTRL_PHY_RST);
 ????? wrfl();
@@ -195,6 +198,12 @@ s32 igc_phy_hw_reset(struct igc_hw *hw)
 ????? wr32(IGC_CTRL, ctrl);
Quoted 8 lines

drivers/net/ethernet/intel/igc/igc_phy.c s32 igc_phy_hw_reset(struct igc_hw *hw) · line 204

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_phy.c +5 -0
 ????? wrfl();
+??? do {
+??????? phpm = rd32(IGC_I225_PHPM);
+??????? timeout--;
+??????? udelay(1);
+??? } while (!(phpm & IGC_PHY_RST_COMP) && timeout);

Print an error, when the timeout is reached?

Good idea. I will add hw_dbg in v2. Thanks.

Quoted 12 lines
Quoted 12 lines
drivers/net/ethernet/intel/igc/igc_phy.c +1 -0
+
 ????? usleep_range(1500, 2000);
 ????? phy->ops.release(hw);
drivers/net/ethernet/intel/igc/igc_regs.h +0 -0
index c82111051898..164c42b39dfa 100644
@@ -12,6 +12,7 @@

? #define IGC_MDIC??????? 0x00020? /* MDI Control - RW */
? #define IGC_MDICNFG??????? 0x00E04? /* MDC/MDIO Configuration - RW */

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

? #define IGC_CONNSW??????? 0x00034? /* Copper/Fiber switch control - RW */
+#define IGC_I225_PHPM??????? 0x00E14???? /* I225 PHY Power Management */
? /* Internal Packet Buffer Size Registers */
? #define IGC_RXPBS??????? 0x02404? /* Rx Packet Buffer Size - RW */

Thank you very much for your comments.

No problem. Thank you for the commits.

Kind regards,

Paul