All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/2] DP83869 Enhancements
@ 2020-05-21 17:47 Dan Murphy
  2020-05-21 17:47 ` [PATCH net-next v3 1/2] net: phy: dp83869: Update port-mirroring to read straps Dan Murphy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Murphy @ 2020-05-21 17:47 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, davem
  Cc: netdev, linux-kernel, devicetree, Dan Murphy

Hello

These are improvements to the DP83869 Ethernet PHY driver.  OP-mode and port
mirroring may be strapped on the device but the software only retrives these
settings from the device tree.  Reading the straps and initializing the
associated stored variables so when setting the PHY up and down the PHY's
configuration values will be retained.

Dan Murphy (2):
  net: phy: dp83869: Update port-mirroring to read straps
  net: phy: dp83869: Set opmode from straps

 drivers/net/phy/dp83869.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

-- 
2.26.2


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

* [PATCH net-next v3 1/2] net: phy: dp83869: Update port-mirroring to read straps
  2020-05-21 17:47 [PATCH net-next v3 0/2] DP83869 Enhancements Dan Murphy
@ 2020-05-21 17:47 ` Dan Murphy
  2020-05-21 17:47 ` [PATCH net-next v3 2/2] net: phy: dp83869: Set opmode from straps Dan Murphy
  2020-05-22 23:13 ` [PATCH net-next v3 0/2] DP83869 Enhancements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Murphy @ 2020-05-21 17:47 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, davem
  Cc: netdev, linux-kernel, devicetree, Dan Murphy

The device tree may not have the property set for port mirroring
because the hardware may have it strapped. If the property is not in the
DT then check the straps and set the port mirroring bit appropriately.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/net/phy/dp83869.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 7996a4aea8d2..073a0f7754a5 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -66,6 +66,7 @@
 
 /* STRAP_STS1 bits */
 #define DP83869_STRAP_STS1_RESERVED		BIT(11)
+#define DP83869_STRAP_MIRROR_ENABLED           BIT(12)
 
 /* PHYCTRL bits */
 #define DP83869_RX_FIFO_SHIFT	12
@@ -191,10 +192,18 @@ static int dp83869_of_init(struct phy_device *phydev)
 	else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
 		dp83869->io_impedance = DP83869_IO_MUX_CFG_IO_IMPEDANCE_MIN;
 
-	if (of_property_read_bool(of_node, "enet-phy-lane-swap"))
+	if (of_property_read_bool(of_node, "enet-phy-lane-swap")) {
 		dp83869->port_mirroring = DP83869_PORT_MIRRORING_EN;
-	else
-		dp83869->port_mirroring = DP83869_PORT_MIRRORING_DIS;
+	} else {
+		/* If the lane swap is not in the DT then check the straps */
+		ret = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_STRAP_STS1);
+		if (ret < 0)
+			return ret;
+		if (ret & DP83869_STRAP_MIRROR_ENABLED)
+			dp83869->port_mirroring = DP83869_PORT_MIRRORING_EN;
+		else
+			dp83869->port_mirroring = DP83869_PORT_MIRRORING_DIS;
+	}
 
 	if (of_property_read_u32(of_node, "rx-fifo-depth",
 				 &dp83869->rx_fifo_depth))
-- 
2.26.2


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

* [PATCH net-next v3 2/2] net: phy: dp83869: Set opmode from straps
  2020-05-21 17:47 [PATCH net-next v3 0/2] DP83869 Enhancements Dan Murphy
  2020-05-21 17:47 ` [PATCH net-next v3 1/2] net: phy: dp83869: Update port-mirroring to read straps Dan Murphy
@ 2020-05-21 17:47 ` Dan Murphy
  2020-05-22 23:13 ` [PATCH net-next v3 0/2] DP83869 Enhancements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Murphy @ 2020-05-21 17:47 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, davem
  Cc: netdev, linux-kernel, devicetree, Dan Murphy

If the op-mode for the device is not set in the device tree then set
the strapped op-mode and store it for later configuration.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/net/phy/dp83869.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 073a0f7754a5..cfb22a21a2e6 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -65,6 +65,7 @@
 #define DP83869_RGMII_RX_CLK_DELAY_EN		BIT(0)
 
 /* STRAP_STS1 bits */
+#define DP83869_STRAP_OP_MODE_MASK		GENMASK(2, 0)
 #define DP83869_STRAP_STS1_RESERVED		BIT(11)
 #define DP83869_STRAP_MIRROR_ENABLED           BIT(12)
 
@@ -161,6 +162,20 @@ static int dp83869_config_port_mirroring(struct phy_device *phydev)
 					  DP83869_CFG3_PORT_MIRROR_EN);
 }
 
+static int dp83869_set_strapped_mode(struct phy_device *phydev)
+{
+	struct dp83869_private *dp83869 = phydev->priv;
+	int val;
+
+	val = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_STRAP_STS1);
+	if (val < 0)
+		return val;
+
+	dp83869->mode = val & DP83869_STRAP_OP_MODE_MASK;
+
+	return 0;
+}
+
 #ifdef CONFIG_OF_MDIO
 static int dp83869_of_init(struct phy_device *phydev)
 {
@@ -185,6 +200,10 @@ static int dp83869_of_init(struct phy_device *phydev)
 		if (dp83869->mode < DP83869_RGMII_COPPER_ETHERNET ||
 		    dp83869->mode > DP83869_SGMII_COPPER_ETHERNET)
 			return -EINVAL;
+	} else {
+		ret = dp83869_set_strapped_mode(phydev);
+		if (ret)
+			return ret;
 	}
 
 	if (of_property_read_bool(of_node, "ti,max-output-impedance"))
@@ -218,7 +237,7 @@ static int dp83869_of_init(struct phy_device *phydev)
 #else
 static int dp83869_of_init(struct phy_device *phydev)
 {
-	return 0;
+	return dp83869_set_strapped_mode(phydev);
 }
 #endif /* CONFIG_OF_MDIO */
 
-- 
2.26.2


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

* Re: [PATCH net-next v3 0/2] DP83869 Enhancements
  2020-05-21 17:47 [PATCH net-next v3 0/2] DP83869 Enhancements Dan Murphy
  2020-05-21 17:47 ` [PATCH net-next v3 1/2] net: phy: dp83869: Update port-mirroring to read straps Dan Murphy
  2020-05-21 17:47 ` [PATCH net-next v3 2/2] net: phy: dp83869: Set opmode from straps Dan Murphy
@ 2020-05-22 23:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-05-22 23:13 UTC (permalink / raw)
  To: dmurphy; +Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel, devicetree

From: Dan Murphy <dmurphy@ti.com>
Date: Thu, 21 May 2020 12:47:36 -0500

> These are improvements to the DP83869 Ethernet PHY driver.  OP-mode and port
> mirroring may be strapped on the device but the software only retrives these
> settings from the device tree.  Reading the straps and initializing the
> associated stored variables so when setting the PHY up and down the PHY's
> configuration values will be retained.

Series applied, thank you.

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

end of thread, other threads:[~2020-05-22 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 17:47 [PATCH net-next v3 0/2] DP83869 Enhancements Dan Murphy
2020-05-21 17:47 ` [PATCH net-next v3 1/2] net: phy: dp83869: Update port-mirroring to read straps Dan Murphy
2020-05-21 17:47 ` [PATCH net-next v3 2/2] net: phy: dp83869: Set opmode from straps Dan Murphy
2020-05-22 23:13 ` [PATCH net-next v3 0/2] DP83869 Enhancements David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.