aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-04-06 21:09:47 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-08 16:55:26 -0400
commit3d604da1e9547c09c9dcc0ee443c306c9ae1a480 (patch)
tree2e85712f508c10f5b7a82c3cc9344da3810d9267
parentd5b40921aa09a0ccc24867a035ec0f13730a1e34 (diff)
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: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/marvell/mvmdio.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 7b5158f654c2..e2f662660313 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -28,6 +28,7 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/clk.h>
31#include <linux/of_mdio.h> 32#include <linux/of_mdio.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
33#include <linux/wait.h> 34#include <linux/wait.h>
@@ -46,6 +47,7 @@
46struct orion_mdio_dev { 47struct orion_mdio_dev {
47 struct mutex lock; 48 struct mutex lock;
48 void __iomem *regs; 49 void __iomem *regs;
50 struct clk *clk;
49 /* 51 /*
50 * If we have access to the error interrupt pin (which is 52 * If we have access to the error interrupt pin (which is
51 * somewhat misnamed as it not only reflects internal errors 53 * somewhat misnamed as it not only reflects internal errors
@@ -230,6 +232,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
230 232
231 init_waitqueue_head(&dev->smi_busy_wait); 233 init_waitqueue_head(&dev->smi_busy_wait);
232 234
235 dev->clk = devm_clk_get(&pdev->dev, NULL);
236 if (!IS_ERR(dev->clk))
237 clk_prepare_enable(dev->clk);
238
233 dev->err_interrupt = platform_get_irq(pdev, 0); 239 dev->err_interrupt = platform_get_irq(pdev, 0);
234 if (dev->err_interrupt != -ENXIO) { 240 if (dev->err_interrupt != -ENXIO) {
235 ret = devm_request_irq(&pdev->dev, dev->err_interrupt, 241 ret = devm_request_irq(&pdev->dev, dev->err_interrupt,
@@ -258,6 +264,8 @@ static int orion_mdio_probe(struct platform_device *pdev)
258 return 0; 264 return 0;
259 265
260out_mdio: 266out_mdio:
267 if (!IS_ERR(dev->clk))
268 clk_disable_unprepare(dev->clk);
261 kfree(bus->irq); 269 kfree(bus->irq);
262 mdiobus_free(bus); 270 mdiobus_free(bus);
263 return ret; 271 return ret;
@@ -272,6 +280,9 @@ static int orion_mdio_remove(struct platform_device *pdev)
272 mdiobus_unregister(bus); 280 mdiobus_unregister(bus);
273 kfree(bus->irq); 281 kfree(bus->irq);
274 mdiobus_free(bus); 282 mdiobus_free(bus);
283 if (!IS_ERR(dev->clk))
284 clk_disable_unprepare(dev->clk);
285
275 return 0; 286 return 0;
276} 287}
277 288