arm: tegra: turn off pll-a/p in LP1
Mayuresh Kulkarni [Fri, 24 Feb 2012 14:05:36 +0000 (19:05 +0530)]
- current code does not turn off pll-a/p in LP1
irrespective of voice call status
- add a new flag to indicate voice call on-going
- use PMC_SCRATCH37 to hold this flag
- if it is set, do not turn-off pll-a/p during LP1
- save-restore PMC_SCRATCH37 if it was used to hold the
voice call on-going flag
- fix few misc formatting issues in tegra3_cpu_clk32k

Bug 924817

Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/85768
(cherry picked from commit 7853981c987ae329620bb54d869016cb74a6c054)

Change-Id: Id5348d2eb44a4bacaf00f6d17edceedaef819e29
Reviewed-on: http://git-master/r/94395
Tested-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: R08711befca33c0506083c3991fe2d88373a5a99e

arch/arm/mach-tegra/pm.c
arch/arm/mach-tegra/sleep-t30.S
arch/arm/mach-tegra/sleep.h

index 22c0099..91e0af3 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/vmalloc.h>
 #include <linux/memblock.h>
 #include <linux/console.h>
+#include <linux/tegra_audio.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -807,6 +808,7 @@ static void tegra_suspend_check_pwr_stats(void)
 int tegra_suspend_dram(enum tegra_suspend_mode mode, unsigned int flags)
 {
        int err = 0;
+       u32 scratch37 = 0xDEADBEEF;
 
        if (WARN_ON(mode <= TEGRA_SUSPEND_NONE ||
                mode >= TEGRA_MAX_SUSPEND_MODE)) {
@@ -814,6 +816,17 @@ int tegra_suspend_dram(enum tegra_suspend_mode mode, unsigned int flags)
                goto fail;
        }
 
+       if (tegra_is_voice_call_active()) {
+               u32 reg;
+
+               /* backup the current value of scratch37 */
+               scratch37 = readl(pmc + PMC_SCRATCH37);
+
+               /* If voice call is active, set a flag in PMC_SCRATCH37 */
+               reg = TEGRA_POWER_LP1_AUDIO;
+               pmc_32kwritel(reg, PMC_SCRATCH37);
+       }
+
        if ((mode == TEGRA_SUSPEND_LP0) && !tegra_pm_irq_lp0_allowed()) {
                pr_info("LP0 not used due to unsupported wakeup events\n");
                mode = TEGRA_SUSPEND_LP1;
@@ -869,6 +882,10 @@ int tegra_suspend_dram(enum tegra_suspend_mode mode, unsigned int flags)
        } else if (mode == TEGRA_SUSPEND_LP1)
                *iram_cpu_lp1_mask = 0;
 
+       /* if scratch37 was clobbered during LP1, restore it */
+       if (scratch37 != 0xDEADBEEF)
+               pmc_32kwritel(scratch37, PMC_SCRATCH37);
+
        restore_cpu_complex(flags);
 
        /* for platforms where the core & CPU power requests are
index a2a88ae..f26f9f7 100644 (file)
@@ -517,7 +517,7 @@ tegra3_cpu_clk32k:
 
        /* enable PLLM via PMC in LP0 */
        ldr     r0, [r4, #PMC_PLLP_WB0_OVERRIDE]
-       orr     r0, r0, #((1<<12) | (1 << 11))
+       orr     r0, r0, #((1 << 12) | (1 << 11))
        str     r0, [r4, #PMC_PLLP_WB0_OVERRIDE]
        mov     pc, lr
 
@@ -541,29 +541,28 @@ lp1_clocks_prepare:
        add     r1, r1, #2
        wait_until r1, r7, r9
 
-#if 1
        /* switch to CLKS */
        mov     r0, #0  /* burst policy = 32KHz */
        str     r0, [r5, #CLK_RESET_SCLK_BURST]
-#endif
 
        /* disable PLLM via PMC in LP1 */
        ldr     r0, [r4, #PMC_PLLP_WB0_OVERRIDE]
-       bic     r0, r0, #(1<<12)
+       bic     r0, r0, #(1 << 12)
        str     r0, [r4, #PMC_PLLP_WB0_OVERRIDE]
        b       powerdown_pll_pcx
 
 powerdown_pll_pcx:
-       /* disable PLLP, PLLA, PLLC, and PLLX in LP0 and LP1 states */
-       ldr     r0, [r4, #PMC_CTRL]
-       tst     r0, #PMC_CTRL_SIDE_EFFECT_LP0
-       beq     powerdown_pll_cx
+       ldr     r11, [r4, #PMC_SCRATCH37]       @ load the LP1 flags
+       tst     r11, #TEGRA_POWER_LP1_AUDIO     @ check if voice call is going on
+       bne     powerdown_pll_cx                @ if yes, do not turn off pll-p/pll-a
+
        ldr     r0, [r5, #CLK_RESET_PLLP_BASE]
        bic     r0, r0, #(1<<30)
        str     r0, [r5, #CLK_RESET_PLLP_BASE]
        ldr     r0, [r5, #CLK_RESET_PLLA_BASE]
        bic     r0, r0, #(1<<30)
        str     r0, [r5, #CLK_RESET_PLLA_BASE]
+
 powerdown_pll_cx:
        ldr     r0, [r5, #CLK_RESET_PLLC_BASE]
        bic     r0, r0, #(1<<30)
index 7307f83..5f0b205 100644 (file)
@@ -31,6 +31,7 @@
    save the diagnostic regsiter in the CPU context is accepted. */
 #define USE_TEGRA_DIAG_REG_SAVE        1
 
+#define TEGRA_POWER_LP1_AUDIO          (1 << 25) /* do not turn off pll-p in LP1 */
 #define TEGRA_POWER_SDRAM_SELFREFRESH  (1 << 26) /* SDRAM is in self-refresh */
 #define TEGRA_POWER_HOTPLUG_SHUTDOWN   (1 << 27) /* Hotplug shutdown */
 #define TEGRA_POWER_CLUSTER_G          (1 << 28) /* G CPU */