From ffcf5bc23865c7391965f522574df00716ca3aa7 Mon Sep 17 00:00:00 2001 From: Mark Kuo Date: Mon, 30 May 2016 19:03:33 +0800 Subject: 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 Reviewed-on: http://git-master/r/1155976 Reviewed-by: Automatic_Commit_Validation_User Tested-by: Jinyoung Park GVS: Gerrit_Virtual_Submit Reviewed-by: Ashutosh Jha --- drivers/pinctrl/pinctrl-tegra186-padctl.c | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'drivers/pinctrl') 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) } EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_pad_secondary_charger_detect); +int tegra_phy_xusb_utmi_vbus_power_on(struct phy *phy) +{ + struct tegra_padctl *padctl; + int port; + int rc; + int status; + + if (!phy) + return -EINVAL; + + padctl = phy_get_drvdata(phy); + port = utmi_phy_to_port(phy); + + status = regulator_is_enabled(padctl->vbus[port]); + mutex_lock(&padctl->lock); + if (padctl->vbus[port]) { + rc = regulator_enable(padctl->vbus[port]); + if (rc) { + dev_err(padctl->dev, "enable port %d vbus failed %d\n", + port, rc); + mutex_unlock(&padctl->lock); + return rc; + } + } + mutex_unlock(&padctl->lock); + dev_info(padctl->dev, "%s: port %d regulator status: %d->%d\n", + __func__, port, status, + regulator_is_enabled(padctl->vbus[port])); + + return 0; +} +EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_vbus_power_on); + +int tegra_phy_xusb_utmi_vbus_power_off(struct phy *phy) +{ + struct tegra_padctl *padctl; + int port; + int rc; + int status; + + if (!phy) + return -EINVAL; + + padctl = phy_get_drvdata(phy); + port = utmi_phy_to_port(phy); + + status = regulator_is_enabled(padctl->vbus[port]); + mutex_lock(&padctl->lock); + if (padctl->vbus[port]) { + rc = regulator_disable(padctl->vbus[port]); + if (rc) { + dev_err(padctl->dev, "disable port %d vbus failed %d\n", + port, rc); + mutex_unlock(&padctl->lock); + return rc; + } + } + mutex_unlock(&padctl->lock); + dev_info(padctl->dev, "%s: port %d regulator status: %d->%d\n", + __func__, port, status, + regulator_is_enabled(padctl->vbus[port])); + + return 0; +} +EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_vbus_power_off); + MODULE_AUTHOR("JC Kuo "); MODULE_DESCRIPTION("Tegra 186 XUSB PADCTL driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.2