diff options
author | Roger Quadros <rogerq@ti.com> | 2014-03-07 00:57:09 -0500 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2014-03-09 03:15:09 -0400 |
commit | 1562864f0f034ea393230b470d104e1196b4a5f1 (patch) | |
tree | fcce7d2423c6f1965af2c670c7472a2da3365fd8 /drivers/phy/phy-ti-pipe3.c | |
parent | 51c9f4adaee3fb01bb6f2e2ed72c0753c2609912 (diff) |
phy: ti-pipe3: cleanup clock handling
As this driver is no longer USB specific, use generic clock names.
- Fix PLL_SD_SHIFT from 9 to 10
- Don't separate prepare/unprepare clock from enable/disable. This
ensures optimal power savings.
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy/phy-ti-pipe3.c')
-rw-r--r-- | drivers/phy/phy-ti-pipe3.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c index fd029b14cb3e..211703c87fb9 100644 --- a/drivers/phy/phy-ti-pipe3.c +++ b/drivers/phy/phy-ti-pipe3.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #define PLL_SELFREQDCO_MASK 0x0000000E | 45 | #define PLL_SELFREQDCO_MASK 0x0000000E |
46 | #define PLL_SELFREQDCO_SHIFT 0x1 | 46 | #define PLL_SELFREQDCO_SHIFT 0x1 |
47 | #define PLL_SD_MASK 0x0003FC00 | 47 | #define PLL_SD_MASK 0x0003FC00 |
48 | #define PLL_SD_SHIFT 0x9 | 48 | #define PLL_SD_SHIFT 10 |
49 | #define SET_PLL_GO 0x1 | 49 | #define SET_PLL_GO 0x1 |
50 | #define PLL_TICOPWDN 0x10000 | 50 | #define PLL_TICOPWDN 0x10000 |
51 | #define PLL_LOCK 0x2 | 51 | #define PLL_LOCK 0x2 |
@@ -72,7 +72,7 @@ struct ti_pipe3 { | |||
72 | struct device *control_dev; | 72 | struct device *control_dev; |
73 | struct clk *wkupclk; | 73 | struct clk *wkupclk; |
74 | struct clk *sys_clk; | 74 | struct clk *sys_clk; |
75 | struct clk *optclk; | 75 | struct clk *refclk; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | struct pipe3_dpll_map { | 78 | struct pipe3_dpll_map { |
@@ -270,23 +270,21 @@ static int ti_pipe3_probe(struct platform_device *pdev) | |||
270 | 270 | ||
271 | phy->dev = &pdev->dev; | 271 | phy->dev = &pdev->dev; |
272 | 272 | ||
273 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); | 273 | phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); |
274 | if (IS_ERR(phy->wkupclk)) { | 274 | if (IS_ERR(phy->wkupclk)) { |
275 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); | 275 | dev_err(&pdev->dev, "unable to get wkupclk\n"); |
276 | return PTR_ERR(phy->wkupclk); | 276 | return PTR_ERR(phy->wkupclk); |
277 | } | 277 | } |
278 | clk_prepare(phy->wkupclk); | ||
279 | 278 | ||
280 | phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m"); | 279 | phy->refclk = devm_clk_get(phy->dev, "refclk"); |
281 | if (IS_ERR(phy->optclk)) { | 280 | if (IS_ERR(phy->refclk)) { |
282 | dev_err(&pdev->dev, "unable to get usb_otg_ss_refclk960m\n"); | 281 | dev_err(&pdev->dev, "unable to get refclk\n"); |
283 | return PTR_ERR(phy->optclk); | 282 | return PTR_ERR(phy->refclk); |
284 | } | 283 | } |
285 | clk_prepare(phy->optclk); | ||
286 | 284 | ||
287 | phy->sys_clk = devm_clk_get(phy->dev, "sys_clkin"); | 285 | phy->sys_clk = devm_clk_get(phy->dev, "sysclk"); |
288 | if (IS_ERR(phy->sys_clk)) { | 286 | if (IS_ERR(phy->sys_clk)) { |
289 | pr_err("%s: unable to get sys_clkin\n", __func__); | 287 | dev_err(&pdev->dev, "unable to get sysclk\n"); |
290 | return -EINVAL; | 288 | return -EINVAL; |
291 | } | 289 | } |
292 | 290 | ||
@@ -326,10 +324,6 @@ static int ti_pipe3_probe(struct platform_device *pdev) | |||
326 | 324 | ||
327 | static int ti_pipe3_remove(struct platform_device *pdev) | 325 | static int ti_pipe3_remove(struct platform_device *pdev) |
328 | { | 326 | { |
329 | struct ti_pipe3 *phy = platform_get_drvdata(pdev); | ||
330 | |||
331 | clk_unprepare(phy->wkupclk); | ||
332 | clk_unprepare(phy->optclk); | ||
333 | if (!pm_runtime_suspended(&pdev->dev)) | 327 | if (!pm_runtime_suspended(&pdev->dev)) |
334 | pm_runtime_put(&pdev->dev); | 328 | pm_runtime_put(&pdev->dev); |
335 | pm_runtime_disable(&pdev->dev); | 329 | pm_runtime_disable(&pdev->dev); |
@@ -343,8 +337,10 @@ static int ti_pipe3_runtime_suspend(struct device *dev) | |||
343 | { | 337 | { |
344 | struct ti_pipe3 *phy = dev_get_drvdata(dev); | 338 | struct ti_pipe3 *phy = dev_get_drvdata(dev); |
345 | 339 | ||
346 | clk_disable(phy->wkupclk); | 340 | if (!IS_ERR(phy->wkupclk)) |
347 | clk_disable(phy->optclk); | 341 | clk_disable_unprepare(phy->wkupclk); |
342 | if (!IS_ERR(phy->refclk)) | ||
343 | clk_disable_unprepare(phy->refclk); | ||
348 | 344 | ||
349 | return 0; | 345 | return 0; |
350 | } | 346 | } |
@@ -354,22 +350,27 @@ static int ti_pipe3_runtime_resume(struct device *dev) | |||
354 | u32 ret = 0; | 350 | u32 ret = 0; |
355 | struct ti_pipe3 *phy = dev_get_drvdata(dev); | 351 | struct ti_pipe3 *phy = dev_get_drvdata(dev); |
356 | 352 | ||
357 | ret = clk_enable(phy->optclk); | 353 | if (!IS_ERR(phy->refclk)) { |
358 | if (ret) { | 354 | ret = clk_prepare_enable(phy->refclk); |
359 | dev_err(phy->dev, "Failed to enable optclk %d\n", ret); | 355 | if (ret) { |
360 | goto err1; | 356 | dev_err(phy->dev, "Failed to enable refclk %d\n", ret); |
357 | goto err1; | ||
358 | } | ||
361 | } | 359 | } |
362 | 360 | ||
363 | ret = clk_enable(phy->wkupclk); | 361 | if (!IS_ERR(phy->wkupclk)) { |
364 | if (ret) { | 362 | ret = clk_prepare_enable(phy->wkupclk); |
365 | dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); | 363 | if (ret) { |
366 | goto err2; | 364 | dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); |
365 | goto err2; | ||
366 | } | ||
367 | } | 367 | } |
368 | 368 | ||
369 | return 0; | 369 | return 0; |
370 | 370 | ||
371 | err2: | 371 | err2: |
372 | clk_disable(phy->optclk); | 372 | if (!IS_ERR(phy->refclk)) |
373 | clk_disable_unprepare(phy->refclk); | ||
373 | 374 | ||
374 | err1: | 375 | err1: |
375 | return ret; | 376 | return ret; |