2012-01-26 23:22:02 +07:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-tegra/sleep.S
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010-2011, NVIDIA Corporation.
|
|
|
|
* Copyright (c) 2011, Google, Inc.
|
|
|
|
*
|
|
|
|
* Author: Colin Cross <ccross@android.com>
|
|
|
|
* Gary King <gking@nvidia.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
2012-03-19 22:55:12 +07:00
|
|
|
|
|
|
|
#include <asm/assembler.h>
|
2012-10-31 16:41:21 +07:00
|
|
|
#include <asm/cache.h>
|
2012-10-31 16:41:17 +07:00
|
|
|
#include <asm/cp15.h>
|
2012-11-13 09:04:48 +07:00
|
|
|
#include <asm/hardware/cache-l2x0.h>
|
2012-03-19 22:55:12 +07:00
|
|
|
|
2012-10-05 03:24:09 +07:00
|
|
|
#include "iomap.h"
|
2012-08-16 16:31:50 +07:00
|
|
|
#include "sleep.h"
|
2012-01-26 23:22:02 +07:00
|
|
|
|
2013-01-17 00:33:55 +07:00
|
|
|
#define CLK_RESET_CCLK_BURST 0x20
|
|
|
|
#define CLK_RESET_CCLK_DIVIDER 0x24
|
|
|
|
|
2013-01-03 13:42:59 +07:00
|
|
|
#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
|
2012-10-31 16:41:17 +07:00
|
|
|
/*
|
|
|
|
* tegra_disable_clean_inv_dcache
|
|
|
|
*
|
|
|
|
* disable, clean & invalidate the D-cache
|
|
|
|
*
|
|
|
|
* Corrupted registers: r1-r3, r6, r8, r9-r11
|
|
|
|
*/
|
|
|
|
ENTRY(tegra_disable_clean_inv_dcache)
|
|
|
|
stmfd sp!, {r0, r4-r5, r7, r9-r11, lr}
|
|
|
|
dmb @ ensure ordering
|
|
|
|
|
|
|
|
/* Disable the D-cache */
|
|
|
|
mrc p15, 0, r2, c1, c0, 0
|
|
|
|
bic r2, r2, #CR_C
|
|
|
|
mcr p15, 0, r2, c1, c0, 0
|
|
|
|
isb
|
|
|
|
|
|
|
|
/* Flush the D-cache */
|
2013-07-03 16:50:38 +07:00
|
|
|
cmp r0, #TEGRA_FLUSH_CACHE_ALL
|
|
|
|
blne v7_flush_dcache_louis
|
|
|
|
bleq v7_flush_dcache_all
|
2012-10-31 16:41:17 +07:00
|
|
|
|
|
|
|
/* Trun off coherency */
|
|
|
|
exit_smp r4, r5
|
|
|
|
|
|
|
|
ldmfd sp!, {r0, r4-r5, r7, r9-r11, pc}
|
|
|
|
ENDPROC(tegra_disable_clean_inv_dcache)
|
2013-01-03 13:42:59 +07:00
|
|
|
#endif
|
2012-10-31 16:41:17 +07:00
|
|
|
|
2013-01-03 13:42:59 +07:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2013-07-03 16:50:39 +07:00
|
|
|
/*
|
|
|
|
* tegra_init_l2_for_a15
|
|
|
|
*
|
|
|
|
* set up the correct L2 cache data RAM latency
|
|
|
|
*/
|
|
|
|
ENTRY(tegra_init_l2_for_a15)
|
|
|
|
mrc p15, 0, r0, c0, c0, 5
|
|
|
|
ubfx r0, r0, #8, #4
|
|
|
|
tst r0, #1 @ only need for cluster 0
|
|
|
|
bne _exit_init_l2_a15
|
|
|
|
|
|
|
|
mrc p15, 0x1, r0, c9, c0, 2
|
|
|
|
and r0, r0, #7
|
|
|
|
cmp r0, #2
|
|
|
|
bicne r0, r0, #7
|
|
|
|
orrne r0, r0, #2
|
|
|
|
mcrne p15, 0x1, r0, c9, c0, 2
|
|
|
|
_exit_init_l2_a15:
|
|
|
|
|
2014-06-30 22:29:12 +07:00
|
|
|
ret lr
|
2013-07-03 16:50:39 +07:00
|
|
|
ENDPROC(tegra_init_l2_for_a15)
|
|
|
|
|
2012-10-31 16:41:21 +07:00
|
|
|
/*
|
|
|
|
* tegra_sleep_cpu_finish(unsigned long v2p)
|
|
|
|
*
|
|
|
|
* enters suspend in LP2 by turning off the mmu and jumping to
|
|
|
|
* tegra?_tear_down_cpu
|
|
|
|
*/
|
|
|
|
ENTRY(tegra_sleep_cpu_finish)
|
2013-07-03 16:50:38 +07:00
|
|
|
mov r4, r0
|
2012-10-31 16:41:21 +07:00
|
|
|
/* Flush and disable the L1 data cache */
|
2013-07-03 16:50:38 +07:00
|
|
|
mov r0, #TEGRA_FLUSH_CACHE_ALL
|
2012-10-31 16:41:21 +07:00
|
|
|
bl tegra_disable_clean_inv_dcache
|
|
|
|
|
2013-07-03 16:50:38 +07:00
|
|
|
mov r0, r4
|
2012-10-31 16:41:21 +07:00
|
|
|
mov32 r6, tegra_tear_down_cpu
|
|
|
|
ldr r1, [r6]
|
|
|
|
add r1, r1, r0
|
|
|
|
|
|
|
|
mov32 r3, tegra_shut_off_mmu
|
|
|
|
add r3, r3, r0
|
|
|
|
mov r0, r1
|
|
|
|
|
2014-06-30 22:29:12 +07:00
|
|
|
ret r3
|
2012-10-31 16:41:21 +07:00
|
|
|
ENDPROC(tegra_sleep_cpu_finish)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tegra_shut_off_mmu
|
|
|
|
*
|
|
|
|
* r0 = physical address to jump to with mmu off
|
|
|
|
*
|
|
|
|
* called with VA=PA mapping
|
|
|
|
* turns off MMU, icache, dcache and branch prediction
|
|
|
|
*/
|
|
|
|
.align L1_CACHE_SHIFT
|
|
|
|
.pushsection .idmap.text, "ax"
|
|
|
|
ENTRY(tegra_shut_off_mmu)
|
|
|
|
mrc p15, 0, r3, c1, c0, 0
|
|
|
|
movw r2, #CR_I | CR_Z | CR_C | CR_M
|
|
|
|
bic r3, r3, r2
|
|
|
|
dsb
|
|
|
|
mcr p15, 0, r3, c1, c0, 0
|
|
|
|
isb
|
2012-11-13 09:04:48 +07:00
|
|
|
#ifdef CONFIG_CACHE_L2X0
|
|
|
|
/* Disable L2 cache */
|
2013-05-20 17:39:25 +07:00
|
|
|
check_cpu_part_num 0xc09, r9, r10
|
ARM: tegra: add LP1 suspend support for Tegra30
The LP1 suspend mode will power off the CPU, clock gated the PLLs and put
SDRAM to self-refresh mode. Any interrupt can wake up device from LP1. The
sequence when LP1 suspending:
* tunning off L1 data cache and the MMU
* storing some EMC registers, DPD (deep power down) status, clk source of
mselect and SCLK burst policy
* putting SDRAM into self-refresh
* switching CPU to CLK_M (12MHz OSC)
* tunning off PLLM, PLLP, PLLA, PLLC and PLLX
* switching SCLK to CLK_S (32KHz OSC)
* shutting off the CPU rail
The sequence of LP1 resuming:
* re-enabling PLLM, PLLP, PLLA, PLLC and PLLX
* restoring the clk source of mselect and SCLK burst policy
* setting up CCLK burst policy to PLLX
* restoring DPD status and some EMC registers
* resuming SDRAM to normal mode
* jumping to the "tegra_resume" from PMC_SCRATCH41
Due to the SDRAM will be put into self-refresh mode, the low level
procedures of LP1 suspending and resuming should be copied to
TEGRA_IRAM_CODE_AREA (TEGRA_IRAM_BASE + SZ_4K) when suspending. Before
restoring the CPU context when resuming, the SDRAM needs to be switched
back to normal mode. And the PLLs need to be re-enabled, SCLK burst policy
be restored, CCLK burst policy be set in PLLX. Then jumping to
"tegra_resume" that was expected to be stored in PMC_SCRATCH41 to restore
CPU context and back to kernel.
Based on the work by: Scott Williams <scwilliams@nvidia.com>
Signed-off-by: Joseph Lo <josephl@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-08-12 16:40:04 +07:00
|
|
|
movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000)
|
|
|
|
movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000)
|
|
|
|
moveq r3, #0
|
|
|
|
streq r3, [r2, #L2X0_CTRL]
|
2012-11-13 09:04:48 +07:00
|
|
|
#endif
|
2014-06-30 22:29:12 +07:00
|
|
|
ret r0
|
2012-10-31 16:41:21 +07:00
|
|
|
ENDPROC(tegra_shut_off_mmu)
|
|
|
|
.popsection
|
2013-01-17 00:33:55 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tegra_switch_cpu_to_pllp
|
|
|
|
*
|
|
|
|
* In LP2 the normal cpu clock pllx will be turned off. Switch the CPU to pllp
|
|
|
|
*/
|
|
|
|
ENTRY(tegra_switch_cpu_to_pllp)
|
|
|
|
/* in LP2 idle (SDRAM active), set the CPU burst policy to PLLP */
|
|
|
|
mov32 r5, TEGRA_CLK_RESET_BASE
|
|
|
|
mov r0, #(2 << 28) @ burst policy = run mode
|
|
|
|
orr r0, r0, #(4 << 4) @ use PLLP in run mode burst
|
|
|
|
str r0, [r5, #CLK_RESET_CCLK_BURST]
|
|
|
|
mov r0, #0
|
|
|
|
str r0, [r5, #CLK_RESET_CCLK_DIVIDER]
|
2014-06-30 22:29:12 +07:00
|
|
|
ret lr
|
2013-01-17 00:33:55 +07:00
|
|
|
ENDPROC(tegra_switch_cpu_to_pllp)
|
2012-10-31 16:41:17 +07:00
|
|
|
#endif
|