AM62L FreeRTOS SDK  11.00.00
scp/psci/v0/psci.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 
48 #ifndef PSCI_H_
49 #define PSCI_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #include <stdint.h>
60 #include <stddef.h>
61 #include <kernel/dpl/SemaphoreP.h>
62 
63 /* ========================================================================== */
64 /* Macros & Typedefs */
65 /* ========================================================================== */
66 
67 /* PSCI function interface */
68 #define PSCI_BASE_FUNC (uint32_t) 0x84000000U
69 #define PSCI_FUNC(n) (PSCI_BASE_FUNC + (n))
70 #define PSCI_FUNC_OFF_64BIT (uint32_t) 0x40000000U
71 #define PSCI_BASE_FUNC_64BIT \
72  (PSCI_BASE_FUNC + PSCI_FUNC_OFF_64BIT)
73 #define PSCI_FUNC_64BIT(n) (PSCI_BASE_FUNC_64BIT + (n))
74 
75 #define PSCI_FUNC_PSCI_VERSION PSCI_FUNC(0)
76 #define PSCI_FUNC_CPU_OFF PSCI_FUNC(2)
77 #define PSCI_FUNC_SYSTEM_RESET PSCI_FUNC(9)
78 #define PSCI_FUNC_CPU_ON_64BIT PSCI_FUNC_64BIT(3)
79 #define PSCI_FUNC_PSCI_FEATURES PSCI_FUNC(10)
80 
81 /* Decode PSCI versions into Major and Minor Versions */
82 #define PSCI_MAJOR_VERSION_SHIFT (16U)
83 #define PSCI_MINOR_VERSION_MASK \
84  ((1U << PSCI_MAJOR_VERSION_SHIFT) - 1)
85 #define PSCI_MAJOR_VERSION_MASK ~PSCI_MINOR_VERSION_MASK
86 #define PSCI_MAJOR_VERSION(ver) \
87  (((ver) & PSCI_MAJOR_VERSION_MASK) >> PSCI_MAJOR_VERSION_SHIFT)
88 #define PSCI_MINOR_VERSION(ver) \
89  ((ver) & PSCI_MINOR_VERSION_MASK)
90 
91 /* PSCI return values */
92 #define PSCI_SUCCESS (0)
93 #define PSCI_NOT_SUPPORTED (-1)
94 #define PSCI_INVALID_PARAMS (-2)
95 #define PSCI_DENIED (-3)
96 #define PSCI_ALREADY_ON (-4)
97 #define PSCI_ON_PENDING (-5)
98 #define PSCI_INTERNAL_FAILURE (-6)
99 #define PSCI_NOT_PRESENT (-7)
100 #define PSCI_DISABLED (-8)
101 #define PSCI_INVALID_ADDRESS (-9)
102 
103 /* ========================================================================== */
104 /* Structure Declarations */
105 /* ========================================================================== */
106 
110 typedef struct PSCI_Config_s *PSCI_Handle;
111 
115 typedef struct PSCI_Object_s
116 {
120  bool isOpen;
121 
122 } PSCI_Object;
123 
133 typedef struct PSCI_Config_s
134 {
137 
138 } PSCI_Config;
139 
140 /* ========================================================================== */
141 /* Function Declarations */
142 /* ========================================================================== */
143 
147 void PSCI_init(void);
148 
152 void PSCI_deinit(void);
153 
161 PSCI_Handle PSCI_open(uint32_t idx);
162 
172 void PSCI_close(PSCI_Handle handle);
173 
182 PSCI_Handle PSCI_getHandle(uint32_t driverInstanceIndex);
183 
189 uint32_t PSCI_getInitDriverIndex(void);
190 
199 int32_t PSCI_getPSCIVersion(PSCI_Handle handle, uint32_t *psciVer);
200 
208 int32_t PSCI_cpuOff(PSCI_Handle handle);
209 
219 int32_t PSCI_cpuOn(PSCI_Handle handle, uint32_t cpuId, uint32_t entryPoint);
220 
229 
239 int32_t PSCI_getFeatures(PSCI_Handle handle, uint32_t functionId, uint32_t *feature);
240 
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif /* #ifndef PSCI_H_ */
247 
PSCI_init
void PSCI_init(void)
Initialize the PSCI module.
PSCI_Handle
struct PSCI_Config_s * PSCI_Handle
A handle that is returned from a PSCI_open() call.
Definition: scp/psci/v0/psci.h:110
PSCI_Config
PSCI Global Configuration.
Definition: scp/psci/v0/psci.h:134
PSCI_cpuOn
int32_t PSCI_cpuOn(PSCI_Handle handle, uint32_t cpuId, uint32_t entryPoint)
Power on the CPU required.
PSCI_getHandle
PSCI_Handle PSCI_getHandle(uint32_t driverInstanceIndex)
This function returns the handle of an open PSCI Instance from the instance index.
SemaphoreP.h
PSCI_systemReset
int32_t PSCI_systemReset(PSCI_Handle handle)
Cold reset of the entire system.
PSCI_getFeatures
int32_t PSCI_getFeatures(PSCI_Handle handle, uint32_t functionId, uint32_t *feature)
Get the features of a PSCI function.
PSCI_cpuOff
int32_t PSCI_cpuOff(PSCI_Handle handle)
Power off the calling CPU.
PSCI_Config::object
PSCI_Object * object
Definition: scp/psci/v0/psci.h:136
PSCI_getInitDriverIndex
uint32_t PSCI_getInitDriverIndex(void)
This function returns the initialised instance index.
PSCI_open
PSCI_Handle PSCI_open(uint32_t idx)
Open the PSCI at index idx.
PSCI_getPSCIVersion
int32_t PSCI_getPSCIVersion(PSCI_Handle handle, uint32_t *psciVer)
Get the PSCI version.
PSCI_Object::mutex
SemaphoreP_Object mutex
Definition: scp/psci/v0/psci.h:118
PSCI_close
void PSCI_close(PSCI_Handle handle)
Function to close the PSCI instance specified by the handle.
PSCI_Object
PSCI driver object.
Definition: scp/psci/v0/psci.h:116
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
PSCI_deinit
void PSCI_deinit(void)
Deinitialize the PSCI module.
PSCI_Object::isOpen
bool isOpen
Definition: scp/psci/v0/psci.h:120