1 /*
2 * Copyright 2019-2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #ifndef _FSL_XRDC2_H_
9 #define _FSL_XRDC2_H_
10
11 #include "fsl_common.h"
12
13 /*!
14 * @addtogroup xrdc2
15 * @{
16 */
17
18 /******************************************************************************
19 * Definitions
20 *****************************************************************************/
21 /*! @brief Driver version. */
22 #define FSL_XRDC2_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
23
24 /* Definitions for XRDC2 Exclusive access lock. */
25 #define XRDC2_EAL_FORCE_RELEASE_MAGIC_0 0x02000046UL
26 #define XRDC2_EAL_FORCE_RELEASE_MAGIC_1 0x02000052UL
27
28 #define XRDC2_EAL_DISABLE (0UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
29 #define XRDC2_EAL_DISABLE_UNTIL_RESET (1UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
30 #define XRDC2_EAL_UNLOCKED (2UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
31 #define XRDC2_EAL_LOCKED (3UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
32
33 #define XRDC2_EAL_MASK XRDC2_MSC_MSAC_W1_EAL_MASK
34
35 /*!
36 * @brief Global configuration lock.
37 */
38 typedef enum _xrdc2_global_config_lock
39 {
40 kXRDC2_GlobalConfigLockDisabled, /*!< Lock disabled, registers can be written by any domain. */
41 kXRDC2_GlobalConfigLockDisabledUntilReset, /*!< Lock disabled until the next reset. */
42 kXRDC2_GlobalConfigLockOwnerOnly, /*!< Lock enabled, only the lock owner can write. */
43 kXRDC2_GlobalConfigLockEnabledUntilReset /*!< Lock enabled, all registers are read only until the next reset. */
44 } xrdc2_global_config_lock_t;
45
46 /*!
47 * @brief XRDC2 secure attribute, the register bit MDACi_MDAj_W0[SA],
48 * secure/nonsecure attribute output on a hit.
49 */
50 typedef enum _xrdc2_secure_attr
51 {
52 kXRDC2_MasterSecure = 0, /*!< Use the bus master's secure/nonsecure attribute directly. */
53 kXRDC2_ForceSecure = 2, /*!< Force the bus attribute for this master to secure. */
54 kXRDC2_ForceNonSecure = 3, /*!< Force the bus attribute for this master to non-secure. */
55 } xrdc2_secure_attr_t;
56
57 /*!
58 * @brief XRDC2 privileged attribute, the register bit MDACi_MDAj_W0[PA],
59 * defines the privileged/user attribute on a hit.
60 */
61 typedef enum _xrdc2_privilege_attr
62 {
63 kXRDC2_MasterPrivilege = 0, /*!< Use the bus master's attribute directly. */
64 kXRDC2_ForceUser = 2, /*!< Force the bus attribute for this master to user. */
65 kXRDC2_ForcePrivilege = 3, /*!< Force the bus attribute for this master to privileged. */
66 } xrdc2_privilege_attr_t;
67
68 /*!
69 * @brief Domain assignment for the bus master.
70 *
71 * XRDC2 compares the bus master @e match @e input with the parameter @ref mask
72 * and @ref match in this structure. If hit, the domain ID, privilege attribute,
73 * and secure attribute are used for the access.
74 */
75 typedef struct _xrdc2_master_domain_assignment
76 {
77 bool lock; /*!< Set true to lock the descriptor. */
78 xrdc2_privilege_attr_t privilegeAttr; /*!< Privilege attribute. */
79 xrdc2_secure_attr_t secureAttr; /*!< Secure attribute. */
80 uint8_t domainId; /*!< Domain ID used when this descriptor hit. */
81 uint16_t mask; /*!< Mask used for descriptor hit. */
82 uint16_t match; /*!< Match used for descriptor hit. */
83 } xrdc2_master_domain_assignment_t;
84
85 /*!
86 * @brief XRDC2 domain access control policy.
87 */
88 typedef enum _xrdc2_access_policy
89 {
90 /* policy SecurePriv SecureUser NonSecurePriv NonSecureUsr */
91 kXRDC2_AccessPolicyNone = 0U, /* 000 none none none none */
92 kXRDC2_AccessPolicyAlt1 = 1U, /* 001 r r none none */
93 kXRDC2_AccessPolicyAlt2 = 2U, /* 010 r,w none none none */
94 kXRDC2_AccessPolicyAlt3 = 3U, /* 011 r,w r,w none none */
95 kXRDC2_AccessPolicyAlt4 = 4U, /* 100 r,w r,w r none */
96 kXRDC2_AccessPolicyAlt5 = 5U, /* 101 r,w r,w r r */
97 kXRDC2_AccessPolicyAlt6 = 6U, /* 110 r,w r,w r,w none */
98 kXRDC2_AccessPolicyAll = 7U /* 111 r,w r,w r,w r,w */
99 } xrdc2_access_policy_t;
100
101 /*!
102 * @brief Access configuration lock mode, the register field PDAC and MRGD LK2.
103 */
104 typedef enum _xrdc2_access_config_lock
105 {
106 kXRDC2_AccessConfigLockDisabled = 0U, /*!< Entire PDACn/MRGDn/MSC can be written. */
107 kXRDC2_AccessConfigLockDisabledUntilReset = 1U, /*!< Entire PDACn/MRGDn/MSC can be written until next reset. */
108 kXRDC2_AccessConfigLockDomainXOnly = 2U, /*!< Domain x only write the DxACP field. */
109 kXRDC2_AccessConfigLockEnabledUntilReset = 3U /*!< PDACn/MRGDn/MSC is read-only until the next reset. */
110 } xrdc2_access_config_lock_t;
111
112 /*!
113 * @brief XRDC2 peripheral domain access control configuration.
114 */
115 typedef struct _xrdc2_periph_access_config
116 {
117 xrdc2_access_config_lock_t lockMode; /*!< PDACn lock configuration. */
118 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
119 } xrdc2_periph_access_config_t;
120
121 /*!
122 * @brief XRDC2 memory region domain access control configuration.
123 */
124 typedef struct _xrdc2_mem_access_config
125 {
126 uint32_t startAddr; /*!< Memory region start address, should be 4k aligned. */
127 uint32_t endAddr; /*!< Memory region end address, (endAddr + 1) should be 4k aligned. */
128 xrdc2_access_config_lock_t lockMode; /*!< MRGDn lock configuration. */
129 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
130 } xrdc2_mem_access_config_t;
131
132 /*!
133 * @brief XRDC2 memory slot domain access control configuration.
134 */
135 typedef struct _xrdc2_mem_slot_access_config
136 {
137 xrdc2_access_config_lock_t lockMode; /*!< Descriptor lock configuration. */
138 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
139 } xrdc2_mem_slot_access_config_t;
140
141 /*******************************************************************************
142 * API
143 ******************************************************************************/
144
145 #if defined(__cplusplus)
146 extern "C" {
147 #endif
148
149 /*!
150 * @brief Initializes the XRDC2 module.
151 *
152 * @param base XRDC2 peripheral base address.
153 */
154 void XRDC2_Init(XRDC2_Type *base);
155
156 /*!
157 * @brief De-initializes the XRDC2 module.
158 *
159 * @param base XRDC2 peripheral base address.
160 */
161 void XRDC2_Deinit(XRDC2_Type *base);
162
163 /*!
164 * @name XRDC2 manager (XRDC2)
165 * @{
166 */
167
168 /*!
169 * @brief Sets the XRDC2 global valid.
170 *
171 * This function sets the XRDC2 global valid or invalid. When the XRDC2 is global
172 * invalid, all accesses from all bus masters to all slaves are allowed.
173 *
174 * @param base XRDC2 peripheral base address.
175 * @param valid True to valid XRDC2.
176 */
177 void XRDC2_SetGlobalValid(XRDC2_Type *base, bool valid);
178
179 /*!
180 * @brief Gets the domain ID of the current bus master.
181 *
182 * This function returns the domain ID of the current bus master.
183 *
184 * @param base XRDC2 peripheral base address.
185 * @return Domain ID of current bus master.
186 */
XRDC2_GetCurrentMasterDomainId(XRDC2_Type * base)187 static inline uint8_t XRDC2_GetCurrentMasterDomainId(XRDC2_Type *base)
188 {
189 #if defined(XRDC2_SR_DIN_MASK)
190 return (uint8_t)((base->SR & XRDC2_SR_DIN_MASK) >> XRDC2_SR_DIN_SHIFT);
191 #else
192 return (uint8_t)((base->SR & XRDC2_SR_DID_MASK) >> XRDC2_SR_DID_SHIFT);
193 #endif
194 }
195
196 /*!
197 * @brief Set the global configuration lock mode.
198 *
199 * Once change the lock mode, it could not be changed until next reset.
200 *
201 * @param base XRDC2 peripheral base address.
202 * @param mode The lock mode.
203 */
XRDC2_SetGlobalConfigLock(XRDC2_Type * base,xrdc2_global_config_lock_t mode)204 static inline void XRDC2_SetGlobalConfigLock(XRDC2_Type *base, xrdc2_global_config_lock_t mode)
205 {
206 base->MCR = (base->MCR & ~XRDC2_MCR_GCL_MASK) | XRDC2_MCR_GCL(mode);
207 }
208
209 /*!
210 * @brief Gets the domain ID of global configuration lock owner.
211 *
212 * @param base XRDC2 peripheral base address.
213 * @return Domain ID of the global configuration lock owner.
214 */
XRDC2_GetCurrentGlobalConfigLockOwnerDomainId(XRDC2_Type * base)215 static inline uint8_t XRDC2_GetCurrentGlobalConfigLockOwnerDomainId(XRDC2_Type *base)
216 {
217 return (uint8_t)((base->SR & XRDC2_SR_GCLO_MASK) >> XRDC2_SR_GCLO_SHIFT);
218 }
219
220 /*@}*/
221
222 /*!
223 * @name XRDC2 Master Domain Assignment Controller (XRDC2_MDAC).
224 * @{
225 */
226
227 /*!
228 * @brief Gets the default master domain assignment.
229 *
230 * This function sets the assignment as follows:
231 *
232 * @code
233 * config->lock = false;
234 * config->privilegeAttr = kXRDC2_MasterPrivilege;
235 * config->secureAttr = kXRDC2_MasterSecure;
236 * config->domainId = 0U;
237 * config->mask = 0U;
238 * config->match = 0U;
239 * @endcode
240 *
241 * @param assignment Pointer to the assignment structure.
242 */
243 void XRDC2_GetDefaultMasterDomainAssignment(xrdc2_master_domain_assignment_t *assignment);
244
245 /*!
246 * @brief Sets the processor bus master domain assignment.
247 *
248 * @param base XRDC2 peripheral base address.
249 * @param master Which master to configure.
250 * @param assignIndex Which assignment register to set.
251 * @param assignment Pointer to the assignment structure.
252 */
253 void XRDC2_SetMasterDomainAssignment(XRDC2_Type *base,
254 xrdc2_master_t master,
255 uint8_t assignIndex,
256 const xrdc2_master_domain_assignment_t *assignment);
257
258 /*!
259 * @brief Locks the bus master domain assignment register.
260 *
261 * This function locks the master domain assignment. One bus master might have
262 * multiple domain assignment registers. The parameter \p assignIndex specifies
263 * which assignment register to lock. After it is locked, the register can't be changed
264 * until next reset.
265 *
266 * @param base XRDC2 peripheral base address.
267 * @param master Which master to configure.
268 * @param assignIndex Which assignment register to lock.
269 */
XRDC2_LockMasterDomainAssignment(XRDC2_Type * base,xrdc2_master_t master,uint8_t assignIndex)270 static inline void XRDC2_LockMasterDomainAssignment(XRDC2_Type *base, xrdc2_master_t master, uint8_t assignIndex)
271 {
272 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_DL_MASK;
273 }
274
275 /*!
276 * @brief Sets the master domain assignment as valid or invalid.
277 *
278 * This function sets the master domain assignment as valid or invalid. One bus master might have
279 * multiple domain assignment registers. The parameter \p assignIndex specifies
280 * which assignment register to configure.
281 *
282 * @param base XRDC2 peripheral base address.
283 * @param master Which master to configure.
284 * @param assignIndex Index for the domain assignment register.
285 * @param valid True to set valid, false to set invalid.
286 */
XRDC2_SetMasterDomainAssignmentValid(XRDC2_Type * base,xrdc2_master_t master,uint8_t assignIndex,bool valid)287 static inline void XRDC2_SetMasterDomainAssignmentValid(XRDC2_Type *base,
288 xrdc2_master_t master,
289 uint8_t assignIndex,
290 bool valid)
291 {
292 if (valid)
293 {
294 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_VLD_MASK;
295 }
296 else
297 {
298 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 &= ~XRDC2_MDAC_MDA_W1_VLD_MASK;
299 }
300 }
301
302 /*@}*/
303
304 /*!
305 * @name XRDC2 Memory Slot Access Controller (XRDC2_MSC).
306 * @{
307 */
308
309 /*!
310 * @brief Gets the default memory slot access configuration.
311 *
312 * This function sets the assignment as follows:
313 *
314 * @code
315 * config->lockMode = kXRDC2_AccessConfigLockDisabled;
316 * config->policy[0] = kXRDC2_AccessPolicyNone;
317 * config->policy[1] = kXRDC2_AccessPolicyNone;
318 * ...
319 * @endcode
320 *
321 * @param config Pointer to the configuration.
322 */
323 void XRDC2_GetMemSlotAccessDefaultConfig(xrdc2_mem_slot_access_config_t *config);
324
325 /*!
326 * @brief Sets the memory slot access policy.
327 *
328 * @param base XRDC2 peripheral base address.
329 * @param memSlot Which memory slot descriptor to set.
330 * @param config Pointer to the access policy configuration structure.
331 */
332 void XRDC2_SetMemSlotAccessConfig(XRDC2_Type *base,
333 xrdc2_mem_slot_t memSlot,
334 const xrdc2_mem_slot_access_config_t *config);
335
336 /*!
337 * @brief Sets the memory slot descriptor as valid or invalid.
338 *
339 * @param base XRDC2 peripheral base address.
340 * @param memSlot Which memory slot descriptor to set.
341 * @param valid True to set valid, false to set invalid.
342 */
343 void XRDC2_SetMemSlotAccessValid(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool valid);
344
345 /*!
346 * @brief Sets the memory slot descriptor lock mode.
347 *
348 * @param base XRDC2 peripheral base address.
349 * @param memSlot Which memory slot descriptor to set.
350 * @param lockMode The lock mode to set.
351 */
352 void XRDC2_SetMemSlotAccessLockMode(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, xrdc2_access_config_lock_t lockMode);
353
354 /*!
355 * @brief Sets the memory slot access policy for specific domain.
356 *
357 * @param base XRDC2 peripheral base address.
358 * @param memSlot The memory slot to operate.
359 * @param domainId The ID of the domain whose policy will be changed.
360 * @param policy The access policy to set.
361 */
362 void XRDC2_SetMemSlotDomainAccessPolicy(XRDC2_Type *base,
363 xrdc2_mem_slot_t memSlot,
364 uint8_t domainId,
365 xrdc2_access_policy_t policy);
366
367 /*!
368 * @brief Enable or disable the memory slot exclusive access lock.
369 *
370 * The lock must be enabled first before use. Once disabled, it could not be
371 * enabled until reset.
372 *
373 * @param base XRDC2 peripheral base address.
374 * @param memSlot The memory slot to operate.
375 * @param enable True to enable, false to disable.
376 */
377 void XRDC2_EnableMemSlotExclAccessLock(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool enable);
378
379 /*!
380 * @brief Get current memory slot exclusive access lock owner.
381 *
382 * @param base XRDC2 peripheral base address.
383 * @param memSlot The memory slot to operate.
384 * @return The domain ID of the lock owner.
385 */
386 uint8_t XRDC2_GetMemSlotExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
387
388 /*!
389 * @brief Try to lock the memory slot exclusive access.
390 *
391 * @param base XRDC2 peripheral base address.
392 * @param memSlot The memory slot to operate.
393 * @retval kStatus_Fail Failed to lock.
394 * @retval kStatus_Success Locked succussfully.
395 */
396 status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
397
398 /*!
399 * @brief Lock the memory slot exclusive access using blocking method.
400 *
401 * @param base XRDC2 peripheral base address.
402 * @param memSlot The memory slot to operate.
403 *
404 * @note This function must be called when the lock is not disabled.
405 */
406 void XRDC2_LockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
407
408 /*!
409 * @brief Unlock the memory slot exclusive access.
410 *
411 * @param base XRDC2 peripheral base address.
412 * @param memSlot The memory slot to operate.
413 *
414 * @note This function must be called by the lock owner.
415 */
XRDC2_UnlockMemSlotExclAccess(XRDC2_Type * base,xrdc2_mem_slot_t memSlot)416 static inline void XRDC2_UnlockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
417 {
418 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_UNLOCKED;
419 }
420
421 /*!
422 * @brief Force the memory slot exclusive access lock release.
423 *
424 * The master does not own the lock could call this function to force release the lock.
425 *
426 * @param base XRDC2 peripheral base address.
427 * @param memSlot The memory slot to operate.
428 */
XRDC2_ForceMemSlotExclAccessLockRelease(XRDC2_Type * base,xrdc2_mem_slot_t memSlot)429 static inline void XRDC2_ForceMemSlotExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
430 {
431 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_0;
432 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_1;
433 }
434
435 /*@}*/
436
437 /*!
438 * @name XRDC2 Memory Region Controller (XRDC2_MRC)
439 * @{
440 */
441
442 /*!
443 * @brief Gets the default memory access configuration.
444 *
445 * This function sets the assignment as follows:
446 *
447 * @code
448 * config->startAddr = 0U;
449 * config->endAddr = 0xFFFFFFFFU;
450 * config->lockMode = kXRDC2_AccessConfigLockDisabled;
451 * config->policy[0] = kXRDC2_AccessPolicyNone;
452 * config->policy[1] = kXRDC2_AccessPolicyNone;
453 * ...
454 * @endcode
455 *
456 * @param config Pointer to the configuration.
457 */
458 void XRDC2_GetMemAccessDefaultConfig(xrdc2_mem_access_config_t *config);
459
460 /*!
461 * @brief Sets the memory region access policy.
462 *
463 * @param base XRDC2 peripheral base address.
464 * @param mem Which memory region descriptor to set.
465 * @param config Pointer to the access policy configuration structure.
466 */
467 void XRDC2_SetMemAccessConfig(XRDC2_Type *base, xrdc2_mem_t mem, const xrdc2_mem_access_config_t *config);
468
469 /*!
470 * @brief Sets the memory region descriptor as valid or invalid.
471 *
472 * @param base XRDC2 peripheral base address.
473 * @param mem Which memory region descriptor to set.
474 * @param valid True to set valid, false to set invalid.
475 */
476 void XRDC2_SetMemAccessValid(XRDC2_Type *base, xrdc2_mem_t mem, bool valid);
477
478 /*!
479 * @brief Sets the memory descriptor lock mode.
480 *
481 * @param base XRDC2 peripheral base address.
482 * @param mem Which memory descriptor to set.
483 * @param lockMode The lock mode to set.
484 */
485 void XRDC2_SetMemAccessLockMode(XRDC2_Type *base, xrdc2_mem_t mem, xrdc2_access_config_lock_t lockMode);
486
487 /*!
488 * @brief Sets the memory region access policy for specific domain.
489 *
490 * @param base XRDC2 peripheral base address.
491 * @param mem The memory region to operate.
492 * @param domainId The ID of the domain whose policy will be changed.
493 * @param policy The access policy to set.
494 */
495 void XRDC2_SetMemDomainAccessPolicy(XRDC2_Type *base, xrdc2_mem_t mem, uint8_t domainId, xrdc2_access_policy_t policy);
496
497 /*!
498 * @brief Enable or disable the memory region exclusive access lock.
499 *
500 * Once disabled, it could not be enabled until reset.
501 *
502 * @param base XRDC2 peripheral base address.
503 * @param mem The memory region to operate.
504 * @param enable True to enable, false to disable.
505 */
506 void XRDC2_EnableMemExclAccessLock(XRDC2_Type *base, xrdc2_mem_t mem, bool enable);
507
508 /*!
509 * @brief Get current memory region exclusive access lock owner.
510 *
511 * @param base XRDC2 peripheral base address.
512 * @param mem The memory region to operate.
513 * @return The domain ID of the lock owner.
514 */
515 uint8_t XRDC2_GetMemExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_t mem);
516
517 /*!
518 * @brief Try to lock the memory region exclusive access.
519 *
520 * @param base XRDC2 peripheral base address.
521 * @param mem The memory region to operate.
522 * @retval kStatus_Fail Failed to lock.
523 * @retval kStatus_Success Locked succussfully.
524 */
525 status_t XRDC2_TryLockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
526
527 /*!
528 * @brief Lock the memory region exclusive access using blocking method.
529 *
530 * @param base XRDC2 peripheral base address.
531 * @param mem The memory region to operate.
532 *
533 * @note This function must be called when the lock is not disabled.
534 */
535 void XRDC2_LockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
536
537 /*!
538 * @brief Unlock the memory region exclusive access.
539 *
540 * @param base XRDC2 peripheral base address.
541 * @param mem The memory region to operate.
542 *
543 * @note This function must be called by the lock owner.
544 */
545 void XRDC2_UnlockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
546
547 /*!
548 * @brief Force the memory region exclusive access lock release.
549 *
550 * The master does not own the lock could call this function to force release the lock.
551 *
552 * @param base XRDC2 peripheral base address.
553 * @param mem The memory region to operate.
554 */
555 void XRDC2_ForceMemExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_t mem);
556
557 /*@}*/
558
559 /*!
560 * @name XRDC2 Peripheral Access Controller (XRDC2_PAC)
561 * @{
562 */
563
564 /*!
565 * @brief Gets the default peripheral access configuration.
566 *
567 * The default configuration is set as follows:
568 * @code
569 * config->lockMode = kXRDC2_AccessConfigLockWritable;
570 * config->policy[0] = kXRDC2_AccessPolicyNone;
571 * config->policy[1] = kXRDC2_AccessPolicyNone;
572 * ...
573 * config->policy[15] = kXRDC2_AccessPolicyNone;
574 * @endcode
575 *
576 * @param config Pointer to the configuration structure.
577 */
578 void XRDC2_GetPeriphAccessDefaultConfig(xrdc2_periph_access_config_t *config);
579
580 /*!
581 * @brief Sets the peripheral access policy.
582 *
583 * @param base XRDC2 peripheral base address.
584 * @param periph Which peripheral descriptor to set.
585 * @param config Pointer to the access policy configuration structure.
586 */
587 void XRDC2_SetPeriphAccessConfig(XRDC2_Type *base, xrdc2_periph_t periph, const xrdc2_periph_access_config_t *config);
588
589 /*!
590 * @brief Sets the peripheral descriptor as valid or invalid.
591 *
592 * @param base XRDC2 peripheral base address.
593 * @param periph Which peripheral descriptor to set.
594 * @param valid True to set valid, false to set invalid.
595 */
596 void XRDC2_SetPeriphAccessValid(XRDC2_Type *base, xrdc2_periph_t periph, bool valid);
597
598 /*!
599 * @brief Sets the peripheral descriptor lock mode.
600 *
601 * @param base XRDC2 peripheral base address.
602 * @param periph Which peripheral descriptor to set.
603 * @param lockMode The lock mode to set.
604 */
605 void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode);
606
607 /*!
608 * @brief Sets the peripheral access policy for specific domain.
609 *
610 * @param base XRDC2 peripheral base address.
611 * @param periph The peripheral to operate.
612 * @param domainId The ID of the domain whose policy will be changed.
613 * @param policy The access policy to set.
614 */
615 void XRDC2_SetPeriphDomainAccessPolicy(XRDC2_Type *base,
616 xrdc2_periph_t periph,
617 uint8_t domainId,
618 xrdc2_access_policy_t policy);
619
620 /*!
621 * @brief Disable the peripheral exclusive access lock.
622 *
623 * Once disabled, it could not be enabled until reset.
624 *
625 * @param base XRDC2 peripheral base address.
626 * @param periph The peripheral to operate.
627 * @param enable True to enable, false to disable.
628 */
629 void XRDC2_EnablePeriphExclAccessLock(XRDC2_Type *base, xrdc2_periph_t periph, bool enable);
630
631 /*!
632 * @brief Get current peripheral exclusive access lock owner.
633 *
634 * @param base XRDC2 peripheral base address.
635 * @param periph The peripheral to operate.
636 * @return The domain ID of the lock owner.
637 */
638 uint8_t XRDC2_GetPeriphExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_periph_t periph);
639
640 /*!
641 * @brief Try to lock the peripheral exclusive access.
642 *
643 * @param base XRDC2 peripheral base address.
644 * @param periph The peripheral to operate.
645 * @retval kStatus_Fail Failed to lock.
646 * @retval kStatus_Success Locked succussfully.
647 */
648 status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
649
650 /*!
651 * @brief Lock the peripheral exclusive access using blocking method.
652 *
653 * @param base XRDC2 peripheral base address.
654 * @param periph The peripheral to operate.
655 *
656 * @note This function must be called when the lock is not disabled.
657 */
658 void XRDC2_LockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
659
660 /*!
661 * @brief Unlock the peripheral exclusive access.
662 *
663 * @param base XRDC2 peripheral base address.
664 * @param periph The peripheral to operate.
665 *
666 * @note This function must be called by the lock owner.
667 */
668 void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
669
670 /*!
671 * @brief Force the peripheral exclusive access lock release.
672 *
673 * The master does not own the lock could call this function to force release the lock.
674 *
675 * @param base XRDC2 peripheral base address.
676 * @param periph The peripheral to operate.
677 */
678 void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph);
679
680 /*@}*/
681
682 #if defined(__cplusplus)
683 }
684 #endif
685
686 /*!
687 * @}
688 */
689
690 #endif /* _FSL_XRDC2_H_ */
691