Skip to content

Commit

Permalink
morello: add shutdown/reboot communication with PCC
Browse files Browse the repository at this point in the history
On Morello SoC platform, SCP has to communicate with PCC over shared
memory interface for system shutdown and reboot. This patch adds
support for the same.

Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
Signed-off-by: Anurag Koul <anurag.koul@arm.com>
Change-Id: I46ad477552f40c530605ea99fe4d30472ecb28d4
  • Loading branch information
chandnich authored and nicola-mazzucato-arm committed Dec 9, 2021
1 parent 291a906 commit 806214b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
8 changes: 8 additions & 0 deletions product/morello/module/morello_system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#
add_library(${SCP_MODULE_TARGET} SCP_MODULE)

if(SCP_ENABLE_PLAT_FVP)
target_compile_definitions(${SCP_MODULE_TARGET} PUBLIC -DPLAT_FVP=1)
endif()

target_include_directories(${SCP_MODULE_TARGET}
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")

Expand All @@ -22,3 +26,7 @@ target_link_libraries(
module-scmi
module-system-power
module-dmc-bing)

if(NOT SCP_ENABLE_PLAT_FVP)
target_link_libraries(${SCP_MODULE_TARGET} PRIVATE module-morello-scp2pcc)
endif()
45 changes: 45 additions & 0 deletions product/morello/module/morello_system/src/mod_morello_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <mod_clock.h>
#include <mod_dmc_bing.h>
#if !defined(PLAT_FVP)
# include <mod_morello_scp2pcc.h>
#endif
#include <mod_morello_system.h>
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
Expand Down Expand Up @@ -115,6 +118,11 @@ struct morello_system_ctx {

/* Pointer to SDS */
const struct mod_sds_api *sds_api;

#if !defined(PLAT_FVP)
/* Pointer to SCP to PCC communication API */
const struct mod_morello_scp2pcc_api *scp2pcc_api;
#endif
};

struct morello_system_isr {
Expand Down Expand Up @@ -177,6 +185,33 @@ static struct morello_system_isr isrs[] = {

static int morello_system_shutdown(enum mod_pd_system_shutdown system_shutdown)
{
#if !defined(PLAT_FVP)
int status;
switch (system_shutdown) {
case MOD_PD_SYSTEM_SHUTDOWN:
FWK_LOG_INFO("[MORELLO SYSTEM] Request PCC for system shutdown");
status = morello_system_ctx.scp2pcc_api->send(
NULL, 0, SCP2PCC_TYPE_SHUTDOWN);
break;

case MOD_PD_SYSTEM_COLD_RESET:
FWK_LOG_INFO("[MORELLO SYSTEM] Request PCC for system reboot");
status =
morello_system_ctx.scp2pcc_api->send(NULL, 0, SCP2PCC_TYPE_REBOOT);
break;

default:
FWK_LOG_INFO("[MORELLO SYSTEM] Unknown shutdown command!");
status = FWK_E_PARAM;
break;
}

if (status != FWK_SUCCESS) {
FWK_LOG_ERR("[MORELLO SYSTEM] Shutdown/Reboot request to PCC failed");
return status;
}
#endif

NVIC_SystemReset();
return FWK_E_DEVICE;
}
Expand Down Expand Up @@ -424,6 +459,16 @@ static int morello_system_bind(fwk_id_t id, unsigned int round)
if (status != FWK_SUCCESS)
return status;

#if !defined(PLAT_FVP)
status = fwk_module_bind(
FWK_ID_MODULE(FWK_MODULE_IDX_MORELLO_SCP2PCC),
FWK_ID_API(FWK_MODULE_IDX_MORELLO_SCP2PCC, 0),
&morello_system_ctx.scp2pcc_api);
if (status != FWK_SUCCESS) {
return status;
}
#endif

return fwk_module_bind(
fwk_module_id_sds,
FWK_ID_API(FWK_MODULE_IDX_SDS, 0),
Expand Down

0 comments on commit 806214b

Please sign in to comment.