1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Secure entry function for CPU Core #1
6 * Texas Instruments, <www.ti.com>
9 * Harinarayan Bhatta <harinarayan@ti.com>
13 #include <asm/arch/omap.h>
14 #include <asm/omap_common.h>
15 #include <linux/linkage.h>
19 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
20 .global flush_dcache_range
23 #define AUX_CORE_BOOT_0 0x48281800
24 #define AUX_CORE_BOOT_1 0x48281804
27 /* DRA7xx ROM code function "startup_BootSlave". This function is where CPU1
28 * waits on WFE, polling on AUX_CORE_BOOT_x registers.
29 * This address is same for J6 and J6 Eco.
31 #define ROM_FXN_STARTUP_BOOTSLAVE 0x00038a64
34 /* Assembly core where CPU1 is woken up into
35 * No need to save-restore registers, does not use stack.
38 ldr r4, =omap_smc_sec_cpu1_args
39 ldm r4, {r0,r1,r2,r3} @ Retrieve args
41 mov r6, #0xFF @ Indicate new Task call
42 mov r12, #0x00 @ Secure Service ID in R12
46 smc 0 @ SMC #0 to enter monitor mode
48 b .Lend @ exit at end of the service execution
51 @ In case of IRQ happening in Secure, then ARM will branch here.
52 @ At that moment, IRQ will be pending and ARM will jump to Non Secure
58 smc 0 @ SMC #0 to enter monitor mode
61 ldr r4, =omap_smc_sec_cpu1_args
62 str r0, [r4, #0x10] @ save return value
63 ldr r4, =AUX_CORE_BOOT_0
66 ldr r4, =ROM_FXN_STARTUP_BOOTSLAVE
67 sev @ Tell CPU0 we are done
68 bx r4 @ Jump back to ROM
72 * u32 omap_smc_sec_cpu1(u32 service, u32 proc_id, u32 flag, u32 *params);
74 * Makes a secure ROM/PPA call on CPU Core #1 on supported platforms.
75 * Assumes that CPU #1 is waiting in ROM code and not yet woken up or used by
78 ENTRY(omap_smc_sec_cpu1)
80 ldr r4, =omap_smc_sec_cpu1_args
81 stm r4, {r0,r1,r2,r3} @ Save args to memory
82 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
84 mov r1, #CONFIG_SYS_CACHELINE_SIZE
85 add r1, r0, r1 @ dcache is not enabled on CPU1, so
86 blx flush_dcache_range @ flush the cache on args buffer
88 ldr r4, =AUX_CORE_BOOT_1
90 str r5, [r4] @ Setup CPU1 entry function
91 ldr r4, =AUX_CORE_BOOT_0
93 str r5, [r4] @ Tell ROM to exit while loop
96 wfe @ Wait for CPU1 to finish
98 ldr r5, [r4] @ Check if CPU1 is done
102 ldr r4, =omap_smc_sec_cpu1_args
103 ldr r0, [r4, #0x10] @ Retrieve return value
105 ENDPROC(omap_smc_sec_cpu1)
108 * Buffer to save function arguments and return value for omap_smc_sec_cpu1
111 omap_smc_sec_cpu1_args:
112 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
113 .balign CONFIG_SYS_CACHELINE_SIZE
114 .rept CONFIG_SYS_CACHELINE_SIZE/4
122 END(omap_smc_sec_cpu1_args)