Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 1 | /* |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 2 | * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 3 | * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
| 8 | #ifndef PM_API_SYS_H |
| 9 | #define PM_API_SYS_H |
| 10 | |
| 11 | #include <stdint.h> |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 12 | #include "pm_defs.h" |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 13 | |
Venkatesh Yadav Abbarapu | 94cf1a7 | 2022-07-12 09:06:01 +0530 | [diff] [blame] | 14 | /********************************************************************* |
| 15 | * Target module IDs macros |
| 16 | ********************************************************************/ |
| 17 | #define LIBPM_MODULE_ID 0x2U |
| 18 | #define LOADER_MODULE_ID 0x7U |
| 19 | |
Michal Simek | 47fd75a | 2022-07-27 14:17:30 +0200 | [diff] [blame] | 20 | #define MODULE_ID_MASK 0x0000ff00U |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 21 | /********************************************************** |
| 22 | * PM API function declarations |
| 23 | **********************************************************/ |
| 24 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 25 | enum pm_ret_status pm_handle_eemi_call(uint32_t flag, uint32_t x0, uint32_t x1, |
| 26 | uint32_t x2, uint32_t x3, uint32_t x4, |
| 27 | uint32_t x5, uint64_t *result); |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 28 | enum pm_ret_status pm_self_suspend(uint32_t nid, |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 29 | uint32_t latency, |
| 30 | uint32_t state, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 31 | uintptr_t address, uint32_t flag); |
| 32 | enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason, uint32_t flag); |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 33 | enum pm_ret_status pm_req_suspend(uint32_t target, |
| 34 | uint8_t ack, |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 35 | uint32_t latency, |
| 36 | uint32_t state, uint32_t flag); |
Tejas Patel | 49cd871 | 2019-01-23 14:18:51 +0530 | [diff] [blame] | 37 | enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 38 | uintptr_t address, uint8_t ack, uint32_t flag); |
Tejas Patel | db81205 | 2019-01-23 14:18:53 +0530 | [diff] [blame] | 39 | enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t device_id, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 40 | uint8_t enable, uint32_t flag); |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 41 | enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag, |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 42 | uint32_t ack); |
Jay Buddhabhatti | a63b354 | 2023-02-28 02:22:02 -0800 | [diff] [blame] | 43 | void pm_client_set_wakeup_sources(uint32_t node_id); |
Tejas Patel | 023116d | 2019-01-08 01:46:41 -0800 | [diff] [blame] | 44 | enum pm_ret_status pm_pll_set_param(uint32_t clk_id, uint32_t param, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 45 | uint32_t value, uint32_t flag); |
Tejas Patel | 023116d | 2019-01-08 01:46:41 -0800 | [diff] [blame] | 46 | enum pm_ret_status pm_pll_get_param(uint32_t clk_id, uint32_t param, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 47 | uint32_t *value, uint32_t flag); |
| 48 | enum pm_ret_status pm_pll_set_mode(uint32_t clk_id, uint32_t mode, |
| 49 | uint32_t flag); |
| 50 | enum pm_ret_status pm_pll_get_mode(uint32_t clk_id, uint32_t *mode, |
| 51 | uint32_t flag); |
| 52 | enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack, |
| 53 | uint32_t flag); |
| 54 | enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype, |
| 55 | uint32_t flag); |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 56 | enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id, |
Venkatesh Yadav Abbarapu | 4b23339 | 2021-10-20 22:11:53 -0600 | [diff] [blame] | 57 | uint32_t arg1, uint32_t arg2, uint32_t arg3, |
| 58 | uint32_t *value, uint32_t flag); |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 59 | enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 60 | uint32_t arg3, uint32_t *data, uint32_t flag); |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 61 | uint32_t pm_get_shutdown_scope(void); |
Ronak Jain | 70d1c58 | 2022-02-04 00:42:55 -0800 | [diff] [blame] | 62 | enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 63 | uint32_t flag); |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 64 | enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 65 | uint32_t address_high, uint32_t flag); |
Tejas Patel | 4201555 | 2020-11-25 01:56:57 -0800 | [diff] [blame] | 66 | enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event, |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 67 | uint32_t wake, uint32_t enable, |
| 68 | uint32_t flag); |
Akshay Belsare | ec1181c | 2023-04-03 10:51:14 +0530 | [diff] [blame] | 69 | enum pm_ret_status pm_get_chipid(uint32_t *value); |
Venkatesh Yadav Abbarapu | 94cf1a7 | 2022-07-12 09:06:01 +0530 | [diff] [blame] | 70 | |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 71 | /* |
Venkatesh Yadav Abbarapu | 94cf1a7 | 2022-07-12 09:06:01 +0530 | [diff] [blame] | 72 | * Assigning of argument values into array elements. |
| 73 | */ |
| 74 | #define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) { \ |
| 75 | pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | ((mid) << 8U) | ((flag) << 24U)); \ |
| 76 | } |
| 77 | |
| 78 | #define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) { \ |
| 79 | pl[1] = (uint32_t)(arg1); \ |
| 80 | PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0)); \ |
| 81 | } |
| 82 | |
| 83 | #define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) { \ |
| 84 | pl[2] = (uint32_t)(arg2); \ |
| 85 | PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1)); \ |
| 86 | } |
| 87 | |
| 88 | #define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) { \ |
| 89 | pl[3] = (uint32_t)(arg3); \ |
| 90 | PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2)); \ |
| 91 | } |
| 92 | |
| 93 | #define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) { \ |
| 94 | pl[4] = (uint32_t)(arg4); \ |
| 95 | PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3)); \ |
| 96 | } |
| 97 | |
| 98 | #define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) { \ |
| 99 | pl[5] = (uint32_t)(arg5); \ |
| 100 | PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4)); \ |
| 101 | } |
| 102 | |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 103 | #endif /* PM_API_SYS_H */ |