diff mbox

[v1,2/2] net: stmmac: add fixed_phy support via fixed-link DT binding

Message ID 1422239858-3452-3-git-send-email-ming.lei@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ming Lei Jan. 26, 2015, 2:37 a.m. UTC
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |    5 ++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Andreas Färber Jan. 26, 2015, 3:01 a.m. UTC | #1
Am 26.01.2015 um 03:37 schrieb Ming Lei:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 8c6b7c16..ddb4351 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -847,8 +847,11 @@ static int stmmac_init_phy(struct net_device *dev)
>  	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
>  	 * device as well.
>  	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
> +	 * But phy_id returned from fixed phy is always zero, so bypass the
> +	 * check for fixed phy.
>  	 */
> -	if (phydev->phy_id == 0) {
> +	if (phydev->phy_id == 0 && (!priv->plat->phy_bus_name ||
> +			strcmp(priv->plat->phy_bus_name,"fixed"))) {

Small nit here: There's a space missing between the arguments.

Cheers,
Andreas

>  		phy_disconnect(phydev);
>  		return -ENODEV;
>  	}
[snip]
diff mbox

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8c6b7c16..ddb4351 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -847,8 +847,11 @@  static int stmmac_init_phy(struct net_device *dev)
 	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
 	 * device as well.
 	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
+	 * But phy_id returned from fixed phy is always zero, so bypass the
+	 * check for fixed phy.
 	 */
-	if (phydev->phy_id == 0) {
+	if (phydev->phy_id == 0 && (!priv->plat->phy_bus_name ||
+			strcmp(priv->plat->phy_bus_name,"fixed"))) {
 		phy_disconnect(phydev);
 		return -ENODEV;
 	}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 3039de2..73a3ced 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -27,6 +27,7 @@ 
 #include <linux/of.h>
 #include <linux/of_net.h>
 #include <linux/of_device.h>
+#include <linux/of_mdio.h>
 
 #include "stmmac.h"
 #include "stmmac_platform.h"
@@ -216,6 +217,15 @@  static int stmmac_probe_config_dt(struct platform_device *pdev,
 		plat->pmt = 1;
 	}
 
+	if (of_phy_is_fixed_link(np)) {
+		int ret = of_phy_register_fixed_link(np);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to register fixed PHY\n");
+			return ret;
+		}
+		plat->phy_bus_name = "fixed";
+	}
+
 	if (of_device_is_compatible(np, "snps,dwmac-3.610") ||
 		of_device_is_compatible(np, "snps,dwmac-3.710")) {
 		plat->enh_desc = 1;