Skip to contentSkip to conversation

sh_eth: call of_mdiobus_register() to register phys

PATCH Superseded Ben Dooks 2 participants 3 messages Feb 17, 2014 – Feb 18, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH v2 1/1 sh_eth: call of_mdiobus_register() to register phys

If the sh_eth device is registered using OF, then the driver should call of_mdiobus_register() to register any PHYs connected to the system.

--
v2:
- allocate mdio->irq array at init time
- set devdata after succesful mdio registration

---
 drivers/net/ethernet/renesas/sh_eth.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +13 -0
index 06970ac..1244509 100644
@@ -40,6 +40,7 @@
 #include <linux/if_vlan.h>
 #include <linux/clk.h>
 #include <linux/sh_eth.h>
+#include <linux/of_mdio.h>
 
 #include "sh_eth.h"
 
@@ -2638,6 +2639,18 @@ static int sh_mdio_init(struct net_device *ndev, int id,
 		goto out_free_bus;
 	}
 
+	if (ndev->dev.parent->of_node) {
+		ret = of_mdiobus_register(mdp->mii_bus,
+					  ndev->dev.parent->of_node);
+		if (ret != 0) {
+			dev_err(&ndev->dev, "of_mdiobus_register() failed\n");
+			goto out_free_bus;
+		}
+
+		dev_set_drvdata(&ndev->dev, mdp->mii_bus);
+		return 0;
+	}
+
 	for (i = 0; i < PHY_MAX_ADDR; i++)
 		mdp->mii_bus->irq[i] = PHY_POLL;
 	if (pd->phy_irq > 0)
Signature · 1 line
1.8.5.3
#1 lore raw

Hello.

Quoted 9 lines · Ben Dooks

If the sh_eth device is registered using OF, then the driver should call of_mdiobus_register() to register any PHYs connected to the system.

--
v2:
- allocate mdio->irq array at init time

Did this also fix something?

Quoted 18 lines

- set devdata after succesful mdio registration

---
  drivers/net/ethernet/renesas/sh_eth.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +1 -0
index 06970ac..1244509 100644
@@ -40,6 +40,7 @@
  #include <linux/if_vlan.h>
  #include <linux/clk.h>
  #include <linux/sh_eth.h>
+#include <linux/of_mdio.h>
 
  #include "sh_eth.h"
 

drivers/net/ethernet/renesas/sh_eth.c static int sh_mdio_init(struct net_device *ndev, int id, · line 2645

Quoted 7 lines
drivers/net/ethernet/renesas/sh_eth.c +4 -0
@@ -2638,6 +2639,18 @@ static int sh_mdio_init(struct net_device *ndev, int id,
  		goto out_free_bus;
  	}
 
+	if (ndev->dev.parent->of_node) {
+		ret = of_mdiobus_register(mdp->mii_bus,
+					  ndev->dev.parent->of_node);
+		if (ret != 0) {

Why not just (ret)?

drivers/net/ethernet/renesas/sh_eth.c static int sh_mdio_init(struct net_device *ndev, int id, · line 2656

Quoted 11 lines
drivers/net/ethernet/renesas/sh_eth.c +8 -0
+			dev_err(&ndev->dev, "of_mdiobus_register() failed\n");
+			goto out_free_bus;
+		}
+
+		dev_set_drvdata(&ndev->dev, mdp->mii_bus);
+		return 0;
+	}
+
  	for (i = 0; i < PHY_MAX_ADDR; i++)
  		mdp->mii_bus->irq[i] = PHY_POLL;
  	if (pd->phy_irq > 0)

With this code I don't have to call irq_of_parse_and_map() myself when
parsing the device node, it seems. What if you insert your code after these initializers? Or could you please base off my patch and remove that superfluous irq_of_parse_and_map() call from sh_eth_parse_dt()? I'm going to post v4 on netdev RSN.

WBR, Sergei

author
#2 lore raw
In reply to Ben Dooks
Quoted 55 lines · Sergei Shtylyov

Hello.

Quoted 9 lines · Ben Dooks

If the sh_eth device is registered using OF, then the driver should call of_mdiobus_register() to register any PHYs connected to the system.

--
v2:
- allocate mdio->irq array at init time

Did this also fix something?

Quoted 19 lines

- set devdata after succesful mdio registration

---
  drivers/net/ethernet/renesas/sh_eth.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +1 -0
index 06970ac..1244509 100644
@@ -40,6 +40,7 @@
  #include <linux/if_vlan.h>
  #include <linux/clk.h>
  #include <linux/sh_eth.h>
+#include <linux/of_mdio.h>
 
  #include "sh_eth.h"
 

drivers/net/ethernet/renesas/sh_eth.c static int sh_mdio_init(struct net_device · line 2646

Quoted 8 lines
drivers/net/ethernet/renesas/sh_eth.c +4 -0
@@ -2638,6 +2639,18 @@ static int sh_mdio_init(struct net_device
 *ndev, int id,
          goto out_free_bus;
      }
 
+    if (ndev->dev.parent->of_node) {
+        ret = of_mdiobus_register(mdp->mii_bus,
+                      ndev->dev.parent->of_node);
+        if (ret != 0) {

Why not just (ret)?

Quoted 9 lines
drivers/net/ethernet/renesas/sh_eth.c +8 -0
+            dev_err(&ndev->dev, "of_mdiobus_register() failed\n");
+            goto out_free_bus;
+        }
+
+        dev_set_drvdata(&ndev->dev, mdp->mii_bus);
+        return 0;
+    }
+
      for (i = 0; i < PHY_MAX_ADDR; i++)
Quoted 8 lines
Quoted 2 lines
drivers/net/ethernet/renesas/sh_eth.c +0 -0
          mdp->mii_bus->irq[i] = PHY_POLL;
      if (pd->phy_irq > 0)

With this code I don't have to call irq_of_parse_and_map() myself
when parsing the device node, it seems. What if you insert your code after these initializers? Or could you please base off my patch and remove that superfluous irq_of_parse_and_map() call from sh_eth_parse_dt()? I'm going to post v4 on netdev RSN.

Aha, I will look into that and adding some LED properties to the KSZ8041 micrel PHYs.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius