Skip to content

Commit e178df3

Browse files
Jolly ShahMichal Simek
authored andcommitted
firmware: xilinx: Implement ZynqMP power management APIs
Add Xilinx ZynqMP firmware APIs to set suspend mode and inform firmware that master has initialized its own power management. Signed-off-by: Rajan Vaja <[email protected]> Signed-off-by: Jolly Shah <[email protected]> Signed-off-by: Michal Simek <[email protected]>
1 parent d4ff6c9 commit e178df3

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

drivers/firmware/xilinx/zynqmp.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,33 @@ static int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset,
530530
return ret;
531531
}
532532

533+
/**
534+
* zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
535+
* master has initialized its own power management
536+
*
537+
* This API function is to be used for notify the power management controller
538+
* about the completed power management initialization.
539+
*
540+
* Return: Returns status, either success or error+reason
541+
*/
542+
static int zynqmp_pm_init_finalize(void)
543+
{
544+
return zynqmp_pm_invoke_fn(PM_PM_INIT_FINALIZE, 0, 0, 0, 0, NULL);
545+
}
546+
547+
/**
548+
* zynqmp_pm_set_suspend_mode() - Set system suspend mode
549+
* @mode: Mode to set for system suspend
550+
*
551+
* This API function is used to set mode of system suspend.
552+
*
553+
* Return: Returns status, either success or error+reason
554+
*/
555+
static int zynqmp_pm_set_suspend_mode(u32 mode)
556+
{
557+
return zynqmp_pm_invoke_fn(PM_SET_SUSPEND_MODE, mode, 0, 0, 0, NULL);
558+
}
559+
533560
static const struct zynqmp_eemi_ops eemi_ops = {
534561
.get_api_version = zynqmp_pm_get_api_version,
535562
.get_chipid = zynqmp_pm_get_chipid,
@@ -546,6 +573,8 @@ static const struct zynqmp_eemi_ops eemi_ops = {
546573
.ioctl = zynqmp_pm_ioctl,
547574
.reset_assert = zynqmp_pm_reset_assert,
548575
.reset_get_status = zynqmp_pm_reset_get_status,
576+
.init_finalize = zynqmp_pm_init_finalize,
577+
.set_suspend_mode = zynqmp_pm_set_suspend_mode,
549578
};
550579

551580
/**

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,23 @@
2828
/* SMC SIP service Call Function Identifier Prefix */
2929
#define PM_SIP_SVC 0xC2000000
3030
#define PM_GET_TRUSTZONE_VERSION 0xa03
31+
#define PM_SET_SUSPEND_MODE 0xa02
32+
#define GET_CALLBACK_DATA 0xa01
3133

3234
/* Number of 32bits values in payload */
3335
#define PAYLOAD_ARG_CNT 4U
3436

37+
/* Number of arguments for a callback */
38+
#define CB_ARG_CNT 4
39+
40+
/* Payload size (consists of callback API ID + arguments) */
41+
#define CB_PAYLOAD_SIZE (CB_ARG_CNT + 1)
42+
3543
enum pm_api_id {
3644
PM_GET_API_VERSION = 1,
3745
PM_RESET_ASSERT = 17,
3846
PM_RESET_GET_STATUS,
47+
PM_PM_INIT_FINALIZE = 21,
3948
PM_GET_CHIPID = 24,
4049
PM_IOCTL = 34,
4150
PM_QUERY_DATA,
@@ -209,6 +218,12 @@ enum zynqmp_pm_reset {
209218
ZYNQMP_PM_RESET_END = ZYNQMP_PM_RESET_PS_PL3
210219
};
211220

221+
enum zynqmp_pm_suspend_reason {
222+
SUSPEND_POWER_REQUEST = 201,
223+
SUSPEND_ALERT,
224+
SUSPEND_SYSTEM_SHUTDOWN,
225+
};
226+
212227
/**
213228
* struct zynqmp_pm_query_data - PM query data
214229
* @qid: query ID
@@ -240,8 +255,13 @@ struct zynqmp_eemi_ops {
240255
int (*reset_assert)(const enum zynqmp_pm_reset reset,
241256
const enum zynqmp_pm_reset_action assert_flag);
242257
int (*reset_get_status)(const enum zynqmp_pm_reset reset, u32 *status);
258+
int (*init_finalize)(void);
259+
int (*set_suspend_mode)(u32 mode);
243260
};
244261

262+
int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
263+
u32 arg2, u32 arg3, u32 *ret_payload);
264+
245265
#if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
246266
const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void);
247267
#else

0 commit comments

Comments
 (0)