aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/smsc
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-12-19 12:03:48 -0500
committerLinus Walleij <linus.walleij@linaro.org>2013-03-01 17:23:20 -0500
commitb6c230196f07b9cdd23ceb899070076cdab0c467 (patch)
treed066263d037076351eac05b308a9fb910b539d32 /drivers/net/ethernet/smsc
parent1e6b6801405ec578c8607e9dabcc4e946ea64f4c (diff)
net/smsc911x: Provide common clock functionality
Some platforms provide clocks which require enabling before the SMSC911x chip will power on. This patch uses the new common clk framework to do just that. If no clock is provided, it will just be ignored and the driver will continue to assume that no clock is required for the chip to run successfully. Acked-by: David S. Miller <davem@davemloft.net> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/net/ethernet/smsc')
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index da5cc9a3b34c..df77df16d991 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -33,6 +33,7 @@
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34 34
35#include <linux/crc32.h> 35#include <linux/crc32.h>
36#include <linux/clk.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include <linux/errno.h> 38#include <linux/errno.h>
38#include <linux/etherdevice.h> 39#include <linux/etherdevice.h>
@@ -144,6 +145,9 @@ struct smsc911x_data {
144 145
145 /* regulators */ 146 /* regulators */
146 struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES]; 147 struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
148
149 /* clock */
150 struct clk *clk;
147}; 151};
148 152
149/* Easy access to information */ 153/* Easy access to information */
@@ -369,7 +373,7 @@ out:
369} 373}
370 374
371/* 375/*
372 * enable resources, currently just regulators. 376 * enable regulator and clock resources.
373 */ 377 */
374static int smsc911x_enable_resources(struct platform_device *pdev) 378static int smsc911x_enable_resources(struct platform_device *pdev)
375{ 379{
@@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev)
382 if (ret) 386 if (ret)
383 netdev_err(ndev, "failed to enable regulators %d\n", 387 netdev_err(ndev, "failed to enable regulators %d\n",
384 ret); 388 ret);
389
390 if (!IS_ERR(pdata->clk)) {
391 ret = clk_prepare_enable(pdata->clk);
392 if (ret < 0)
393 netdev_err(ndev, "failed to enable clock %d\n", ret);
394 }
395
385 return ret; 396 return ret;
386} 397}
387 398
@@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev)
396 407
397 ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies), 408 ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
398 pdata->supplies); 409 pdata->supplies);
410
411 if (!IS_ERR(pdata->clk))
412 clk_disable_unprepare(pdata->clk);
413
399 return ret; 414 return ret;
400} 415}
401 416
@@ -421,6 +436,12 @@ static int smsc911x_request_resources(struct platform_device *pdev)
421 if (ret) 436 if (ret)
422 netdev_err(ndev, "couldn't get regulators %d\n", 437 netdev_err(ndev, "couldn't get regulators %d\n",
423 ret); 438 ret);
439
440 /* Request clock */
441 pdata->clk = clk_get(&pdev->dev, NULL);
442 if (IS_ERR(pdata->clk))
443 netdev_warn(ndev, "couldn't get clock %li\n", PTR_ERR(pdata->clk));
444
424 return ret; 445 return ret;
425} 446}
426 447
@@ -436,6 +457,12 @@ static void smsc911x_free_resources(struct platform_device *pdev)
436 /* Free regulators */ 457 /* Free regulators */
437 regulator_bulk_free(ARRAY_SIZE(pdata->supplies), 458 regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
438 pdata->supplies); 459 pdata->supplies);
460
461 /* Free clock */
462 if (!IS_ERR(pdata->clk)) {
463 clk_put(pdata->clk);
464 pdata->clk = NULL;
465 }
439} 466}
440 467
441/* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read 468/* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read