1 #include <linux/linkage.h>
2 #include <linux/init.h>
5 #include <asm/asm-offsets.h>
6 #include <asm/hardware/cache-l2x0.h>
13 #define APB_MISC_GP_HIDREV 0x804
14 #define PMC_SCRATCH41 0x140
16 #define RESET_DATA(x) ((TEGRA_RESET_##x)*4)
18 .section ".text.head", "ax"
22 * Tegra specific entry point for secondary CPUs.
23 * The secondary kernel init calls v7_flush_dcache_all before it enables
24 * the L1; however, the L1 comes out of reset in an undefined state, so
25 * the clean + invalidate performed by v7_flush_dcache_all causes a bunch
26 * of cache lines with uninitialized data and uninitialized tags to get
27 * written out to memory, which does really unpleasant things to the main
28 * processor. We fix this by performing an invalidate, rather than a
29 * clean + invalidate, before jumping into the kernel.
31 ENTRY(v7_invalidate_l1)
33 mcr p15, 2, r0, c0, c0, 0
34 mrc p15, 1, r0, c0, c0, 0
37 and r2, r1, r0, lsr #13
41 and r3, r1, r0, lsr #3 @ NumWays - 1
42 add r2, r2, #1 @ NumSets
45 add r0, r0, #4 @ SetShift
48 add r4, r3, #1 @ NumWays
49 1: sub r2, r2, #1 @ NumSets--
50 mov r3, r4 @ Temp = NumWays
51 2: subs r3, r3, #1 @ Temp--
54 orr r5, r5, r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
55 mcr p15, 0, r5, c7, c6, 2
62 ENDPROC(v7_invalidate_l1)
65 ENTRY(tegra_secondary_startup)
67 /* Enable coresight */
69 mcr p14, 0, r0, c7, c12, 6
71 ENDPROC(tegra_secondary_startup)
73 #ifdef CONFIG_PM_SLEEP
77 * CPU boot vector when restarting the a CPU following
78 * an LP2 transition. Also branched to by LP0 and LP1 resume after
83 /* Enable coresight */
85 mcr p14, 0, r0, c7, c12, 6
91 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
92 /* Are we on Tegra20? */
93 mov32 r6, TEGRA_APB_MISC_BASE
94 ldr r0, [r6, #APB_MISC_GP_HIDREV]
98 /* Clear the flow controller flags for this CPU. */
99 mov32 r2, TEGRA_FLOW_CTRL_BASE + FLOW_CTRL_CPU0_CSR @ CPU0 CSR
101 /* Clear event & intr flag */
103 #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
104 movw r0, #0x0FFD @ enable, cluster_switch, immed, & bitmaps
110 #ifdef CONFIG_HAVE_ARM_SCU
112 mov32 r0, TEGRA_ARM_PERIF_BASE
118 /* L2 cache resume & re-enable */
119 l2_cache_resume r0, r1, r2, l2x0_saved_regs_addr
122 ENDPROC(tegra_resume)
125 #ifdef CONFIG_CACHE_L2X0
126 .globl l2x0_saved_regs_addr
127 l2x0_saved_regs_addr:
131 .align L1_CACHE_SHIFT
132 ENTRY(__tegra_cpu_reset_handler_start)
135 * __tegra_cpu_reset_handler:
137 * Common handler for all CPU reset events.
139 * Register usage within the reset handler:
141 * R7 = CPU present (to the OS) mask
142 * R8 = CPU in LP1 state mask
143 * R9 = CPU in LP2 state mask
146 * R12 = pointer to reset handler data
148 * NOTE: This code is copied to IRAM. All code and data accesses
149 * must be position-independent.
152 .align L1_CACHE_SHIFT
153 ENTRY(__tegra_cpu_reset_handler)
155 cpsid aif, 0x13 @ SVC mode, interrupts disabled
156 mrc p15, 0, r10, c0, c0, 5 @ MPIDR
157 and r10, r10, #0x3 @ R10 = CPU number
159 mov r11, r11, lsl r10 @ R11 = CPU mask
160 adr r12, __tegra_cpu_reset_handler_data
163 /* Does the OS know about this CPU? */
164 ldr r7, [r12, #RESET_DATA(MASK_PRESENT)]
165 tst r7, r11 @ if !present
166 bleq __die @ CPU not present (to OS)
169 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
170 /* Are we on Tegra20? */
171 mov32 r6, TEGRA_APB_MISC_BASE
172 ldr r0, [r6, #APB_MISC_GP_HIDREV]
176 /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
177 mov32 r6, TEGRA_PMC_BASE
180 strne r0, [r6, #PMC_SCRATCH41]
184 /* Waking up from LP2? */
185 ldr r9, [r12, #RESET_DATA(MASK_LP2)]
186 tst r9, r11 @ if in_lp2
188 ldr lr, [r12, #RESET_DATA(STARTUP_LP2)]
190 bleq __die @ no LP2 startup handler
197 * Can only be secondary boot (initial or hotplug) but CPU 0
201 bleq __die @ CPU0 cannot be here
202 ldr lr, [r12, #RESET_DATA(STARTUP_SECONDARY)]
204 bleq __die @ no secondary startup handler
209 * We don't know why the CPU reset. Just kill it.
210 * The LR register will contain the address we died at + 4.
215 mov32 r7, TEGRA_PMC_BASE
216 str lr, [r7, #PMC_SCRATCH41]
218 mov32 r7, TEGRA_CLK_RESET_BASE
220 /* Are we on Tegra20? */
221 mov32 r6, TEGRA_APB_MISC_BASE
222 ldr r0, [r6, #APB_MISC_GP_HIDREV]
227 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
230 str r1, [r7, #0x340] @ CLK_RST_CPU_CMPLX_SET
233 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
234 mov32 r6, TEGRA_FLOW_CTRL_BASE
237 moveq r1, #FLOW_CTRL_HALT_CPU0_EVENTS
238 moveq r2, #FLOW_CTRL_CPU0_CSR
239 movne r1, r10, lsl #3
240 addne r2, r1, #(FLOW_CTRL_CPU1_CSR-8)
241 addne r1, r1, #(FLOW_CTRL_HALT_CPU1_EVENTS-8)
243 /* Clear CPU "event" and "interrupt" flags and power gate
244 it when halting but not before it is in the "WFI" state. */
246 orr r0, r0, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
247 orr r0, r0, #FLOW_CTRL_CSR_ENABLE
250 /* Unconditionally halt this CPU */
251 mov r0, #FLOW_CTRL_WAITEVENT
253 ldr r0, [r6, +r1] @ memory barrier
257 wfi @ CPU should be power gated here
259 /* If the CPU didn't power gate above just kill it's clock. */
262 str r0, [r7, #348] @ CLK_CPU_CMPLX_SET
265 /* If the CPU still isn't dead, just spin here. */
267 ENDPROC(__tegra_cpu_reset_handler)
269 .align L1_CACHE_SHIFT
270 .type __tegra_cpu_reset_handler_data, %object
271 .globl __tegra_cpu_reset_handler_data
272 __tegra_cpu_reset_handler_data:
273 .rept TEGRA_RESET_DATA_SIZE
276 .align L1_CACHE_SHIFT
278 ENTRY(__tegra_cpu_reset_handler_end)