mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: cpsw: fix probe with fixed-link
@ 2018-02-13 21:48 Andreas Schmidt
  2018-02-16  7:42 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schmidt @ 2018-02-13 21:48 UTC (permalink / raw)
  To: barebox

If cpsw slave is set to fixed-link cpsw probe still try to probe and use
a phy. This patch fix cpsw probe in case of fixed-link.

Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
---
 drivers/net/cpsw.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index d11ca33f7..37e480248 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -184,6 +184,7 @@ struct cpsw_slave {
 	struct eth_device		edev;
 	struct cpsw_priv		*cpsw;
 	struct device_d			dev;
+	int				fixed_link;
 };
 
 struct cpdma_desc {
@@ -913,18 +914,20 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
 	struct eth_device	*edev = &slave->edev;
 	struct device_d		*dev = &slave->dev;
 	int ret;
-	struct phy_device *phy;
+	struct phy_device *phy = NULL;
 
-	phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		goto err_out;
-	}
+	if (!slave->fixed_link) {
+		phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
+		if (IS_ERR(phy)) {
+			ret = PTR_ERR(phy);
+			goto err_out;
+		}
 
-	phy->dev.device_node = priv->slaves[slave_num].dev.device_node;
-	ret = phy_register_device(phy);
-	if (ret)
-		goto err_out;
+		phy->dev.device_node = priv->slaves[slave_num].dev.device_node;
+		ret = phy_register_device(phy);
+		if (ret)
+			goto err_out;
+	}
 
 	sprintf(dev->name, "cpsw-slave");
 	dev->id = slave->slave_num;
@@ -957,7 +960,8 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
 	return 0;
 
 err_register_dev:
-	phy_unregister_device(phy);
+	if (!slave->fixed_link)
+		phy_unregister_device(phy);
 err_register_edev:
 	unregister_device(dev);
 err_out:
@@ -1103,11 +1107,20 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
 			uint32_t phy_id[2];
 
 			ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
-			if (ret)
-				return ret;
+			if (!ret) {
+				slave->phy_id = phy_id[1];
+				slave->fixed_link = 0;
+			} else {
+				struct device_node *fl_np;
+				fl_np = of_find_node_by_name(child, "fixed-link");
+				if (fl_np) {
+					slave->phy_id = -1;
+					slave->fixed_link = 1;
+				} else
+					return ret;
+			}
 
 			slave->dev.device_node = child;
-			slave->phy_id = phy_id[1];
 			slave->phy_if = of_get_phy_mode(child);
 			slave->slave_num = i;
 
-- 
2.14.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] net: cpsw: fix probe with fixed-link
  2018-02-13 21:48 [PATCH] net: cpsw: fix probe with fixed-link Andreas Schmidt
@ 2018-02-16  7:42 ` Sascha Hauer
  2018-02-22 22:16   ` [PATCH v2] " Andreas Schmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2018-02-16  7:42 UTC (permalink / raw)
  To: Andreas Schmidt; +Cc: barebox

Hi Andreas,

On Tue, Feb 13, 2018 at 10:48:16PM +0100, Andreas Schmidt wrote:
> If cpsw slave is set to fixed-link cpsw probe still try to probe and use
> a phy. This patch fix cpsw probe in case of fixed-link.
> 
> Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
> ---
>  drivers/net/cpsw.c | 41 +++++++++++++++++++++++++++--------------
>  1 file changed, 27 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index d11ca33f7..37e480248 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -184,6 +184,7 @@ struct cpsw_slave {
>  	struct eth_device		edev;
>  	struct cpsw_priv		*cpsw;
>  	struct device_d			dev;
> +	int				fixed_link;
>  };
>  
>  struct cpdma_desc {
> @@ -913,18 +914,20 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
>  	struct eth_device	*edev = &slave->edev;
>  	struct device_d		*dev = &slave->dev;
>  	int ret;
> -	struct phy_device *phy;
> +	struct phy_device *phy = NULL;
>  
> -	phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
> -	if (IS_ERR(phy)) {
> -		ret = PTR_ERR(phy);
> -		goto err_out;
> -	}
> +	if (!slave->fixed_link) {
> +		phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
> +		if (IS_ERR(phy)) {
> +			ret = PTR_ERR(phy);
> +			goto err_out;
> +		}

Calling mdiobus_scan() here is not only wrong for a fixed phy, it is
wrong for a regular mdiobus phy aswell. I just sent out a patch which
just removes the call to mdiobus_scan(). Tested on a beaglebone which
has a real phy, it should work for you aswell.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2] net: cpsw: fix probe with fixed-link
  2018-02-16  7:42 ` Sascha Hauer
@ 2018-02-22 22:16   ` Andreas Schmidt
  2018-02-27  8:41     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schmidt @ 2018-02-22 22:16 UTC (permalink / raw)
  To: barebox

While cpsw is probe dt, it accepts only slaves nodes with "phy_id" property.
In case of fixed-link there are no "phy_id" property and probe would be failed.
This patch avoid the failure due to missing "phy_id" in case of fixed-link.

Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
---

Changes since v1:
  - rework after "[PATCH] net: cpsw: remove unnecessary mdiobus_scan()" patch was committed.

---
 drivers/net/cpsw.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 928b97774..3d3939cfa 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -1089,11 +1089,13 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
 
 		if (i < priv->num_slaves && !strncmp(child->name, "slave", 5)) {
 			struct cpsw_slave *slave = &priv->slaves[i];
-			uint32_t phy_id[2];
+			uint32_t phy_id[2] = {-1, -1};
 
-			ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
-			if (ret)
-				return ret;
+			if (!of_find_node_by_name(child, "fixed-link")) {
+				ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
+				if (ret)
+					return ret;
+			}
 
 			slave->dev.device_node = child;
 			slave->phy_id = phy_id[1];
-- 
2.14.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] net: cpsw: fix probe with fixed-link
  2018-02-22 22:16   ` [PATCH v2] " Andreas Schmidt
@ 2018-02-27  8:41     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-02-27  8:41 UTC (permalink / raw)
  To: Andreas Schmidt; +Cc: barebox

On Thu, Feb 22, 2018 at 11:16:27PM +0100, Andreas Schmidt wrote:
> While cpsw is probe dt, it accepts only slaves nodes with "phy_id" property.
> In case of fixed-link there are no "phy_id" property and probe would be failed.
> This patch avoid the failure due to missing "phy_id" in case of fixed-link.
> 
> Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
> ---
> 
> Changes since v1:
>   - rework after "[PATCH] net: cpsw: remove unnecessary mdiobus_scan()" patch was committed.
> 
> ---
>  drivers/net/cpsw.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index 928b97774..3d3939cfa 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -1089,11 +1089,13 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
>  
>  		if (i < priv->num_slaves && !strncmp(child->name, "slave", 5)) {
>  			struct cpsw_slave *slave = &priv->slaves[i];
> -			uint32_t phy_id[2];
> +			uint32_t phy_id[2] = {-1, -1};
>  
> -			ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
> -			if (ret)
> -				return ret;
> +			if (!of_find_node_by_name(child, "fixed-link")) {
> +				ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
> +				if (ret)
> +					return ret;
> +			}
>  
>  			slave->dev.device_node = child;
>  			slave->phy_id = phy_id[1];
> -- 
> 2.14.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-02-27  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 21:48 [PATCH] net: cpsw: fix probe with fixed-link Andreas Schmidt
2018-02-16  7:42 ` Sascha Hauer
2018-02-22 22:16   ` [PATCH v2] " Andreas Schmidt
2018-02-27  8:41     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox