RTEMS 6.1-rc4
Loading...
Searching...
No Matches
fsl_src.h
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2020 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_SRC_H_
10#define _FSL_SRC_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
26#define FSL_SRC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
33{
34#if (defined(FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT) && FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT)
35 kSRC_ResetOutputEnableFlag = SRC_SRSR_RESET_OUT_MASK,
37#endif /* FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT */
38#if !(defined(FSL_FEATURE_SRC_HAS_NO_SRSR_WBI) && FSL_FEATURE_SRC_HAS_NO_SRSR_WBI)
39 kSRC_WarmBootIndicationFlag = SRC_SRSR_WBI_MASK,
41#endif /* FSL_FEATURE_SRC_HAS_NO_SRSR_WBI */
42 kSRC_TemperatureSensorResetFlag = SRC_SRSR_TSR_MASK,
47#if (defined(FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B) && FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B)
48 kSRC_Wdog3ResetFlag = SRC_SRSR_WDOG3_RST_B_MASK,
51#endif /* FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B */
52#if (defined(FSL_FEATURE_SRC_HAS_SRSR_SW) && FSL_FEATURE_SRC_HAS_SRSR_SW)
53 kSRC_SoftwareResetFlag = SRC_SRSR_SW_MASK,
57#endif /* FSL_FEATURE_SRC_HAS_SRSR_SW */
58#if (defined(FSL_FEATURE_SRC_HAS_SRSR_JTAG_SW_RST) && FSL_FEATURE_SRC_HAS_SRSR_JTAG_SW_RST)
59 kSRC_JTAGSystemResetFlag =
60 SRC_SRSR_JTAG_SW_RST_MASK,
61#endif /* FSL_FEATURE_SRC_HAS_SRSR_JTAG_SW_RST */
62 kSRC_JTAGSoftwareResetFlag = SRC_SRSR_SJC_MASK,
64 kSRC_JTAGGeneratedResetFlag = SRC_SRSR_JTAG_MASK,
67 kSRC_WatchdogResetFlag = SRC_SRSR_WDOG_MASK,
70#if (defined(FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B)
71 kSRC_IppUserResetFlag = SRC_SRSR_IPP_USER_RESET_B_MASK,
74#endif /* FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B */
75#if (defined(FSL_FEATURE_SRC_HAS_SRSR_SNVS) && FSL_FEATURE_SRC_HAS_SRSR_SNVS)
76 kSRC_SNVSFailResetFlag = SRC_SRSR_SNVS_MASK,
79#endif /* FSL_FEATURE_SRC_HAS_SRSR_SNVS */
80#if (defined(FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B)
81 kSRC_CsuResetFlag = SRC_SRSR_CSU_RESET_B_MASK,
83#endif /* FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B */
84#if (defined(FSL_FEATURE_SRC_HAS_SRSR_LOCKUP) && FSL_FEATURE_SRC_HAS_SRSR_LOCKUP)
85 kSRC_CoreLockupResetFlag = SRC_SRSR_LOCKUP_MASK,
87#endif /* FSL_FEATURE_SRC_HAS_SRSR_LOCKUP */
88#if (defined(FSL_FEATURE_SRC_HAS_SRSR_POR) && FSL_FEATURE_SRC_HAS_SRSR_POR)
89 kSRC_PowerOnResetFlag = SRC_SRSR_POR_MASK,
91#endif /* FSL_FEATURE_SRC_HAS_SRSR_POR */
92#if (defined(FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ) && FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ)
93 kSRC_LockupSysResetFlag =
94 SRC_SRSR_LOCKUP_SYSRESETREQ_MASK,
97#endif /* FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ */
98#if (defined(FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B)
99 kSRC_IppResetPinFlag = SRC_SRSR_IPP_RESET_B_MASK,
101#endif /* FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B */
102};
103
104#if (defined(FSL_FEATURE_SRC_HAS_SISR) && FSL_FEATURE_SRC_HAS_SISR)
108enum _src_status_flags
109{
110 kSRC_Core0WdogResetReqFlag =
111 SRC_SISR_CORE0_WDOG_RST_REQ_MASK,
112};
113#endif /* FSL_FEATURE_SRC_HAS_SISR */
114
115#if (defined(FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH) && FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH)
122typedef enum _src_mix_reset_stretch_cycles
123{
124 kSRC_MixResetStretchCycleAlt0 = 0U,
125 kSRC_MixResetStretchCycleAlt1 = 1U,
126 kSRC_MixResetStretchCycleAlt2 = 2U,
127 kSRC_MixResetStretchCycleAlt3 = 3U,
128} src_mix_reset_stretch_cycles_t;
129#endif /* FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH */
130
131#if (defined(FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN) && FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN)
135typedef enum _src_wdog3_reset_option
136{
137 kSRC_Wdog3ResetOptionAlt0 = 0U,
138 kSRC_Wdog3ResetOptionAlt1 = 1U,
139} src_wdog3_reset_option_t;
140#endif /* FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN */
141
150{
156
157#if defined(__cplusplus)
158extern "C" {
159#endif
160
161/*******************************************************************************
162 * API
163 ******************************************************************************/
164
165#if (defined(FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST) && FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST)
174static inline void SRC_EnableWDOG3Reset(SRC_Type *base, bool enable)
175{
176 if (enable)
177 {
178 base->SCR = (base->SCR & ~SRC_SCR_MASK_WDOG3_RST_MASK) | SRC_SCR_MASK_WDOG3_RST(0xA);
179 }
180 else
181 {
182 base->SCR = (base->SCR & ~SRC_SCR_MASK_WDOG3_RST_MASK) | SRC_SCR_MASK_WDOG3_RST(0x5);
183 }
184}
185#endif /* FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST */
186
187#if (defined(FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH) && FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH)
194static inline void SRC_SetMixResetStretchCycles(SRC_Type *base, src_mix_reset_stretch_cycles_t option)
195{
196 base->SCR = (base->SCR & ~SRC_SCR_MIX_RST_STRCH_MASK) | SRC_SCR_MIX_RST_STRCH(option);
197}
198#endif /* FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH */
199
200#if (defined(FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG) && FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG)
207static inline void SRC_EnableCoreDebugResetAfterPowerGate(SRC_Type *base, bool enable)
208{
209 if (enable)
210 {
211 base->SCR &= ~SRC_SCR_DBG_RST_MSK_PG_MASK;
212 }
213 else
214 {
215 base->SCR |= SRC_SCR_DBG_RST_MSK_PG_MASK;
216 }
217}
218#endif /* FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG */
219
220#if (defined(FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN) && FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN)
227static inline void SRC_SetWdog3ResetOption(SRC_Type *base, src_wdog3_reset_option_t option)
228{
229 base->SCR = (base->SCR & ~SRC_SCR_WDOG3_RST_OPTN_MASK) | SRC_SCR_WDOG3_RST_OPTN(option);
230}
231#endif /* FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN */
232
233#if (defined(FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST) && FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST)
239static inline void SRC_DoSoftwareResetARMCoreDebug(SRC_Type *base)
240{
241 base->SCR |= SRC_SCR_CORES_DBG_RST_MASK;
242}
243
249static inline bool SRC_GetSoftwareResetARMCoreDebugDone(SRC_Type *base)
250{
251 return (0U == (base->SCR & SRC_SCR_CORES_DBG_RST_MASK));
252}
253#endif /* FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST */
254
255#if (defined(FSL_FEATURE_SRC_HAS_SCR_MTSR) && FSL_FEATURE_SRC_HAS_SCR_MTSR)
265static inline void SRC_EnableTemperatureSensorReset(SRC_Type *base, bool enable)
266{
267 if (enable) /* Temperature sensor reset is not masked. (default) */
268 {
269 base->SCR = (base->SCR & ~SRC_SCR_MTSR_MASK) | SRC_SCR_MTSR(0x2);
270 }
271 else /* The on-chip temperature sensor interrupt will not create a reset to the chip. */
272 {
273 base->SCR = (base->SCR & ~SRC_SCR_MTSR_MASK) | SRC_SCR_MTSR(0x5);
274 }
275}
276#endif /* FSL_FEATURE_SRC_HAS_SCR_MTSR */
277
278#if (defined(FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST) && FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST)
284static inline void SRC_DoAssertCore0DebugReset(SRC_Type *base)
285{
286 base->SCR |= SRC_SCR_CORE0_DBG_RST_MASK;
287}
288
294static inline bool SRC_GetAssertCore0DebugResetDone(SRC_Type *base)
295{
296 return (0U == (base->SCR & SRC_SCR_CORE0_DBG_RST_MASK));
297}
298#endif /* FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST */
299
300#if (defined(FSL_FEATURE_SRC_HAS_SCR_CORE0_RST) && FSL_FEATURE_SRC_HAS_SCR_CORE0_RST)
306static inline void SRC_DoSoftwareResetARMCore0(SRC_Type *base)
307{
308 base->SCR |= SRC_SCR_CORE0_RST_MASK;
309}
310
317static inline bool SRC_GetSoftwareResetARMCore0Done(SRC_Type *base)
318{
319 return (0U == (base->SCR & SRC_SCR_CORE0_RST_MASK));
320}
321#endif /* FSL_FEATURE_SRC_HAS_SCR_CORE0_RST */
322
323#if (defined(FSL_FEATURE_SRC_HAS_SCR_SWRC) && FSL_FEATURE_SRC_HAS_SCR_SWRC)
332static inline void SRC_DoSoftwareResetARMCore(SRC_Type *base)
333{
334 base->SCR |= SRC_SCR_SWRC_MASK;
335}
336
343static inline bool SRC_GetSoftwareResetARMCoreDone(SRC_Type *base)
344{
345 return (0U == (base->SCR & SRC_SCR_SWRC_MASK));
346}
347#endif /* FSL_FEATURE_SRC_HAS_SCR_SWRC */
348
349#if (defined(FSL_FEATURE_SRC_HAS_SCR_EIM_RST) && FSL_FEATURE_SRC_HAS_SCR_EIM_RST)
359static inline void SRC_AssertEIMReset(SRC_Type *base, bool enable)
360{
361 if (enable)
362 {
363 base->SCR |= SRC_SCR_EIM_RST_MASK;
364 }
365 else
366 {
367 base->SCR &= ~SRC_SCR_EIM_RST_MASK;
368 }
369}
370#endif /* FSL_FEATURE_SRC_HAS_SCR_EIM_RST */
371
383static inline void SRC_EnableWDOGReset(SRC_Type *base, bool enable)
384{
385 if (enable) /* WDOG Reset is not masked in SRC (default). */
386 {
387 base->SCR = (base->SCR & ~SRC_SCR_MWDR_MASK) | SRC_SCR_MWDR(0xA);
388 }
389 else /* WDOG Reset is masked in SRC. */
390 {
391 base->SCR = (base->SCR & ~SRC_SCR_MWDR_MASK) | SRC_SCR_MWDR(0x5);
392 }
393}
394
395#if !(defined(FSL_FEATURE_SRC_HAS_NO_SCR_WRBC) && FSL_FEATURE_SRC_HAS_NO_SCR_WRBC)
406static inline void SRC_SetWarmResetBypassCount(SRC_Type *base, src_warm_reset_bypass_count_t option)
407{
408 base->SCR = (base->SCR & ~SRC_SCR_WRBC_MASK) | SRC_SCR_WRBC(option);
409}
410#endif /* FSL_FEATURE_SRC_HAS_NO_SCR_WRBC */
411
412#if (defined(FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST) && FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST)
419static inline void SRC_EnableLockupReset(SRC_Type *base, bool enable)
420{
421 if (enable) /* Enable lockup reset. */
422 {
423 base->SCR |= SRC_SCR_LOCKUP_RST_MASK;
424 }
425 else /* Disable lockup reset. */
426 {
427 base->SCR &= ~SRC_SCR_LOCKUP_RST_MASK;
428 }
429}
430#endif /* FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST */
431
432#if (defined(FSL_FEATURE_SRC_HAS_SCR_LUEN) && FSL_FEATURE_SRC_HAS_SCR_LUEN)
441static inline void SRC_EnableCoreLockupReset(SRC_Type *base, bool enable)
442{
443 if (enable) /* Core lockup will cause system reset. */
444 {
445 base->SCR |= SRC_SCR_LUEN_MASK;
446 }
447 else /* Core lockup will not cause system reset. */
448 {
449 base->SCR &= ~SRC_SCR_LUEN_MASK;
450 }
451}
452#endif /* FSL_FEATURE_SRC_HAS_SCR_LUEN */
453
454#if !(defined(FSL_FEATURE_SRC_HAS_NO_SCR_WRE) && FSL_FEATURE_SRC_HAS_NO_SCR_WRE)
464static inline void SRC_EnableWarmReset(SRC_Type *base, bool enable)
465{
466 if (enable)
467 {
468 base->SCR |= SRC_SCR_WRE_MASK;
469 }
470 else
471 {
472 base->SCR &= ~SRC_SCR_WRE_MASK;
473 }
474}
475#endif /* FSL_FEATURE_SRC_HAS_NO_SCR_WRE */
476
477#if (defined(FSL_FEATURE_SRC_HAS_SISR) && FSL_FEATURE_SRC_HAS_SISR)
484static inline uint32_t SRC_GetStatusFlags(SRC_Type *base)
485{
486 return base->SISR;
487}
488#endif /* FSL_FEATURE_SRC_HAS_SISR */
489
499static inline uint32_t SRC_GetBootModeWord1(SRC_Type *base)
500{
501 return base->SBMR1;
502}
503
513static inline uint32_t SRC_GetBootModeWord2(SRC_Type *base)
514{
515 return base->SBMR2;
516}
517
518#if !(defined(FSL_FEATURE_SRC_HAS_NO_SRSR_WBI) && FSL_FEATURE_SRC_HAS_NO_SRSR_WBI)
531static inline void SRC_SetWarmBootIndication(SRC_Type *base, bool enable)
532{
533 if (enable)
534 {
535 base->SRSR = (base->SRSR & ~SRC_SRSR_W1C_BITS_MASK) | SRC_SRSR_WBI_MASK;
536 }
537 else
538 {
539 base->SRSR = (base->SRSR & ~SRC_SRSR_W1C_BITS_MASK) & ~SRC_SRSR_WBI_MASK;
540 }
541}
542#endif /* FSL_FEATURE_SRC_HAS_NO_SRSR_WBI */
543
550static inline uint32_t SRC_GetResetStatusFlags(SRC_Type *base)
551{
552 return base->SRSR;
553}
554
561void SRC_ClearResetStatusFlags(SRC_Type *base, uint32_t flags);
562
575static inline void SRC_SetGeneralPurposeRegister(SRC_Type *base, uint32_t index, uint32_t value)
576{
577 assert(index < SRC_GPR_COUNT);
578
579 base->GPR[index] = value;
580}
581
589static inline uint32_t SRC_GetGeneralPurposeRegister(SRC_Type *base, uint32_t index)
590{
591 assert(index < SRC_GPR_COUNT);
592
593 return base->GPR[index];
594}
595
596#if defined(__cplusplus)
597}
598#endif
602#endif /* _FSL_SRC_H_ */
#define SRC_SCR_MASK_WDOG3_RST(x)
Definition: MIMXRT1052.h:42907
void SRC_ClearResetStatusFlags(SRC_Type *base, uint32_t flags)
Clear the status flags of SRC.
Definition: fsl_src.c:34
enum _src_warm_reset_bypass_count src_warm_reset_bypass_count_t
Selection of WARM reset bypass count.
_src_warm_reset_bypass_count
Selection of WARM reset bypass count.
Definition: fsl_src.h:150
_src_reset_status_flags
SRC reset status flags.
Definition: fsl_src.h:33
@ kSRC_WarmResetWaitClk64
Definition: fsl_src.h:154
@ kSRC_WarmResetWaitClk32
Definition: fsl_src.h:153
@ kSRC_WarmResetWaitClk16
Definition: fsl_src.h:152
@ kSRC_WarmResetWaitAlways
Definition: fsl_src.h:151
@ kSRC_WarmBootIndicationFlag
Definition: fsl_src.h:39
@ kSRC_TemperatureSensorResetFlag
Definition: fsl_src.h:42
@ kSRC_JTAGGeneratedResetFlag
Definition: fsl_src.h:64
@ kSRC_JTAGSoftwareResetFlag
Definition: fsl_src.h:62
@ kSRC_WatchdogResetFlag
Definition: fsl_src.h:67
Definition: MIMXRT1052.h:42848