aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/patches-4.9/408-net-phy-hook-up-clause-45-autonegotiation-restart.patch
blob: 7a16bd596374cb9ae10d258672a7a5c1c7b5dc44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Fri, 13 Jan 2017 11:17:30 +0000
Subject: [PATCH] net: phy: hook up clause 45 autonegotiation restart

genphy_restart_aneg() can only restart autonegotiation on clause 22
PHYs.  Add a phy_restart_aneg() function which selects between the
clause 22 and clause 45 restart functionality depending on the PHY
type.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---

--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -134,6 +134,24 @@ static int phy_config_interrupt(struct p
 	return 0;
 }
 
+/**
+ * phy_restart_aneg - restart auto-negotiation
+ * @phydev: target phy_device struct
+ *
+ * Restart the autonegotiation on @phydev.  Returns >= 0 on success or
+ * negative errno on error.
+ */
+static int phy_restart_aneg(struct phy_device *phydev)
+{
+	int ret;
+
+	if (phydev->is_c45)
+		ret = genphy_c45_restart_aneg(phydev);
+	else
+		ret = genphy_restart_aneg(phydev);
+
+	return ret;
+}
 
 /**
  * phy_aneg_done - return auto-negotiation status
@@ -1403,3 +1421,14 @@ int phy_ethtool_set_link_ksettings(struc
 	return phy_ethtool_ksettings_set(phydev, cmd);
 }
 EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
+
+int phy_ethtool_nway_reset(struct net_device *ndev)
+{
+	struct phy_device *phydev = ndev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return phy_restart_aneg(phydev);
+}
+EXPORT_SYMBOL(phy_ethtool_nway_reset);