Add Xilinx ZynqMP firmware APIs to set suspend mode and inform firmware that master has initialized its own power management.
Unified · Split
| @@ -530,6 +530,33 @@ static int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, · 529 unmodified lines | |||
| 530 | return ret; | 530 | return ret; |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 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 | |||
| 533 | static const struct zynqmp_eemi_ops eemi_ops = { | 560 | static const struct zynqmp_eemi_ops eemi_ops = { |
| 534 | .get_api_version = zynqmp_pm_get_api_version, | 561 | .get_api_version = zynqmp_pm_get_api_version, |
| 535 | .get_chipid = zynqmp_pm_get_chipid, | 562 | .get_chipid = zynqmp_pm_get_chipid, |
| @@ -546,6 +573,8 @@ static const struct zynqmp_eemi_ops eemi_ops = { · 10 unmodified lines | |||
| 546 | .ioctl = zynqmp_pm_ioctl, | 573 | .ioctl = zynqmp_pm_ioctl, |
| 547 | .reset_assert = zynqmp_pm_reset_assert, | 574 | .reset_assert = zynqmp_pm_reset_assert, |
| 548 | .reset_get_status = zynqmp_pm_reset_get_status, | 575 | .reset_get_status = zynqmp_pm_reset_get_status, |
| 576 | .init_finalize = zynqmp_pm_init_finalize, | ||
| 577 | .set_suspend_mode = zynqmp_pm_set_suspend_mode, | ||
| 549 | }; | 578 | }; |
| 550 | 579 | ||
| 551 | /** | 580 | /** |
| @@ -28,14 +28,23 @@ · 27 unmodified lines | |||
| 28 | /* SMC SIP service Call Function Identifier Prefix */ | 28 | /* SMC SIP service Call Function Identifier Prefix */ |
| 29 | #define PM_SIP_SVC 0xC2000000 | 29 | #define PM_SIP_SVC 0xC2000000 |
| 30 | #define PM_GET_TRUSTZONE_VERSION 0xa03 | 30 | #define PM_GET_TRUSTZONE_VERSION 0xa03 |
| 31 | #define PM_SET_SUSPEND_MODE 0xa02 | ||
| 32 | #define GET_CALLBACK_DATA 0xa01 | ||
| 31 | 33 | ||
| 32 | /* Number of 32bits values in payload */ | 34 | /* Number of 32bits values in payload */ |
| 33 | #define PAYLOAD_ARG_CNT 4U | 35 | #define PAYLOAD_ARG_CNT 4U |
| 34 | 36 | ||
| 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 | |||
| 35 | enum pm_api_id { | 43 | enum pm_api_id { |
| 36 | PM_GET_API_VERSION = 1, | 44 | PM_GET_API_VERSION = 1, |
| 37 | PM_RESET_ASSERT = 17, | 45 | PM_RESET_ASSERT = 17, |
| 38 | PM_RESET_GET_STATUS, | 46 | PM_RESET_GET_STATUS, |
| 47 | PM_PM_INIT_FINALIZE = 21, | ||
| 39 | PM_GET_CHIPID = 24, | 48 | PM_GET_CHIPID = 24, |
| 40 | PM_IOCTL = 34, | 49 | PM_IOCTL = 34, |
| 41 | PM_QUERY_DATA, | 50 | PM_QUERY_DATA, |
| @@ -209,6 +218,12 @@ enum zynqmp_pm_reset { · 167 unmodified lines | |||
| 209 | ZYNQMP_PM_RESET_END = ZYNQMP_PM_RESET_PS_PL3 | 218 | ZYNQMP_PM_RESET_END = ZYNQMP_PM_RESET_PS_PL3 |
| 210 | }; | 219 | }; |
| 211 | 220 | ||
| 221 | enum zynqmp_pm_suspend_reason { | ||
| 222 | SUSPEND_POWER_REQUEST = 201, | ||
| 223 | SUSPEND_ALERT, | ||
| 224 | SUSPEND_SYSTEM_SHUTDOWN, | ||
| 225 | }; | ||
| 226 | |||
| 212 | /** | 227 | /** |
| 213 | * struct zynqmp_pm_query_data - PM query data | 228 | * struct zynqmp_pm_query_data - PM query data |
| 214 | * @qid: query ID | 229 | * @qid: query ID |
| @@ -240,8 +255,13 @@ struct zynqmp_eemi_ops { · 25 unmodified lines | |||
| 240 | int (*reset_assert)(const enum zynqmp_pm_reset reset, | 255 | int (*reset_assert)(const enum zynqmp_pm_reset reset, |
| 241 | const enum zynqmp_pm_reset_action assert_flag); | 256 | const enum zynqmp_pm_reset_action assert_flag); |
| 242 | int (*reset_get_status)(const enum zynqmp_pm_reset reset, u32 *status); | 257 | int (*reset_get_status)(const enum zynqmp_pm_reset reset, u32 *status); |
| 258 | int (*init_finalize)(void); | ||
| 259 | int (*set_suspend_mode)(u32 mode); | ||
| 243 | }; | 260 | }; |
| 244 | 261 | ||
| 262 | int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1, | ||
| 263 | u32 arg2, u32 arg3, u32 *ret_payload); | ||
| 264 | |||
| 245 | #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) | 265 | #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) |
| 246 | const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void); | 266 | const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void); |
| 247 | #else | 267 | #else |