diff options
Diffstat (limited to 'drivers/net')
| -rw-r--r-- | drivers/net/ethernet/smsc/smsc911x.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 48e2b99bec51..3663b9e04a31 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 | */ |
| 374 | static int smsc911x_enable_resources(struct platform_device *pdev) | 378 | static 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 |
