From 61ef376aa2fa85b6eec23d314e7e308f80d18b8d Mon Sep 17 00:00:00 2001 From: Siva Durga Prasad Paladugu Date: Mon, 30 Apr 2018 15:56:10 +0530 Subject: [PATCH] zynqmp: pm: Allow to set shutdown scope via pm_system_shutdown API psci system_reset and system_off calls now retrieve shutdown scope on the fly. The default scope is system, but it can be changed by calling pm_system_shutdown(2, scope) Until full support for different restart scopes becomes available with PSCI 1.1 this change allows users to set the reboot scope to match their application needs. Possible scope values: 0 - APU subsystem: does not affect RPU, PMU or PL 1 - PS only: shutdown/restart entire PS without affecting PL 2 - System: shutdown/restart applies to entire system Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Davorin Mista --- plat/xilinx/zynqmp/plat_psci.c | 4 ++-- plat/xilinx/zynqmp/pm_service/pm_api_sys.c | 22 +++++++++++++++++++++- plat/xilinx/zynqmp/pm_service/pm_api_sys.h | 1 + plat/xilinx/zynqmp/pm_service/pm_defs.h | 11 +++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/plat/xilinx/zynqmp/plat_psci.c b/plat/xilinx/zynqmp/plat_psci.c index 27cdddb2c..d0df6a871 100644 --- a/plat/xilinx/zynqmp/plat_psci.c +++ b/plat/xilinx/zynqmp/plat_psci.c @@ -249,7 +249,7 @@ static void __dead2 zynqmp_system_off(void) /* Send the power down request to the PMU */ pm_system_shutdown(PMF_SHUTDOWN_TYPE_SHUTDOWN, - PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM); + pm_get_shutdown_scope()); while (1) wfi(); @@ -284,7 +284,7 @@ static void __dead2 zynqmp_system_reset(void) /* Send the system reset request to the PMU */ pm_system_shutdown(PMF_SHUTDOWN_TYPE_RESET, - PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM); + pm_get_shutdown_scope()); while (1) wfi(); diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c index d746c2865..4b709abff 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c +++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c @@ -19,6 +19,19 @@ #include "pm_common.h" #include "pm_ipi.h" +/* default shutdown/reboot scope is system(2) */ +static unsigned int pm_shutdown_scope = PMF_SHUTDOWN_SUBTYPE_SYSTEM; + +/** + * pm_get_shutdown_scope() - Get the currently set shutdown scope + * + * @return Shutdown scope value + */ +unsigned int pm_get_shutdown_scope(void) +{ + return pm_shutdown_scope; +} + /** * Assigning of argument values into array elements. */ @@ -215,7 +228,8 @@ enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target, /** * pm_system_shutdown() - PM call to request a system shutdown or restart - * @restart Shutdown or restart? 0 for shutdown, 1 for restart + * @type Shutdown or restart? 0=shutdown, 1=restart, 2=setscope + * @subtype Scope: 0=APU-subsystem, 1=PS, 2=system * * @return Returns status, either success or error+reason */ @@ -223,6 +237,12 @@ enum pm_ret_status pm_system_shutdown(unsigned int type, unsigned int subtype) { uint32_t payload[PAYLOAD_ARG_CNT]; + if (type == PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY) { + /* Setting scope for subsequent PSCI reboot or shutdown */ + pm_shutdown_scope = subtype; + return PM_RET_SUCCESS; + } + PM_PACK_PAYLOAD3(payload, PM_SYSTEM_SHUTDOWN, type, subtype); return pm_ipi_send(primary_proc, payload); } diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h index 135bcc800..e850b79e1 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h +++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h @@ -114,6 +114,7 @@ enum pm_ret_status pm_secure_rsaaes(uint32_t address_high, uint32_t size, uint32_t flags); void pm_get_callbackdata(uint32_t *data, size_t count); +unsigned int pm_get_shutdown_scope(void); enum pm_ret_status pm_pinctrl_request(unsigned int pin); enum pm_ret_status pm_pinctrl_release(unsigned int pin); enum pm_ret_status pm_pinctrl_get_function(unsigned int pin, diff --git a/plat/xilinx/zynqmp/pm_service/pm_defs.h b/plat/xilinx/zynqmp/pm_service/pm_defs.h index 1938c198b..cc5144517 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_defs.h +++ b/plat/xilinx/zynqmp/pm_service/pm_defs.h @@ -239,11 +239,22 @@ enum pm_boot_status { PM_BOOT_ERROR, }; +/** + * @PMF_SHUTDOWN_TYPE_SHUTDOWN: shutdown + * @PMF_SHUTDOWN_TYPE_RESET: reset/reboot + * @PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY: set the shutdown/reboot scope + */ enum pm_shutdown_type { PMF_SHUTDOWN_TYPE_SHUTDOWN, PMF_SHUTDOWN_TYPE_RESET, + PMF_SHUTDOWN_TYPE_SETSCOPE_ONLY, }; +/** + * @PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM: shutdown/reboot APU subsystem only + * @PMF_SHUTDOWN_SUBTYPE_PS_ONLY: shutdown/reboot entire PS (but not PL) + * @PMF_SHUTDOWN_SUBTYPE_SYSTEM: shutdown/reboot entire system + */ enum pm_shutdown_subtype { PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM, PMF_SHUTDOWN_SUBTYPE_PS_ONLY, -- GitLab