xref: /optee_os/core/arch/arm/include/sm/pm.h (revision d50fee0321fe6853ac6352cf0fd548666457b407)
11bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */
286e50a60SPeng Fan /*
386e50a60SPeng Fan  * Copyright 2017 NXP
486e50a60SPeng Fan  * All rights reserved.
586e50a60SPeng Fan  *
686e50a60SPeng Fan  * Redistribution and use in source and binary forms, with or without
786e50a60SPeng Fan  * modification, are permitted provided that the following conditions are met:
886e50a60SPeng Fan  *
986e50a60SPeng Fan  * 1. Redistributions of source code must retain the above copyright notice,
1086e50a60SPeng Fan  * this list of conditions and the following disclaimer.
1186e50a60SPeng Fan  *
1286e50a60SPeng Fan  * 2. Redistributions in binary form must reproduce the above copyright notice,
1386e50a60SPeng Fan  * this list of conditions and the following disclaimer in the documentation
1486e50a60SPeng Fan  * and/or other materials provided with the distribution.
1586e50a60SPeng Fan  *
1686e50a60SPeng Fan  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1786e50a60SPeng Fan  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1886e50a60SPeng Fan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1986e50a60SPeng Fan  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2086e50a60SPeng Fan  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2186e50a60SPeng Fan  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2286e50a60SPeng Fan  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2386e50a60SPeng Fan  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2486e50a60SPeng Fan  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2586e50a60SPeng Fan  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2686e50a60SPeng Fan  * POSSIBILITY OF SUCH DAMAGE.
2786e50a60SPeng Fan  */
2886e50a60SPeng Fan 
29*d50fee03SEtienne Carriere #ifndef __SM_PM_H
30*d50fee03SEtienne Carriere #define __SM_PM_H
3186e50a60SPeng Fan #include <stdint.h>
3286e50a60SPeng Fan #include <types_ext.h>
3386e50a60SPeng Fan 
3486e50a60SPeng Fan struct sm_pm_ctx {
3586e50a60SPeng Fan 	uint32_t sp;
3686e50a60SPeng Fan 	paddr_t cpu_resume_addr;
3786e50a60SPeng Fan 	uint32_t suspend_regs[16];
3886e50a60SPeng Fan };
3986e50a60SPeng Fan 
4086e50a60SPeng Fan /* suspend/resume core functions */
4186e50a60SPeng Fan void sm_pm_cpu_suspend_save(struct sm_pm_ctx *ptr, uint32_t sp);
4286e50a60SPeng Fan void sm_pm_cpu_do_suspend(uint32_t *ptr);
4386e50a60SPeng Fan void sm_pm_cpu_do_resume(void);
4486e50a60SPeng Fan 
4586e50a60SPeng Fan /*
4686e50a60SPeng Fan  * Exported to platform suspend, arg will be passed to fn as r0
4786e50a60SPeng Fan  * Return value: 0  - cpu resumed from suspended state.
4886e50a60SPeng Fan  *               -1 - cpu not suspended.
4986e50a60SPeng Fan  */
5086e50a60SPeng Fan int sm_pm_cpu_suspend(uint32_t arg, int (*fn)(uint32_t));
5186e50a60SPeng Fan #endif
52