blob: ffee80522acd6bfd588dc39b02d7579feb657b3d [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.
Ronak Jain51790442024-05-29 22:32:20 -07003 * Copyright (c) 2022-2024, 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 Patela3e34ad2019-02-01 17:25:19 +053056enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
Tejas Patel18072da2021-02-25 20:16:56 -080057 uint32_t arg3, uint32_t *data, uint32_t flag);
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +053058uint32_t pm_get_shutdown_scope(void);
Ronak Jain70d1c582022-02-04 00:42:55 -080059enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
Tejas Patel18072da2021-02-25 20:16:56 -080060 uint32_t flag);
Jolly Shahed05a712019-03-22 05:33:39 +053061enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low,
Tejas Patel18072da2021-02-25 20:16:56 -080062 uint32_t address_high, uint32_t flag);
Tejas Patel42015552020-11-25 01:56:57 -080063enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event,
Tejas Patel18072da2021-02-25 20:16:56 -080064 uint32_t wake, uint32_t enable,
65 uint32_t flag);
Akshay Belsareec1181c2023-04-03 10:51:14 +053066enum pm_ret_status pm_get_chipid(uint32_t *value);
Venkatesh Yadav Abbarapu94cf1a72022-07-12 09:06:01 +053067
Prasad Kummari7d0623a2023-06-09 14:32:00 +053068/*
Venkatesh Yadav Abbarapu94cf1a72022-07-12 09:06:01 +053069 * Assigning of argument values into array elements.
70 */
71#define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) { \
72 pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | ((mid) << 8U) | ((flag) << 24U)); \
73}
74
75#define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) { \
76 pl[1] = (uint32_t)(arg1); \
77 PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0)); \
78}
79
80#define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) { \
81 pl[2] = (uint32_t)(arg2); \
82 PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1)); \
83}
84
85#define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) { \
86 pl[3] = (uint32_t)(arg3); \
87 PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2)); \
88}
89
90#define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) { \
91 pl[4] = (uint32_t)(arg4); \
92 PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3)); \
93}
94
95#define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) { \
96 pl[5] = (uint32_t)(arg5); \
97 PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4)); \
98}
99
Tejas Patel9d09ff92019-01-08 01:46:35 -0800100#endif /* PM_API_SYS_H */