Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / marvell / mvmdio.c
index 3472574602b27f4ea06dc542627b3c005063f49a..e2f6626603138e7e7d4c7cc01e4853e83a0920a9 100644 (file)
@@ -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;
 }
 
@@ -295,3 +306,4 @@ module_platform_driver(orion_mdio_driver);
 MODULE_DESCRIPTION("Marvell MDIO interface driver");
 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:orion-mdio");