1 /*
2 * Copyright (C) 2018 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 */
34 /**
35 * \file sciclient_priv.h
36 *
37 * \brief This file contains the handle structure used internally by sciclient.
38 */
39 #ifndef SCICLIENT_PRIV_H_
40 #define SCICLIENT_PRIV_H_
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
46 #include <stdint.h>
47 #include <ti/csl/hw_types.h>
48 #include <ti/csl/csl_sec_proxy.h>
49 #include <ti/osal/osal.h>
50 #include <ti/osal/SemaphoreP.h>
51 #include <ti/osal/RegisterIntr.h>
53 #include <ti/drv/sciclient/sciclient.h>
54 #include <ti/drv/sciclient/src/sciclient_romMessages.h>
55 #include <ti/drv/sciclient/soc/sciclient_soc_priv.h>
57 #if defined (SOC_AM65XX)
58 #include <ti/drv/sciclient/soc/V0/sciclient_firmware_V0.h>
59 #include <ti/drv/sciclient/soc/V0/sciclient_defaultBoardcfg.h>
60 #endif
62 #if defined (SOC_J721E) || defined (SOC_J7200)
63 #include <ti/drv/sciclient/soc/V1/sciclient_firmware_V1.h>
64 #include <ti/drv/sciclient/soc/V1/sciclient_defaultBoardcfg.h>
65 #endif
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
71 /* ========================================================================== */
72 /* Macros & Typedefs */
73 /* ========================================================================== */
75 /**
76 * \brief Maximum number of messages waiting to be read.
77 * Cannot be greater than 256.
78 */
79 #define SCICLIENT_MAX_QUEUE_SIZE (7U)
81 /* Current context is SECURE */
82 #define SCICLIENT_SECURE_CONTEXT (0U)
84 /* Current context is NON-SECURE */
85 #define SCICLIENT_NON_SECURE_CONTEXT (1U)
87 /* ========================================================================== */
88 /* Structure Declarations */
89 /* ========================================================================== */
91 /**
92 * \brief Map structure used by #Sciclient_init function.
93 */
94 typedef struct
95 {
96 uint8_t context;
97 /**< context(sec/non-sec) **/
99 uint32_t hostId;
100 /**< CPU ID of the A53/A72/R5F/DSP */
102 uint32_t reqHighPrioThreadId;
103 /**< Thread ID of the high priority thread(write) allowed for the CPU */
105 uint32_t reqLowPrioThreadId;
106 /**< Thread ID of the low priority thread(write) allowed for the CPU */
108 uint32_t notificationRespThreadId;
109 /**< Thread ID of the thread(write) for sending a notification to the
110 * firmware
111 */
113 uint32_t respThreadId;
114 /**< Thread ID of the response thread(read) available for the CPU */
116 uint32_t notificationThreadId;
117 /**< Thread ID of the notification thread(read) available for the CPU */
119 uint32_t respIntrNum;
120 /**< Response Interrupt Number. */
121 } Sciclient_MapStruct_t;
123 /**
124 * \brief Handle for #Sciclient_service function
125 */
126 typedef struct
127 {
128 SemaphoreP_Handle semHandles[SCICLIENT_MAX_QUEUE_SIZE];
129 /**< Semaphore is posted when there is a interrupt for the response.
130 * Index is the currSeqId
131 */
132 SemaphoreP_Status semStatus[SCICLIENT_MAX_QUEUE_SIZE];
133 /**< Status returned for the SemaphoreP_pend corresponding to a
134 * particular seqId.
135 */
136 uint32_t currSeqId;
137 /**< Sequence ID of the current request **/
138 HwiP_Handle notificationIntr;
139 /**< Interrupt for notification **/
140 HwiP_Handle respIntr[2];
141 /**< Interrupt for response message. Have 2 for secure and non-secure context **/
142 uint32_t opModeFlag;
143 /**< Operation mode for the Sciclient Service API. Refer to
144 * \ref Sciclient_ServiceOperationMode for valid values.
145 */
146 uint8_t initCount;
147 /**< Count to keep track of the number of inits/de-inits done. Actual
148 * initialization done
149 * only when initCount=0, and de-init done only when initCount=1
150 */
151 uint32_t isSecureMode;
152 /**< Variable to check whether Core context is secure/non-secure. This has
153 * to be given by the user via configParams. Default value is 0.
154 */
156 } Sciclient_ServiceHandle_t;
159 /**
160 * \anchor Sciclient_proxyMap
161 * \name Sciclient map structure
162 * @{
163 * Map structure for R5F,A53,GPU and ICSSG \n
164 * in different contexts.
165 */
166 extern const Sciclient_MapStruct_t gSciclientMap[SCICLIENT_CONTEXT_MAX_NUM];
167 /* @} */
169 /* ========================================================================== */
170 /* Function Declarations */
171 /* ========================================================================== */
173 /**<
174 * \brief API to send the board configuration messsage to the firmware .
175 * Valid(not NULL) pointer to Sciclient_BoardCfgPrms_t will use the
176 * provided values for tisci_msg_board_config_req, otherwise
177 * default values are used .
178 *
179 * \param pInPrms [IN] Pointer to #Sciclient_BoardCfgPrms_t .
180 *
181 * \return status Status of the message.
182 */
183 int32_t Sciclient_boardCfg(const Sciclient_BoardCfgPrms_t * pInPrms);
185 #ifdef __cplusplus
186 }
187 #endif
189 #endif /* #ifndef SCICLIENT_PRIV_H_*/