diff options
| author | Mark Kuo <mkuo@nvidia.com> | 2016-05-30 07:03:33 -0400 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-09-30 04:48:27 -0400 |
| commit | ffcf5bc23865c7391965f522574df00716ca3aa7 (patch) | |
| tree | c925c011fc5c284d636afc89d0fff21ff244b60d /drivers/pinctrl | |
| parent | bd0f55f20e82cac0c25a2724a66cb136c47eda45 (diff) | |
padctl: t186: add APIs to control USB vbus
Add a pair of APIs to power on or off USB vbus when required. This is
currently being used in host controller driver when enabling host CDP
function.
Bug 200192880
Change-Id: I1b90ec766add24c84d57f3717ae51e78ad6f1cce
Signed-off-by: Mark Kuo <mkuo@nvidia.com>
Reviewed-on: http://git-master/r/1155976
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Jinyoung Park <jinyoungp@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Diffstat (limited to 'drivers/pinctrl')
| -rw-r--r-- | drivers/pinctrl/pinctrl-tegra186-padctl.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-tegra186-padctl.c b/drivers/pinctrl/pinctrl-tegra186-padctl.c index 4a6ea92f3..d914f36f8 100644 --- a/drivers/pinctrl/pinctrl-tegra186-padctl.c +++ b/drivers/pinctrl/pinctrl-tegra186-padctl.c | |||
| @@ -3568,6 +3568,72 @@ bool tegra_phy_xusb_utmi_pad_secondary_charger_detect(struct phy *phy) | |||
| 3568 | } | 3568 | } |
| 3569 | EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_pad_secondary_charger_detect); | 3569 | EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_pad_secondary_charger_detect); |
| 3570 | 3570 | ||
| 3571 | int tegra_phy_xusb_utmi_vbus_power_on(struct phy *phy) | ||
| 3572 | { | ||
| 3573 | struct tegra_padctl *padctl; | ||
| 3574 | int port; | ||
| 3575 | int rc; | ||
| 3576 | int status; | ||
| 3577 | |||
| 3578 | if (!phy) | ||
| 3579 | return -EINVAL; | ||
| 3580 | |||
| 3581 | padctl = phy_get_drvdata(phy); | ||
| 3582 | port = utmi_phy_to_port(phy); | ||
| 3583 | |||
| 3584 | status = regulator_is_enabled(padctl->vbus[port]); | ||
| 3585 | mutex_lock(&padctl->lock); | ||
| 3586 | if (padctl->vbus[port]) { | ||
| 3587 | rc = regulator_enable(padctl->vbus[port]); | ||
| 3588 | if (rc) { | ||
| 3589 | dev_err(padctl->dev, "enable port %d vbus failed %d\n", | ||
| 3590 | port, rc); | ||
| 3591 | mutex_unlock(&padctl->lock); | ||
| 3592 | return rc; | ||
| 3593 | } | ||
| 3594 | } | ||
| 3595 | mutex_unlock(&padctl->lock); | ||
| 3596 | dev_info(padctl->dev, "%s: port %d regulator status: %d->%d\n", | ||
| 3597 | __func__, port, status, | ||
| 3598 | regulator_is_enabled(padctl->vbus[port])); | ||
| 3599 | |||
| 3600 | return 0; | ||
| 3601 | } | ||
| 3602 | EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_vbus_power_on); | ||
| 3603 | |||
| 3604 | int tegra_phy_xusb_utmi_vbus_power_off(struct phy *phy) | ||
| 3605 | { | ||
| 3606 | struct tegra_padctl *padctl; | ||
| 3607 | int port; | ||
| 3608 | int rc; | ||
| 3609 | int status; | ||
| 3610 | |||
| 3611 | if (!phy) | ||
| 3612 | return -EINVAL; | ||
| 3613 | |||
| 3614 | padctl = phy_get_drvdata(phy); | ||
| 3615 | port = utmi_phy_to_port(phy); | ||
| 3616 | |||
| 3617 | status = regulator_is_enabled(padctl->vbus[port]); | ||
| 3618 | mutex_lock(&padctl->lock); | ||
| 3619 | if (padctl->vbus[port]) { | ||
| 3620 | rc = regulator_disable(padctl->vbus[port]); | ||
| 3621 | if (rc) { | ||
| 3622 | dev_err(padctl->dev, "disable port %d vbus failed %d\n", | ||
| 3623 | port, rc); | ||
| 3624 | mutex_unlock(&padctl->lock); | ||
| 3625 | return rc; | ||
| 3626 | } | ||
| 3627 | } | ||
| 3628 | mutex_unlock(&padctl->lock); | ||
| 3629 | dev_info(padctl->dev, "%s: port %d regulator status: %d->%d\n", | ||
| 3630 | __func__, port, status, | ||
| 3631 | regulator_is_enabled(padctl->vbus[port])); | ||
| 3632 | |||
| 3633 | return 0; | ||
| 3634 | } | ||
| 3635 | EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_vbus_power_off); | ||
| 3636 | |||
| 3571 | MODULE_AUTHOR("JC Kuo <jckuo@nvidia.com>"); | 3637 | MODULE_AUTHOR("JC Kuo <jckuo@nvidia.com>"); |
| 3572 | MODULE_DESCRIPTION("Tegra 186 XUSB PADCTL driver"); | 3638 | MODULE_DESCRIPTION("Tegra 186 XUSB PADCTL driver"); |
| 3573 | MODULE_LICENSE("GPL v2"); | 3639 | MODULE_LICENSE("GPL v2"); |
