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