ARM: tegra: powergate: Allow calling power up when already powered
Colin Cross [Sat, 8 Jan 2011 21:59:15 +0000 (13:59 -0800)]
Allow calling tegra_powergate_sequence_power_up on a partition
that is already powered.  Reset the partition, and return success
with the clock enabled.

Change-Id: I776c6a84091f0bb8faca22d87b3fabf0cfede564
Signed-off-by: Colin Cross <ccross@android.com>

Rebase-Id: Rbb11d3daa286f0eaf69c76c5ba023b3aa7188ed9

arch/arm/mach-tegra/powergate.c

index c6bc8f8..8a2f6a7 100644 (file)
@@ -136,10 +136,33 @@ int tegra_powergate_remove_clamping(int id)
 }
 
 /* Must be called with clk disabled, and returns with clk enabled */
+static int tegra_powergate_reset_module(struct clk *clk)
+{
+       int ret;
+
+       tegra_periph_reset_assert(clk);
+
+       udelay(10);
+
+       ret = clk_enable(clk);
+       if (ret)
+               return ret;
+
+       udelay(10);
+
+       tegra_periph_reset_deassert(clk);
+
+       return 0;
+}
+
+/* Must be called with clk disabled, and returns with clk enabled */
 int tegra_powergate_sequence_power_up(int id, struct clk *clk)
 {
        int ret;
 
+       if (tegra_powergate_is_powered(id))
+               return tegra_powergate_reset_module(clk);
+
        tegra_periph_reset_assert(clk);
 
        ret = tegra_powergate_power_on(id);