All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: net: cpsw: add support for fixed-links.
@ 2015-11-09 19:24 Daniel Trautmann
  2015-11-10  3:47 ` David Miller
  2015-11-10  3:49 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Trautmann @ 2015-11-09 19:24 UTC (permalink / raw)
  To: netdev; +Cc: davem, mugunthanvnm, balbi, Daniel Trautmann

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: Daniel Trautmann <dtrautmann@ibhsoftec.com>
---
 drivers/net/ethernet/ti/cpsw.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 040fbc1..3e32365 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2039,19 +2039,35 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
 		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
 		parp = of_get_property(slave_node, "phy_id", &lenp);
 		if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
-			dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
-			goto no_phy_slave;
-		}
-		mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
-		phyid = be32_to_cpup(parp+1);
-		mdio = of_find_device_by_node(mdio_node);
-		of_node_put(mdio_node);
-		if (!mdio) {
-			dev_err(&pdev->dev, "Missing mdio platform device\n");
-			return -EINVAL;
+			if (!of_phy_is_fixed_link(slave_node)) {
+				dev_err(&pdev->dev,
+					"Missing slave[%d] phy_id property\n",
+					i);
+				goto no_phy_slave;
+			}
+
+			ret = of_phy_register_fixed_link(slave_node);
+			if (ret) {
+				dev_err(&pdev->dev, "cannot register fixed PHY\n");
+				return ret;
+			}
+
+			/* In the case of a fixed PHY, the DT node associated
+			 * to the PHY is the Ethernet MAC DT node.
+			 */
+			priv->phy_node = of_node_get(slave_node);
+		} else {
+			mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
+			phyid = be32_to_cpup(parp + 1);
+			mdio = of_find_device_by_node(mdio_node);
+			of_node_put(mdio_node);
+			if (!mdio) {
+				dev_err(&pdev->dev, "Missing mdio platform device\n");
+				return -EINVAL;
+			}
+			snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
+				 PHY_ID_FMT, mdio->name, phyid);
 		}
-		snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
-			 PHY_ID_FMT, mdio->name, phyid);
 		slave_data->phy_if = of_get_phy_mode(slave_node);
 		if (slave_data->phy_if < 0) {
 			dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
-- 
1.9.1

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

* Re: [PATCH] drivers: net: cpsw: add support for fixed-links.
  2015-11-09 19:24 [PATCH] drivers: net: cpsw: add support for fixed-links Daniel Trautmann
@ 2015-11-10  3:47 ` David Miller
  2015-11-10  3:49 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-11-10  3:47 UTC (permalink / raw)
  To: dtrautmann; +Cc: netdev, mugunthanvnm, balbi

From: Daniel Trautmann <dtrautmann@ibhsoftec.com>
Date: Mon, 9 Nov 2015 20:24:14 +0100

> @@ -2039,19 +2039,35 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
>  		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
>  		parp = of_get_property(slave_node, "phy_id", &lenp);
>  		if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
> -			dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);

I know this has nothing to do with your patch, but that length check
is completely bogus.

It should be "sizeof(__be32) * 2" not "sizeof(void *) * 2".

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

* Re: [PATCH] drivers: net: cpsw: add support for fixed-links.
  2015-11-09 19:24 [PATCH] drivers: net: cpsw: add support for fixed-links Daniel Trautmann
  2015-11-10  3:47 ` David Miller
@ 2015-11-10  3:49 ` David Miller
  2015-11-10 11:39   ` Daniel Trautmann
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2015-11-10  3:49 UTC (permalink / raw)
  To: dtrautmann; +Cc: netdev, mugunthanvnm, balbi

From: Daniel Trautmann <dtrautmann@ibhsoftec.com>
Date: Mon, 9 Nov 2015 20:24:14 +0100

> 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: Daniel Trautmann <dtrautmann@ibhsoftec.com>

This patch doesn't apply cleanly at all.

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

* Re: [PATCH] drivers: net: cpsw: add support for fixed-links.
  2015-11-10  3:49 ` David Miller
@ 2015-11-10 11:39   ` Daniel Trautmann
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Trautmann @ 2015-11-10 11:39 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, mugunthanvnm, balbi

On Mon, Nov 09, 2015 at 10:49:51PM -0500, David Miller wrote:
> From: Daniel Trautmann <dtrautmann@ibhsoftec.com>
> Date: Mon, 9 Nov 2015 20:24:14 +0100
> 
> > 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: Daniel Trautmann <dtrautmann@ibhsoftec.com>
> 
> This patch doesn't apply cleanly at all.

Sorry, I was working on the wrong branch.
I found there is a similar patch already in netdev-next, I will
check this an submit a new Patch if necessary.

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

end of thread, other threads:[~2015-11-10 11:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09 19:24 [PATCH] drivers: net: cpsw: add support for fixed-links Daniel Trautmann
2015-11-10  3:47 ` David Miller
2015-11-10  3:49 ` David Miller
2015-11-10 11:39   ` Daniel Trautmann

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.