netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] altera tse: add support for lixed-links.
@ 2015-04-21 16:32 Andreas Oetken
  2015-04-21 21:37 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andreas Oetken @ 2015-04-21 16:32 UTC (permalink / raw)
  To: Vince Bridgers, netdev, nios2-dev; +Cc: Andreas Oetken

From: Andreas Oetken <ennoerlangen@gmail.com>

Add support for fixed-links in configurations without PHY.
(e.g. connection to a switch, SGMII point to point, SFPs)

Check: Documentation/devicetree/bindings/net/fixed-link.txt.
Signed-off-by: Andreas Oetken <ennoerlangen@gmail.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 36 +++++++++++++++++++++------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index dbbbd34..a90262e 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -777,6 +777,7 @@ static int init_phy(struct net_device *dev)
 	struct altera_tse_private *priv = netdev_priv(dev);
 	struct phy_device *phydev;
 	struct device_node *phynode;
+	bool fixed_link = false;
 
 	/* Avoid init phy in case of no phy present */
 	if (!priv->phy_iface)
@@ -789,13 +790,32 @@ static int init_phy(struct net_device *dev)
 	phynode = of_parse_phandle(priv->device->of_node, "phy-handle", 0);
 
 	if (!phynode) {
-		netdev_dbg(dev, "no phy-handle found\n");
-		if (!priv->mdio) {
-			netdev_err(dev,
-				   "No phy-handle nor local mdio specified\n");
-			return -ENODEV;
+		/* check if a fixed-link is defined in device-tree */
+		if (of_phy_is_fixed_link(priv->device->of_node)) {
+			if (of_phy_register_fixed_link(priv->device->of_node)
+			    < 0) {
+				netdev_err(dev, "cannot register fixed PHY\n");
+				return -ENODEV;
+			}
+
+			/* In the case of a fixed PHY, the DT node associated
+			* to the PHY is the Ethernet MAC DT node.
+			*/
+			phynode = of_node_get(priv->device->of_node);
+			fixed_link = true;
+
+			netdev_dbg(dev, "fixed-link detected\n");
+			phydev = of_phy_connect(dev, phynode,
+						&altera_tse_adjust_link,
+						0, priv->phy_iface);
+		} else {
+			netdev_dbg(dev, "no phy-handle found\n");
+			if (!priv->mdio) {
+				netdev_err(dev, "No phy-handle nor local mdio specified\n");
+				return -ENODEV;
+			}
+			phydev = connect_local_phy(dev);
 		}
-		phydev = connect_local_phy(dev);
 	} else {
 		netdev_dbg(dev, "phy-handle found\n");
 		phydev = of_phy_connect(dev, phynode,
@@ -819,10 +839,10 @@ static int init_phy(struct net_device *dev)
 	/* Broken HW is sometimes missing the pull-up resistor on the
 	 * MDIO line, which results in reads to non-existent devices returning
 	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
-	 * device as well.
+	 * device as well. If a fixed-link is used the phy_id is always 0.
 	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
 	 */
-	if (phydev->phy_id == 0) {
+	if ((phydev->phy_id == 0) && !fixed_link) {
 		netdev_err(dev, "Bad PHY UID 0x%08x\n", phydev->phy_id);
 		phy_disconnect(phydev);
 		return -ENODEV;
-- 
2.1.4

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

* Re: [PATCH] altera tse: add support for lixed-links.
  2015-04-21 16:32 [PATCH] altera tse: add support for lixed-links Andreas Oetken
@ 2015-04-21 21:37 ` David Miller
  2015-04-22 13:22 ` [PATCH v2] altera tse: add support for fixed-links Andreas Oetken
  2015-04-25 16:07 ` [PATCH v3] " Andreas Oetken
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-04-21 21:37 UTC (permalink / raw)
  To: ennoerlangen; +Cc: vbridger, netdev, nios2-dev, ennoerlangen

From: Andreas Oetken <ennoerlangen@googlemail.com>
Date: Tue, 21 Apr 2015 18:32:25 +0200

Subject typo "lixed --> fixed"

> +			/* In the case of a fixed PHY, the DT node associated
> +			* to the PHY is the Ethernet MAC DT node.
> +			*/

Not indented properly, the second and third line of this comment need
one extra space before the first "*".

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

* [PATCH v2] altera tse: add support for fixed-links.
  2015-04-21 16:32 [PATCH] altera tse: add support for lixed-links Andreas Oetken
  2015-04-21 21:37 ` David Miller
@ 2015-04-22 13:22 ` Andreas Oetken
  2015-04-23 18:57   ` David Miller
  2015-04-25 16:07 ` [PATCH v3] " Andreas Oetken
  2 siblings, 1 reply; 6+ messages in thread
From: Andreas Oetken @ 2015-04-22 13:22 UTC (permalink / raw)
  To: Vince Bridgers, netdev, nios2-dev; +Cc: Andreas Oetken

From: Andreas Oetken <ennoerlangen@gmail.com>

Add support for fixed-links in configurations without PHY.
(e.g. connection to a switch, SGMII point to point, SFPs)

Check: Documentation/devicetree/bindings/net/fixed-link.txt.
Signed-off-by: Andreas Oetken <ennoerlangen@gmail.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 36 +++++++++++++++++++++------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index dbbbd34..b37f4df 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -777,6 +777,7 @@ static int init_phy(struct net_device *dev)
 	struct altera_tse_private *priv = netdev_priv(dev);
 	struct phy_device *phydev;
 	struct device_node *phynode;
+	bool fixed_link = false;
 
 	/* Avoid init phy in case of no phy present */
 	if (!priv->phy_iface)
@@ -789,13 +790,32 @@ static int init_phy(struct net_device *dev)
 	phynode = of_parse_phandle(priv->device->of_node, "phy-handle", 0);
 
 	if (!phynode) {
-		netdev_dbg(dev, "no phy-handle found\n");
-		if (!priv->mdio) {
-			netdev_err(dev,
-				   "No phy-handle nor local mdio specified\n");
-			return -ENODEV;
+		/* check if a fixed-link is defined in device-tree */
+		if (of_phy_is_fixed_link(priv->device->of_node)) {
+			if (of_phy_register_fixed_link(priv->device->of_node)
+			    < 0) {
+				netdev_err(dev, "cannot register fixed PHY\n");
+				return -ENODEV;
+			}
+
+			/* In the case of a fixed PHY, the DT node associated
+			 * to the PHY is the Ethernet MAC DT node.
+			 */
+			phynode = of_node_get(priv->device->of_node);
+			fixed_link = true;
+
+			netdev_dbg(dev, "fixed-link detected\n");
+			phydev = of_phy_connect(dev, phynode,
+						&altera_tse_adjust_link,
+						0, priv->phy_iface);
+		} else {
+			netdev_dbg(dev, "no phy-handle found\n");
+			if (!priv->mdio) {
+				netdev_err(dev, "No phy-handle nor local mdio specified\n");
+				return -ENODEV;
+			}
+			phydev = connect_local_phy(dev);
 		}
-		phydev = connect_local_phy(dev);
 	} else {
 		netdev_dbg(dev, "phy-handle found\n");
 		phydev = of_phy_connect(dev, phynode,
@@ -819,10 +839,10 @@ static int init_phy(struct net_device *dev)
 	/* Broken HW is sometimes missing the pull-up resistor on the
 	 * MDIO line, which results in reads to non-existent devices returning
 	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
-	 * device as well.
+	 * device as well. If a fixed-link is used the phy_id is always 0.
 	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
 	 */
-	if (phydev->phy_id == 0) {
+	if ((phydev->phy_id == 0) && !fixed_link) {
 		netdev_err(dev, "Bad PHY UID 0x%08x\n", phydev->phy_id);
 		phy_disconnect(phydev);
 		return -ENODEV;
-- 
2.1.4

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

* Re: [PATCH v2] altera tse: add support for fixed-links.
  2015-04-22 13:22 ` [PATCH v2] altera tse: add support for fixed-links Andreas Oetken
@ 2015-04-23 18:57   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-04-23 18:57 UTC (permalink / raw)
  To: ennoerlangen; +Cc: vbridger, netdev, nios2-dev, ennoerlangen

From: Andreas Oetken <ennoerlangen@googlemail.com>
Date: Wed, 22 Apr 2015 15:22:22 +0200

> +		/* check if a fixed-link is defined in device-tree */
> +		if (of_phy_is_fixed_link(priv->device->of_node)) {
> +			if (of_phy_register_fixed_link(priv->device->of_node)
> +			    < 0) {

You should store the return value of of_phy_register_fixed_link() and return
that as the error code when it fails.

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

* [PATCH v3] altera tse: add support for fixed-links.
  2015-04-21 16:32 [PATCH] altera tse: add support for lixed-links Andreas Oetken
  2015-04-21 21:37 ` David Miller
  2015-04-22 13:22 ` [PATCH v2] altera tse: add support for fixed-links Andreas Oetken
@ 2015-04-25 16:07 ` Andreas Oetken
  2015-04-26 20:07   ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Andreas Oetken @ 2015-04-25 16:07 UTC (permalink / raw)
  To: Vince Bridgers, netdev, nios2-dev; +Cc: Andreas Oetken

From: Andreas Oetken <ennoerlangen@gmail.com>

Add support for fixed-links in configurations without PHY.
(e.g. connection to a switch, SGMII point to point, SFPs)

Check: Documentation/devicetree/bindings/net/fixed-link.txt.
Signed-off-by: Andreas Oetken <ennoerlangen@gmail.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 37 +++++++++++++++++++++------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index dbbbd34..b41e8a8 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -777,6 +777,8 @@ static int init_phy(struct net_device *dev)
 	struct altera_tse_private *priv = netdev_priv(dev);
 	struct phy_device *phydev;
 	struct device_node *phynode;
+	bool fixed_link = false;
+	int rc = 0;
 
 	/* Avoid init phy in case of no phy present */
 	if (!priv->phy_iface)
@@ -789,13 +791,32 @@ static int init_phy(struct net_device *dev)
 	phynode = of_parse_phandle(priv->device->of_node, "phy-handle", 0);
 
 	if (!phynode) {
-		netdev_dbg(dev, "no phy-handle found\n");
-		if (!priv->mdio) {
-			netdev_err(dev,
-				   "No phy-handle nor local mdio specified\n");
-			return -ENODEV;
+		/* check if a fixed-link is defined in device-tree */
+		if (of_phy_is_fixed_link(priv->device->of_node)) {
+			rc = of_phy_register_fixed_link(priv->device->of_node);
+			if (rc < 0) {
+				netdev_err(dev, "cannot register fixed PHY\n");
+				return rc;
+			}
+
+			/* In the case of a fixed PHY, the DT node associated
+			 * to the PHY is the Ethernet MAC DT node.
+			 */
+			phynode = of_node_get(priv->device->of_node);
+			fixed_link = true;
+
+			netdev_dbg(dev, "fixed-link detected\n");
+			phydev = of_phy_connect(dev, phynode,
+						&altera_tse_adjust_link,
+						0, priv->phy_iface);
+		} else {
+			netdev_dbg(dev, "no phy-handle found\n");
+			if (!priv->mdio) {
+				netdev_err(dev, "No phy-handle nor local mdio specified\n");
+				return -ENODEV;
+			}
+			phydev = connect_local_phy(dev);
 		}
-		phydev = connect_local_phy(dev);
 	} else {
 		netdev_dbg(dev, "phy-handle found\n");
 		phydev = of_phy_connect(dev, phynode,
@@ -819,10 +840,10 @@ static int init_phy(struct net_device *dev)
 	/* Broken HW is sometimes missing the pull-up resistor on the
 	 * MDIO line, which results in reads to non-existent devices returning
 	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
-	 * device as well.
+	 * device as well. If a fixed-link is used the phy_id is always 0.
 	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
 	 */
-	if (phydev->phy_id == 0) {
+	if ((phydev->phy_id == 0) && !fixed_link) {
 		netdev_err(dev, "Bad PHY UID 0x%08x\n", phydev->phy_id);
 		phy_disconnect(phydev);
 		return -ENODEV;
-- 
2.1.4

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

* Re: [PATCH v3] altera tse: add support for fixed-links.
  2015-04-25 16:07 ` [PATCH v3] " Andreas Oetken
@ 2015-04-26 20:07   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-04-26 20:07 UTC (permalink / raw)
  To: ennoerlangen; +Cc: vbridger, netdev, nios2-dev, ennoerlangen

From: Andreas Oetken <ennoerlangen@googlemail.com>
Date: Sat, 25 Apr 2015 18:07:52 +0200

> From: Andreas Oetken <ennoerlangen@gmail.com>
> 
> Add support for fixed-links in configurations without PHY.
> (e.g. connection to a switch, SGMII point to point, SFPs)
> 
> Check: Documentation/devicetree/bindings/net/fixed-link.txt.
> Signed-off-by: Andreas Oetken <ennoerlangen@gmail.com>

Applied.

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

end of thread, other threads:[~2015-04-26 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 16:32 [PATCH] altera tse: add support for lixed-links Andreas Oetken
2015-04-21 21:37 ` David Miller
2015-04-22 13:22 ` [PATCH v2] altera tse: add support for fixed-links Andreas Oetken
2015-04-23 18:57   ` David Miller
2015-04-25 16:07 ` [PATCH v3] " Andreas Oetken
2015-04-26 20:07   ` David Miller

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).