From 7e5f0abf9ac7e7d189609a091406e09ac7885593 Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Tue, 12 Jul 2022 09:06:01 +0530 Subject: [PATCH] refactor(versal): move payload and module ID macros Move the payload and module ID macros from the pm_api_sys.c file and add it in the header file, as these macros can be used other than PM. Signed-off-by: Venkatesh Yadav Abbarapu Reviewed-by: Michal Simek Change-Id: I678444b79ac3799a82bd93915e4639b3babf5fb9 --- plat/xilinx/versal/pm_service/pm_api_sys.c | 41 ---------------------- plat/xilinx/versal/pm_service/pm_api_sys.h | 41 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.c b/plat/xilinx/versal/pm_service/pm_api_sys.c index db7804900..27bfaed74 100644 --- a/plat/xilinx/versal/pm_service/pm_api_sys.c +++ b/plat/xilinx/versal/pm_service/pm_api_sys.c @@ -18,15 +18,6 @@ #include "pm_svc_main.h" #include "../drivers/arm/gic/v3/gicv3_private.h" -/********************************************************************* - * Target module IDs macros - ********************************************************************/ -#define LIBPM_MODULE_ID 0x2U -#define LOADER_MODULE_ID 0x7U - -#define MODE 0x80000000U -#define MODULE_ID_MASK 0x0000ff00 - /* default shutdown/reboot scope is system(2) */ static uint32_t pm_shutdown_scope = XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM; @@ -40,38 +31,6 @@ uint32_t pm_get_shutdown_scope(void) return pm_shutdown_scope; } -/** - * Assigning of argument values into array elements. - */ -#define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) { \ - pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | ((mid) << 8U) | ((flag) << 24U)); \ -} - -#define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) { \ - pl[1] = (uint32_t)(arg1); \ - PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0)); \ -} - -#define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) { \ - pl[2] = (uint32_t)(arg2); \ - PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1)); \ -} - -#define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) { \ - pl[3] = (uint32_t)(arg3); \ - PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2)); \ -} - -#define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) { \ - pl[4] = (uint32_t)(arg4); \ - PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3)); \ -} - -#define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) { \ - pl[5] = (uint32_t)(arg5); \ - PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4)); \ -} - /* PM API functions */ /** diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.h b/plat/xilinx/versal/pm_service/pm_api_sys.h index 8343533aa..6fa65c25a 100644 --- a/plat/xilinx/versal/pm_service/pm_api_sys.h +++ b/plat/xilinx/versal/pm_service/pm_api_sys.h @@ -10,6 +10,14 @@ #include #include "pm_defs.h" +/********************************************************************* + * Target module IDs macros + ********************************************************************/ +#define LIBPM_MODULE_ID 0x2U +#define LOADER_MODULE_ID 0x7U + +#define MODE 0x80000000U +#define MODULE_ID_MASK 0x0000ff00 /********************************************************** * PM API function declarations **********************************************************/ @@ -56,4 +64,37 @@ enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low, enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event, uint32_t wake, uint32_t enable, uint32_t flag); + +/** + * Assigning of argument values into array elements. + */ +#define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) { \ + pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | ((mid) << 8U) | ((flag) << 24U)); \ +} + +#define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) { \ + pl[1] = (uint32_t)(arg1); \ + PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0)); \ +} + +#define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) { \ + pl[2] = (uint32_t)(arg2); \ + PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1)); \ +} + +#define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) { \ + pl[3] = (uint32_t)(arg3); \ + PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2)); \ +} + +#define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) { \ + pl[4] = (uint32_t)(arg4); \ + PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3)); \ +} + +#define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) { \ + pl[5] = (uint32_t)(arg5); \ + PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4)); \ +} + #endif /* PM_API_SYS_H */ -- 2.39.5