Skip to content

Commit

Permalink
net: mvmdio: get and enable optional clock
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
shesselba authored and davem330 committed Apr 8, 2013
1 parent d5b4092 commit 3d604da
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/marvell/mvmdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 3d604da

Please sign in to comment.