11bb92983SJerome Forissier // SPDX-License-Identifier: BSD-2-Clause 286e50a60SPeng Fan /* 386e50a60SPeng Fan * Copyright 2017 NXP 486e50a60SPeng Fan * 586e50a60SPeng Fan * Peng Fan <peng.fan@nxp.com> 686e50a60SPeng Fan */ 786e50a60SPeng Fan 886e50a60SPeng Fan #include <arm32.h> 986e50a60SPeng Fan #include <console.h> 1086e50a60SPeng Fan #include <drivers/imx_uart.h> 1186e50a60SPeng Fan #include <io.h> 1286e50a60SPeng Fan #include <kernel/cache_helpers.h> 1365401337SJens Wiklander #include <kernel/boot.h> 1486e50a60SPeng Fan #include <kernel/misc.h> 1586e50a60SPeng Fan #include <kernel/panic.h> 1686e50a60SPeng Fan #include <kernel/thread.h> 1786e50a60SPeng Fan #include <kernel/tlb_helpers.h> 1886e50a60SPeng Fan #include <kernel/tz_ssvce_pl310.h> 1986e50a60SPeng Fan #include <mm/core_memprot.h> 2086e50a60SPeng Fan #include <mm/core_mmu.h> 2186e50a60SPeng Fan #include <platform_config.h> 2286e50a60SPeng Fan #include <sm/optee_smc.h> 2386e50a60SPeng Fan #include <sm/pm.h> 2486e50a60SPeng Fan #include <sm/psci.h> 2586e50a60SPeng Fan #include <sm/sm.h> 2686e50a60SPeng Fan #include <stdint.h> 2786e50a60SPeng Fan 2886e50a60SPeng Fan #if CFG_TEE_CORE_NB_CORE > 4 2986e50a60SPeng Fan #error "Max support 4 cores in one cluster now" 3086e50a60SPeng Fan #endif 3186e50a60SPeng Fan sm_pm_cpu_suspend_save(struct sm_pm_ctx * ctx,uint32_t sp)3286e50a60SPeng Fanvoid sm_pm_cpu_suspend_save(struct sm_pm_ctx *ctx, uint32_t sp) 3386e50a60SPeng Fan { 3486e50a60SPeng Fan struct thread_core_local *p = thread_get_core_local(); 3586e50a60SPeng Fan 3686e50a60SPeng Fan p->sm_pm_ctx_phys = virt_to_phys((void *)ctx); 3786e50a60SPeng Fan 3886e50a60SPeng Fan /* The content will be passed to sm_pm_cpu_do_resume as register sp */ 3986e50a60SPeng Fan ctx->sp = sp; 4086e50a60SPeng Fan ctx->cpu_resume_addr = 4186e50a60SPeng Fan virt_to_phys((void *)(vaddr_t)sm_pm_cpu_do_resume); 4286e50a60SPeng Fan 4386e50a60SPeng Fan sm_pm_cpu_do_suspend(ctx->suspend_regs); 4486e50a60SPeng Fan 4586e50a60SPeng Fan dcache_op_level1(DCACHE_OP_CLEAN_INV); 4686e50a60SPeng Fan 4786e50a60SPeng Fan #ifdef CFG_PL310 48*c2e4eb43SAnton Rybakov arm_cl2_cleanbyway(core_mmu_get_va(PL310_BASE, MEM_AREA_IO_SEC, 1)); 4986e50a60SPeng Fan #endif 5086e50a60SPeng Fan } 51