From 4df8c74291952f18d43fb608290db0ce7cc27d42 Mon Sep 17 00:00:00 2001 From: Rohan Somvanshi Date: Wed, 4 Jul 2012 10:43:10 +0000 Subject: ARM: tegra: usb: turn off power during suspend Turn off regulators along with clocks during suspend Bug 991262 Reviewed-on: http://git-master/r/108820 (cherry picked from commit 41ae7ac21a2c08da0e4312b8395b380a704fa16c) Change-Id: Ib49eec5d91571d75881f4d252d956dece1d37d60 Signed-off-by: Rakesh Bodla Reviewed-on: http://git-master/r/105364 Reviewed-by: Rohan Somvanshi Tested-by: Rohan Somvanshi Reviewed-by: Automatic_Commit_Validation_User --- arch/arm/mach-tegra/usb_phy.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'arch/arm/mach-tegra/usb_phy.c') diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c index b072283da294..f6e64f08c30a 100644 --- a/arch/arm/mach-tegra/usb_phy.c +++ b/arch/arm/mach-tegra/usb_phy.c @@ -2,7 +2,7 @@ * arch/arm/mach-tegra/usb_phy.c * * Copyright (C) 2010 Google, Inc. - * Copyright (C) 2010 - 2011 NVIDIA Corporation + * Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved. * * Author: * Erik Gilling @@ -32,6 +32,7 @@ #include #include "tegra_usb_phy.h" #include +#include #define ERR(stuff...) pr_err("usb_phy: " stuff) #define WARNING(stuff...) pr_warning("usb_phy: " stuff) @@ -133,6 +134,16 @@ static irqreturn_t usb_phy_dev_vbus_pmu_irq_thr(int irq, void *pdata) { struct tegra_usb_phy *phy = pdata; + if (phy->vdd_reg && !phy->vdd_reg_on) { + regulator_enable(phy->vdd_reg); + phy->vdd_reg_on = 1; + /* + * Optimal time to get the regulator turned on + * before detecting vbus interrupt. + */ + mdelay(15); + } + /* clk is disabled during phy power off and not here*/ if (!phy->ctrl_clk_on) { clk_enable(phy->ctrlr_clk); @@ -339,9 +350,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev) } } - if (phy->vdd_reg) - regulator_enable(phy->vdd_reg); - return phy; fail_init: @@ -405,7 +413,6 @@ void tegra_usb_phy_close(struct tegra_usb_phy *phy) } if (phy->vdd_reg) { - regulator_disable(phy->vdd_reg); regulator_put(phy->vdd_reg); } @@ -473,6 +480,18 @@ int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) } } + if (phy->vdd_reg && phy->vdd_reg_on) { +#ifndef CONFIG_ARCH_TEGRA_2x_SOC + regulator_disable(phy->vdd_reg); + phy->vdd_reg_on = false; +#else + if (tegra_get_revision() >= TEGRA_REVISION_A03) { + regulator_disable(phy->vdd_reg); + phy->vdd_reg_on = false; + } +#endif + } + phy->phy_power_on = false; return err; @@ -487,6 +506,11 @@ int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) if (phy->phy_power_on) return status; + if (phy->vdd_reg && !phy->vdd_reg_on) { + regulator_enable(phy->vdd_reg); + phy->vdd_reg_on = true; + } + /* In device mode clock is turned on by pmu irq handler * if pmu irq is not available clocks will not be turned off/on */ -- cgit v1.2.3