Commit | Line | Data |
---|---|---|
4f2494cf GP |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r | |
4 | \r | |
4059386c | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
4f2494cf GP |
6 | \r |
7 | System Control and Management Interface V1.0\r | |
8 | http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r | |
9 | DEN0056A_System_Control_and_Management_Interface.pdf\r | |
10 | **/\r | |
11 | #ifndef SCMI_PRIVATE_H_\r | |
12 | #define SCMI_PRIVATE_H_\r | |
13 | \r | |
14 | // SCMI protocol IDs.\r | |
15 | typedef enum {\r | |
16 | SCMI_PROTOCOL_ID_BASE = 0x10,\r | |
17 | SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,\r | |
18 | SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,\r | |
19 | SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,\r | |
20 | SCMI_PROTOCOL_ID_CLOCK = 0x14,\r | |
21 | SCMI_PROTOCOL_ID_SENSOR = 0x15\r | |
22 | } SCMI_PROTOCOL_ID;\r | |
23 | \r | |
24 | // SCMI message types.\r | |
25 | typedef enum {\r | |
26 | SCMI_MESSAGE_TYPE_COMMAND = 0,\r | |
27 | SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is deliberate.\r | |
28 | SCMI_MESSAGE_TYPE_NOTIFICATION = 3\r | |
29 | } SCMI_MESSAGE_TYPE;\r | |
30 | \r | |
31 | // SCMI response error codes.\r | |
32 | typedef enum {\r | |
33 | SCMI_SUCCESS = 0,\r | |
34 | SCMI_NOT_SUPPORTED = -1,\r | |
35 | SCMI_INVALID_PARAMETERS = -2,\r | |
36 | SCMI_DENIED = -3,\r | |
37 | SCMI_NOT_FOUND = -4,\r | |
38 | SCMI_OUT_OF_RANGE = -5,\r | |
39 | SCMI_BUSY = -6,\r | |
40 | SCMI_COMMS_ERROR = -7,\r | |
41 | SCMI_GENERIC_ERROR = -8,\r | |
42 | SCMI_HARDWARE_ERROR = -9,\r | |
43 | SCMI_PROTOCOL_ERROR = -10\r | |
44 | } SCMI_STATUS;\r | |
45 | \r | |
46 | // SCMI message IDs common to all protocols.\r | |
47 | typedef enum {\r | |
48 | SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,\r | |
49 | SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,\r | |
50 | SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2\r | |
51 | } SCMI_MESSAGE_ID;\r | |
52 | \r | |
53 | // Not defined in SCMI specification but will help to identify a message.\r | |
54 | typedef struct {\r | |
55 | SCMI_PROTOCOL_ID ProtocolId;\r | |
56 | UINT32 MessageId;\r | |
57 | } SCMI_COMMAND;\r | |
58 | \r | |
59 | #pragma pack(1)\r | |
60 | \r | |
61 | // Response to a SCMI command.\r | |
62 | typedef struct {\r | |
63 | INT32 Status;\r | |
64 | UINT32 ReturnValues[];\r | |
65 | } SCMI_MESSAGE_RESPONSE;\r | |
66 | \r | |
67 | // Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]\r | |
68 | #define MESSAGE_TYPE_SHIFT 8\r | |
69 | #define PROTOCOL_ID_SHIFT 10\r | |
70 | #define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \\r | |
71 | MsgType << MESSAGE_TYPE_SHIFT | \\r | |
72 | ProtocolId << PROTOCOL_ID_SHIFT | \\r | |
73 | MsgId \\r | |
74 | )\r | |
75 | // SCMI message header.\r | |
76 | typedef struct {\r | |
77 | UINT32 MessageHeader;\r | |
78 | } SCMI_MESSAGE_HEADER;\r | |
79 | \r | |
80 | #pragma pack()\r | |
81 | \r | |
82 | /** Return a pointer to the message payload.\r | |
83 | \r | |
84 | @param[out] Payload Holds pointer to the message payload.\r | |
85 | \r | |
86 | @retval EFI_SUCCESS Payload holds a valid message payload pointer.\r | |
87 | @retval EFI_TIMEOUT Time out error if MTL channel is busy.\r | |
88 | @retval EFI_UNSUPPORTED If MTL channel is unsupported.\r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | ScmiCommandGetPayload (\r | |
92 | OUT UINT32** Payload\r | |
93 | );\r | |
94 | \r | |
95 | /** Execute a SCMI command and receive a response.\r | |
96 | \r | |
97 | This function uses a MTL channel to transfer message to SCP\r | |
98 | and waits for a response.\r | |
99 | \r | |
100 | @param[in] Command Pointer to the SCMI command (Protocol ID\r | |
101 | and Message ID)\r | |
102 | \r | |
103 | @param[in,out] PayloadLength SCMI command message length.\r | |
104 | \r | |
105 | @param[out] OPTIONAL ReturnValues Pointer to SCMI response.\r | |
106 | \r | |
107 | @retval OUT EFI_SUCCESS Command sent and message received successfully.\r | |
108 | @retval OUT EFI_UNSUPPORTED Channel not supported.\r | |
109 | @retval OUT EFI_TIMEOUT Timeout on the channel.\r | |
110 | @retval OUT EFI_DEVICE_ERROR Channel not ready.\r | |
111 | @retval OUT EFI_DEVICE_ERROR Message Header corrupted.\r | |
112 | @retval OUT EFI_DEVICE_ERROR SCMI error.\r | |
113 | **/\r | |
114 | EFI_STATUS\r | |
115 | ScmiCommandExecute (\r | |
116 | IN SCMI_COMMAND *Command,\r | |
117 | IN OUT UINT32 *PayloadLength,\r | |
118 | OUT UINT32 **ReturnValues OPTIONAL\r | |
119 | );\r | |
120 | \r | |
121 | /** Return protocol version from SCP for a given protocol ID.\r | |
122 | \r | |
123 | @param[in] Protocol ID Protocol ID.\r | |
124 | @param[out] Version Pointer to version of the protocol.\r | |
125 | \r | |
126 | @retval EFI_SUCCESS Version holds a valid version received\r | |
127 | from the SCP.\r | |
128 | @retval EFI_DEVICE_ERROR SCMI error.\r | |
129 | @retval !(EFI_SUCCESS) Other errors.\r | |
130 | **/\r | |
131 | EFI_STATUS\r | |
132 | ScmiGetProtocolVersion (\r | |
133 | IN SCMI_PROTOCOL_ID ProtocolId,\r | |
134 | OUT UINT32 *Version\r | |
135 | );\r | |
136 | \r | |
137 | /** Return protocol attributes from SCP for a given protocol ID.\r | |
138 | \r | |
139 | @param[in] Protocol ID Protocol ID.\r | |
140 | @param[out] ReturnValues Pointer to attributes of the protocol.\r | |
141 | \r | |
142 | @retval EFI_SUCCESS ReturnValues points to protocol attributes.\r | |
143 | @retval EFI_DEVICE_ERROR SCMI error.\r | |
144 | @retval !(EFI_SUCCESS) Other errors.\r | |
145 | **/\r | |
146 | EFI_STATUS\r | |
147 | ScmiGetProtocolAttributes (\r | |
148 | IN SCMI_PROTOCOL_ID ProtocolId,\r | |
149 | OUT UINT32 **ReturnValues\r | |
150 | );\r | |
151 | \r | |
152 | /** Return protocol message attributes from SCP for a given protocol ID.\r | |
153 | \r | |
154 | @param[in] Protocol ID Protocol ID.\r | |
155 | \r | |
156 | @param[out] Attributes Pointer to attributes of the protocol.\r | |
157 | \r | |
158 | @retval EFI_SUCCESS ReturnValues points to protocol message attributes.\r | |
159 | @retval EFI_DEVICE_ERROR SCMI error.\r | |
160 | @retval !(EFI_SUCCESS) Other errors.\r | |
161 | **/\r | |
162 | EFI_STATUS\r | |
163 | ScmiGetProtocolMessageAttributes (\r | |
164 | IN SCMI_PROTOCOL_ID ProtocolId,\r | |
165 | OUT UINT32 **ReturnValues\r | |
166 | );\r | |
167 | \r | |
168 | #endif /* SCMI_PRIVATE_H_ */\r |