blob: 3fcb62f7f21abb8169605a15f9b44114d7ae805c [file] [log] [blame]
Tejas Patel9d09ff92019-01-08 01:46:35 -08001/*
Tanmay Shahff34daa2021-08-09 11:00:41 -07002 * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
Jay Buddhabhatti26e138a2022-12-21 23:03:35 -08003 * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
Tejas Patel9d09ff92019-01-08 01:46:35 -08004 *
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 Patelfe0e10a2019-12-08 23:29:44 -080012#include "pm_defs.h"
Tejas Patel9d09ff92019-01-08 01:46:35 -080013
Venkatesh Yadav Abbarapu94cf1a72022-07-12 09:06:01 +053014/*********************************************************************
15 * Target module IDs macros
16 ********************************************************************/
17#define LIBPM_MODULE_ID 0x2U
18#define LOADER_MODULE_ID 0x7U
19
Michal Simek47fd75a2022-07-27 14:17:30 +020020#define MODULE_ID_MASK 0x0000ff00U
Tejas Patel9d09ff92019-01-08 01:46:35 -080021/**********************************************************
22 * PM API function declarations
23 **********************************************************/
24
Tanmay Shahff34daa2021-08-09 11:00:41 -070025enum 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 Patelfe0e10a2019-12-08 23:29:44 -080028enum pm_ret_status pm_self_suspend(uint32_t nid,
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +053029 uint32_t latency,
30 uint32_t state,
Tejas Patel18072da2021-02-25 20:16:56 -080031 uintptr_t address, uint32_t flag);
32enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason, uint32_t flag);
Tejas Patelfe0e10a2019-12-08 23:29:44 -080033enum pm_ret_status pm_req_suspend(uint32_t target,
34 uint8_t ack,
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +053035 uint32_t latency,
36 uint32_t state, uint32_t flag);
Tejas Patel49cd8712019-01-23 14:18:51 +053037enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address,
Tejas Patel18072da2021-02-25 20:16:56 -080038 uintptr_t address, uint8_t ack, uint32_t flag);
Tejas Pateldb812052019-01-23 14:18:53 +053039enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t device_id,
Tejas Patel18072da2021-02-25 20:16:56 -080040 uint8_t enable, uint32_t flag);
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +053041enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag,
Tanmay Shahfdae9e82022-08-26 15:06:00 -070042 uint32_t ack);
Jay Buddhabhattia63b3542023-02-28 02:22:02 -080043void pm_client_set_wakeup_sources(uint32_t node_id);
Tejas Patel023116d2019-01-08 01:46:41 -080044enum pm_ret_status pm_pll_set_param(uint32_t clk_id, uint32_t param,
Tejas Patel18072da2021-02-25 20:16:56 -080045 uint32_t value, uint32_t flag);
Tejas Patel023116d2019-01-08 01:46:41 -080046enum pm_ret_status pm_pll_get_param(uint32_t clk_id, uint32_t param,
Tejas Patel18072da2021-02-25 20:16:56 -080047 uint32_t *value, uint32_t flag);
48enum pm_ret_status pm_pll_set_mode(uint32_t clk_id, uint32_t mode,
49 uint32_t flag);
50enum pm_ret_status pm_pll_get_mode(uint32_t clk_id, uint32_t *mode,
51 uint32_t flag);
52enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
53 uint32_t flag);
54enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype,
55 uint32_t flag);
Tejas Patel9141f442019-01-10 03:03:48 -080056enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id,
Venkatesh Yadav Abbarapu4b233392021-10-20 22:11:53 -060057 uint32_t arg1, uint32_t arg2, uint32_t arg3,
58 uint32_t *value, uint32_t flag);
Tejas Patela3e34ad2019-02-01 17:25:19 +053059enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
Tejas Patel18072da2021-02-25 20:16:56 -080060 uint32_t arg3, uint32_t *data, uint32_t flag);
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +053061uint32_t pm_get_shutdown_scope(void);
Ronak Jain70d1c582022-02-04 00:42:55 -080062enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
Tejas Patel18072da2021-02-25 20:16:56 -080063 uint32_t flag);
Jolly Shahed05a712019-03-22 05:33:39 +053064enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low,
Tejas Patel18072da2021-02-25 20:16:56 -080065 uint32_t address_high, uint32_t flag);
Tejas Patel42015552020-11-25 01:56:57 -080066enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event,
Tejas Patel18072da2021-02-25 20:16:56 -080067 uint32_t wake, uint32_t enable,
68 uint32_t flag);
Akshay Belsareec1181c2023-04-03 10:51:14 +053069enum pm_ret_status pm_get_chipid(uint32_t *value);
Venkatesh Yadav Abbarapu94cf1a72022-07-12 09:06:01 +053070
Prasad Kummari7d0623a2023-06-09 14:32:00 +053071/*
Venkatesh Yadav Abbarapu94cf1a72022-07-12 09:06:01 +053072 * 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 Patel9d09ff92019-01-08 01:46:35 -0800103#endif /* PM_API_SYS_H */