ARM: tegra: usb: keep usb vdd regulator on
Rakesh Bodla [Mon, 30 Jul 2012 09:46:18 +0000 (14:46 +0530)]
Adding the conditions during which USB vdd
regulator should be kept ON.

Bug 1024425
Bug 1012078
Bug 1018538

Change-Id: I3319c91ecc02891ea4467f73be2b84a3817dab36
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/119279
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

arch/arm/mach-tegra/usb_phy.c

index 00a44dd..80a3337 100644 (file)
@@ -136,7 +136,7 @@ static irqreturn_t usb_phy_dev_vbus_pmu_irq_thr(int irq, void *pdata)
 
        if (phy->vdd_reg && !phy->vdd_reg_on) {
                regulator_enable(phy->vdd_reg);
-               phy->vdd_reg_on = 1;
+               phy->vdd_reg_on = true;
                /*
                 * Optimal time to get the regulator turned on
                 * before detecting vbus interrupt.
@@ -469,25 +469,30 @@ int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
        clk_disable(phy->sys_clk);
        if (phy->pdata->op_mode == TEGRA_USB_OPMODE_HOST) {
                if (!phy->pdata->u_data.host.hot_plug &&
-                       !phy->pdata->u_data.host.remote_wakeup_supported)
+                       !phy->pdata->u_data.host.remote_wakeup_supported) {
                        clk_disable(phy->ctrlr_clk);
+                       phy->ctrl_clk_on = false;
+                       if (phy->vdd_reg && phy->vdd_reg_on) {
+                               regulator_disable(phy->vdd_reg);
+                               phy->vdd_reg_on = false;
+                       }
+               }
        } else {
-               /* In device mode clock is turned on by pmu irq handler
-                * if pmu irq is not available clocks will not be turned off/on
+               /* In device mode clock regulator/clocks will be turned off
+                * only if pmu interrupt is present on the board and host mode
+                * support through OTG is supported on the board.
                 */
-               if (phy->pdata->u_data.dev.vbus_pmu_irq) {
+               if (phy->pdata->u_data.dev.vbus_pmu_irq &&
+                       phy->pdata->builtin_host_disabled) {
                        clk_disable(phy->ctrlr_clk);
                        phy->ctrl_clk_on = false;
+                       if (phy->vdd_reg && phy->vdd_reg_on) {
+                               regulator_disable(phy->vdd_reg);
+                               phy->vdd_reg_on = false;
+                       }
                }
        }
 
-       if (phy->vdd_reg && phy->vdd_reg_on)
-               if (phy->pdata->has_hostpc ||
-                       phy->pdata->builtin_host_disabled) {
-                       regulator_disable(phy->vdd_reg);
-                       phy->vdd_reg_on = false;
-               }
-
        phy->phy_power_on = false;
 
        return err;