AM62L FreeRTOS SDK  11.02.00
scp/scmi/v0/scmi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
49 #ifndef SCMI_H
50 #define SCMI_H
51 
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55 
56 #include <stdint.h>
57 #include <stddef.h>
58 #include <kernel/dpl/SemaphoreP.h>
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
65 #define SCMI_MAX_POSSIBLE_PARENTS (16U)
66 
68 typedef void* SCMI_Handle;
69 
70 /* ========================================================================== */
71 /* Structure Declarations */
72 /* ========================================================================== */
73 
77 typedef struct
78 {
79  uint8_t *buf;
81  uint32_t size;
84 
85 typedef struct
86 {
87  uint8_t id;
89  uint8_t protocol_id;
91  uint8_t type;
93  uint16_t seq;
94  /* The token to identify the message. When a message returns, the
95  * platform returns the whole message header unmodified including the
96  * token.
97  */
98  uint32_t status;
101 
102 typedef struct
103 {
106  uint8_t *inputMessage;
110  uint8_t *outputMessage;
115 
116 typedef struct
117 {
118  uint32_t version;
120  uint32_t numAgents;
122  uint32_t numProtocols;
126  uint8_t protocols[SCMI_BASE_MAX_NUM_PROTOCOLS];
128  uint8_t vendor[SCMI_BASE_NAME_LENGTH_MAX];
130  uint8_t subVendor[SCMI_BASE_NAME_LENGTH_MAX];
133 
134 typedef struct
135 {
136  uint32_t version;
138  uint32_t numPowerDomains;
140  uint32_t statsLen;
142  uint64_t statsAddr;
145 
146 typedef struct
147 {
148  uint32_t version;
150  uint32_t numClocks;
153 
154 typedef struct
155 {
166 } SCMI_Object;
167 
168 typedef struct SCMI_Config_s
169 {
170  uint32_t isOpen;
180 } SCMI_Config;
181 
182 
183 /* ========================================================================== */
184 /* Function Declarations */
185 /* ========================================================================== */
186 
192 void SCMI_init(void);
193 
197 void SCMI_deinit(void);
198 
207 SCMI_Handle SCMI_open(uint32_t instanceIndex);
208 
218 void SCMI_close(SCMI_Handle handle);
219 
228 SCMI_Handle SCMI_getHandle(uint32_t driverInstanceIndex);
229 
237 int32_t SCMI_getSCMIProtocolErrorMapped(int32_t errorCode);
238 
245 void SCMI_getProtocolVersionLog(uint32_t instanceIndex);
246 
252 uint32_t SCMI_getInitDriverIndex(void);
253 
259 /* ========================================================================== */
260 /* Internal Declarations */
261 /* ========================================================================== */
269 static inline void SCMI_initSCMIMessageData(SCMI_MessageData *msg);
270 
271 /* ========================================================================== */
272 /* Internal Definitions */
273 /* ========================================================================== */
275 {
276  msg->header.id = 0xFFU;
277  msg->header.protocol_id = 0xFFU;
278  msg->header.seq = 0xFFU;
279  msg->header.status = 0xFFU;
280  msg->header.type = 0xFFU;
281  msg->inputMessage = NULL;
282  msg->inputMessageSize = 0U;
283  msg->outputMessage = NULL;
284  msg->outputMessageSize = 0U;
285 }
286 
287 #endif
SCMI_messageHeader
Definition: scp/scmi/v0/scmi.h:86
SCMI_AgentDataInfo::numAgents
uint32_t numAgents
Definition: scp/scmi/v0/scmi.h:120
SCMI_initSCMIMessageData
static void SCMI_initSCMIMessageData(SCMI_MessageData *msg)
Function to initialize the SCMI_MessageData structure.
Definition: scp/scmi/v0/scmi.h:274
SCMI_MessageData::outputMessageSize
uint32_t outputMessageSize
Definition: scp/scmi/v0/scmi.h:112
SCMI_MessageData::inputMessage
uint8_t * inputMessage
Definition: scp/scmi/v0/scmi.h:106
SCMI_deinit
void SCMI_deinit(void)
This function de-initializes the SCMI module.
SCMI_Config::powerDomainProto
SCMI_PowerDomainProtocol powerDomainProto
Definition: scp/scmi/v0/scmi.h:176
SCMI_open
SCMI_Handle SCMI_open(uint32_t instanceIndex)
This function opens a given SCMI instance.
SCMI_Object::transferObject
void * transferObject
Definition: scp/scmi/v0/scmi.h:160
SCMI_MessageData
Definition: scp/scmi/v0/scmi.h:103
SCMI_Object
Definition: scp/scmi/v0/scmi.h:155
SCMI_ClockProtocol::numClocks
uint32_t numClocks
Definition: scp/scmi/v0/scmi.h:150
SCMI_getSCMIProtocolErrorMapped
int32_t SCMI_getSCMIProtocolErrorMapped(int32_t errorCode)
This function translates the SCMI error codes to SystemP error codes.
NULL
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
SCMI_PowerDomainProtocol::statsLen
uint32_t statsLen
Definition: scp/scmi/v0/scmi.h:140
SCMI_BASE_MAX_NUM_PROTOCOLS
#define SCMI_BASE_MAX_NUM_PROTOCOLS
Definition: scmi_protocol.h:53
SCMI_Config::agentInfo
SCMI_AgentDataInfo agentInfo
Definition: scp/scmi/v0/scmi.h:174
SCMI_AgentDataInfo::implementationVersion
uint32_t implementationVersion
Definition: scp/scmi/v0/scmi.h:124
SCMI_Handle
void * SCMI_Handle
A handle that is returned from a SCMI_open() call.
Definition: scp/scmi/v0/scmi.h:68
SCMI_PowerDomainProtocol::numPowerDomains
uint32_t numPowerDomains
Definition: scp/scmi/v0/scmi.h:138
SCMI_messageHeader::type
uint8_t type
Definition: scp/scmi/v0/scmi.h:91
SemaphoreP.h
SCMI_ClockProtocol::version
uint32_t version
Definition: scp/scmi/v0/scmi.h:148
SCMI_MessageData::header
SCMI_messageHeader header
Definition: scp/scmi/v0/scmi.h:104
SCMI_AgentDataInfo
Definition: scp/scmi/v0/scmi.h:117
scmi_protocol.h
SCMI_messageHeader::status
uint32_t status
Definition: scp/scmi/v0/scmi.h:98
SCMI_ClockProtocol
Definition: scp/scmi/v0/scmi.h:147
SCMI_messageHeader::seq
uint16_t seq
Definition: scp/scmi/v0/scmi.h:93
SCMI_BASE_NAME_LENGTH_MAX
#define SCMI_BASE_NAME_LENGTH_MAX
Definition: scmi_protocol.h:52
SCMI_Config::object
SCMI_Object * object
Definition: scp/scmi/v0/scmi.h:172
SCMI_MessageData::inputMessageSize
uint32_t inputMessageSize
Definition: scp/scmi/v0/scmi.h:108
SCMI_Config::clockProto
SCMI_ClockProtocol clockProto
Definition: scp/scmi/v0/scmi.h:178
SCMI_PowerDomainProtocol::statsAddr
uint64_t statsAddr
Definition: scp/scmi/v0/scmi.h:142
SCMI_Object::requiredProtoList
uint8_t * requiredProtoList
Definition: scp/scmi/v0/scmi.h:158
SCMI_AgentDataInfo::version
uint32_t version
Definition: scp/scmi/v0/scmi.h:118
SCMI_Config
Definition: scp/scmi/v0/scmi.h:169
SCMI_messageHeader::protocol_id
uint8_t protocol_id
Definition: scp/scmi/v0/scmi.h:89
SCMI_Object::sharedMem
SCMI_SharedMemory * sharedMem
Definition: scp/scmi/v0/scmi.h:162
SCMI_getInitDriverIndex
uint32_t SCMI_getInitDriverIndex(void)
This function returns the initialised instance index.
SCMI_SharedMemory
SCMI_SharedMemory - Description of a Shared memory buffer.
Definition: scp/scmi/v0/scmi.h:78
SCMI_PowerDomainProtocol::version
uint32_t version
Definition: scp/scmi/v0/scmi.h:136
SCMI_MessageData::outputMessage
uint8_t * outputMessage
Definition: scp/scmi/v0/scmi.h:110
SCMI_PowerDomainProtocol
Definition: scp/scmi/v0/scmi.h:135
SCMI_SharedMemory::size
uint32_t size
Definition: scp/scmi/v0/scmi.h:81
SCMI_Object::lockSem
SemaphoreP_Object lockSem
Definition: scp/scmi/v0/scmi.h:164
SCMI_close
void SCMI_close(SCMI_Handle handle)
This function closes a given SCMI instance.
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
SCMI_AgentDataInfo::numProtocols
uint32_t numProtocols
Definition: scp/scmi/v0/scmi.h:122
SCMI_Config::isOpen
uint32_t isOpen
Definition: scp/scmi/v0/scmi.h:170
SCMI_SharedMemory::buf
uint8_t * buf
Definition: scp/scmi/v0/scmi.h:79
SCMI_getHandle
SCMI_Handle SCMI_getHandle(uint32_t driverInstanceIndex)
This function returns the handle of an open SCMI Instance from the instance index.
SCMI_Object::requiredProtoCount
uint32_t requiredProtoCount
Definition: scp/scmi/v0/scmi.h:156
SCMI_init
void SCMI_init(void)
SCMI initialization function. This function should be called before calling any driver APIs and only ...
SCMI_messageHeader::id
uint8_t id
Definition: scp/scmi/v0/scmi.h:87
SCMI_getProtocolVersionLog
void SCMI_getProtocolVersionLog(uint32_t instanceIndex)
This function logs the SCMI version probed during init time.