1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2013 Samsung Electronics
8 #include <asm/arch/cpu.h>
10 .globl relocate_wait_code
12 adr r0, code_base @ r0: source address (start)
13 adr r1, code_end @ r1: source address (end)
14 ldr r2, =0x02073000 @ r2: target address
23 * Secondary core waits here until Primary wake it up.
24 * Below code is copied to (CFG_IRAM_TOP - 0x1000)
25 * This is a workaround code which is supposed to act as a
26 * substitute/supplement to the iROM code.
28 * This workaround code is relocated to the address 0x02073000
29 * because that comes out to be the last 4KB of the iRAM
30 * (Base Address - 0x02020000, Limit Address - 0x020740000).
32 * U-Boot and kernel are aware of this code and flags by the simple
33 * fact that we are implementing a workaround in the last 4KB
34 * of the iRAM and we have already defined these flag and address
35 * values in both kernel and U-Boot for our use.
40 * These addresses are being used as flags in u-boot and kernel.
42 * Jump address for resume and flag to check for resume/reset:
43 * Resume address - 0x2073008
44 * Resume flag - 0x207300C
46 * Jump address for cluster switching:
47 * Switch address - 0x2073018
49 * Jump address for core hotplug:
50 * Hotplug address - 0x207301C
52 * Jump address for C2 state (Reserved for future not being used right now):
53 * C2 address - 0x2073024
55 * Managed per core status for the active cluster:
56 * CPU0 state - 0x2073028
57 * CPU1 state - 0x207302C
58 * CPU2 state - 0x2073030
59 * CPU3 state - 0x2073034
61 * Managed per core GIC status for the active cluster:
62 * CPU0 gic state - 0x2073038
63 * CPU1 gic state - 0x207303C
64 * CPU2 gic state - 0x2073040
65 * CPU3 gic state - 0x2073044
68 * Step-1: Read current CPU status.
69 * Step-2: If it's a resume then continue, else jump to step 4.
70 * Step-3: Clear inform1 PMU register and jump to inform0 value.
71 * Step-4: If it's a switch, C2 or reset, get the hotplug address.
72 * Step-5: If address is not available, enter WFE.
73 * Step-6: If address is available, jump to that address.
75 nop @ for backward compatibility
76 .word 0x0 @ REG0: RESUME_ADDR
77 .word 0x0 @ REG1: RESUME_FLAG
81 .word 0x0 @ REG4: SWITCH_ADDR
83 .word 0x0 @ REG5: CPU1_BOOT_REG
86 .word 0x0 @ REG7: REG_C2_ADDR
88 .word 0x1 @ CPU0_STATE : RESET
89 .word 0x2 @ CPU1_STATE : SECONDARY RESET
90 .word 0x2 @ CPU2_STATE : SECONDARY RESET
91 .word 0x2 @ CPU3_STATE : SECONDARY RESET
93 .word 0x0 @ CPU0 - GICD_IGROUPR0
94 .word 0x0 @ CPU1 - GICD_IGROUPR0
95 .word 0x0 @ CPU2 - GICD_IGROUPR0
96 .word 0x0 @ CPU3 - GICD_IGROUPR0
99 mrc p15, 0, r7, c0, c0, 5 @ read MPIDR
100 and r7, r7, #0xf @ r7 = cpu id
101 /* Read the current cpu state */
102 ldr r10, [r0, r7, lsl #2]
105 adrne r0, _switch_addr
108 ldr r0, =(0x10040000 + 0x804)
114 ldrne r1, =(0x10040000 + 0x800)
117 ldrne pc, =0x23e00000
118 adr r0, _hotplug_addr