1 #include <linux/linkage.h>
2 #include <linux/init.h>
11 #define APB_MISC_GP_HIDREV 0x804
12 #define PMC_SCRATCH41 0x140
14 #define RESET_DATA(x) ((TEGRA_RESET_##x)*4)
16 .section ".text.head", "ax"
20 * Tegra specific entry point for secondary CPUs.
21 * The secondary kernel init calls v7_flush_dcache_all before it enables
22 * the L1; however, the L1 comes out of reset in an undefined state, so
23 * the clean + invalidate performed by v7_flush_dcache_all causes a bunch
24 * of cache lines with uninitialized data and uninitialized tags to get
25 * written out to memory, which does really unpleasant things to the main
26 * processor. We fix this by performing an invalidate, rather than a
27 * clean + invalidate, before jumping into the kernel.
29 ENTRY(v7_invalidate_l1)
31 mcr p15, 2, r0, c0, c0, 0
32 mrc p15, 1, r0, c0, c0, 0
35 and r2, r1, r0, lsr #13
39 and r3, r1, r0, lsr #3 @ NumWays - 1
40 add r2, r2, #1 @ NumSets
43 add r0, r0, #4 @ SetShift
46 add r4, r3, #1 @ NumWays
47 1: sub r2, r2, #1 @ NumSets--
48 mov r3, r4 @ Temp = NumWays
49 2: subs r3, r3, #1 @ Temp--
52 orr r5, r5, r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
53 mcr p15, 0, r5, c7, c6, 2
60 ENDPROC(v7_invalidate_l1)
63 ENTRY(tegra_secondary_startup)
65 /* Enable coresight */
67 mcr p14, 0, r0, c7, c12, 6
69 ENDPROC(tegra_secondary_startup)
72 ENTRY(__tegra_cpu_reset_handler_start)
75 * __tegra_cpu_reset_handler:
77 * Common handler for all CPU reset events.
79 * Register usage within the reset handler:
81 * R7 = CPU present (to the OS) mask
82 * R8 = CPU in LP1 state mask
83 * R9 = CPU in LP2 state mask
86 * R12 = pointer to reset handler data
88 * NOTE: This code is copied to IRAM. All code and data accesses
89 * must be position-independent.
93 ENTRY(__tegra_cpu_reset_handler)
95 cpsid aif, 0x13 @ SVC mode, interrupts disabled
96 mrc p15, 0, r10, c0, c0, 5 @ MPIDR
97 and r10, r10, #0x3 @ R10 = CPU number
99 mov r11, r11, lsl r10 @ R11 = CPU mask
100 adr r12, __tegra_cpu_reset_handler_data
103 /* Does the OS know about this CPU? */
104 ldr r7, [r12, #RESET_DATA(MASK_PRESENT)]
105 tst r7, r11 @ if !present
106 bleq __die @ CPU not present (to OS)
109 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
110 /* Are we on Tegra20? */
111 mov32 r6, TEGRA_APB_MISC_BASE
112 ldr r0, [r6, #APB_MISC_GP_HIDREV]
116 /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
117 mov32 r6, TEGRA_PMC_BASE
120 strne r0, [r6, #PMC_SCRATCH41]
126 * Can only be secondary boot (initial or hotplug) but CPU 0
130 bleq __die @ CPU0 cannot be here
131 ldr lr, [r12, #RESET_DATA(STARTUP_SECONDARY)]
133 bleq __die @ no secondary startup handler
138 * We don't know why the CPU reset. Just kill it.
139 * The LR register will contain the address we died at + 4.
144 mov32 r7, TEGRA_PMC_BASE
145 str lr, [r7, #PMC_SCRATCH41]
147 mov32 r7, TEGRA_CLK_RESET_BASE
149 /* Are we on Tegra20? */
150 mov32 r6, TEGRA_APB_MISC_BASE
151 ldr r0, [r6, #APB_MISC_GP_HIDREV]
156 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
159 str r1, [r7, #0x340] @ CLK_RST_CPU_CMPLX_SET
162 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
163 mov32 r6, TEGRA_FLOW_CTRL_BASE
166 moveq r1, #FLOW_CTRL_HALT_CPU0_EVENTS
167 moveq r2, #FLOW_CTRL_CPU0_CSR
168 movne r1, r10, lsl #3
169 addne r2, r1, #(FLOW_CTRL_CPU1_CSR-8)
170 addne r1, r1, #(FLOW_CTRL_HALT_CPU1_EVENTS-8)
172 /* Clear CPU "event" and "interrupt" flags and power gate
173 it when halting but not before it is in the "WFI" state. */
175 orr r0, r0, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
176 orr r0, r0, #FLOW_CTRL_CSR_ENABLE
179 /* Unconditionally halt this CPU */
180 mov r0, #FLOW_CTRL_WAITEVENT
182 ldr r0, [r6, +r1] @ memory barrier
186 wfi @ CPU should be power gated here
188 /* If the CPU didn't power gate above just kill it's clock. */
191 str r0, [r7, #348] @ CLK_CPU_CMPLX_SET
194 /* If the CPU still isn't dead, just spin here. */
196 ENDPROC(__tegra_cpu_reset_handler)
198 .align L1_CACHE_SHIFT
199 .type __tegra_cpu_reset_handler_data, %object
200 .globl __tegra_cpu_reset_handler_data
201 __tegra_cpu_reset_handler_data:
202 .rept TEGRA_RESET_DATA_SIZE
205 .align L1_CACHE_SHIFT
207 ENTRY(__tegra_cpu_reset_handler_end)