aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorVivek Gautam <gautam.vivek@samsung.com>2014-05-13 06:00:17 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2014-05-13 08:37:08 -0400
commit4fc8a4e65fda3271357bbea933206851736894da (patch)
treec4bc83882d0d81aaab42739b8d3bc8fdefdd0b5e /drivers/phy
parent59025887fb08a8b913605fb20f8a62eb0bb69b36 (diff)
phy: exynos5-usbdrd: Add facility for VBUS supply
Adding support to enable/disable VBUS controlled by a regulator, to enable vbus supply on the port. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-exynos5-usbdrd.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
index 8fcdd9434346..76d862b2202f 100644
--- a/drivers/phy/phy-exynos5-usbdrd.c
+++ b/drivers/phy/phy-exynos5-usbdrd.c
@@ -24,6 +24,7 @@
24#include <linux/mfd/syscon.h> 24#include <linux/mfd/syscon.h>
25#include <linux/mfd/syscon/exynos5-pmu.h> 25#include <linux/mfd/syscon/exynos5-pmu.h>
26#include <linux/regmap.h> 26#include <linux/regmap.h>
27#include <linux/regulator/consumer.h>
27 28
28/* Exynos USB PHY registers */ 29/* Exynos USB PHY registers */
29#define EXYNOS5_FSEL_9MHZ6 0x0 30#define EXYNOS5_FSEL_9MHZ6 0x0
@@ -170,6 +171,7 @@ struct exynos5_usbdrd_phy {
170 } phys[EXYNOS5_DRDPHYS_NUM]; 171 } phys[EXYNOS5_DRDPHYS_NUM];
171 u32 extrefclk; 172 u32 extrefclk;
172 struct clk *ref_clk; 173 struct clk *ref_clk;
174 struct regulator *vbus;
173}; 175};
174 176
175static inline 177static inline
@@ -438,6 +440,7 @@ static int exynos5_usbdrd_phy_exit(struct phy *phy)
438 440
439static int exynos5_usbdrd_phy_power_on(struct phy *phy) 441static int exynos5_usbdrd_phy_power_on(struct phy *phy)
440{ 442{
443 int ret;
441 struct phy_usb_instance *inst = phy_get_drvdata(phy); 444 struct phy_usb_instance *inst = phy_get_drvdata(phy);
442 struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); 445 struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst);
443 446
@@ -445,10 +448,24 @@ static int exynos5_usbdrd_phy_power_on(struct phy *phy)
445 448
446 clk_prepare_enable(phy_drd->ref_clk); 449 clk_prepare_enable(phy_drd->ref_clk);
447 450
451 /* Enable VBUS supply */
452 if (phy_drd->vbus) {
453 ret = regulator_enable(phy_drd->vbus);
454 if (ret) {
455 dev_err(phy_drd->dev, "Failed to enable VBUS supply\n");
456 goto fail_vbus;
457 }
458 }
459
448 /* Power-on PHY*/ 460 /* Power-on PHY*/
449 inst->phy_cfg->phy_isol(inst, 0); 461 inst->phy_cfg->phy_isol(inst, 0);
450 462
451 return 0; 463 return 0;
464
465fail_vbus:
466 clk_disable_unprepare(phy_drd->ref_clk);
467
468 return ret;
452} 469}
453 470
454static int exynos5_usbdrd_phy_power_off(struct phy *phy) 471static int exynos5_usbdrd_phy_power_off(struct phy *phy)
@@ -461,6 +478,10 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)
461 /* Power-off the PHY */ 478 /* Power-off the PHY */
462 inst->phy_cfg->phy_isol(inst, 1); 479 inst->phy_cfg->phy_isol(inst, 1);
463 480
481 /* Disable VBUS supply */
482 if (phy_drd->vbus)
483 regulator_disable(phy_drd->vbus);
484
464 clk_disable_unprepare(phy_drd->ref_clk); 485 clk_disable_unprepare(phy_drd->ref_clk);
465 486
466 return 0; 487 return 0;
@@ -600,6 +621,17 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
600 break; 621 break;
601 } 622 }
602 623
624 /* Get Vbus regulator */
625 phy_drd->vbus = devm_regulator_get(dev, "vbus");
626 if (IS_ERR(phy_drd->vbus)) {
627 ret = PTR_ERR(phy_drd->vbus);
628 if (ret == -EPROBE_DEFER)
629 return ret;
630
631 dev_warn(dev, "Failed to get VBUS supply regulator\n");
632 phy_drd->vbus = NULL;
633 }
634
603 dev_vdbg(dev, "Creating usbdrd_phy phy\n"); 635 dev_vdbg(dev, "Creating usbdrd_phy phy\n");
604 636
605 for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) { 637 for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {