Skip to content

Commit 8ab871f

Browse files
glneotmlind
authored andcommitted
ARM: OMAP2+: sleep43xx: Call secure suspend/resume handlers
During suspend CPU context may be lost in both non-secure and secure CPU states. The kernel can handle saving and restoring the non-secure context but must call into the secure side to allow it to save any context it may lose. Add these calls here. Note that on systems with OP-TEE available the suspend call is issued to OP-TEE using the ARM SMCCC, but the resume call is always issued to the ROM. This is because on waking from suspend the ROM is restored as the secure monitor. It is this resume call that instructs the ROM to restore OP-TEE, all subsequent calls will be handled by OP-TEE and should use the ARM SMCCC. Signed-off-by: Andrew F. Davis <[email protected]> Acked-by: Dave Gerlach <[email protected]> Reviewed-by: Lokesh Vutla <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent 48840e1 commit 8ab871f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

arch/arm/mach-omap2/omap-secure.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
#define OMAP4_PPA_L2_POR_INDEX 0x23
5454
#define OMAP4_PPA_CPU_ACTRL_SMP_INDEX 0x25
5555

56+
#define AM43xx_PPA_SVC_PM_SUSPEND 0x71
57+
#define AM43xx_PPA_SVC_PM_RESUME 0x72
58+
5659
/* Secure RX-51 PPA (Primary Protected Application) APIs */
5760
#define RX51_PPA_HWRNG 29
5861
#define RX51_PPA_L2_INVAL 40

arch/arm/mach-omap2/pm33xx-core.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "prm33xx.h"
2929
#include "soc.h"
3030
#include "sram.h"
31+
#include "omap-secure.h"
3132

3233
static struct powerdomain *cefuse_pwrdm, *gfx_pwrdm, *per_pwrdm, *mpu_pwrdm;
3334
static struct clockdomain *gfx_l4ls_clkdm;
@@ -166,6 +167,16 @@ static int am43xx_suspend(unsigned int state, int (*fn)(unsigned long),
166167
{
167168
int ret = 0;
168169

170+
/* Suspend secure side on HS devices */
171+
if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
172+
if (optee_available)
173+
omap_smccc_smc(AM43xx_PPA_SVC_PM_SUSPEND, 0);
174+
else
175+
omap_secure_dispatcher(AM43xx_PPA_SVC_PM_SUSPEND,
176+
FLAG_START_CRITICAL,
177+
0, 0, 0, 0, 0);
178+
}
179+
169180
amx3_pre_suspend_common();
170181
scu_power_mode(scu_base, SCU_PM_POWEROFF);
171182
ret = cpu_suspend(args, fn);
@@ -174,6 +185,19 @@ static int am43xx_suspend(unsigned int state, int (*fn)(unsigned long),
174185
if (!am43xx_check_off_mode_enable())
175186
amx3_post_suspend_common();
176187

188+
/*
189+
* Resume secure side on HS devices.
190+
*
191+
* Note that even on systems with OP-TEE available this resume call is
192+
* issued to the ROM. This is because upon waking from suspend the ROM
193+
* is restored as the secure monitor. On systems with OP-TEE ROM will
194+
* restore OP-TEE during this call.
195+
*/
196+
if (omap_type() != OMAP2_DEVICE_TYPE_GP)
197+
omap_secure_dispatcher(AM43xx_PPA_SVC_PM_RESUME,
198+
FLAG_START_CRITICAL,
199+
0, 0, 0, 0, 0);
200+
177201
return ret;
178202
}
179203

0 commit comments

Comments
 (0)