diff --git a/docs/plat/xilinx-versal-net.rst b/docs/plat/xilinx-versal-net.rst index 1db7695b1..3f31d40c9 100644 --- a/docs/plat/xilinx-versal-net.rst +++ b/docs/plat/xilinx-versal-net.rst @@ -40,3 +40,16 @@ Xilinx Versal NET platform specific build options * `TFA_NO_PM` : Platform Management support. - 0 : Enable Platform Management (Default) - 1 : Disable Platform Management + +* `CPU_PWRDWN_SGI`: Select the SGI for triggering CPU power down request to + secondary cores on receiving power down callback from + firmware. Options: + + - `0` : SGI 0 + - `1` : SGI 1 + - `2` : SGI 2 + - `3` : SGI 3 + - `4` : SGI 4 + - `5` : SGI 5 + - `6` : SGI 6 (Default) + - `7` : SGI 7 diff --git a/docs/plat/xilinx-versal.rst b/docs/plat/xilinx-versal.rst index e76b95574..aa094f757 100644 --- a/docs/plat/xilinx-versal.rst +++ b/docs/plat/xilinx-versal.rst @@ -56,6 +56,19 @@ Xilinx Versal platform specific build options - `spp_itr6` : SPP ITR6 - `emu_itr6` : EMU ITR6 +* `CPU_PWRDWN_SGI`: Select the SGI for triggering CPU power down request to + secondary cores on receiving power down callback from + firmware. Options: + + - `0` : SGI 0 + - `1` : SGI 1 + - `2` : SGI 2 + - `3` : SGI 3 + - `4` : SGI 4 + - `5` : SGI 5 + - `6` : SGI 6 (Default) + - `7` : SGI 7 + # PLM->TF-A Parameter Passing ------------------------------ The PLM populates a data structure with image information for the TF-A. The TF-A diff --git a/plat/xilinx/common/include/plat_common.h b/plat/xilinx/common/include/plat_common.h index 676baa2c7..2958868fc 100644 --- a/plat/xilinx/common/include/plat_common.h +++ b/plat/xilinx/common/include/plat_common.h @@ -14,4 +14,16 @@ (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ }) +/******************************************************************************* + * interrupt handling related constants + ******************************************************************************/ +#define ARM_IRQ_SEC_SGI_0 8U +#define ARM_IRQ_SEC_SGI_1 9U +#define ARM_IRQ_SEC_SGI_2 10U +#define ARM_IRQ_SEC_SGI_3 11U +#define ARM_IRQ_SEC_SGI_4 12U +#define ARM_IRQ_SEC_SGI_5 13U +#define ARM_IRQ_SEC_SGI_6 14U +#define ARM_IRQ_SEC_SGI_7 15U + #endif /* PLAT_COMMON_H */ diff --git a/plat/xilinx/common/pm_service/pm_svc_main.c b/plat/xilinx/common/pm_service/pm_svc_main.c index 622dc24ec..8ff4949a0 100644 --- a/plat/xilinx/common/pm_service/pm_svc_main.c +++ b/plat/xilinx/common/pm_service/pm_svc_main.c @@ -50,6 +50,19 @@ static void notify_os(void) write_icc_asgi1r_el1(reg); } +static uint64_t cpu_pwrdwn_req_handler(uint32_t id, uint32_t flags, + void *handle, void *cookie) +{ + uint32_t cpu_id = plat_my_core_pos(); + + VERBOSE("Powering down CPU %d\n", cpu_id); + + /* Deactivate CPU power down SGI */ + plat_ic_end_of_interrupt(CPU_PWR_DOWN_REQ_INTR); + + return psci_cpu_off(); +} + static void request_cpu_pwrdwn(void) { VERBOSE("CPU power down request received\n"); @@ -160,6 +173,12 @@ int32_t pm_setup(void) pm_ipi_init(primary_proc); pm_up = true; + /* register SGI handler for CPU power down request */ + ret = request_intr_type_el3(CPU_PWR_DOWN_REQ_INTR, cpu_pwrdwn_req_handler); + if (ret != 0) { + WARN("BL31: registering SGI interrupt failed\n"); + } + /* * Enable IPI IRQ * assume the rich OS is OK to handle callback IRQs now. diff --git a/plat/xilinx/versal/include/platform_def.h b/plat/xilinx/versal/include/platform_def.h index 0ea21b26b..d3a734be5 100644 --- a/plat/xilinx/versal/include/platform_def.h +++ b/plat/xilinx/versal/include/platform_def.h @@ -9,6 +9,7 @@ #define PLATFORM_DEF_H #include +#include #include "versal_def.h" /******************************************************************************* @@ -122,6 +123,8 @@ #define PLAT_VERSAL_G0_IRQ_PROPS(grp) \ INTR_PROP_DESC(PLAT_VERSAL_IPI_IRQ, GIC_HIGHEST_SEC_PRIORITY, grp, \ GIC_INTR_CFG_EDGE), \ + INTR_PROP_DESC(CPU_PWR_DOWN_REQ_INTR, GIC_HIGHEST_SEC_PRIORITY, grp, \ + GIC_INTR_CFG_EDGE) #define IRQ_MAX 142U diff --git a/plat/xilinx/versal/platform.mk b/plat/xilinx/versal/platform.mk index 35d6bc7e7..2f0799698 100644 --- a/plat/xilinx/versal/platform.mk +++ b/plat/xilinx/versal/platform.mk @@ -11,6 +11,8 @@ override RESET_TO_BL31 := 1 PL011_GENERIC_UART := 1 IPI_CRC_CHECK := 0 HARDEN_SLS_ALL := 0 +CPU_PWRDWN_SGI ?= 6 +$(eval $(call add_define_val,CPU_PWR_DOWN_REQ_INTR,ARM_IRQ_SEC_SGI_${CPU_PWRDWN_SGI})) # A72 Erratum for SoC ERRATA_A72_859971 := 1 diff --git a/plat/xilinx/versal_net/include/platform_def.h b/plat/xilinx/versal_net/include/platform_def.h index 334714b26..8cb7deb1d 100644 --- a/plat/xilinx/versal_net/include/platform_def.h +++ b/plat/xilinx/versal_net/include/platform_def.h @@ -10,6 +10,7 @@ #define PLATFORM_DEF_H #include +#include #include "versal_net_def.h" /******************************************************************************* @@ -124,6 +125,8 @@ #define PLAT_ARM_G0_IRQ_PROPS(grp) \ INTR_PROP_DESC(PLAT_VERSAL_IPI_IRQ, GIC_HIGHEST_SEC_PRIORITY, grp, \ + GIC_INTR_CFG_EDGE), \ + INTR_PROP_DESC(CPU_PWR_DOWN_REQ_INTR, GIC_HIGHEST_SEC_PRIORITY, grp, \ GIC_INTR_CFG_EDGE) #define IRQ_MAX 200U diff --git a/plat/xilinx/versal_net/platform.mk b/plat/xilinx/versal_net/platform.mk index b2acecae1..da91abc82 100644 --- a/plat/xilinx/versal_net/platform.mk +++ b/plat/xilinx/versal_net/platform.mk @@ -21,6 +21,8 @@ IPI_CRC_CHECK := 0 GIC_ENABLE_V4_EXTN := 0 GICV3_SUPPORT_GIC600 := 1 TFA_NO_PM := 0 +CPU_PWRDWN_SGI ?= 6 +$(eval $(call add_define_val,CPU_PWR_DOWN_REQ_INTR,ARM_IRQ_SEC_SGI_${CPU_PWRDWN_SGI})) override CTX_INCLUDE_AARCH32_REGS := 0