* [PATCH] net: mvmdio: get and enable optional clock @ 2013-04-07 11:09 Sebastian Hesselbarth 2013-04-07 11:09 ` [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property Sebastian Hesselbarth ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Sebastian Hesselbarth @ 2013-04-07 11:09 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: David S. Miller, Florian Fainelli, Thomas Petazzoni, Greg Kroah-Hartman, netdev, linux-kernel Marvell mdio driver uses internal registers that can be clock gated on some SoCs. This patch just adds optional clock handling, to allow to pass and enable the corresponding clock. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> --- Cc: "David S. Miller" <davem@davemloft.net> Cc: Florian Fainelli <florian@openwrt.org> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index 7b5158f..e2f6626 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -28,6 +28,7 @@ #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/io.h> +#include <linux/clk.h> #include <linux/of_mdio.h> #include <linux/sched.h> #include <linux/wait.h> @@ -46,6 +47,7 @@ struct orion_mdio_dev { struct mutex lock; void __iomem *regs; + struct clk *clk; /* * If we have access to the error interrupt pin (which is * somewhat misnamed as it not only reflects internal errors @@ -230,6 +232,10 @@ static int orion_mdio_probe(struct platform_device *pdev) init_waitqueue_head(&dev->smi_busy_wait); + dev->clk = devm_clk_get(&pdev->dev, NULL); + if (!IS_ERR(dev->clk)) + clk_prepare_enable(dev->clk); + dev->err_interrupt = platform_get_irq(pdev, 0); if (dev->err_interrupt != -ENXIO) { ret = devm_request_irq(&pdev->dev, dev->err_interrupt, @@ -258,6 +264,8 @@ static int orion_mdio_probe(struct platform_device *pdev) return 0; out_mdio: + if (!IS_ERR(dev->clk)) + clk_disable_unprepare(dev->clk); kfree(bus->irq); mdiobus_free(bus); return ret; @@ -272,6 +280,9 @@ static int orion_mdio_remove(struct platform_device *pdev) mdiobus_unregister(bus); kfree(bus->irq); mdiobus_free(bus); + if (!IS_ERR(dev->clk)) + clk_disable_unprepare(dev->clk); + return 0; } -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property 2013-04-07 11:09 [PATCH] net: mvmdio: get and enable optional clock Sebastian Hesselbarth @ 2013-04-07 11:09 ` Sebastian Hesselbarth [not found] ` <1365332988-9053-2-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-04-08 9:32 ` [PATCH] net: mvmdio: get and enable optional clock Florian Fainelli 2013-04-08 20:56 ` David Miller 2 siblings, 1 reply; 5+ messages in thread From: Sebastian Hesselbarth @ 2013-04-07 11:09 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: Grant Likely, Rob Herring, Florian Fainelli, devicetree-discuss, netdev, linux-kernel Using DT for mdiobus and ethernet-phy requires to know the PHY address, which is hard to guess if you don't know it. This patch extends of_mdiobus_register to scan mdiobus for PHYs if reg property of the corresponding node is not set. This also allows to have phy nodes in SoC DT files where the reg property can be overwritten in the board file later. To encourage people to finally set the actual phy address, the mdiobus scan is noisier than required. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> --- Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Florian Fainelli <florian@openwrt.org> Cc: devicetree-discuss@lists.ozlabs.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/of/of_mdio.c | 64 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index e3a8b22..23049ae 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -34,7 +34,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) { struct phy_device *phy; struct device_node *child; - int rc, i; + const __be32 *paddr; + u32 addr; + bool is_c45, scanphys = false; + int rc, i, len; /* Mask out all PHYs from auto probing. Instead the PHYs listed in * the device tree are populated after the bus has been registered */ @@ -54,14 +57,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) /* Loop over the child nodes and register a phy_device for each one */ for_each_available_child_of_node(np, child) { - const __be32 *paddr; - u32 addr; - int len; - bool is_c45; - /* A PHY must have a reg property in the range [0-31] */ paddr = of_get_property(child, "reg", &len); if (!paddr || len < sizeof(*paddr)) { + scanphys = true; dev_err(&mdio->dev, "%s has invalid PHY address\n", child->full_name); continue; @@ -111,6 +110,59 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) child->name, addr); } + if (!scanphys) + return 0; + + /* auto scan for PHYs with empty reg property */ + for_each_available_child_of_node(np, child) { + /* Skip PHYs with reg property set */ + paddr = of_get_property(child, "reg", &len); + if (paddr) + continue; + + is_c45 = of_device_is_compatible(child, + "ethernet-phy-ieee802.3-c45"); + + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + /* skip already registered PHYs */ + if (mdio->phy_map[addr]) + continue; + + /* be noisy to encourage people to set reg property */ + dev_info(&mdio->dev, "scan phy %s at address %i\n", + child->name, addr); + + phy = get_phy_device(mdio, addr, is_c45); + if (!phy || IS_ERR(phy)) + continue; + + if (mdio->irq) { + mdio->irq[addr] = + irq_of_parse_and_map(child, 0); + if (!mdio->irq[addr]) + mdio->irq[addr] = PHY_POLL; + } + + /* Associate the OF node with the device structure so it + * can be looked up later */ + of_node_get(child); + phy->dev.of_node = child; + + /* All data is now stored in the phy struct; + * register it */ + rc = phy_device_register(phy); + if (rc) { + phy_device_free(phy); + of_node_put(child); + continue; + } + + dev_info(&mdio->dev, "registered phy %s at address %i\n", + child->name, addr); + break; + } + } + return 0; } EXPORT_SYMBOL(of_mdiobus_register); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1365332988-9053-2-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property [not found] ` <1365332988-9053-2-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2013-04-08 20:56 ` David Miller 0 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2013-04-08 20:56 UTC (permalink / raw) To: sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, florian-p3rKhJxN3npAfugRpC6u6w From: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Date: Sun, 7 Apr 2013 13:09:48 +0200 > Using DT for mdiobus and ethernet-phy requires to know the PHY address, which > is hard to guess if you don't know it. This patch extends of_mdiobus_register > to scan mdiobus for PHYs if reg property of the corresponding node is not set. > This also allows to have phy nodes in SoC DT files where the reg property can > be overwritten in the board file later. To encourage people to finally set the > actual phy address, the mdiobus scan is noisier than required. > > Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Applied. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: mvmdio: get and enable optional clock 2013-04-07 11:09 [PATCH] net: mvmdio: get and enable optional clock Sebastian Hesselbarth 2013-04-07 11:09 ` [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property Sebastian Hesselbarth @ 2013-04-08 9:32 ` Florian Fainelli 2013-04-08 20:56 ` David Miller 2 siblings, 0 replies; 5+ messages in thread From: Florian Fainelli @ 2013-04-08 9:32 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: David S. Miller, Thomas Petazzoni, Greg Kroah-Hartman, netdev, linux-kernel Le 04/07/13 13:09, Sebastian Hesselbarth a écrit : > Marvell mdio driver uses internal registers that can be clock gated on > some SoCs. This patch just adds optional clock handling, to allow to pass > and enable the corresponding clock. > > Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Looks good to me: Acked-by: Florian Fainelli <florian@openwrt.org> -- Florian ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: mvmdio: get and enable optional clock 2013-04-07 11:09 [PATCH] net: mvmdio: get and enable optional clock Sebastian Hesselbarth 2013-04-07 11:09 ` [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property Sebastian Hesselbarth 2013-04-08 9:32 ` [PATCH] net: mvmdio: get and enable optional clock Florian Fainelli @ 2013-04-08 20:56 ` David Miller 2 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2013-04-08 20:56 UTC (permalink / raw) To: sebastian.hesselbarth Cc: florian, thomas.petazzoni, gregkh, netdev, linux-kernel From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Date: Sun, 7 Apr 2013 13:09:47 +0200 > Marvell mdio driver uses internal registers that can be clock gated on > some SoCs. This patch just adds optional clock handling, to allow to pass > and enable the corresponding clock. > > Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Applied. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-08 20:56 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-07 11:09 [PATCH] net: mvmdio: get and enable optional clock Sebastian Hesselbarth 2013-04-07 11:09 ` [PATCH] net: of_mdio: scan mdiobus for PHYs without reg property Sebastian Hesselbarth [not found] ` <1365332988-9053-2-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-04-08 20:56 ` David Miller 2013-04-08 9:32 ` [PATCH] net: mvmdio: get and enable optional clock Florian Fainelli 2013-04-08 20:56 ` 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).