diff options
author | Tony Lindgren <tony@atomide.com> | 2014-08-27 19:28:09 -0400 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2014-09-24 05:48:32 -0400 |
commit | bad8e33582cb3ea5f3a7a3517ca48e0a03be11a3 (patch) | |
tree | 2475e28d99397abb754c22dd9386d8192280caab /drivers/phy | |
parent | 62dc5769bbd9f187e2e5df64f4e3b5affd48fe7b (diff) |
usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls
We don't need twl4030_phy_power() any longer now that we have
the runtime PM calls. Let's get rid of it as it's confusing.
No functional changes, just move the code and use res instead
of ret as we are not returning that value.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r-- | drivers/phy/phy-twl4030-usb.c | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index a292db01b503..519cc909b25a 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c | |||
@@ -383,45 +383,6 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on) | |||
383 | WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); | 383 | WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); |
384 | } | 384 | } |
385 | 385 | ||
386 | static void twl4030_phy_power(struct twl4030_usb *twl, int on) | ||
387 | { | ||
388 | int ret; | ||
389 | |||
390 | if (on) { | ||
391 | ret = regulator_enable(twl->usb3v1); | ||
392 | if (ret) | ||
393 | dev_err(twl->dev, "Failed to enable usb3v1\n"); | ||
394 | |||
395 | ret = regulator_enable(twl->usb1v8); | ||
396 | if (ret) | ||
397 | dev_err(twl->dev, "Failed to enable usb1v8\n"); | ||
398 | |||
399 | /* | ||
400 | * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP | ||
401 | * in twl4030) resets the VUSB_DEDICATED2 register. This reset | ||
402 | * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to | ||
403 | * SLEEP. We work around this by clearing the bit after usv3v1 | ||
404 | * is re-activated. This ensures that VUSB3V1 is really active. | ||
405 | */ | ||
406 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); | ||
407 | |||
408 | ret = regulator_enable(twl->usb1v5); | ||
409 | if (ret) | ||
410 | dev_err(twl->dev, "Failed to enable usb1v5\n"); | ||
411 | |||
412 | __twl4030_phy_power(twl, 1); | ||
413 | twl4030_usb_write(twl, PHY_CLK_CTRL, | ||
414 | twl4030_usb_read(twl, PHY_CLK_CTRL) | | ||
415 | (PHY_CLK_CTRL_CLOCKGATING_EN | | ||
416 | PHY_CLK_CTRL_CLK32K_EN)); | ||
417 | } else { | ||
418 | __twl4030_phy_power(twl, 0); | ||
419 | regulator_disable(twl->usb1v5); | ||
420 | regulator_disable(twl->usb1v8); | ||
421 | regulator_disable(twl->usb3v1); | ||
422 | } | ||
423 | } | ||
424 | |||
425 | static int twl4030_usb_runtime_suspend(struct device *dev) | 386 | static int twl4030_usb_runtime_suspend(struct device *dev) |
426 | { | 387 | { |
427 | struct twl4030_usb *twl = dev_get_drvdata(dev); | 388 | struct twl4030_usb *twl = dev_get_drvdata(dev); |
@@ -430,7 +391,10 @@ static int twl4030_usb_runtime_suspend(struct device *dev) | |||
430 | if (twl->asleep) | 391 | if (twl->asleep) |
431 | return 0; | 392 | return 0; |
432 | 393 | ||
433 | twl4030_phy_power(twl, 0); | 394 | __twl4030_phy_power(twl, 0); |
395 | regulator_disable(twl->usb1v5); | ||
396 | regulator_disable(twl->usb1v8); | ||
397 | regulator_disable(twl->usb3v1); | ||
434 | twl->asleep = 1; | 398 | twl->asleep = 1; |
435 | 399 | ||
436 | return 0; | 400 | return 0; |
@@ -439,12 +403,38 @@ static int twl4030_usb_runtime_suspend(struct device *dev) | |||
439 | static int twl4030_usb_runtime_resume(struct device *dev) | 403 | static int twl4030_usb_runtime_resume(struct device *dev) |
440 | { | 404 | { |
441 | struct twl4030_usb *twl = dev_get_drvdata(dev); | 405 | struct twl4030_usb *twl = dev_get_drvdata(dev); |
406 | int res; | ||
442 | 407 | ||
443 | dev_dbg(twl->dev, "%s\n", __func__); | 408 | dev_dbg(twl->dev, "%s\n", __func__); |
444 | if (!twl->asleep) | 409 | if (!twl->asleep) |
445 | return 0; | 410 | return 0; |
446 | 411 | ||
447 | twl4030_phy_power(twl, 1); | 412 | res = regulator_enable(twl->usb3v1); |
413 | if (res) | ||
414 | dev_err(twl->dev, "Failed to enable usb3v1\n"); | ||
415 | |||
416 | res = regulator_enable(twl->usb1v8); | ||
417 | if (res) | ||
418 | dev_err(twl->dev, "Failed to enable usb1v8\n"); | ||
419 | |||
420 | /* | ||
421 | * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP | ||
422 | * in twl4030) resets the VUSB_DEDICATED2 register. This reset | ||
423 | * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to | ||
424 | * SLEEP. We work around this by clearing the bit after usv3v1 | ||
425 | * is re-activated. This ensures that VUSB3V1 is really active. | ||
426 | */ | ||
427 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); | ||
428 | |||
429 | res = regulator_enable(twl->usb1v5); | ||
430 | if (res) | ||
431 | dev_err(twl->dev, "Failed to enable usb1v5\n"); | ||
432 | |||
433 | __twl4030_phy_power(twl, 1); | ||
434 | twl4030_usb_write(twl, PHY_CLK_CTRL, | ||
435 | twl4030_usb_read(twl, PHY_CLK_CTRL) | | ||
436 | (PHY_CLK_CTRL_CLOCKGATING_EN | | ||
437 | PHY_CLK_CTRL_CLK32K_EN)); | ||
448 | twl->asleep = 0; | 438 | twl->asleep = 0; |
449 | 439 | ||
450 | return 0; | 440 | return 0; |