1 /***************************************************************************//**
2 * \file cy_crypto_core_hw.h
3 * \version 2.90
4 *
5 * \brief
6 * This file provides the headers to the API for the utils
7 * in the Crypto driver.
8 *
9 ********************************************************************************
10 * \copyright
11 * Copyright (c) (2020-2022), Cypress Semiconductor Corporation (an Infineon company) or
12 * an affiliate of Cypress Semiconductor Corporation.
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 *******************************************************************************/
27
28
29 #if !defined (CY_CRYPTO_CORE_HW_H)
30 #define CY_CRYPTO_CORE_HW_H
31
32 #include "cy_device.h"
33
34 #if defined (CY_IP_MXCRYPTO)
35
36 #include "cy_crypto_common.h"
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 20.5', 1, \
43 'Since CY_CRYPTO_V1 is decided by PDL device agnostic / hardware specific model, use of #undef will not make it ambiguous that which macros exist at a particular point within a translation unit.')
44
45
46 #if (CY_IP_MXCRYPTO_VERSION == 1u)
47 #include "ip/cyip_crypto.h"
48 #endif
49
50 #if (CY_IP_MXCRYPTO_VERSION == 2u)
51 #include "ip/cyip_crypto_v2.h"
52
53 /* CRYPTO.CTL */
54 #if !defined(CRYPTO_CTL_ENABLED_Pos)
55 #define CRYPTO_CTL_ENABLED_Pos CRYPTO_V2_CTL_ENABLED_Pos
56 #endif
57 #if !defined(CRYPTO_CTL_ENABLED_Msk)
58 #define CRYPTO_CTL_ENABLED_Msk CRYPTO_V2_CTL_ENABLED_Msk
59 #endif
60
61 /* CRYPTO.STATUS */
62 #if !defined(CRYPTO_STATUS_VU_BUSY_Pos)
63 #define CRYPTO_STATUS_VU_BUSY_Pos 7UL
64 #endif
65 #if !defined(CRYPTO_STATUS_VU_BUSY_Msk)
66 #define CRYPTO_STATUS_VU_BUSY_Msk 0x80UL
67 #endif
68
69 /* CRYPTO.ERROR_STATUS1 */
70 #if !defined(CRYPTO_ERROR_STATUS1_DATA23_Pos)
71 #define CRYPTO_ERROR_STATUS1_DATA23_Pos 0UL
72 #endif
73 #if !defined(CRYPTO_ERROR_STATUS1_DATA23_Msk)
74 #define CRYPTO_ERROR_STATUS1_DATA23_Msk 0xFFFFFFUL
75 #endif
76 #if !defined(CRYPTO_ERROR_STATUS1_IDX_Pos)
77 #define CRYPTO_ERROR_STATUS1_IDX_Pos CRYPTO_V2_ERROR_STATUS1_IDX_Pos
78 #endif
79 #if !defined(CRYPTO_ERROR_STATUS1_IDX_Msk)
80 #define CRYPTO_ERROR_STATUS1_IDX_Msk CRYPTO_V2_ERROR_STATUS1_IDX_Msk
81 #endif
82 #if !defined(CRYPTO_ERROR_STATUS1_VALID_Pos)
83 #define CRYPTO_ERROR_STATUS1_VALID_Pos CRYPTO_V2_ERROR_STATUS1_VALID_Pos
84 #endif
85 #if !defined(CRYPTO_ERROR_STATUS1_VALID_Msk)
86 #define CRYPTO_ERROR_STATUS1_VALID_Msk CRYPTO_V2_ERROR_STATUS1_VALID_Msk
87 #endif
88
89 /* CRYPTO.INSTR_FF_STATUS */
90 #if !defined(CRYPTO_INSTR_FF_STATUS_USED_Pos)
91 #define CRYPTO_INSTR_FF_STATUS_USED_Pos CRYPTO_V2_INSTR_FF_STATUS_USED_Pos
92 #endif
93 #if !defined(CRYPTO_INSTR_FF_STATUS_USED_Msk)
94 #define CRYPTO_INSTR_FF_STATUS_USED_Msk CRYPTO_V2_INSTR_FF_STATUS_USED_Msk
95 #endif
96 #if !defined(CRYPTO_INSTR_FF_STATUS_EVENT_Pos)
97 #define CRYPTO_INSTR_FF_STATUS_EVENT_Pos CRYPTO_V2_INSTR_FF_STATUS_EVENT_Pos
98 #endif
99 #if !defined(CRYPTO_INSTR_FF_STATUS_EVENT_Msk)
100 #define CRYPTO_INSTR_FF_STATUS_EVENT_Msk CRYPTO_V2_INSTR_FF_STATUS_EVENT_Msk
101 #endif
102 #if !defined(CRYPTO_INSTR_FF_STATUS_BUSY_Pos)
103 #define CRYPTO_INSTR_FF_STATUS_BUSY_Pos CRYPTO_V2_LOAD0_FF_STATUS_BUSY_Pos
104 #endif
105 #if !defined(CRYPTO_INSTR_FF_STATUS_BUSY_Msk)
106 #define CRYPTO_INSTR_FF_STATUS_BUSY_Msk CRYPTO_V2_LOAD0_FF_STATUS_BUSY_Msk
107 #endif
108
109 /* CRYPTO.INSTR_FF_WR */
110 #if !defined(CRYPTO_INSTR_FF_WR_DATA32_Pos)
111 #define CRYPTO_INSTR_FF_WR_DATA32_Pos CRYPTO_V2_INSTR_FF_WR_DATA32_Pos
112 #endif
113 #if !defined(CRYPTO_INSTR_FF_WR_DATA32_Msk)
114 #define CRYPTO_INSTR_FF_WR_DATA32_Msk CRYPTO_V2_INSTR_FF_WR_DATA32_Msk
115 #endif
116
117 /* CRYPTO.RF_DATA */
118 #if !defined(CRYPTO_RF_DATA_DATA32_Pos)
119 #define CRYPTO_RF_DATA_DATA32_Pos CRYPTO_V2_VU_RF_DATA_DATA32_Pos
120 #endif
121 #if !defined(CRYPTO_RF_DATA_DATA32_Msk)
122 #define CRYPTO_RF_DATA_DATA32_Msk CRYPTO_V2_VU_RF_DATA_DATA32_Msk
123 #endif
124
125 /* CRYPTO.AES_CTL */
126 #if !defined(CRYPTO_AES_CTL_KEY_SIZE_Pos)
127 #define CRYPTO_AES_CTL_KEY_SIZE_Pos CRYPTO_V2_AES_CTL_KEY_SIZE_Pos
128 #endif
129 #if !defined(CRYPTO_AES_CTL_KEY_SIZE_Msk)
130 #define CRYPTO_AES_CTL_KEY_SIZE_Msk CRYPTO_V2_AES_CTL_KEY_SIZE_Msk
131 #endif
132
133 /* CRYPTO.PR_LFSR_CTL0 */
134 #if !defined(CRYPTO_PR_LFSR_CTL0_LFSR32_Pos)
135 #define CRYPTO_PR_LFSR_CTL0_LFSR32_Pos CRYPTO_V2_PR_LFSR_CTL0_LFSR32_Pos
136 #endif
137 #if !defined(CRYPTO_PR_LFSR_CTL0_LFSR32_Msk)
138 #define CRYPTO_PR_LFSR_CTL0_LFSR32_Msk CRYPTO_V2_PR_LFSR_CTL0_LFSR32_Msk
139 #endif
140
141 /* CRYPTO.PR_LFSR_CTL1 */
142 #if !defined(CRYPTO_PR_LFSR_CTL1_LFSR31_Pos)
143 #define CRYPTO_PR_LFSR_CTL1_LFSR31_Pos CRYPTO_V2_PR_LFSR_CTL1_LFSR31_Pos
144 #endif
145 #if !defined(CRYPTO_PR_LFSR_CTL1_LFSR31_Msk)
146 #define CRYPTO_PR_LFSR_CTL1_LFSR31_Msk CRYPTO_V2_PR_LFSR_CTL1_LFSR31_Msk
147 #endif
148
149 /* CRYPTO.PR_LFSR_CTL2 */
150 #if !defined(CRYPTO_PR_LFSR_CTL2_LFSR29_Pos)
151 #define CRYPTO_PR_LFSR_CTL2_LFSR29_Pos CRYPTO_V2_PR_LFSR_CTL2_LFSR29_Pos
152 #endif
153 #if !defined(CRYPTO_PR_LFSR_CTL2_LFSR29_Msk)
154 #define CRYPTO_PR_LFSR_CTL2_LFSR29_Msk CRYPTO_V2_PR_LFSR_CTL2_LFSR29_Msk
155 #endif
156
157 /* CRYPTO.TR_CTL0 */
158 #if !defined(CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV_Pos)
159 #define CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV_Pos CRYPTO_V2_TR_CTL0_SAMPLE_CLOCK_DIV_Pos
160 #endif
161 #if !defined(CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV_Msk)
162 #define CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV_Msk CRYPTO_V2_TR_CTL0_SAMPLE_CLOCK_DIV_Msk
163 #endif
164 #if !defined(CRYPTO_TR_CTL0_RED_CLOCK_DIV_Pos)
165 #define CRYPTO_TR_CTL0_RED_CLOCK_DIV_Pos CRYPTO_V2_TR_CTL0_RED_CLOCK_DIV_Pos
166 #endif
167 #if !defined(CRYPTO_TR_CTL0_RED_CLOCK_DIV_Msk)
168 #define CRYPTO_TR_CTL0_RED_CLOCK_DIV_Msk CRYPTO_V2_TR_CTL0_RED_CLOCK_DIV_Msk
169 #endif
170 #if !defined(CRYPTO_TR_CTL0_INIT_DELAY_Pos)
171 #define CRYPTO_TR_CTL0_INIT_DELAY_Pos CRYPTO_V2_TR_CTL0_INIT_DELAY_Pos
172 #endif
173 #if !defined(CRYPTO_TR_CTL0_INIT_DELAY_Msk)
174 #define CRYPTO_TR_CTL0_INIT_DELAY_Msk CRYPTO_V2_TR_CTL0_INIT_DELAY_Msk
175 #endif
176 #if !defined(CRYPTO_TR_CTL0_VON_NEUMANN_CORR_Pos)
177 #define CRYPTO_TR_CTL0_VON_NEUMANN_CORR_Pos CRYPTO_V2_TR_CTL0_VON_NEUMANN_CORR_Pos
178 #endif
179 #if !defined(CRYPTO_TR_CTL0_VON_NEUMANN_CORR_Msk)
180 #define CRYPTO_TR_CTL0_VON_NEUMANN_CORR_Msk CRYPTO_V2_TR_CTL0_VON_NEUMANN_CORR_Msk
181 #endif
182 #if !defined(CRYPTO_TR_CTL0_STOP_ON_AP_DETECT_Pos)
183 #define CRYPTO_TR_CTL0_STOP_ON_AP_DETECT_Pos CRYPTO_V2_TR_CTL0_STOP_ON_AP_DETECT_Pos
184 #endif
185 #if !defined(CRYPTO_TR_CTL0_STOP_ON_AP_DETECT_Msk)
186 #define CRYPTO_TR_CTL0_STOP_ON_AP_DETECT_Msk CRYPTO_V2_TR_CTL0_STOP_ON_AP_DETECT_Msk
187 #endif
188 #if !defined(CRYPTO_TR_CTL0_STOP_ON_RC_DETECT_Pos)
189 #define CRYPTO_TR_CTL0_STOP_ON_RC_DETECT_Pos CRYPTO_V2_TR_CTL0_STOP_ON_RC_DETECT_Pos
190 #endif
191 #if !defined(CRYPTO_TR_CTL0_STOP_ON_RC_DETECT_Msk)
192 #define CRYPTO_TR_CTL0_STOP_ON_RC_DETECT_Msk CRYPTO_V2_TR_CTL0_STOP_ON_RC_DETECT_Msk
193 #endif
194
195 /* CRYPTO.TR_CTL1 */
196 #if !defined(CRYPTO_TR_CTL1_RO11_EN_Pos)
197 #define CRYPTO_TR_CTL1_RO11_EN_Pos CRYPTO_V2_TR_CTL1_RO11_EN_Pos
198 #endif
199 #if !defined(CRYPTO_TR_CTL1_RO11_EN_Msk)
200 #define CRYPTO_TR_CTL1_RO11_EN_Msk CRYPTO_V2_TR_CTL1_RO11_EN_Msk
201 #endif
202 #if !defined(CRYPTO_TR_CTL1_RO15_EN_Pos)
203 #define CRYPTO_TR_CTL1_RO15_EN_Pos CRYPTO_V2_TR_CTL1_RO15_EN_Pos
204 #endif
205 #if !defined(CRYPTO_TR_CTL1_RO15_EN_Msk)
206 #define CRYPTO_TR_CTL1_RO15_EN_Msk CRYPTO_V2_TR_CTL1_RO15_EN_Msk
207 #endif
208 #if !defined(CRYPTO_TR_CTL1_GARO15_EN_Pos)
209 #define CRYPTO_TR_CTL1_GARO15_EN_Pos CRYPTO_V2_TR_CTL1_GARO15_EN_Pos
210 #endif
211 #if !defined(CRYPTO_TR_CTL1_GARO15_EN_Msk)
212 #define CRYPTO_TR_CTL1_GARO15_EN_Msk CRYPTO_V2_TR_CTL1_GARO15_EN_Msk
213 #endif
214 #if !defined(CRYPTO_TR_CTL1_GARO31_EN_Pos)
215 #define CRYPTO_TR_CTL1_GARO31_EN_Pos CRYPTO_V2_TR_CTL1_GARO31_EN_Pos
216 #endif
217 #if !defined(CRYPTO_TR_CTL1_GARO31_EN_Msk)
218 #define CRYPTO_TR_CTL1_GARO31_EN_Msk CRYPTO_V2_TR_CTL1_GARO31_EN_Msk
219 #endif
220 #if !defined(CRYPTO_TR_CTL1_FIRO15_EN_Pos)
221 #define CRYPTO_TR_CTL1_FIRO15_EN_Pos CRYPTO_V2_TR_CTL1_FIRO15_EN_Pos
222 #endif
223 #if !defined(CRYPTO_TR_CTL1_FIRO15_EN_Msk)
224 #define CRYPTO_TR_CTL1_FIRO15_EN_Msk CRYPTO_V2_TR_CTL1_FIRO15_EN_Msk
225 #endif
226 #if !defined(CRYPTO_TR_CTL1_FIRO31_EN_Pos)
227 #define CRYPTO_TR_CTL1_FIRO31_EN_Pos CRYPTO_V2_TR_CTL1_FIRO31_EN_Pos
228 #endif
229 #if !defined(CRYPTO_TR_CTL1_FIRO31_EN_Msk)
230 #define CRYPTO_TR_CTL1_FIRO31_EN_Msk CRYPTO_V2_TR_CTL1_FIRO31_EN_Msk
231 #endif
232
233 /* CRYPTO.TR_RESULT */
234 #if !defined(CRYPTO_TR_RESULT_DATA32_Pos)
235 #define CRYPTO_TR_RESULT_DATA32_Pos CRYPTO_V2_TR_RESULT_DATA32_Pos
236 #endif
237 #if !defined(CRYPTO_TR_RESULT_DATA32_Msk)
238 #define CRYPTO_TR_RESULT_DATA32_Msk CRYPTO_V2_TR_RESULT_DATA32_Msk
239 #endif
240
241 /* CRYPTO.TR_GARO_CTL */
242 #if !defined(CRYPTO_TR_GARO_CTL_POLYNOMIAL31_Pos)
243 #define CRYPTO_TR_GARO_CTL_POLYNOMIAL31_Pos CRYPTO_V2_TR_GARO_CTL_POLYNOMIAL31_Pos
244 #endif
245 #if !defined(CRYPTO_TR_GARO_CTL_POLYNOMIAL31_Msk)
246 #define CRYPTO_TR_GARO_CTL_POLYNOMIAL31_Msk CRYPTO_V2_TR_GARO_CTL_POLYNOMIAL31_Msk
247 #endif
248
249 /* CRYPTO.TR_FIRO_CTL */
250 #if !defined(CRYPTO_TR_FIRO_CTL_POLYNOMIAL31_Pos)
251 #define CRYPTO_TR_FIRO_CTL_POLYNOMIAL31_Pos CRYPTO_V2_TR_FIRO_CTL_POLYNOMIAL31_Pos
252 #endif
253 #if !defined(CRYPTO_TR_FIRO_CTL_POLYNOMIAL31_Msk)
254 #define CRYPTO_TR_FIRO_CTL_POLYNOMIAL31_Msk CRYPTO_V2_TR_FIRO_CTL_POLYNOMIAL31_Msk
255 #endif
256
257 /* CRYPTO.TR_MON_CTL */
258 #if !defined(CRYPTO_TR_MON_CTL_BITSTREAM_SEL_Pos)
259 #define CRYPTO_TR_MON_CTL_BITSTREAM_SEL_Pos CRYPTO_V2_TR_MON_CTL_BITSTREAM_SEL_Pos
260 #endif
261 #if !defined(CRYPTO_TR_MON_CTL_BITSTREAM_SEL_Msk)
262 #define CRYPTO_TR_MON_CTL_BITSTREAM_SEL_Msk CRYPTO_V2_TR_MON_CTL_BITSTREAM_SEL_Msk
263 #endif
264
265 /* CRYPTO.TR_MON_CMD */
266 #if !defined(CRYPTO_TR_MON_CMD_START_AP_Pos)
267 #define CRYPTO_TR_MON_CMD_START_AP_Pos CRYPTO_V2_TR_MON_CMD_START_AP_Pos
268 #endif
269 #if !defined(CRYPTO_TR_MON_CMD_START_AP_Msk)
270 #define CRYPTO_TR_MON_CMD_START_AP_Msk CRYPTO_V2_TR_MON_CMD_START_AP_Msk
271 #endif
272 #if !defined(CRYPTO_TR_MON_CMD_START_RC_Pos)
273 #define CRYPTO_TR_MON_CMD_START_RC_Pos CRYPTO_V2_TR_MON_CMD_START_RC_Pos
274 #endif
275 #if !defined(CRYPTO_TR_MON_CMD_START_RC_Msk)
276 #define CRYPTO_TR_MON_CMD_START_RC_Msk CRYPTO_V2_TR_MON_CMD_START_RC_Msk
277 #endif
278
279 /* CRYPTO.TR_MON_RC_CTL */
280 #if !defined(CRYPTO_TR_MON_RC_CTL_CUTOFF_COUNT8_Pos)
281 #define CRYPTO_TR_MON_RC_CTL_CUTOFF_COUNT8_Pos CRYPTO_V2_TR_MON_RC_CTL_CUTOFF_COUNT8_Pos
282 #endif
283 #if !defined(CRYPTO_TR_MON_RC_CTL_CUTOFF_COUNT8_Msk)
284 #define CRYPTO_TR_MON_RC_CTL_CUTOFF_COUNT8_Msk CRYPTO_V2_TR_MON_RC_CTL_CUTOFF_COUNT8_Msk
285 #endif
286
287 /* CRYPTO.TR_MON_RC_STATUS0 */
288 #if !defined(CRYPTO_TR_MON_RC_STATUS0_BIT_Pos)
289 #define CRYPTO_TR_MON_RC_STATUS0_BIT_Pos CRYPTO_V2_TR_MON_RC_STATUS0_BIT_Pos
290 #endif
291 #if !defined(CRYPTO_TR_MON_RC_STATUS0_BIT_Msk)
292 #define CRYPTO_TR_MON_RC_STATUS0_BIT_Msk CRYPTO_V2_TR_MON_RC_STATUS0_BIT_Msk
293 #endif
294
295 /* CRYPTO.TR_MON_RC_STATUS1 */
296 #if !defined(CRYPTO_TR_MON_RC_STATUS1_REP_COUNT_Pos)
297 #define CRYPTO_TR_MON_RC_STATUS1_REP_COUNT_Pos CRYPTO_V2_TR_MON_RC_STATUS1_REP_COUNT_Pos
298 #endif
299 #if !defined(CRYPTO_TR_MON_RC_STATUS1_REP_COUNT_Msk)
300 #define CRYPTO_TR_MON_RC_STATUS1_REP_COUNT_Msk CRYPTO_V2_TR_MON_RC_STATUS1_REP_COUNT_Msk
301 #endif
302
303 /* CRYPTO.TR_MON_AP_CTL */
304 #if !defined(CRYPTO_TR_MON_AP_CTL_CUTOFF_COUNT16_Pos)
305 #define CRYPTO_TR_MON_AP_CTL_CUTOFF_COUNT16_Pos CRYPTO_V2_TR_MON_AP_CTL_CUTOFF_COUNT16_Pos
306 #endif
307 #if !defined(CRYPTO_TR_MON_AP_CTL_CUTOFF_COUNT16_Msk)
308 #define CRYPTO_TR_MON_AP_CTL_CUTOFF_COUNT16_Msk CRYPTO_V2_TR_MON_AP_CTL_CUTOFF_COUNT16_Msk
309 #endif
310 #if !defined(CRYPTO_TR_MON_AP_CTL_WINDOW_SIZE_Pos)
311 #define CRYPTO_TR_MON_AP_CTL_WINDOW_SIZE_Pos CRYPTO_V2_TR_MON_AP_CTL_WINDOW_SIZE_Pos
312 #endif
313 #if !defined(CRYPTO_TR_MON_AP_CTL_WINDOW_SIZE_Msk)
314 #define CRYPTO_TR_MON_AP_CTL_WINDOW_SIZE_Msk CRYPTO_V2_TR_MON_AP_CTL_WINDOW_SIZE_Msk
315 #endif
316
317 /* CRYPTO.TR_MON_AP_STATUS0 */
318 #if !defined(CRYPTO_TR_MON_AP_STATUS0_BIT_Pos)
319 #define CRYPTO_TR_MON_AP_STATUS0_BIT_Pos CRYPTO_V2_TR_MON_AP_STATUS0_BIT_Pos
320 #endif
321 #if !defined(CRYPTO_TR_MON_AP_STATUS0_BIT_Msk)
322 #define CRYPTO_TR_MON_AP_STATUS0_BIT_Msk CRYPTO_V2_TR_MON_AP_STATUS0_BIT_Msk
323 #endif
324
325 /* CRYPTO.TR_MON_AP_STATUS1 */
326 #if !defined(CRYPTO_TR_MON_AP_STATUS1_OCC_COUNT_Pos)
327 #define CRYPTO_TR_MON_AP_STATUS1_OCC_COUNT_Pos CRYPTO_V2_TR_MON_AP_STATUS1_OCC_COUNT_Pos
328 #endif
329 #if !defined(CRYPTO_TR_MON_AP_STATUS1_OCC_COUNT_Msk)
330 #define CRYPTO_TR_MON_AP_STATUS1_OCC_COUNT_Msk CRYPTO_V2_TR_MON_AP_STATUS1_OCC_COUNT_Msk
331 #endif
332 #if !defined(CRYPTO_TR_MON_AP_STATUS1_WINDOW_INDEX_Pos)
333 #define CRYPTO_TR_MON_AP_STATUS1_WINDOW_INDEX_Pos CRYPTO_V2_TR_MON_AP_STATUS1_WINDOW_INDEX_Pos
334 #endif
335 #if !defined(CRYPTO_TR_MON_AP_STATUS1_WINDOW_INDEX_Msk)
336 #define CRYPTO_TR_MON_AP_STATUS1_WINDOW_INDEX_Msk CRYPTO_V2_TR_MON_AP_STATUS1_WINDOW_INDEX_Msk
337 #endif
338
339 /* CRYPTO.VU_STATUS */
340 #if !defined(CRYPTO_VU_STATUS_CARRY_Pos)
341 #define CRYPTO_VU_STATUS_CARRY_Pos CRYPTO_V2_VU_STATUS_CARRY_Pos
342 #endif
343 #if !defined(CRYPTO_VU_STATUS_CARRY_Msk)
344 #define CRYPTO_VU_STATUS_CARRY_Msk CRYPTO_V2_VU_STATUS_CARRY_Msk
345 #endif
346 #if !defined(CRYPTO_VU_STATUS_EVEN_Pos)
347 #define CRYPTO_VU_STATUS_EVEN_Pos CRYPTO_V2_VU_STATUS_EVEN_Pos
348 #endif
349 #if !defined(CRYPTO_VU_STATUS_EVEN_Msk)
350 #define CRYPTO_VU_STATUS_EVEN_Msk CRYPTO_V2_VU_STATUS_EVEN_Msk
351 #endif
352 #if !defined(CRYPTO_VU_STATUS_ZERO_Pos)
353 #define CRYPTO_VU_STATUS_ZERO_Pos CRYPTO_V2_VU_STATUS_ZERO_Pos
354 #endif
355 #if !defined(CRYPTO_VU_STATUS_ZERO_Msk)
356 #define CRYPTO_VU_STATUS_ZERO_Msk CRYPTO_V2_VU_STATUS_ZERO_Msk
357 #endif
358 #if !defined(CRYPTO_VU_STATUS_ONE_Pos)
359 #define CRYPTO_VU_STATUS_ONE_Pos CRYPTO_V2_VU_STATUS_ONE_Pos
360 #endif
361 #if !defined(CRYPTO_VU_STATUS_ONE_Msk)
362 #define CRYPTO_VU_STATUS_ONE_Msk CRYPTO_V2_VU_STATUS_ONE_Msk
363 #endif
364
365 /* CRYPTO.INTR */
366 #if !defined(CRYPTO_INTR_TR_INITIALIZED_Pos)
367 #define CRYPTO_INTR_TR_INITIALIZED_Pos CRYPTO_V2_INTR_TR_INITIALIZED_Pos
368 #endif
369 #if !defined(CRYPTO_INTR_TR_INITIALIZED_Msk)
370 #define CRYPTO_INTR_TR_INITIALIZED_Msk CRYPTO_V2_INTR_TR_INITIALIZED_Msk
371 #endif
372 #if !defined(CRYPTO_INTR_TR_DATA_AVAILABLE_Pos)
373 #define CRYPTO_INTR_TR_DATA_AVAILABLE_Pos CRYPTO_V2_INTR_TR_DATA_AVAILABLE_Pos
374 #endif
375 #if !defined(CRYPTO_INTR_TR_DATA_AVAILABLE_Msk)
376 #define CRYPTO_INTR_TR_DATA_AVAILABLE_Msk CRYPTO_V2_INTR_TR_DATA_AVAILABLE_Msk
377 #endif
378 #if !defined(CRYPTO_INTR_INSTR_OPC_ERROR_Pos)
379 #define CRYPTO_INTR_INSTR_OPC_ERROR_Pos CRYPTO_V2_INTR_INSTR_OPC_ERROR_Pos
380 #endif
381 #if !defined(CRYPTO_INTR_INSTR_OPC_ERROR_Msk)
382 #define CRYPTO_INTR_INSTR_OPC_ERROR_Msk CRYPTO_V2_INTR_INSTR_OPC_ERROR_Msk
383 #endif
384 #if !defined(CRYPTO_INTR_INSTR_CC_ERROR_Pos)
385 #define CRYPTO_INTR_INSTR_CC_ERROR_Pos CRYPTO_V2_INTR_INSTR_CC_ERROR_Pos
386 #endif
387 #if !defined(CRYPTO_INTR_INSTR_CC_ERROR_Msk)
388 #define CRYPTO_INTR_INSTR_CC_ERROR_Msk CRYPTO_V2_INTR_INSTR_CC_ERROR_Msk
389 #endif
390 #if !defined(CRYPTO_INTR_BUS_ERROR_Pos)
391 #define CRYPTO_INTR_BUS_ERROR_Pos CRYPTO_V2_INTR_BUS_ERROR_Pos
392 #endif
393 #if !defined(CRYPTO_INTR_BUS_ERROR_Msk)
394 #define CRYPTO_INTR_BUS_ERROR_Msk CRYPTO_V2_INTR_BUS_ERROR_Msk
395 #endif
396 #if !defined(CRYPTO_INTR_TR_AP_DETECT_ERROR_Pos)
397 #define CRYPTO_INTR_TR_AP_DETECT_ERROR_Pos CRYPTO_V2_INTR_TR_AP_DETECT_ERROR_Pos
398 #endif
399 #if !defined(CRYPTO_INTR_TR_AP_DETECT_ERROR_Msk)
400 #define CRYPTO_INTR_TR_AP_DETECT_ERROR_Msk CRYPTO_V2_INTR_TR_AP_DETECT_ERROR_Msk
401 #endif
402 #if !defined(CRYPTO_INTR_TR_RC_DETECT_ERROR_Pos)
403 #define CRYPTO_INTR_TR_RC_DETECT_ERROR_Pos CRYPTO_V2_INTR_TR_RC_DETECT_ERROR_Pos
404 #endif
405 #if !defined(CRYPTO_INTR_TR_RC_DETECT_ERROR_Msk)
406 #define CRYPTO_INTR_TR_RC_DETECT_ERROR_Msk CRYPTO_V2_INTR_TR_RC_DETECT_ERROR_Msk
407 #endif
408
409 /* CRYPTO.INTR_MASK */
410 #if !defined(CRYPTO_INTR_MASK_INSTR_FF_LEVEL_Pos)
411 #define CRYPTO_INTR_MASK_INSTR_FF_LEVEL_Pos CRYPTO_V2_INTR_MASK_INSTR_FF_LEVEL_Pos
412 #endif
413 #if !defined(CRYPTO_INTR_MASK_INSTR_FF_LEVEL_Msk)
414 #define CRYPTO_INTR_MASK_INSTR_FF_LEVEL_Msk CRYPTO_V2_INTR_MASK_INSTR_FF_LEVEL_Msk
415 #endif
416 #if !defined(CRYPTO_INTR_MASK_INSTR_FF_OVERFLOW_Pos)
417 #define CRYPTO_INTR_MASK_INSTR_FF_OVERFLOW_Pos CRYPTO_V2_INTR_MASK_INSTR_FF_OVERFLOW_Pos
418 #endif
419 #if !defined(CRYPTO_INTR_MASK_INSTR_FF_OVERFLOW_Msk)
420 #define CRYPTO_INTR_MASK_INSTR_FF_OVERFLOW_Msk CRYPTO_V2_INTR_MASK_INSTR_FF_OVERFLOW_Msk
421 #endif
422 #if !defined(CRYPTO_INTR_MASK_TR_INITIALIZED_Pos)
423 #define CRYPTO_INTR_MASK_TR_INITIALIZED_Pos CRYPTO_V2_INTR_MASK_TR_INITIALIZED_Pos
424 #endif
425 #if !defined(CRYPTO_INTR_MASK_TR_INITIALIZED_Msk)
426 #define CRYPTO_INTR_MASK_TR_INITIALIZED_Msk CRYPTO_V2_INTR_MASK_TR_INITIALIZED_Msk
427 #endif
428 #if !defined(CRYPTO_INTR_MASK_TR_DATA_AVAILABLE_Pos)
429 #define CRYPTO_INTR_MASK_TR_DATA_AVAILABLE_Pos CRYPTO_V2_INTR_MASK_TR_DATA_AVAILABLE_Pos
430 #endif
431 #if !defined(CRYPTO_INTR_MASK_TR_DATA_AVAILABLE_Msk)
432 #define CRYPTO_INTR_MASK_TR_DATA_AVAILABLE_Msk CRYPTO_V2_INTR_MASK_TR_DATA_AVAILABLE_Msk
433 #endif
434 #if !defined(CRYPTO_INTR_MASK_PR_DATA_AVAILABLE_Pos)
435 #define CRYPTO_INTR_MASK_PR_DATA_AVAILABLE_Pos CRYPTO_V2_INTR_MASK_PR_DATA_AVAILABLE_Pos
436 #endif
437 #if !defined(CRYPTO_INTR_MASK_PR_DATA_AVAILABLE_Msk)
438 #define CRYPTO_INTR_MASK_PR_DATA_AVAILABLE_Msk CRYPTO_V2_INTR_MASK_PR_DATA_AVAILABLE_Msk
439 #endif
440 #if !defined(CRYPTO_INTR_MASK_INSTR_OPC_ERROR_Pos)
441 #define CRYPTO_INTR_MASK_INSTR_OPC_ERROR_Pos CRYPTO_V2_INTR_MASK_INSTR_OPC_ERROR_Pos
442 #endif
443 #if !defined(CRYPTO_INTR_MASK_INSTR_OPC_ERROR_Msk)
444 #define CRYPTO_INTR_MASK_INSTR_OPC_ERROR_Msk CRYPTO_V2_INTR_MASK_INSTR_OPC_ERROR_Msk
445 #endif
446 #if !defined(CRYPTO_INTR_MASK_INSTR_CC_ERROR_Pos)
447 #define CRYPTO_INTR_MASK_INSTR_CC_ERROR_Pos CRYPTO_V2_INTR_MASK_INSTR_CC_ERROR_Pos
448 #endif
449 #if !defined(CRYPTO_INTR_MASK_INSTR_CC_ERROR_Msk)
450 #define CRYPTO_INTR_MASK_INSTR_CC_ERROR_Msk CRYPTO_V2_INTR_MASK_INSTR_CC_ERROR_Msk
451 #endif
452 #if !defined(CRYPTO_INTR_MASK_BUS_ERROR_Pos)
453 #define CRYPTO_INTR_MASK_BUS_ERROR_Pos CRYPTO_V2_INTR_MASK_BUS_ERROR_Pos
454 #endif
455 #if !defined(CRYPTO_INTR_MASK_BUS_ERROR_Msk)
456 #define CRYPTO_INTR_MASK_BUS_ERROR_Msk CRYPTO_V2_INTR_MASK_BUS_ERROR_Msk
457 #endif
458 #if !defined(CRYPTO_INTR_MASK_TR_AP_DETECT_ERROR_Pos)
459 #define CRYPTO_INTR_MASK_TR_AP_DETECT_ERROR_Pos CRYPTO_V2_INTR_MASK_TR_AP_DETECT_ERROR_Pos
460 #endif
461 #if !defined(CRYPTO_INTR_MASK_TR_AP_DETECT_ERROR_Msk)
462 #define CRYPTO_INTR_MASK_TR_AP_DETECT_ERROR_Msk CRYPTO_V2_INTR_MASK_TR_AP_DETECT_ERROR_Msk
463 #endif
464 #if !defined(CRYPTO_INTR_MASK_TR_RC_DETECT_ERROR_Pos)
465 #define CRYPTO_INTR_MASK_TR_RC_DETECT_ERROR_Pos CRYPTO_V2_INTR_MASK_TR_RC_DETECT_ERROR_Pos
466 #endif
467 #if !defined(CRYPTO_INTR_MASK_TR_RC_DETECT_ERROR_Msk)
468 #define CRYPTO_INTR_MASK_TR_RC_DETECT_ERROR_Msk CRYPTO_V2_INTR_MASK_TR_RC_DETECT_ERROR_Msk
469 #endif
470 #endif
471
472
473 /** \cond INTERNAL */
474
475 /*******************************************************************************
476 * CRYPTO
477 *******************************************************************************/
478 /* Non-changed registers */
479 #define REG_CRYPTO_CTL(base) (((CRYPTO_Type*)(base))->CTL)
480 #define REG_CRYPTO_ERROR_STATUS0(base) (((CRYPTO_Type*)(base))->ERROR_STATUS0)
481 #define REG_CRYPTO_ERROR_STATUS1(base) (((CRYPTO_Type*)(base))->ERROR_STATUS1)
482 #define REG_CRYPTO_PR_LFSR_CTL0(base) (((CRYPTO_Type*)(base))->PR_LFSR_CTL0)
483 #define REG_CRYPTO_PR_LFSR_CTL1(base) (((CRYPTO_Type*)(base))->PR_LFSR_CTL1)
484 #define REG_CRYPTO_PR_LFSR_CTL2(base) (((CRYPTO_Type*)(base))->PR_LFSR_CTL2)
485 #define REG_CRYPTO_TR_CTL0(base) (((CRYPTO_Type*)(base))->TR_CTL0)
486 #define REG_CRYPTO_TR_CTL1(base) (((CRYPTO_Type*)(base))->TR_CTL1)
487 #define REG_CRYPTO_TR_GARO_CTL(base) (((CRYPTO_Type*)(base))->TR_GARO_CTL)
488 #define REG_CRYPTO_TR_FIRO_CTL(base) (((CRYPTO_Type*)(base))->TR_FIRO_CTL)
489 #define REG_CRYPTO_TR_MON_CTL(base) (((CRYPTO_Type*)(base))->TR_MON_CTL)
490 #define REG_CRYPTO_TR_MON_CMD(base) (((CRYPTO_Type*)(base))->TR_MON_CMD)
491 #define REG_CRYPTO_TR_MON_RC_CTL(base) (((CRYPTO_Type*)(base))->TR_MON_RC_CTL)
492 #define REG_CRYPTO_TR_MON_RC_STATUS0(base) (((CRYPTO_Type*)(base))->TR_MON_RC_STATUS0)
493 #define REG_CRYPTO_TR_MON_RC_STATUS1(base) (((CRYPTO_Type*)(base))->TR_MON_RC_STATUS1)
494 #define REG_CRYPTO_TR_MON_AP_CTL(base) (((CRYPTO_Type*)(base))->TR_MON_AP_CTL)
495 #define REG_CRYPTO_TR_MON_AP_STATUS0(base) (((CRYPTO_Type*)(base))->TR_MON_AP_STATUS0)
496 #define REG_CRYPTO_TR_MON_AP_STATUS1(base) (((CRYPTO_Type*)(base))->TR_MON_AP_STATUS1)
497
498 /* Changed registers in the regmap */
499 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
500
501 /* Use PDL device agnostic model */
502
503 #define REG_CRYPTO_STATUS(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoStatusOffset))
504 #define REG_CRYPTO_INSTR_FF_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoIstrFfCtlOffset))
505 #define REG_CRYPTO_INSTR_FF_STATUS(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoInstrFfStatusOffset))
506 #define REG_CRYPTO_INSTR_FF_WR(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoInstrFfWrOffset))
507 #define REG_CRYPTO_AES_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoAesCtlOffset))
508 #define REG_CRYPTO_PR_RESULT(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoPrResultOffset))
509 #define REG_CRYPTO_TR_RESULT(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoTrResultOffset))
510 #define REG_CRYPTO_CRC_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoCrcCtlOffset))
511 #define REG_CRYPTO_CRC_DATA_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoCrcDataCtlOffset))
512 #define REG_CRYPTO_CRC_POL_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoCrcPolCtlOffset))
513 #define REG_CRYPTO_CRC_REM_CTL(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoCrcRemCtlOffset))
514 #define REG_CRYPTO_CRC_REM_RESULT(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoCrcRemResultOffset))
515 #define REG_CRYPTO_VU_CTL0(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoVuCtl0Offset))
516 #define REG_CRYPTO_VU_CTL1(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoVuCtl1Offset))
517 #define REG_CRYPTO_VU_STATUS(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoVuStatusOffset))
518 #define REG_CRYPTO_INTR(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoIntrOffset))
519 #define REG_CRYPTO_INTR_SET(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoIntrSetOffset))
520 #define REG_CRYPTO_INTR_MASK(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoIntrMaskOffset))
521 #define REG_CRYPTO_INTR_MASKED(base) (*(volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoIntrMaskedOffset))
522 #define REG_CRYPTO_VU_RF_DATA(base, reg) ( (volatile uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoVuRfDataOffset))[(reg)]
523 #define REG_CRYPTO_MEM_BUFF(base) ( (uint32_t*)((uint32_t)(base) + cy_cryptoIP->cryptoMemBufOffset))
524
525 #else
526
527 /* Use hardware specific model*/
528
529 #undef CY_CRYPTO_V1
530 #define CY_CRYPTO_V1 (1U == CY_IP_MXCRYPTO_VERSION) /* true if the mxcrypto version is 1 */
531
532 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
533 #define REG_CRYPTO_STATUS(base) (((CRYPTO_V1_Type*)(base))->STATUS)
534 #define REG_CRYPTO_INSTR_FF_CTL(base) (((CRYPTO_V1_Type*)(base))->INSTR_FF_CTL)
535 #define REG_CRYPTO_INSTR_FF_STATUS(base) (((CRYPTO_V1_Type*)(base))->INSTR_FF_STATUS)
536 #define REG_CRYPTO_INSTR_FF_WR(base) (((CRYPTO_V1_Type*)(base))->INSTR_FF_WR)
537 #define REG_CRYPTO_AES_CTL(base) (((CRYPTO_V1_Type*)(base))->AES_CTL)
538 #define REG_CRYPTO_PR_RESULT(base) (((CRYPTO_V1_Type*)(base))->PR_RESULT)
539 #define REG_CRYPTO_TR_RESULT(base) (((CRYPTO_V1_Type*)(base))->TR_RESULT)
540 #define REG_CRYPTO_CRC_CTL(base) (((CRYPTO_V1_Type*)(base))->CRC_CTL)
541 #define REG_CRYPTO_CRC_DATA_CTL(base) (((CRYPTO_V1_Type*)(base))->CRC_DATA_CTL)
542 #define REG_CRYPTO_CRC_POL_CTL(base) (((CRYPTO_V1_Type*)(base))->CRC_POL_CTL)
543 #define REG_CRYPTO_CRC_REM_CTL(base) (((CRYPTO_V1_Type*)(base))->CRC_REM_CTL)
544 #define REG_CRYPTO_CRC_REM_RESULT(base) (((CRYPTO_V1_Type*)(base))->CRC_REM_RESULT)
545 #define REG_CRYPTO_VU_CTL0(base) (((CRYPTO_V1_Type*)(base))->VU_CTL0)
546 #define REG_CRYPTO_VU_CTL1(base) (((CRYPTO_V1_Type*)(base))->VU_CTL1)
547 #define REG_CRYPTO_VU_STATUS(base) (((CRYPTO_V1_Type*)(base))->VU_STATUS)
548 #define REG_CRYPTO_INTR(base) (((CRYPTO_V1_Type*)(base))->INTR)
549 #define REG_CRYPTO_INTR_SET(base) (((CRYPTO_V1_Type*)(base))->INTR_SET)
550 #define REG_CRYPTO_INTR_MASK(base) (((CRYPTO_V1_Type*)(base))->INTR_MASK)
551 #define REG_CRYPTO_INTR_MASKED(base) (((CRYPTO_V1_Type*)(base))->INTR_MASKED)
552 #define REG_CRYPTO_VU_RF_DATA(base, reg) (((CRYPTO_V1_Type*)(base))->RF_DATA[(reg)])
553 #define REG_CRYPTO_MEM_BUFF(base) (uint32_t *)(&((CRYPTO_V1_Type*)(base))->MEM_BUFF)
554 #endif
555
556 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
557 #define REG_CRYPTO_STATUS(base) (((CRYPTO_V2_Type*)(base))->STATUS)
558 #define REG_CRYPTO_INSTR_FF_CTL(base) (((CRYPTO_V2_Type*)(base))->INSTR_FF_CTL)
559 #define REG_CRYPTO_INSTR_FF_STATUS(base) (((CRYPTO_V2_Type*)(base))->INSTR_FF_STATUS)
560 #define REG_CRYPTO_INSTR_FF_WR(base) (((CRYPTO_V2_Type*)(base))->INSTR_FF_WR)
561 #define REG_CRYPTO_AES_CTL(base) (((CRYPTO_V2_Type*)(base))->AES_CTL)
562 #define REG_CRYPTO_PR_RESULT(base) (((CRYPTO_V2_Type*)(base))->PR_RESULT)
563 #define REG_CRYPTO_TR_RESULT(base) (((CRYPTO_V2_Type*)(base))->TR_RESULT)
564 #define REG_CRYPTO_CRC_CTL(base) (((CRYPTO_V2_Type*)(base))->CRC_CTL)
565 #define REG_CRYPTO_CRC_DATA_CTL(base) (((CRYPTO_V2_Type*)(base))->CRC_DATA_CTL)
566 #define REG_CRYPTO_CRC_POL_CTL(base) (((CRYPTO_V2_Type*)(base))->CRC_POL_CTL)
567 #define REG_CRYPTO_CRC_REM_CTL(base) (((CRYPTO_V2_Type*)(base))->CRC_REM_CTL)
568 #define REG_CRYPTO_CRC_REM_RESULT(base) (((CRYPTO_V2_Type*)(base))->CRC_REM_RESULT)
569 #define REG_CRYPTO_VU_CTL0(base) (((CRYPTO_V2_Type*)(base))->VU_CTL0)
570 #define REG_CRYPTO_VU_CTL1(base) (((CRYPTO_V2_Type*)(base))->VU_CTL1)
571 #define REG_CRYPTO_VU_STATUS(base) (((CRYPTO_V2_Type*)(base))->VU_STATUS)
572 #define REG_CRYPTO_INTR(base) (((CRYPTO_V2_Type*)(base))->INTR)
573 #define REG_CRYPTO_INTR_SET(base) (((CRYPTO_V2_Type*)(base))->INTR_SET)
574 #define REG_CRYPTO_INTR_MASK(base) (((CRYPTO_V2_Type*)(base))->INTR_MASK)
575 #define REG_CRYPTO_INTR_MASKED(base) (((CRYPTO_V2_Type*)(base))->INTR_MASKED)
576 #define REG_CRYPTO_VU_RF_DATA(base, reg) (((CRYPTO_V2_Type*)(base))->VU_RF_DATA[(reg)])
577 #define REG_CRYPTO_MEM_BUFF(base) (uint32_t *)(&((CRYPTO_V2_Type*)(base))->MEM_BUFF)
578 #endif
579
580 #endif /* !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC) */
581
582 /* Old V1 registers in the regmap */
583 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
584 #define REG_CRYPTO_RAM_PWRUP_DELAY(base) (((CRYPTO_V1_Type*)(base))->RAM_PWRUP_DELAY)
585 #define REG_CRYPTO_STR_RESULT(base) (((CRYPTO_V1_Type*)(base))->STR_RESULT)
586 #define REG_CRYPTO_SHA_CTL(base) (((CRYPTO_V1_Type*)(base))->SHA_CTL)
587 #define REG_CRYPTO_CRC_LFSR_CTL(base) (((CRYPTO_V1_Type*)(base))->CRC_LFSR_CTL)
588 #endif
589
590 /* New V2 registers in the regmap */
591 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
592 #define REG_CRYPTO_RAM_PWR_CTL(base) (((CRYPTO_V2_Type*)(base))->RAM_PWR_CTL)
593 #define REG_CRYPTO_RAM_PWR_DELAY_CTL(base) (((CRYPTO_V2_Type*)(base))->RAM_PWR_DELAY_CTL)
594 #define REG_CRYPTO_ECC_CTL(base) (((CRYPTO_V2_Type*)(base))->ECC_CTL)
595 #define REG_CRYPTO_PR_MAX_CTL(base) (((CRYPTO_V2_Type*)(base))->PR_MAX_CTL)
596 #define REG_CRYPTO_PR_CMD(base) (((CRYPTO_V2_Type*)(base))->PR_CMD)
597 #define REG_CRYPTO_TR_CTL2(base) (((CRYPTO_V2_Type*)(base))->TR_CTL2)
598 #define REG_CRYPTO_TR_STATUS(base) (((CRYPTO_V2_Type*)(base))->TR_STATUS)
599 #define REG_CRYPTO_TR_CMD(base) (((CRYPTO_V2_Type*)(base))->TR_CMD)
600 #define REG_CRYPTO_LOAD0_FF_STATUS(base) (((CRYPTO_V2_Type*)(base))->LOAD0_FF_STATUS)
601 #define REG_CRYPTO_LOAD1_FF_STATUS(base) (((CRYPTO_V2_Type*)(base))->LOAD1_FF_STATUS)
602 #define REG_CRYPTO_STORE_FF_STATUS(base) (((CRYPTO_V2_Type*)(base))->STORE_FF_STATUS)
603 #define REG_CRYPTO_RESULT(base) (((CRYPTO_V2_Type*)(base))->RESULT)
604 #define REG_CRYPTO_VU_CTL2(base) (((CRYPTO_V2_Type*)(base))->VU_CTL2)
605 #define REG_CRYPTO_DEV_KEY_ADDR0_CTL(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_ADDR0_CTL)
606 #define REG_CRYPTO_DEV_KEY_ADDR0(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_ADDR0)
607 #define REG_CRYPTO_DEV_KEY_ADDR1_CTL(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_ADDR1_CTL)
608 #define REG_CRYPTO_DEV_KEY_ADDR1(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_ADDR1)
609 #define REG_CRYPTO_DEV_KEY_STATUS(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_STATUS)
610 #define REG_CRYPTO_DEV_KEY_CTL0(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_CTL0)
611 #define REG_CRYPTO_DEV_KEY_CTL1(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_CTL1)
612 #endif
613
614 /* The CRYPTO internal-memory buffer-size in 32-bit words. */
615 //#define CY_CRYPTO_MEM_BUFF_SIZE_U32 (cy_device->cryptoMemSize)
616 /* The CRYPTO internal-memory buffer-size in bytes. */
617 #define CY_CRYPTO_MEM_BUFF_SIZE (CY_CRYPTO_MEM_BUFF_SIZE_U32 * 4u)
618
619 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
620 /* Device Crypto IP descriptor type */
621 typedef struct
622 {
623 /* CRYPTO register offsets */
624 uint32_t cryptoStatusOffset;
625 uint32_t cryptoIstrFfCtlOffset;
626 uint32_t cryptoInstrFfStatusOffset;
627 uint32_t cryptoInstrFfWrOffset;
628 uint32_t cryptoVuRfDataOffset;
629 uint32_t cryptoAesCtlOffset;
630 uint32_t cryptoPrResultOffset;
631 uint32_t cryptoTrResultOffset;
632 uint32_t cryptoCrcCtlOffset;
633 uint32_t cryptoCrcDataCtlOffset;
634 uint32_t cryptoCrcPolCtlOffset;
635 uint32_t cryptoCrcRemCtlOffset;
636 uint32_t cryptoCrcRemResultOffset;
637 uint32_t cryptoVuCtl0Offset;
638 uint32_t cryptoVuCtl1Offset;
639 uint32_t cryptoVuStatusOffset;
640 uint32_t cryptoIntrOffset;
641 uint32_t cryptoIntrSetOffset;
642 uint32_t cryptoIntrMaskOffset;
643 uint32_t cryptoIntrMaskedOffset;
644 uint32_t cryptoMemBufOffset;
645 } cy_stc_cryptoIP_t;
646
647 /*******************************************************************************
648 * Global Variables
649 *******************************************************************************/
650 extern const cy_stc_cryptoIP_t cy_cryptoIpBlockCfgPSoC6_01;
651 extern const cy_stc_cryptoIP_t cy_cryptoIpBlockCfgPSoC6_02;
652 extern const cy_stc_cryptoIP_t *cy_cryptoIP;
653 #endif
654
655 #define CY_CRYPTO_REGFILE_R0 (0x00u)
656 #define CY_CRYPTO_REGFILE_R1 (0x01u)
657 #define CY_CRYPTO_REGFILE_R2 (0x02u)
658 #define CY_CRYPTO_REGFILE_R3 (0x03u)
659 #define CY_CRYPTO_REGFILE_R4 (0x04u)
660 #define CY_CRYPTO_REGFILE_R5 (0x05u)
661 #define CY_CRYPTO_REGFILE_R6 (0x06u)
662 #define CY_CRYPTO_REGFILE_R7 (0x07u)
663 #define CY_CRYPTO_REGFILE_R8 (0x08u)
664 #define CY_CRYPTO_REGFILE_R9 (0x09u)
665 #define CY_CRYPTO_REGFILE_R10 (0x0Au)
666 #define CY_CRYPTO_REGFILE_R11 (0x0Bu)
667 #define CY_CRYPTO_REGFILE_R12 (0x0Cu)
668 #define CY_CRYPTO_REGFILE_R13 (0x0Du)
669 #define CY_CRYPTO_REGFILE_R14 (0x0Eu)
670 #define CY_CRYPTO_REGFILE_R15 (0x0Fu)
671
672 #define CY_CRYPTO_RSRC0_SHIFT (0u)
673 #define CY_CRYPTO_RSRC4_SHIFT (4u)
674 #define CY_CRYPTO_RSRC8_SHIFT (8u)
675 #define CY_CRYPTO_RSRC12_SHIFT (12u)
676 #define CY_CRYPTO_RSRC13_SHIFT (13u)
677 #define CY_CRYPTO_RSRC16_SHIFT (16u)
678 #define CY_CRYPTO_RSRC20_SHIFT (20u)
679 #define CY_CRYPTO_RSRC23_SHIFT (23u)
680 #define CY_CRYPTO_RSRC26_SHIFT (26u)
681 #define CY_CRYPTO_RSRC30_SHIFT (30u)
682
683 #define CY_CRYPTO_OPCODE_POS (24u)
684
685 /* Define bit mask for all errors interrupt sources */
686 #define CY_CRYPTO_INTR_ERROR_MASK ((uint32_t)(CRYPTO_INTR_INSTR_OPC_ERROR_Msk | \
687 CRYPTO_INTR_INSTR_CC_ERROR_Msk | \
688 CRYPTO_INTR_BUS_ERROR_Msk | \
689 CRYPTO_INTR_TR_AP_DETECT_ERROR_Msk | \
690 CRYPTO_INTR_TR_RC_DETECT_ERROR_Msk))
691
692 /* Define bit mask for all errors interrupt sources for interrupt setting register */
693 #define CY_CRYPTO_INTR_SET_ERROR_MASK ((uint32_t)(CRYPTO_INTR_SET_INSTR_OPC_ERROR_Msk | \
694 CRYPTO_INTR_SET_INSTR_CC_ERROR_Msk | \
695 CRYPTO_INTR_SET_BUS_ERROR_Msk | \
696 CRYPTO_INTR_SET_TR_AP_DETECT_ERROR_Msk | \
697 CRYPTO_INTR_SET_TR_RC_DETECT_ERROR_Msk))
698
699 /* Define bit mask for all errors interrupt sources for interrupt masking register */
700 #define CY_CRYPTO_INTR_MASK_ERROR_MASK ((uint32_t)(CRYPTO_INTR_MASK_INSTR_OPC_ERROR_Msk | \
701 CRYPTO_INTR_MASK_INSTR_CC_ERROR_Msk | \
702 CRYPTO_INTR_MASK_BUS_ERROR_Msk | \
703 CRYPTO_INTR_MASK_TR_AP_DETECT_ERROR_Msk | \
704 CRYPTO_INTR_MASK_TR_RC_DETECT_ERROR_Msk))
705
706 /* Define bit mask for all errors interrupt sources for interrupt masked sources check */
707 #define CY_CRYPTO_INTR_MASKED_ERROR_MASK ((uint32_t)(CRYPTO_INTR_MASKED_INSTR_OPC_ERROR_Msk | \
708 CRYPTO_INTR_MASKED_INSTR_CC_ERROR_Msk | \
709 CRYPTO_INTR_MASKED_BUS_ERROR_Msk | \
710 CRYPTO_INTR_MASKED_TR_AP_DETECT_ERROR_Msk | \
711 CRYPTO_INTR_MASKED_TR_RC_DETECT_ERROR_Msk))
712
713 #define CY_CRYPTO_INSTR_FIFODEPTH (8u)
714 #define CY_CRYPTO_V1_DATA_FIFODEPTH (8u)
715 #define CY_CRYPTO_V2_DATA_FIFODEPTH (16u)
716
717 #define CY_CRYPTO_INSTR_SINGLE (1u)
718 #define CY_CRYPTO_INSTR_DOUBLE (2u)
719 #define CY_CRYPTO_INSTR_TRIPLE (3u)
720
721 #define CY_CRYPTO_MIN(a,b) (((a) < (b)) ? (a) : (b))
722 #define CY_CRYPTO_MAX(a,b) (((a) > (b)) ? (a) : (b))
723
724 typedef enum
725 {
726 CY_CRYPTO_CTL_ENABLED_DISABLED = 0u,
727 CY_CRYPTO_CTL_ENABLED_ENABLED = 1u,
728 } cy_en_crypto_hw_enable_t;
729
730 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
731 __STATIC_INLINE void Cy_Crypto_Core_HwInit(void);
732 #endif
733
734 void Cy_Crypto_Core_ClearVuRegisters(CRYPTO_Type *base);
735 void Cy_Crypto_Core_Vu_RunInstr(CRYPTO_Type *base, bool blockingMode, uint32_t instr, uint32_t params);
736
737 /** \endcond */
738
739
740 /**
741 * \addtogroup group_crypto_lld_hw_functions
742 * \{
743 */
744
745 cy_en_crypto_status_t Cy_Crypto_Core_Enable(CRYPTO_Type *base);
746
747 cy_en_crypto_status_t Cy_Crypto_Core_Disable(CRYPTO_Type *base);
748
749 cy_en_crypto_status_t Cy_Crypto_Core_Cleanup(CRYPTO_Type *base);
750
751 cy_en_crypto_status_t Cy_Crypto_Core_Shutdown(CRYPTO_Type *base);
752
753 cy_en_crypto_status_t Cy_Crypto_Core_GetLibInfo(cy_en_crypto_lib_info_t *libInfo);
754
755 cy_en_crypto_status_t Cy_Crypto_Core_SetVuMemoryAddress(CRYPTO_Type *base, uint32_t const *vuMemoryAddr, uint32_t vuMemorySize);
756
757 __STATIC_INLINE uint32_t * Cy_Crypto_Core_GetVuMemoryAddress(CRYPTO_Type *base);
758
759 uint32_t Cy_Crypto_Core_GetVuMemorySize(CRYPTO_Type *base);
760
761 void Cy_Crypto_Core_InvertEndianness(void *inArrPtr, uint32_t byteSize);
762
763 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
764 /*******************************************************************************
765 * Function Name: Cy_Crypto_Core_HwInit
766 ****************************************************************************//**
767 *
768 * The function to initialize the Crypto hardware.
769 *
770 * This function is for internal use.
771 *
772 *******************************************************************************/
Cy_Crypto_Core_HwInit(void)773 __STATIC_INLINE void Cy_Crypto_Core_HwInit(void)
774 {
775 cy_cryptoIP = (CY_CRYPTO_V1) ? &cy_cryptoIpBlockCfgPSoC6_01 : &cy_cryptoIpBlockCfgPSoC6_02;
776 }
777 #endif
778
779 /*******************************************************************************
780 * Function Name: Cy_Crypto_Core_IsEnabled
781 ****************************************************************************//**
782 *
783 * The function checks whether the Crypto hardware is enabled.
784 *
785 * \param base
786 * The pointer to the CRYPTO instance.
787 *
788 * \return
789 * Crypto status \ref cy_en_crypto_status_t
790 *
791 * \funcusage
792 * \snippet crypto/snippet/main.c snippet_myCryptoCoreStopCryptoUse
793 *
794 *******************************************************************************/
Cy_Crypto_Core_IsEnabled(CRYPTO_Type * base)795 __STATIC_INLINE bool Cy_Crypto_Core_IsEnabled(CRYPTO_Type *base)
796 {
797 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
798 if (cy_cryptoIP == NULL)
799 {
800 Cy_Crypto_Core_HwInit();
801 }
802 #endif
803
804 return (1uL == (uint32_t)_FLD2VAL(CRYPTO_CTL_ENABLED, REG_CRYPTO_CTL(base)));
805 }
806
807 /*******************************************************************************
808 * Function Name: Cy_Crypto_Core_GetFIFODepth
809 ****************************************************************************//**
810 *
811 * Returns the total available number of instructions in the instruction FIFO.
812 *
813 * \param base
814 * The pointer to the CRYPTO instance.
815 *
816 *******************************************************************************/
Cy_Crypto_Core_GetFIFODepth(CRYPTO_Type * base)817 __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFODepth(CRYPTO_Type *base)
818 {
819 (void)base; /* Suppress warning */
820 return (CY_CRYPTO_INSTR_FIFODEPTH);
821 }
822
823 /*******************************************************************************
824 * Function Name: Cy_Crypto_Core_GetFIFOUsed
825 ****************************************************************************//**
826 *
827 * Returns the number of instructions in the instruction FIFO.
828 * The value of this field ranges from 0 to 8
829 *
830 * \param base
831 * The pointer to the CRYPTO instance.
832 *
833 *******************************************************************************/
Cy_Crypto_Core_GetFIFOUsed(CRYPTO_Type * base)834 __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFOUsed(CRYPTO_Type *base)
835 {
836 return((uint8_t)_FLD2VAL(CRYPTO_INSTR_FF_STATUS_USED, REG_CRYPTO_INSTR_FF_STATUS(base)));
837 }
838
839 /*******************************************************************************
840 * Function Name: Cy_Crypto_Core_WaitForInstrFifoAvailable
841 *****************************************************************************//**
842 *
843 * Waits until number of entries in the instruction FIFO is less than
844 * specified number.
845 *
846 * \param base
847 * The pointer to the CRYPTO instance.
848 *
849 * \param instr
850 * The number of needed available space in the instruction FIFO.
851 *
852 *******************************************************************************/
Cy_Crypto_Core_WaitForInstrFifoAvailable(CRYPTO_Type * base,uint32_t instr)853 __STATIC_INLINE void Cy_Crypto_Core_WaitForInstrFifoAvailable(CRYPTO_Type *base, uint32_t instr)
854 {
855 while((uint32_t)(_FLD2VAL(CRYPTO_INSTR_FF_STATUS_USED, REG_CRYPTO_INSTR_FF_STATUS(base))) >= (CY_CRYPTO_INSTR_FIFODEPTH - instr))
856 {
857 }
858 }
859
860 /*******************************************************************************
861 * Function Name: Cy_Crypto_Core_WaitForFifoAvailable
862 *****************************************************************************//**
863 *
864 * Waits until number of entries in the instruction FIFO is less than
865 * specified in EVENT_LEVEL field in FF_CTL register, an event is generated:
866 * "event" = INSTR_FF_STATUS.USED < EVENT_LEVEL.
867 * By default EVENT_LEVEL = 0;
868 *
869 * \param base
870 * The pointer to the CRYPTO instance.
871 *
872 *******************************************************************************/
Cy_Crypto_Core_WaitForFifoAvailable(CRYPTO_Type * base)873 __STATIC_INLINE void Cy_Crypto_Core_WaitForFifoAvailable(CRYPTO_Type *base)
874 {
875 while((_FLD2VAL(CRYPTO_INSTR_FF_STATUS_EVENT, REG_CRYPTO_INSTR_FF_STATUS(base))) == 0u)
876 {
877 }
878 }
879
880 /*******************************************************************************
881 * Function Name: Cy_Crypto_Core_WaitForReady
882 *****************************************************************************//**
883 *
884 * Waits until all instruction in FIFO will be completed
885 *
886 * \param base
887 * The pointer to the CRYPTO instance.
888 *
889 *******************************************************************************/
Cy_Crypto_Core_WaitForReady(CRYPTO_Type * base)890 __STATIC_INLINE void Cy_Crypto_Core_WaitForReady(CRYPTO_Type *base)
891 {
892 while(REG_CRYPTO_STATUS(base) != 0u)
893 {
894 }
895 }
896
897 /*******************************************************************************
898 * Function Name: Cy_Crypto_Wait_Vu_ForComplete
899 ****************************************************************************//**
900 *
901 * Waits until VU instruction will be completed
902 *
903 * \param base
904 * The pointer to the CRYPTO instance.
905 *
906 *******************************************************************************/
Cy_Crypto_Core_Vu_WaitForComplete(CRYPTO_Type * base)907 __STATIC_INLINE void Cy_Crypto_Core_Vu_WaitForComplete(CRYPTO_Type *base)
908 {
909 /* Wait until the VU instruction is complete */
910 if (CY_CRYPTO_V1)
911 {
912 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
913 while (0uL != _FLD2VAL(CRYPTO_STATUS_VU_BUSY, REG_CRYPTO_STATUS(base)))
914 {
915 }
916 #endif
917 }
918 else
919 {
920 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
921 while (0uL != REG_CRYPTO_STATUS(base))
922 {
923 }
924 #endif
925 }
926 }
927
928 /******************************************************************************
929 * Function Name: Cy_Crypto_Core_SetInterruptMask
930 ***************************************************************************//**
931 *
932 * Masks / unmasks multiple interrupt sources.
933 *
934 * \param base
935 * The pointer to the CRYPTO instance.
936 *
937 * \param interrupts
938 * Mask bits. See definitions above.
939 *
940 ******************************************************************************/
Cy_Crypto_Core_SetInterruptMask(CRYPTO_Type * base,uint32_t interrupts)941 __STATIC_INLINE void Cy_Crypto_Core_SetInterruptMask(CRYPTO_Type *base, uint32_t interrupts)
942 {
943 REG_CRYPTO_INTR_MASK(base) = interrupts;
944 }
945
946 /******************************************************************************
947 * Function Name: Cy_Crypto_Core_GetInterruptMask
948 ***************************************************************************//**
949 *
950 * Reports mask / unmask multiple interrupt sources.
951 *
952 * \param base
953 * The pointer to the CRYPTO instance.
954 *
955 * \return
956 * Mask bits. See definitions above.
957 *
958 ******************************************************************************/
Cy_Crypto_Core_GetInterruptMask(CRYPTO_Type const * base)959 __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptMask(CRYPTO_Type const *base)
960 {
961 return (REG_CRYPTO_INTR_MASK(base));
962 }
963
964 /******************************************************************************
965 * Function Name: Cy_Crypto_Core_GetInterruptStatusMasked
966 ***************************************************************************//**
967 *
968 * Reports states of multiple enabled interrupt sources.
969 *
970 * \param base
971 * The pointer to the CRYPTO instance.
972 *
973 * \return
974 * Source bits. See definitions above.
975 *
976 *****************************************************************************/
Cy_Crypto_Core_GetInterruptStatusMasked(CRYPTO_Type const * base)977 __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptStatusMasked(CRYPTO_Type const *base)
978 {
979 return (REG_CRYPTO_INTR_MASKED(base));
980 }
981
982 /******************************************************************************
983 * Function Name: Cy_Crypto_Core_GetInterruptStatus
984 ***************************************************************************//**
985 *
986 * Reports states of multiple interrupt sources.
987 *
988 * \param base
989 * The pointer to the CRYPTO instance.
990 *
991 * \return
992 * Source bits. See definitions above.
993 *
994 ******************************************************************************/
Cy_Crypto_Core_GetInterruptStatus(CRYPTO_Type * base)995 __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptStatus(CRYPTO_Type *base)
996 {
997 return (REG_CRYPTO_INTR(base));
998 }
999
1000 /******************************************************************************
1001 * Function Name: Cy_Crypto_Core_SetInterrupt
1002 ***************************************************************************//**
1003 *
1004 * Sets one of more interrupt sources
1005 *
1006 * \param base
1007 * The pointer to the CRYPTO instance.
1008 *
1009 * \param interrupts
1010 * Source bit(s)
1011 *
1012 ******************************************************************************/
Cy_Crypto_Core_SetInterrupt(CRYPTO_Type * base,uint32_t interrupts)1013 __STATIC_INLINE void Cy_Crypto_Core_SetInterrupt(CRYPTO_Type *base, uint32_t interrupts)
1014 {
1015 REG_CRYPTO_INTR_SET(base) = interrupts;
1016 }
1017
1018 /******************************************************************************
1019 * Function Name: Cy_Crypto_Core_ClearInterrupt
1020 ***************************************************************************//**
1021 *
1022 * Clears multiple interrupt sources.
1023 *
1024 * \param base
1025 * The pointer to the CRYPTO instance.
1026 *
1027 * \param interrupts
1028 * Source bit(s). See definitions above.
1029 *
1030 ******************************************************************************/
Cy_Crypto_Core_ClearInterrupt(CRYPTO_Type * base,uint32_t interrupts)1031 __STATIC_INLINE void Cy_Crypto_Core_ClearInterrupt(CRYPTO_Type *base, uint32_t interrupts)
1032 {
1033 REG_CRYPTO_INTR(base) = interrupts;
1034 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
1035 (void) REG_CRYPTO_INTR(base);
1036 }
1037
1038 /*******************************************************************************
1039 * Function Name: Cy_Crypto_Core_GetVuMemoryAddress
1040 ****************************************************************************//**
1041 *
1042 * Gets Crypto memory buffer address
1043 *
1044 * \param base
1045 * The pointer to the CRYPTO instance.
1046 *
1047 * \return
1048 * Current Crypto MEM_BUFF location address or NULL if Crypto IP is not enabled.
1049 *
1050 *******************************************************************************/
Cy_Crypto_Core_GetVuMemoryAddress(CRYPTO_Type * base)1051 __STATIC_INLINE uint32_t * Cy_Crypto_Core_GetVuMemoryAddress(CRYPTO_Type *base)
1052 {
1053 #if !defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
1054 return (cy_cryptoIP != NULL) ? (uint32_t *)REG_CRYPTO_VU_CTL1(base) : (uint32_t *)NULL;
1055 #else
1056 return (uint32_t *)REG_CRYPTO_VU_CTL1(base);
1057 #endif
1058 }
1059
1060 /** \} group_crypto_lld_hw_functions */
1061
1062 CY_MISRA_BLOCK_END('MISRA C-2012 Rule 20.5')
1063
1064 #if defined(__cplusplus)
1065 }
1066 #endif
1067
1068 #endif /* CY_IP_MXCRYPTO */
1069
1070 #endif /* #if !defined (CY_CRYPTO_CORE_HW_H) */
1071
1072
1073 /* [] END OF FILE */
1074