stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode
@ 2019-11-26 14:04 Adrian Bunk
  2019-11-26 14:04 ` [4.14/4.19 patch 2/2] net: phy: dp83867: increase SGMII autoneg timer duration Adrian Bunk
  2019-11-27  2:31 ` [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Sasha Levin
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Bunk @ 2019-11-26 14:04 UTC (permalink / raw)
  To: stable, netdev
  Cc: Max Uvarov, Heiner Kallweit, Florian Fainelli, Andrew Lunn,
	David S . Miller, Adrian Bunk

From: Max Uvarov <muvarov@gmail.com>

Commit 333061b924539c0de081339643f45514f5f1c1e6 upstream.

For supporting 10Mps speed in SGMII mode DP83867_10M_SGMII_RATE_ADAPT bit
of DP83867_10M_SGMII_CFG register has to be cleared by software.
That does not affect speeds 100 and 1000 so can be done on init.

Signed-off-by: Max Uvarov <muvarov@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
[ adapted for kernels without phy_modify_mmd ]
Signed-off-by: Adrian Bunk <bunk@kernel.org>
---
- already in 5.3
- applies and builds against 4.14 and 4.19
- tested with 4.14
---
 drivers/net/phy/dp83867.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 12b09e6e03ba..81106314e6da 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -37,6 +37,8 @@
 #define DP83867_STRAP_STS1	0x006E
 #define DP83867_RGMIIDCTL	0x0086
 #define DP83867_IO_MUX_CFG	0x0170
+#define DP83867_10M_SGMII_CFG   0x016F
+#define DP83867_10M_SGMII_RATE_ADAPT_MASK BIT(7)
 
 #define DP83867_SW_RESET	BIT(15)
 #define DP83867_SW_RESTART	BIT(14)
@@ -283,6 +285,23 @@ static int dp83867_config_init(struct phy_device *phydev)
 		}
 	}
 
+	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+		/* For support SPEED_10 in SGMII mode
+		 * DP83867_10M_SGMII_RATE_ADAPT bit
+		 * has to be cleared by software. That
+		 * does not affect SPEED_100 and
+		 * SPEED_1000.
+		 */
+		val = phy_read_mmd(phydev, DP83867_DEVADDR,
+				   DP83867_10M_SGMII_CFG);
+		val &= ~DP83867_10M_SGMII_RATE_ADAPT_MASK;
+		ret = phy_write_mmd(phydev, DP83867_DEVADDR,
+				    DP83867_10M_SGMII_CFG, val);
+
+		if (ret)
+			return ret;
+	}
+
 	/* Enable Interrupt output INT_OE in CFG3 register */
 	if (phy_interrupt_is_valid(phydev)) {
 		val = phy_read(phydev, DP83867_CFG3);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [4.14/4.19 patch 2/2] net: phy: dp83867: increase SGMII autoneg timer duration
  2019-11-26 14:04 [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Adrian Bunk
@ 2019-11-26 14:04 ` Adrian Bunk
  2019-11-27  2:31 ` [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Bunk @ 2019-11-26 14:04 UTC (permalink / raw)
  To: stable, netdev
  Cc: Max Uvarov, Heiner Kallweit, Florian Fainelli, Andrew Lunn,
	David S . Miller, Adrian Bunk

From: Max Uvarov <muvarov@gmail.com>

Commit 1a97a477e666cbdededab93bd3754e508f0c09d7 upstream.

After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 are 01).
That is not enough to finalize autonegatiation on some devices.
Increase this timer duration to maximum supported 16ms.

Signed-off-by: Max Uvarov <muvarov@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
[ adapted for kernels without phy_modify_mmd ]
Signed-off-by: Adrian Bunk <bunk@kernel.org>
---
- already in 5.3
- applies and builds against 4.14 and 4.19
- tested with 4.14
---
 drivers/net/phy/dp83867.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 81106314e6da..e03e91d5f1b1 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -33,6 +33,12 @@
 
 /* Extended Registers */
 #define DP83867_CFG4            0x0031
+#define DP83867_CFG4_SGMII_ANEG_MASK (BIT(5) | BIT(6))
+#define DP83867_CFG4_SGMII_ANEG_TIMER_11MS   (3 << 5)
+#define DP83867_CFG4_SGMII_ANEG_TIMER_800US  (2 << 5)
+#define DP83867_CFG4_SGMII_ANEG_TIMER_2US    (1 << 5)
+#define DP83867_CFG4_SGMII_ANEG_TIMER_16MS   (0 << 5)
+
 #define DP83867_RGMIICTL	0x0032
 #define DP83867_STRAP_STS1	0x006E
 #define DP83867_RGMIIDCTL	0x0086
@@ -300,6 +306,18 @@ static int dp83867_config_init(struct phy_device *phydev)
 
 		if (ret)
 			return ret;
+
+		/* After reset SGMII Autoneg timer is set to 2us (bits 6 and 5
+		 * are 01). That is not enough to finalize autoneg on some
+		 * devices. Increase this timer duration to maximum 16ms.
+		 */
+		val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4);
+		val &= ~DP83867_CFG4_SGMII_ANEG_MASK;
+		val |= DP83867_CFG4_SGMII_ANEG_TIMER_16MS;
+		ret = phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4, val);
+
+		if (ret)
+			return ret;
 	}
 
 	/* Enable Interrupt output INT_OE in CFG3 register */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode
  2019-11-26 14:04 [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Adrian Bunk
  2019-11-26 14:04 ` [4.14/4.19 patch 2/2] net: phy: dp83867: increase SGMII autoneg timer duration Adrian Bunk
@ 2019-11-27  2:31 ` Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2019-11-27  2:31 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: stable, netdev, Max Uvarov, Heiner Kallweit, Florian Fainelli,
	Andrew Lunn, David S . Miller

On Tue, Nov 26, 2019 at 04:04:05PM +0200, Adrian Bunk wrote:
>From: Max Uvarov <muvarov@gmail.com>
>
>Commit 333061b924539c0de081339643f45514f5f1c1e6 upstream.
>
>For supporting 10Mps speed in SGMII mode DP83867_10M_SGMII_RATE_ADAPT bit
>of DP83867_10M_SGMII_CFG register has to be cleared by software.
>That does not affect speeds 100 and 1000 so can be done on init.
>
>Signed-off-by: Max Uvarov <muvarov@gmail.com>
>Cc: Heiner Kallweit <hkallweit1@gmail.com>
>Cc: Florian Fainelli <f.fainelli@gmail.com>
>Cc: Andrew Lunn <andrew@lunn.ch>
>Signed-off-by: David S. Miller <davem@davemloft.net>
>[ adapted for kernels without phy_modify_mmd ]
>Signed-off-by: Adrian Bunk <bunk@kernel.org>
>---
>- already in 5.3
>- applies and builds against 4.14 and 4.19
>- tested with 4.14

Looks like Greg took these in, thanks!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-27  2:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 14:04 [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Adrian Bunk
2019-11-26 14:04 ` [4.14/4.19 patch 2/2] net: phy: dp83867: increase SGMII autoneg timer duration Adrian Bunk
2019-11-27  2:31 ` [4.14/4.19 patch 1/2] net: phy: dp83867: fix speed 10 in sgmii mode Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).