// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (C) 2017 NXP * * Peng Fan */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static int suspended_init; int imx7_cpu_suspend(uint32_t power_state __unused, uintptr_t entry, uint32_t context_id __unused, struct sm_nsec_ctx *nsec) { uint32_t suspend_ocram_base = core_mmu_get_va(TRUSTZONE_OCRAM_START + SUSPEND_OCRAM_OFFSET, MEM_AREA_TEE_COHERENT); struct imx7_pm_info *p = (struct imx7_pm_info *)suspend_ocram_base; int ret; return 0; if (!suspended_init) { imx7_suspend_init(); suspended_init = 1; } sm_save_unbanked_regs(&nsec->ub_regs); ret = sm_pm_cpu_suspend((uint32_t)p, (int (*)(uint32_t)) (suspend_ocram_base + sizeof(*p))); /* * Sometimes sm_pm_cpu_suspend may not really suspended, * we need to check it's return value to restore reg or not */ if (ret < 0) { DMSG("=== Not suspended, GPC IRQ Pending ===\n"); return 0; } plat_cpu_reset_late(); sm_restore_unbanked_regs(&nsec->ub_regs); /* Set entry for back to Linux */ nsec->mon_lr = (uint32_t)entry; main_init_gic(); DMSG("=== Back from Suspended ===\n"); return 0; }