1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * arch/arm/mach-tegra/sleep.S
5 * Copyright (c) 2010-2011, NVIDIA Corporation.
6 * Copyright (c) 2011, Google, Inc.
8 * Author: Colin Cross <ccross@android.com>
9 * Gary King <gking@nvidia.com>
12 #include <linux/linkage.h>
14 #include <asm/assembler.h>
15 #include <asm/cache.h>
17 #include <asm/hardware/cache-l2x0.h>
22 #define CLK_RESET_CCLK_BURST 0x20
23 #define CLK_RESET_CCLK_DIVIDER 0x24
25 #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
27 * tegra_disable_clean_inv_dcache
29 * disable, clean & invalidate the D-cache
31 * Corrupted registers: r1-r3, r6, r8, r9-r11
33 ENTRY(tegra_disable_clean_inv_dcache)
34 stmfd sp!, {r0, r4-r5, r7, r9-r11, lr}
37 /* Disable the D-cache */
38 mrc p15, 0, r2, c1, c0, 0
39 tst r2, #CR_C @ see tegra_sleep_cpu()
41 mcrne p15, 0, r2, c1, c0, 0
44 /* Flush the D-cache */
45 cmp r0, #TEGRA_FLUSH_CACHE_ALL
46 blne v7_flush_dcache_louis
47 bleq v7_flush_dcache_all
49 /* Trun off coherency */
52 ldmfd sp!, {r0, r4-r5, r7, r9-r11, pc}
53 ENDPROC(tegra_disable_clean_inv_dcache)
56 #ifdef CONFIG_PM_SLEEP
58 * tegra_init_l2_for_a15
60 * set up the correct L2 cache data RAM latency
62 ENTRY(tegra_init_l2_for_a15)
63 mrc p15, 0, r0, c0, c0, 5
65 tst r0, #1 @ only need for cluster 0
68 mrc p15, 0x1, r0, c9, c0, 2
73 mcrne p15, 0x1, r0, c9, c0, 2
77 ENDPROC(tegra_init_l2_for_a15)
80 * tegra_sleep_cpu_finish(unsigned long v2p)
82 * enters suspend in LP2 by turning off the mmu and jumping to
83 * tegra?_tear_down_cpu
85 ENTRY(tegra_sleep_cpu_finish)
87 /* Flush and disable the L1 data cache */
88 mov r0, #TEGRA_FLUSH_CACHE_ALL
89 bl tegra_disable_clean_inv_dcache
92 mov32 r6, tegra_tear_down_cpu
96 mov32 r3, tegra_shut_off_mmu
101 ENDPROC(tegra_sleep_cpu_finish)
106 * r0 = physical address to jump to with mmu off
108 * called with VA=PA mapping
109 * turns off MMU, icache, dcache and branch prediction
111 .align L1_CACHE_SHIFT
112 .pushsection .idmap.text, "ax"
113 ENTRY(tegra_shut_off_mmu)
114 mrc p15, 0, r3, c1, c0, 0
115 movw r2, #CR_I | CR_Z | CR_C | CR_M
118 mcr p15, 0, r3, c1, c0, 0
120 #ifdef CONFIG_CACHE_L2X0
121 /* Disable L2 cache */
122 check_cpu_part_num 0xc09, r9, r10
125 mov32 r2, TEGRA_ARM_PERIF_BASE + 0x3000
126 ldr r3, [r2, #L2X0_CTRL]
127 tst r3, #L2X0_CTRL_EN @ see tegra_sleep_cpu()
129 strne r3, [r2, #L2X0_CTRL]
132 ENDPROC(tegra_shut_off_mmu)
136 * tegra_switch_cpu_to_pllp
138 * In LP2 the normal cpu clock pllx will be turned off. Switch the CPU to pllp
140 ENTRY(tegra_switch_cpu_to_pllp)
141 /* in LP2 idle (SDRAM active), set the CPU burst policy to PLLP */
142 mov32 r5, TEGRA_CLK_RESET_BASE
143 mov r0, #(2 << 28) @ burst policy = run mode
144 orr r0, r0, #(4 << 4) @ use PLLP in run mode burst
145 str r0, [r5, #CLK_RESET_CCLK_BURST]
147 str r0, [r5, #CLK_RESET_CCLK_DIVIDER]
149 ENDPROC(tegra_switch_cpu_to_pllp)