RTEMS 6.1-rc2
Loading...
Searching...
No Matches
fsl_mu.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2022 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_MU_H_
9#define _FSL_MU_H_
10
11#include "fsl_common.h"
12
18/******************************************************************************
19 * Definitions
20 *****************************************************************************/
21
22/* Compatibility Macros */
23#ifndef MU_CR_NMI_MASK
24#define MU_CR_NMI_MASK 0U
25#endif
26
27#if (defined(FSL_FEATURE_MU_HAS_RESET_INT) && FSL_FEATURE_MU_HAS_RESET_INT)
28
29#ifndef FSL_FEATURE_MU_HAS_RESET_ASSERT_INT
30#define FSL_FEATURE_MU_HAS_RESET_ASSERT_INT 1
31#endif
32
33#ifndef FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT
34#define FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT 1
35#endif
36
37#endif /* FSL_FEATURE_MU_HAS_RESET_INT */
38
42#define FSL_MU_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
49{
50 kMU_Tx0EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 3U)),
51 kMU_Tx1EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 2U)),
52 kMU_Tx2EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 1U)),
53 kMU_Tx3EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 0U)),
55 kMU_Rx0FullFlag = (1U << (MU_SR_RFn_SHIFT + 3U)),
56 kMU_Rx1FullFlag = (1U << (MU_SR_RFn_SHIFT + 2U)),
57 kMU_Rx2FullFlag = (1U << (MU_SR_RFn_SHIFT + 1U)),
58 kMU_Rx3FullFlag = (1U << (MU_SR_RFn_SHIFT + 0U)),
60 kMU_GenInt0Flag = (1U << (MU_SR_GIPn_SHIFT + 3U)),
61 kMU_GenInt1Flag = (1U << (MU_SR_GIPn_SHIFT + 2U)),
62 kMU_GenInt2Flag = (1U << (MU_SR_GIPn_SHIFT + 1U)),
63 kMU_GenInt3Flag = (1U << (MU_SR_GIPn_SHIFT + 0U)),
65 kMU_EventPendingFlag = MU_SR_EP_MASK,
66 kMU_FlagsUpdatingFlag = MU_SR_FUP_MASK,
68#if (defined(FSL_FEATURE_MU_HAS_RESET_ASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
69 kMU_ResetAssertInterruptFlag = MU_SR_RAIP_MASK,
70#endif
71#if (defined(FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT)
72 kMU_ResetDeassertInterruptFlag = MU_SR_RDIP_MASK,
73#endif
74
75#if (defined(FSL_FEATURE_MU_HAS_SR_RS) && FSL_FEATURE_MU_HAS_SR_RS)
76 kMU_OtherSideInResetFlag = MU_SR_RS_MASK,
77#endif
78
79#if (defined(FSL_FEATURE_MU_HAS_SR_MURIP) && FSL_FEATURE_MU_HAS_SR_MURIP)
80 kMU_MuResetInterruptFlag = MU_SR_MURIP_MASK,
81#endif
82#if (defined(FSL_FEATURE_MU_HAS_SR_HRIP) && FSL_FEATURE_MU_HAS_SR_HRIP)
83 kMU_HardwareResetInterruptFlag = MU_SR_HRIP_MASK,
84#endif
85};
86
91{
92 kMU_Tx0EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 3U)),
93 kMU_Tx1EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 2U)),
94 kMU_Tx2EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 1U)),
95 kMU_Tx3EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 0U)),
97 kMU_Rx0FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 3U)),
98 kMU_Rx1FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 2U)),
99 kMU_Rx2FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 1U)),
100 kMU_Rx3FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 0U)),
102 kMU_GenInt0InterruptEnable = (int)(1U << (MU_CR_GIEn_SHIFT + 3U)),
103 kMU_GenInt1InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 2U)),
104 kMU_GenInt2InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 1U)),
105 kMU_GenInt3InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 0U)),
107#if (defined(FSL_FEATURE_MU_HAS_RESET_ASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
108 kMU_ResetAssertInterruptEnable = MU_CR_RAIE_MASK,
109#endif
110#if (defined(FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
111 kMU_ResetDeassertInterruptEnable = MU_CR_RDIE_MASK,
112#endif
113#if (defined(FSL_FEATURE_MU_HAS_SR_MURIP) && FSL_FEATURE_MU_HAS_SR_MURIP)
114 kMU_MuResetInterruptEnable = MU_CR_MURIE_MASK,
118#endif
119#if (defined(FSL_FEATURE_MU_HAS_SR_HRIP) && FSL_FEATURE_MU_HAS_SR_HRIP)
120 kMU_HardwareResetInterruptEnable = MU_CR_HRIE_MASK,
121#endif
122};
123
128{
129#if !(defined(FSL_FEATURE_MU_NO_NMI) && FSL_FEATURE_MU_NO_NMI)
130 kMU_NmiInterruptTrigger = MU_CR_NMI_MASK,
131#endif
132 kMU_GenInt0InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 3U)),
133 kMU_GenInt1InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 2U)),
134 kMU_GenInt2InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 1U)),
135 kMU_GenInt3InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 0U))
137
142{
143 kMU_MsgReg0 = 0,
144 kMU_MsgReg1,
145 kMU_MsgReg2,
146 kMU_MsgReg3,
148
149/*******************************************************************************
150 * API
151 ******************************************************************************/
152
153#if defined(__cplusplus)
154extern "C" {
155#endif
156
168void MU_Init(MU_Type *base);
169
177void MU_Deinit(MU_Type *base);
178
179/* @} */
180
203static inline void MU_SendMsgNonBlocking(MU_Type *base, uint32_t regIndex, uint32_t msg)
204{
205 assert(regIndex < MU_TR_COUNT);
206
207 base->TR[regIndex] = msg;
208}
209
219void MU_SendMsg(MU_Type *base, uint32_t regIndex, uint32_t msg);
220
242static inline uint32_t MU_ReceiveMsgNonBlocking(MU_Type *base, uint32_t regIndex)
243{
244 assert(regIndex < MU_TR_COUNT);
245
246 return base->RR[regIndex];
247}
248
258uint32_t MU_ReceiveMsg(MU_Type *base, uint32_t regIndex);
259
260/* @} */
261
288static inline void MU_SetFlagsNonBlocking(MU_Type *base, uint32_t flags)
289{
290 uint32_t reg = base->CR;
291 reg = (reg & ~((MU_CR_GIRn_MASK | MU_CR_NMI_MASK) | MU_CR_Fn_MASK)) | MU_CR_Fn(flags);
292 base->CR = reg;
293}
294
308void MU_SetFlags(MU_Type *base, uint32_t flags);
309
318static inline uint32_t MU_GetFlags(MU_Type *base)
319{
320 return (base->SR & MU_SR_Fn_MASK) >> MU_SR_Fn_SHIFT;
321}
322
323/* @} */
324
353static inline uint32_t MU_GetStatusFlags(MU_Type *base)
354{
355 return (base->SR & (MU_SR_TEn_MASK | MU_SR_RFn_MASK | MU_SR_GIPn_MASK | MU_SR_EP_MASK | MU_SR_FUP_MASK
356#if (defined(FSL_FEATURE_MU_HAS_SR_RS) && FSL_FEATURE_MU_HAS_SR_RS)
357 | MU_SR_RS_MASK
358#endif
359#if (defined(FSL_FEATURE_MU_HAS_RESET_ASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
360 | MU_SR_RAIP_MASK
361#endif
362#if (defined(FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
363 | MU_SR_RDIP_MASK
364#endif
365#if (defined(FSL_FEATURE_MU_HAS_SR_MURIP) && FSL_FEATURE_MU_HAS_SR_MURIP)
366 | MU_SR_MURIP_MASK
367#endif
368#if (defined(FSL_FEATURE_MU_HAS_SR_HRIP) && FSL_FEATURE_MU_HAS_SR_HRIP)
369 | MU_SR_HRIP_MASK
370#endif
371 ));
372}
373
382static inline uint32_t MU_GetInterruptsPending(MU_Type *base)
383{
384 uint32_t irqMask = base->CR & (MU_CR_GIEn_MASK | MU_CR_TIEn_MASK | MU_CR_RIEn_MASK);
385 return (base->SR & irqMask);
386}
387
414static inline void MU_ClearStatusFlags(MU_Type *base, uint32_t mask)
415{
416 /* regMask is the mask of w1c status bits. */
417 uint32_t regMask = MU_SR_GIPn_MASK;
418
419#if (defined(FSL_FEATURE_MU_HAS_RESET_ASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
420 regMask |= MU_SR_RAIP_MASK;
421#endif
422#if (defined(FSL_FEATURE_MU_HAS_RESET_DEASSERT_INT) && FSL_FEATURE_MU_HAS_RESET_ASSERT_INT)
423 regMask |= MU_SR_RDIP_MASK;
424#endif
425
426#if (defined(FSL_FEATURE_MU_HAS_SR_MURIP) && FSL_FEATURE_MU_HAS_SR_MURIP)
427 regMask |= MU_SR_MURIP_MASK;
428#endif
429
430#if (defined(FSL_FEATURE_MU_HAS_SR_HRIP) && FSL_FEATURE_MU_HAS_SR_HRIP)
431 regMask |= MU_SR_HRIP_MASK;
432#endif
433
434 base->SR = (mask & regMask);
435}
436
451static inline void MU_EnableInterrupts(MU_Type *base, uint32_t mask)
452{
453 uint32_t reg = base->CR;
454 reg = (reg & ~(MU_CR_GIRn_MASK | MU_CR_NMI_MASK)) | mask;
455 base->CR = reg;
456}
457
472static inline void MU_DisableInterrupts(MU_Type *base, uint32_t mask)
473{
474 uint32_t reg = base->CR;
475 reg &= ~((MU_CR_GIRn_MASK | MU_CR_NMI_MASK) | mask);
476 base->CR = reg;
477}
478
501status_t MU_TriggerInterrupts(MU_Type *base, uint32_t mask);
502
503#if !(defined(FSL_FEATURE_MU_NO_NMI) && FSL_FEATURE_MU_NO_NMI)
511static inline void MU_ClearNmi(MU_Type *base)
512{
513 base->SR = MU_SR_NMIC_MASK;
514}
515#endif /* FSL_FEATURE_MU_NO_NMI */
516
517/* @} */
518
524#if !(defined(FSL_FEATURE_MU_NO_RSTH) && FSL_FEATURE_MU_NO_RSTH)
535void MU_BootCoreB(MU_Type *base, mu_core_boot_mode_t mode);
536
545static inline void MU_HoldCoreBReset(MU_Type *base)
546{
547#if (defined(FSL_FEATURE_MU_HAS_CCR) && FSL_FEATURE_MU_HAS_CCR)
548 base->CCR |= MU_CCR_RSTH_MASK;
549#else /* FSL_FEATURE_MU_HAS_CCR */
550 uint32_t reg = base->CR;
551 reg = (reg & ~(MU_CR_GIRn_MASK | MU_CR_NMI_MASK)) | MU_CR_RSTH_MASK;
552 base->CR = reg;
553#endif /* FSL_FEATURE_MU_HAS_CCR */
554}
555
564void MU_BootOtherCore(MU_Type *base, mu_core_boot_mode_t mode);
565
573static inline void MU_HoldOtherCoreReset(MU_Type *base)
574{
575 /*
576 * MU_HoldOtherCoreReset and MU_HoldCoreBReset are the same, MU_HoldCoreBReset
577 * is kept for compatible with older platforms.
578 */
579 MU_HoldCoreBReset(base);
580}
581#endif /* FSL_FEATURE_MU_NO_RSTH */
582
583#if !(defined(FSL_FEATURE_MU_NO_MUR) && FSL_FEATURE_MU_NO_MUR)
595static inline void MU_ResetBothSides(MU_Type *base)
596{
597 uint32_t reg = base->CR;
598 reg = (reg & ~(MU_CR_GIRn_MASK | MU_CR_NMI_MASK)) | MU_CR_MUR_MASK;
599 base->CR = reg;
600
601#if (defined(FSL_FEATURE_MU_HAS_SR_RS) && FSL_FEATURE_MU_HAS_SR_RS)
602 /* Wait for the other side out of reset. */
603 while (0U != (base->SR & MU_SR_RS_MASK))
604 {
605 }
606#endif /* FSL_FEATURE_MU_HAS_SR_RS */
607}
608#endif /* FSL_FEATURE_MU_NO_MUR */
609
610#if (defined(FSL_FEATURE_MU_HAS_HRM) && FSL_FEATURE_MU_HAS_HRM)
620static inline void MU_MaskHardwareReset(MU_Type *base, bool mask)
621{
622#if (defined(FSL_FEATURE_MU_HAS_CCR) && FSL_FEATURE_MU_HAS_CCR)
623 if (mask)
624 {
625 base->CCR |= MU_CCR_HRM_MASK;
626 }
627 else
628 {
629 base->CCR &= ~MU_CCR_HRM_MASK;
630 }
631#else /* FSL_FEATURE_MU_HAS_CCR */
632 if (mask)
633 {
634 base->CR |= MU_CR_HRM_MASK;
635 }
636 else
637 {
638 base->CR &= ~MU_CR_HRM_MASK;
639 }
640#endif /* FSL_FEATURE_MU_HAS_CCR */
641}
642#endif /* FSL_FEATURE_MU_HAS_HRM */
643
644#if !(defined(FSL_FEATURE_MU_NO_HR) && FSL_FEATURE_MU_NO_HR)
682void MU_HardwareResetOtherCore(MU_Type *base, bool waitReset, bool holdReset, mu_core_boot_mode_t bootMode);
683#endif /* FSL_FEATURE_MU_NO_HR */
684
685#if !(defined(FSL_FEATURE_MU_NO_CLKE) && FSL_FEATURE_MU_NO_CLKE)
698static inline void MU_SetClockOnOtherCoreEnable(MU_Type *base, bool enable)
699{
700#if (defined(FSL_FEATURE_MU_HAS_CCR) && FSL_FEATURE_MU_HAS_CCR)
701 if (enable)
702 {
703 base->CCR |= MU_CCR_CLKE_MASK;
704 }
705 else
706 {
707 base->CCR &= ~MU_CCR_CLKE_MASK;
708 }
709#else /* FSL_FEATURE_MU_HAS_CCR */
710 uint32_t reg = base->CR;
711
712 reg &= ~(MU_CR_GIRn_MASK | MU_CR_NMI_MASK);
713
714 if (enable)
715 {
716 reg |= MU_CR_CLKE_MASK;
717 }
718 else
719 {
720 reg &= ~MU_CR_CLKE_MASK;
721 }
722
723 base->CR = reg;
724#endif /* FSL_FEATURE_MU_HAS_CCR */
725}
726#endif /* FSL_FEATURE_MU_NO_CLKE */
727
728#if !(defined(FSL_FEATURE_MU_NO_PM) && FSL_FEATURE_MU_NO_PM)
737static inline mu_power_mode_t MU_GetOtherCorePowerMode(MU_Type *base)
738{
739 uint32_t ret = (base->SR & MU_SR_PM_MASK) >> MU_SR_PM_SHIFT;
740
741 return (mu_power_mode_t)ret;
742}
743#endif /* FSL_FEATURE_MU_NO_PM */
744
745/* @} */
746
747#if defined(__cplusplus)
748}
749#endif /*_cplusplus*/
752#endif /* _FSL_MU_H_*/
#define MU_CR_Fn(x)
Definition: MIMXRT1166_cm4.h:64115
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
void MU_HardwareResetOtherCore(MU_Type *base, bool waitReset, bool holdReset, mu_core_boot_mode_t bootMode)
Hardware reset the other core.
Definition: fsl_mu.c:358
status_t MU_TriggerInterrupts(MU_Type *base, uint32_t mask)
Triggers interrupts to the other core.
Definition: fsl_mu.c:165
uint32_t MU_ReceiveMsg(MU_Type *base, uint32_t regIndex)
Blocks to receive a message.
Definition: fsl_mu.c:106
void MU_SetFlags(MU_Type *base, uint32_t flags)
Blocks setting the 3-bit MU flags reflect on the other MU side.
Definition: fsl_mu.c:132
_mu_interrupt_trigger
MU interrupt that could be triggered to the other core.
Definition: fsl_mu.h:128
void MU_Init(MU_Type *base)
Initializes the MU module.
Definition: fsl_mu.c:54
void MU_BootCoreB(MU_Type *base, mu_core_boot_mode_t mode)
Boots the core at B side.
Definition: fsl_mu.c:197
void MU_BootOtherCore(MU_Type *base, mu_core_boot_mode_t mode)
Boots the other core.
Definition: fsl_mu.c:228
_mu_msg_reg_index
MU message register.
Definition: fsl_mu.h:142
void MU_Deinit(MU_Type *base)
De-initializes the MU module.
Definition: fsl_mu.c:68
_mu_interrupt_enable
MU interrupt source to enable.
Definition: fsl_mu.h:91
enum _mu_msg_reg_index mu_msg_reg_index_t
MU message register.
_mu_status_flags
MU status flags.
Definition: fsl_mu.h:49
void MU_SendMsg(MU_Type *base, uint32_t regIndex, uint32_t msg)
Blocks to send a message.
Definition: fsl_mu.c:84
@ kMU_GenInt2InterruptTrigger
Definition: fsl_mu.h:134
@ kMU_GenInt0InterruptTrigger
Definition: fsl_mu.h:132
@ kMU_NmiInterruptTrigger
Definition: fsl_mu.h:130
@ kMU_GenInt3InterruptTrigger
Definition: fsl_mu.h:135
@ kMU_GenInt1InterruptTrigger
Definition: fsl_mu.h:133
@ kMU_GenInt1InterruptEnable
Definition: fsl_mu.h:103
@ kMU_Tx0EmptyInterruptEnable
Definition: fsl_mu.h:92
@ kMU_Rx2FullInterruptEnable
Definition: fsl_mu.h:99
@ kMU_Rx3FullInterruptEnable
Definition: fsl_mu.h:100
@ kMU_Rx0FullInterruptEnable
Definition: fsl_mu.h:97
@ kMU_Tx2EmptyInterruptEnable
Definition: fsl_mu.h:94
@ kMU_Tx3EmptyInterruptEnable
Definition: fsl_mu.h:95
@ kMU_Tx1EmptyInterruptEnable
Definition: fsl_mu.h:93
@ kMU_GenInt2InterruptEnable
Definition: fsl_mu.h:104
@ kMU_GenInt3InterruptEnable
Definition: fsl_mu.h:105
@ kMU_Rx1FullInterruptEnable
Definition: fsl_mu.h:98
@ kMU_GenInt0InterruptEnable
Definition: fsl_mu.h:102
@ kMU_Tx1EmptyFlag
Definition: fsl_mu.h:51
@ kMU_GenInt2Flag
Definition: fsl_mu.h:62
@ kMU_FlagsUpdatingFlag
Definition: fsl_mu.h:66
@ kMU_Rx0FullFlag
Definition: fsl_mu.h:55
@ kMU_Rx2FullFlag
Definition: fsl_mu.h:57
@ kMU_GenInt0Flag
Definition: fsl_mu.h:60
@ kMU_Rx3FullFlag
Definition: fsl_mu.h:58
@ kMU_Tx2EmptyFlag
Definition: fsl_mu.h:52
@ kMU_GenInt1Flag
Definition: fsl_mu.h:61
@ kMU_GenInt3Flag
Definition: fsl_mu.h:63
@ kMU_Tx0EmptyFlag
Definition: fsl_mu.h:50
@ kMU_Tx3EmptyFlag
Definition: fsl_mu.h:53
@ kMU_EventPendingFlag
Definition: fsl_mu.h:65
@ kMU_Rx1FullFlag
Definition: fsl_mu.h:56
Definition: MIMXRT1166_cm4.h:64004
Definition: b1553brm.c:94