1 #include <linux/linkage.h>
2 #include <linux/init.h>
6 #include <mach/iomap.h>
12 #define APB_MISC_GP_HIDREV 0x804
13 #define PMC_SCRATCH41 0x140
15 #define RESET_DATA(x) ((TEGRA_RESET_##x)*4)
17 .section ".text.head", "ax"
21 * Tegra specific entry point for secondary CPUs.
22 * The secondary kernel init calls v7_flush_dcache_all before it enables
23 * the L1; however, the L1 comes out of reset in an undefined state, so
24 * the clean + invalidate performed by v7_flush_dcache_all causes a bunch
25 * of cache lines with uninitialized data and uninitialized tags to get
26 * written out to memory, which does really unpleasant things to the main
27 * processor. We fix this by performing an invalidate, rather than a
28 * clean + invalidate, before jumping into the kernel.
30 ENTRY(v7_invalidate_l1)
32 mcr p15, 2, r0, c0, c0, 0
33 mrc p15, 1, r0, c0, c0, 0
36 and r2, r1, r0, lsr #13
40 and r3, r1, r0, lsr #3 @ NumWays - 1
41 add r2, r2, #1 @ NumSets
44 add r0, r0, #4 @ SetShift
47 add r4, r3, #1 @ NumWays
48 1: sub r2, r2, #1 @ NumSets--
49 mov r3, r4 @ Temp = NumWays
50 2: subs r3, r3, #1 @ Temp--
53 orr r5, r5, r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
54 mcr p15, 0, r5, c7, c6, 2
61 ENDPROC(v7_invalidate_l1)
64 ENTRY(tegra_secondary_startup)
66 /* Enable coresight */
68 mcr p14, 0, r0, c7, c12, 6
70 ENDPROC(tegra_secondary_startup)
73 ENTRY(__tegra_cpu_reset_handler_start)
76 * __tegra_cpu_reset_handler:
78 * Common handler for all CPU reset events.
80 * Register usage within the reset handler:
82 * R7 = CPU present (to the OS) mask
83 * R8 = CPU in LP1 state mask
84 * R9 = CPU in LP2 state mask
87 * R12 = pointer to reset handler data
89 * NOTE: This code is copied to IRAM. All code and data accesses
90 * must be position-independent.
94 ENTRY(__tegra_cpu_reset_handler)
96 cpsid aif, 0x13 @ SVC mode, interrupts disabled
97 mrc p15, 0, r10, c0, c0, 5 @ MPIDR
98 and r10, r10, #0x3 @ R10 = CPU number
100 mov r11, r11, lsl r10 @ R11 = CPU mask
101 adr r12, __tegra_cpu_reset_handler_data
104 /* Does the OS know about this CPU? */
105 ldr r7, [r12, #RESET_DATA(MASK_PRESENT)]
106 tst r7, r11 @ if !present
107 bleq __die @ CPU not present (to OS)
110 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
111 /* Are we on Tegra20? */
112 mov32 r6, TEGRA_APB_MISC_BASE
113 ldr r0, [r6, #APB_MISC_GP_HIDREV]
117 /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
118 mov32 r6, TEGRA_PMC_BASE
121 strne r0, [r6, #PMC_SCRATCH41]
127 * Can only be secondary boot (initial or hotplug) but CPU 0
131 bleq __die @ CPU0 cannot be here
132 ldr lr, [r12, #RESET_DATA(STARTUP_SECONDARY)]
134 bleq __die @ no secondary startup handler
139 * We don't know why the CPU reset. Just kill it.
140 * The LR register will contain the address we died at + 4.
145 mov32 r7, TEGRA_PMC_BASE
146 str lr, [r7, #PMC_SCRATCH41]
148 mov32 r7, TEGRA_CLK_RESET_BASE
150 /* Are we on Tegra20? */
151 mov32 r6, TEGRA_APB_MISC_BASE
152 ldr r0, [r6, #APB_MISC_GP_HIDREV]
157 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
160 str r1, [r7, #0x340] @ CLK_RST_CPU_CMPLX_SET
163 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
164 mov32 r6, TEGRA_FLOW_CTRL_BASE
167 moveq r1, #FLOW_CTRL_HALT_CPU0_EVENTS
168 moveq r2, #FLOW_CTRL_CPU0_CSR
169 movne r1, r10, lsl #3
170 addne r2, r1, #(FLOW_CTRL_CPU1_CSR-8)
171 addne r1, r1, #(FLOW_CTRL_HALT_CPU1_EVENTS-8)
173 /* Clear CPU "event" and "interrupt" flags and power gate
174 it when halting but not before it is in the "WFI" state. */
176 orr r0, r0, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
177 orr r0, r0, #FLOW_CTRL_CSR_ENABLE
180 /* Unconditionally halt this CPU */
181 mov r0, #FLOW_CTRL_WAITEVENT
183 ldr r0, [r6, +r1] @ memory barrier
187 wfi @ CPU should be power gated here
189 /* If the CPU didn't power gate above just kill it's clock. */
192 str r0, [r7, #348] @ CLK_CPU_CMPLX_SET
195 /* If the CPU still isn't dead, just spin here. */
197 ENDPROC(__tegra_cpu_reset_handler)
199 .align L1_CACHE_SHIFT
200 .type __tegra_cpu_reset_handler_data, %object
201 .globl __tegra_cpu_reset_handler_data
202 __tegra_cpu_reset_handler_data:
203 .rept TEGRA_RESET_DATA_SIZE
206 .align L1_CACHE_SHIFT
208 ENTRY(__tegra_cpu_reset_handler_end)