Skip to content

Commit

Permalink
plat-sam: psci: add support for suspend and idle.
Browse files Browse the repository at this point in the history
Based on the previous work to add suspend on sama5d2 platform, add
the PSCI glue to call suspend function. psci_cpu_suspend() is used to
put the platform in light suspend mode (STANDBY) whereas
psci_system_suspend() puts the system into the suspend mode selected by
CFG_ATMEL_PM_SUSPEND_MODE at compile time.

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
  • Loading branch information
clementleger authored and jforissier committed Jan 31, 2022
1 parent d031d1e commit 92012a6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions core/arch/arm/plat-sam/pm/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,47 @@

#include <drivers/atmel_rstc.h>
#include <drivers/atmel_shdwc.h>
#include <drivers/pm/sam/atmel_pm.h>
#include <kernel/panic.h>
#include <sm/psci.h>
#include <sm/std_smc.h>
#include <stdint.h>
#include <trace.h>

int psci_system_suspend(uintptr_t entry, uint32_t context_id __unused,
struct sm_nsec_ctx *nsec)
{
if (!atmel_pm_suspend_available())
return PSCI_RET_NOT_SUPPORTED;

if (atmel_pm_suspend(entry, nsec))
return PSCI_RET_INTERNAL_FAILURE;

return PSCI_RET_SUCCESS;
}

int psci_cpu_suspend(uint32_t power_state,
uintptr_t entry __unused, uint32_t context_id __unused,
struct sm_nsec_ctx *nsec __unused)
{
uint32_t type = 0;

if (atmel_pm_suspend_available())
return PSCI_RET_NOT_SUPPORTED;

type = (power_state & PSCI_POWER_STATE_TYPE_MASK) >>
PSCI_POWER_STATE_TYPE_SHIFT;

if (type != PSCI_POWER_STATE_TYPE_STANDBY) {
DMSG("Power state %x not supported", type);
return PSCI_RET_INVALID_PARAMETERS;
}

atmel_pm_cpu_idle();

return PSCI_RET_SUCCESS;
}

void __noreturn psci_system_off(void)
{
if (!atmel_shdwc_available())
Expand Down Expand Up @@ -42,6 +77,11 @@ int psci_features(uint32_t psci_fid)
if (atmel_shdwc_available())
return PSCI_RET_SUCCESS;
return PSCI_RET_NOT_SUPPORTED;
case PSCI_CPU_SUSPEND:
case PSCI_SYSTEM_SUSPEND:
if (atmel_pm_suspend_available())
return PSCI_RET_SUCCESS;
return PSCI_RET_NOT_SUPPORTED;
default:
return PSCI_RET_NOT_SUPPORTED;
}
Expand Down

0 comments on commit 92012a6

Please sign in to comment.