提交 3d604da1 编写于 作者: S Sebastian Hesselbarth 提交者: David S. Miller

net: mvmdio: get and enable optional clock

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: NSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: NFlorian Fainelli <florian@openwrt.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d5b40921
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -46,6 +47,7 @@ ...@@ -46,6 +47,7 @@
struct orion_mdio_dev { struct orion_mdio_dev {
struct mutex lock; struct mutex lock;
void __iomem *regs; void __iomem *regs;
struct clk *clk;
/* /*
* If we have access to the error interrupt pin (which is * If we have access to the error interrupt pin (which is
* somewhat misnamed as it not only reflects internal errors * somewhat misnamed as it not only reflects internal errors
...@@ -230,6 +232,10 @@ static int orion_mdio_probe(struct platform_device *pdev) ...@@ -230,6 +232,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
init_waitqueue_head(&dev->smi_busy_wait); 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); dev->err_interrupt = platform_get_irq(pdev, 0);
if (dev->err_interrupt != -ENXIO) { if (dev->err_interrupt != -ENXIO) {
ret = devm_request_irq(&pdev->dev, dev->err_interrupt, ret = devm_request_irq(&pdev->dev, dev->err_interrupt,
...@@ -258,6 +264,8 @@ static int orion_mdio_probe(struct platform_device *pdev) ...@@ -258,6 +264,8 @@ static int orion_mdio_probe(struct platform_device *pdev)
return 0; return 0;
out_mdio: out_mdio:
if (!IS_ERR(dev->clk))
clk_disable_unprepare(dev->clk);
kfree(bus->irq); kfree(bus->irq);
mdiobus_free(bus); mdiobus_free(bus);
return ret; return ret;
...@@ -272,6 +280,9 @@ static int orion_mdio_remove(struct platform_device *pdev) ...@@ -272,6 +280,9 @@ static int orion_mdio_remove(struct platform_device *pdev)
mdiobus_unregister(bus); mdiobus_unregister(bus);
kfree(bus->irq); kfree(bus->irq);
mdiobus_free(bus); mdiobus_free(bus);
if (!IS_ERR(dev->clk))
clk_disable_unprepare(dev->clk);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册