2019-05-19 21:51:31 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-01-27 00:22:02 +08: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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
2012-03-19 23:55:12 +08:00
|
|
|
|
|
|
|
#include <asm/assembler.h>
|
2012-10-31 17:41:21 +08:00
|
|
|
#include <asm/cache.h>
|
2012-10-31 17:41:17 +08:00
|
|
|
#include <asm/cp15.h>
|
2012-11-13 10:04:48 +08:00
|
|
|
#include <asm/hardware/cache-l2x0.h>
|
2012-03-19 23:55:12 +08:00
|
|
|
|
2012-10-05 04:24:09 +08:00
|
|
|
#include "iomap.h"
|
2012-08-16 17:31:50 +08:00
|
|
|
#include "sleep.h"
|
2012-01-27 00:22:02 +08:00
|
|
|
|
2013-01-17 01:33:55 +08:00
|
|
|
#define CLK_RESET_CCLK_BURST 0x20
|
|
|
|
#define CLK_RESET_CCLK_DIVIDER 0x24
|
|
|
|
|
ARM: 9263/1: use .arch directives instead of assembler command line flags
Similar to commit a6c30873ee4a ("ARM: 8989/1: use .fpu assembler
directives instead of assembler arguments").
GCC and GNU binutils support setting the "sub arch" via -march=,
-Wa,-march, target function attribute, and .arch assembler directive.
Clang was missing support for -Wa,-march=, but this was implemented in
clang-13.
The behavior of both GCC and Clang is to
prefer -Wa,-march= over -march= for assembler and assembler-with-cpp
sources, but Clang will warn about the -march= being unused.
clang: warning: argument unused during compilation: '-march=armv6k'
[-Wunused-command-line-argument]
Since most assembler is non-conditionally assembled with one sub arch
(modulo arch/arm/delay-loop.S which conditionally is assembled as armv4
based on CONFIG_ARCH_RPC, and arch/arm/mach-at91/pm-suspend.S which is
conditionally assembled as armv7-a based on CONFIG_CPU_V7), prefer the
.arch assembler directive.
Add a few more instances found in compile testing as found by Arnd and
Nathan.
Link: https://github.com/llvm/llvm-project/commit/1d51c699b9e2ebc5bcfdbe85c74cc871426333d4
Link: https://bugs.llvm.org/show_bug.cgi?id=48894
Link: https://github.com/ClangBuiltLinux/linux/issues/1195
Link: https://github.com/ClangBuiltLinux/linux/issues/1315
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-10-25 03:44:41 +08:00
|
|
|
.arch armv7-a
|
|
|
|
|
2013-01-03 14:42:59 +08:00
|
|
|
#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
|
2012-10-31 17:41:17 +08: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
|
2019-03-18 06:52:10 +08:00
|
|
|
tst r2, #CR_C @ see tegra_sleep_cpu()
|
2012-10-31 17:41:17 +08:00
|
|
|
bic r2, r2, #CR_C
|
2019-03-18 06:52:10 +08:00
|
|
|
mcrne p15, 0, r2, c1, c0, 0
|
2012-10-31 17:41:17 +08:00
|
|
|
isb
|
|
|
|
|
|
|
|
/* Flush the D-cache */
|
2013-07-03 17:50:38 +08:00
|
|
|
cmp r0, #TEGRA_FLUSH_CACHE_ALL
|
|
|
|
blne v7_flush_dcache_louis
|
|
|
|
bleq v7_flush_dcache_all
|
2012-10-31 17:41:17 +08: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 14:42:59 +08:00
|
|
|
#endif
|
2012-10-31 17:41:17 +08:00
|
|
|
|
2013-01-03 14:42:59 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2013-07-03 17:50:39 +08: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 23:29:12 +08:00
|
|
|
ret lr
|
2013-07-03 17:50:39 +08:00
|
|
|
ENDPROC(tegra_init_l2_for_a15)
|
|
|
|
|
2012-10-31 17:41:21 +08: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 17:50:38 +08:00
|
|
|
mov r4, r0
|
2012-10-31 17:41:21 +08:00
|
|
|
/* Flush and disable the L1 data cache */
|
2013-07-03 17:50:38 +08:00
|
|
|
mov r0, #TEGRA_FLUSH_CACHE_ALL
|
2012-10-31 17:41:21 +08:00
|
|
|
bl tegra_disable_clean_inv_dcache
|
|
|
|
|
2013-07-03 17:50:38 +08:00
|
|
|
mov r0, r4
|
2012-10-31 17:41:21 +08: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 23:29:12 +08:00
|
|
|
ret r3
|
2012-10-31 17:41:21 +08: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 10:04:48 +08:00
|
|
|
#ifdef CONFIG_CACHE_L2X0
|
|
|
|
/* Disable L2 cache */
|
2013-05-20 18:39:25 +08:00
|
|
|
check_cpu_part_num 0xc09, r9, r10
|
2019-03-18 06:52:10 +08:00
|
|
|
retne r0
|
|
|
|
|
|
|
|
mov32 r2, TEGRA_ARM_PERIF_BASE + 0x3000
|
|
|
|
ldr r3, [r2, #L2X0_CTRL]
|
|
|
|
tst r3, #L2X0_CTRL_EN @ see tegra_sleep_cpu()
|
|
|
|
mov r3, #0
|
|
|
|
strne r3, [r2, #L2X0_CTRL]
|
2012-11-13 10:04:48 +08:00
|
|
|
#endif
|
2014-06-30 23:29:12 +08:00
|
|
|
ret r0
|
2012-10-31 17:41:21 +08:00
|
|
|
ENDPROC(tegra_shut_off_mmu)
|
|
|
|
.popsection
|
2013-01-17 01:33:55 +08: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 23:29:12 +08:00
|
|
|
ret lr
|
2013-01-17 01:33:55 +08:00
|
|
|
ENDPROC(tegra_switch_cpu_to_pllp)
|
2012-10-31 17:41:17 +08:00
|
|
|
#endif
|