RTEMS 6.1-rc6
Loading...
Searching...
No Matches
fsl_snvs_hp.h
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2017-2022, NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_SNVS_HP_H_
10#define _FSL_SNVS_HP_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
25#define FSL_SNVS_HP_DRIVER_VERSION (MAKE_VERSION(2, 3, 2))
27
30{
31 kSNVS_RTC_AlarmInterrupt = SNVS_HPCR_HPTA_EN_MASK,
32 kSNVS_RTC_PeriodicInterrupt = SNVS_HPCR_PI_EN_MASK,
34
37{
38 kSNVS_RTC_AlarmInterruptFlag = SNVS_HPSR_HPTA_MASK,
39 kSNVS_RTC_PeriodicInterruptFlag = SNVS_HPSR_PI_MASK,
40 kSNVS_ZMK_ZeroFlag = (int)SNVS_HPSR_ZMK_ZERO_MASK,
41 kSNVS_OTPMK_ZeroFlag = SNVS_HPSR_OTPMK_ZERO_MASK,
43
44/* Re-map Security Violation for RT11xx specific violation*/
45#ifndef SNVS_HPSVSR_SV0_MASK
46#define SNVS_HPSVSR_SV0_MASK SNVS_HPSVSR_CAAM_MASK
47#endif
48
49#ifndef SNVS_HPSVSR_SV1_MASK
50#define SNVS_HPSVSR_SV1_MASK SNVS_HPSVSR_JTAGC_MASK
51#endif
52
53#ifndef SNVS_HPSVSR_SV2_MASK
54#define SNVS_HPSVSR_SV2_MASK SNVS_HPSVSR_WDOG2_MASK
55#endif
56
57#ifndef SNVS_HPSVSR_SV4_MASK
58#define SNVS_HPSVSR_SV4_MASK SNVS_HPSVSR_SRC_MASK
59#endif
60
61#ifndef SNVS_HPSVSR_SV5_MASK
62#define SNVS_HPSVSR_SV5_MASK SNVS_HPSVSR_OCOTP_MASK
63#endif
64
67{
68 kSNVS_LP_ViolationFlag = SNVS_HPSVSR_SW_LPSV_MASK,
69 kSNVS_ZMK_EccFailFlag = SNVS_HPSVSR_ZMK_ECC_FAIL_MASK,
71 kSNVS_LP_SoftwareViolationFlag = SNVS_HPSVSR_SW_LPSV_MASK,
72 kSNVS_FatalSoftwareViolationFlag = SNVS_HPSVSR_SW_FSV_MASK,
73 kSNVS_SoftwareViolationFlag = SNVS_HPSVSR_SW_SV_MASK,
74 kSNVS_Violation0Flag = SNVS_HPSVSR_SV0_MASK,
75 kSNVS_Violation1Flag = SNVS_HPSVSR_SV1_MASK,
76 kSNVS_Violation2Flag = SNVS_HPSVSR_SV2_MASK,
77#if defined(SNVS_HPSVSR_SV3_MASK)
78 kSNVS_Violation3Flag = SNVS_HPSVSR_SV3_MASK,
79#endif /* SNVS_HPSVSR_SV3_MASK */
80 kSNVS_Violation4Flag = SNVS_HPSVSR_SV4_MASK,
81 kSNVS_Violation5Flag = SNVS_HPSVSR_SV5_MASK,
83
90#define SNVS_MAKE_HP_SV_FLAG(x) (1U << (SNVS_HPSVSR_SV0_SHIFT + (x)))
91
94{
95 uint16_t year;
96 uint8_t month;
97 uint8_t day;
98 uint8_t hour;
99 uint8_t minute;
100 uint8_t second;
102
113{
116 uint32_t rtcCalValue;
121
124{
134
135/*******************************************************************************
136 * API
137 ******************************************************************************/
138
139#if defined(__cplusplus)
140extern "C" {
141#endif
142
155void SNVS_HP_Init(SNVS_Type *base);
156
162void SNVS_HP_Deinit(SNVS_Type *base);
163
173
179void SNVS_HP_RTC_Deinit(SNVS_Type *base);
180
193
211
219
235
243
244#if (defined(FSL_FEATURE_SNVS_HAS_SRTC) && (FSL_FEATURE_SNVS_HAS_SRTC > 0))
250void SNVS_HP_RTC_TimeSynchronize(SNVS_Type *base);
251#endif /* FSL_FEATURE_SNVS_HAS_SRTC */
252
267static inline void SNVS_HP_RTC_EnableInterrupts(SNVS_Type *base, uint32_t mask)
268{
269 base->HPCR |= mask;
270}
271
279static inline void SNVS_HP_RTC_DisableInterrupts(SNVS_Type *base, uint32_t mask)
280{
281 base->HPCR &= ~mask;
282}
283
293
310
318static inline void SNVS_HP_RTC_ClearStatusFlags(SNVS_Type *base, uint32_t mask)
319{
320 base->HPSR |= mask;
321}
322
335static inline void SNVS_HP_RTC_StartTimer(SNVS_Type *base)
336{
337 base->HPCR |= SNVS_HPCR_RTC_EN_MASK;
338 while (0U == (base->HPCR & SNVS_HPCR_RTC_EN_MASK))
339 {
340 }
341}
342
348static inline void SNVS_HP_RTC_StopTimer(SNVS_Type *base)
349{
350 base->HPCR &= ~SNVS_HPCR_RTC_EN_MASK;
351 while ((base->HPCR & SNVS_HPCR_RTC_EN_MASK) != 0U)
352 {
353 }
354}
355
364static inline void SNVS_HP_EnableMasterKeySelection(SNVS_Type *base, bool enable)
365{
366 if (enable)
367 {
368 base->HPCOMR |= SNVS_HPCOMR_MKS_EN_MASK;
369 }
370 else
371 {
372 base->HPCOMR &= (~SNVS_HPCOMR_MKS_EN_MASK);
373 }
374}
375
381static inline void SNVS_HP_ProgramZeroizableMasterKey(SNVS_Type *base)
382{
383 base->HPCOMR |= SNVS_HPCOMR_PROG_ZMK_MASK;
384}
385
399static inline void SNVS_HP_ChangeSSMState(SNVS_Type *base)
400{
401 base->HPCOMR |= SNVS_HPCOMR_SSM_ST_MASK;
402}
403
415static inline void SNVS_HP_SetSoftwareFatalSecurityViolation(SNVS_Type *base)
416{
417 base->HPCOMR |= SNVS_HPCOMR_SW_FSV_MASK;
418}
419
430static inline void SNVS_HP_SetSoftwareSecurityViolation(SNVS_Type *base)
431{
432 base->HPCOMR |= SNVS_HPCOMR_SW_SV_MASK;
433}
434
441static inline snvs_hp_ssm_state_t SNVS_HP_GetSSMState(SNVS_Type *base)
442{
443 return (snvs_hp_ssm_state_t)((uint32_t)((base->HPSR & SNVS_HPSR_SSM_STATE_MASK) >> SNVS_HPSR_SSM_STATE_SHIFT));
444}
445
453static inline void SNVS_HP_ResetLP(SNVS_Type *base)
454{
455 base->HPCOMR |= SNVS_HPCOMR_LP_SWR_MASK;
456}
457
469static inline void SNVS_HP_EnableHighAssuranceCounter(SNVS_Type *base, bool enable)
470{
471 if (enable)
472 {
473 base->HPCOMR |= SNVS_HPCOMR_HAC_EN_MASK;
474 }
475 else
476 {
477 base->HPCOMR &= (~SNVS_HPCOMR_HAC_EN_MASK);
478 }
479}
480
487static inline void SNVS_HP_StartHighAssuranceCounter(SNVS_Type *base, bool start)
488{
489 if (start)
490 {
491 base->HPCOMR &= (~SNVS_HPCOMR_HAC_STOP_MASK);
492 }
493 else
494 {
495 base->HPCOMR |= SNVS_HPCOMR_HAC_STOP_MASK;
496 }
497}
498
505static inline void SNVS_HP_SetHighAssuranceCounterInitialValue(SNVS_Type *base, uint32_t value)
506{
507 base->HPHACIVR = value;
508}
509
517static inline void SNVS_HP_LoadHighAssuranceCounter(SNVS_Type *base)
518{
519 base->HPCOMR |= SNVS_HPCOMR_HAC_LOAD_MASK;
520}
521
528static inline uint32_t SNVS_HP_GetHighAssuranceCounter(SNVS_Type *base)
529{
530 return base->HPHACR;
531}
532
545static inline void SNVS_HP_ClearHighAssuranceCounter(SNVS_Type *base)
546{
547 base->HPCOMR |= SNVS_HPCOMR_HAC_CLEAR_MASK;
548}
549
558static inline void SNVS_HP_LockHighAssuranceCounter(SNVS_Type *base)
559{
560 base->HPLR |= SNVS_HPLR_HAC_L_MASK;
561}
562
574static inline uint32_t SNVS_HP_GetStatusFlags(SNVS_Type *base)
575{
576 return base->HPSR;
577}
578
591static inline void SNVS_HP_ClearStatusFlags(SNVS_Type *base, uint32_t mask)
592{
593 base->HPSR = mask;
594}
595
605static inline uint32_t SNVS_HP_GetSecurityViolationStatusFlags(SNVS_Type *base)
606{
607 return base->HPSVSR;
608}
609
628static inline void SNVS_HP_ClearSecurityViolationStatusFlags(SNVS_Type *base, uint32_t mask)
629{
630 base->HPSVSR = mask;
631}
632
633#if defined(FSL_FEATURE_SNVS_HAS_SET_LOCK) && (FSL_FEATURE_SNVS_HAS_SET_LOCK > 0)
640void SNVS_HP_SetLocks(SNVS_Type *base);
641#endif /* FSL_FEATURE_SNVS_HAS_SET_LOCK */
642
643#if defined(__cplusplus)
644}
645#endif
646
649#endif /* _FSL_SNVS_HP_H_ */
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
struct _snvs_hp_rtc_datetime snvs_hp_rtc_datetime_t
Structure is used to hold the date and time.
struct _snvs_hp_rtc_config snvs_hp_rtc_config_t
SNVS config structure.
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime)
Sets the SNVS RTC alarm time.
Definition: fsl_snvs_hp.c:412
enum _snvs_hp_status_flags snvs_hp_status_flags_t
List of SNVS flags.
status_t SNVS_HP_RTC_SetDatetime(SNVS_Type *base, const snvs_hp_rtc_datetime_t *datetime)
Sets the SNVS RTC date and time according to the given time structure.
Definition: fsl_snvs_hp.c:354
enum _snvs_hp_sv_status_flags snvs_hp_sv_status_flags_t
List of SNVS security violation flags.
_snvs_hp_interrupts
List of SNVS interrupts.
Definition: fsl_snvs_hp.h:30
void SNVS_HP_RTC_Init(SNVS_Type *base, const snvs_hp_rtc_config_t *config)
Ungates the SNVS clock and configures the peripheral for basic operation.
Definition: fsl_snvs_hp.c:277
void SNVS_HP_RTC_GetAlarm(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime)
Returns the SNVS RTC alarm time.
Definition: fsl_snvs_hp.c:457
void SNVS_HP_Deinit(SNVS_Type *base)
Deinitialize the SNVS.
Definition: fsl_snvs_hp.c:260
_snvs_hp_status_flags
List of SNVS flags.
Definition: fsl_snvs_hp.h:37
enum _snvs_hp_interrupts snvs_hp_interrupts_t
List of SNVS interrupts.
uint32_t SNVS_HP_RTC_GetEnabledInterrupts(SNVS_Type *base)
Gets the enabled SNVS interrupts.
Definition: fsl_snvs_hp.c:526
_snvs_hp_ssm_state
List of SNVS Security State Machine State.
Definition: fsl_snvs_hp.h:124
void SNVS_HP_RTC_Deinit(SNVS_Type *base)
Stops the RTC and SRTC timers.
Definition: fsl_snvs_hp.c:299
void SNVS_HP_RTC_GetDefaultConfig(snvs_hp_rtc_config_t *config)
Fills in the SNVS config struct with the default settings.
Definition: fsl_snvs_hp.c:317
void SNVS_HP_Init(SNVS_Type *base)
Initialize the SNVS.
Definition: fsl_snvs_hp.c:246
_snvs_hp_sv_status_flags
List of SNVS security violation flags.
Definition: fsl_snvs_hp.h:67
void SNVS_HP_RTC_GetDatetime(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime)
Gets the SNVS RTC time and stores it in the given time structure.
Definition: fsl_snvs_hp.c:391
enum _snvs_hp_ssm_state snvs_hp_ssm_state_t
List of SNVS Security State Machine State.
uint32_t SNVS_HP_RTC_GetStatusFlags(SNVS_Type *base)
Gets the SNVS status flags.
Definition: fsl_snvs_hp.c:501
@ kSNVS_RTC_AlarmInterrupt
Definition: fsl_snvs_hp.h:31
@ kSNVS_RTC_PeriodicInterrupt
Definition: fsl_snvs_hp.h:32
@ kSNVS_RTC_PeriodicInterruptFlag
Definition: fsl_snvs_hp.h:39
@ kSNVS_RTC_AlarmInterruptFlag
Definition: fsl_snvs_hp.h:38
@ kSNVS_ZMK_ZeroFlag
Definition: fsl_snvs_hp.h:40
@ kSNVS_OTPMK_ZeroFlag
Definition: fsl_snvs_hp.h:41
@ kSNVS_SSMSoftFail
Definition: fsl_snvs_hp.h:127
@ kSNVS_SSMSecure
Definition: fsl_snvs_hp.h:132
@ kSNVS_SSMInitInter
Definition: fsl_snvs_hp.h:128
@ kSNVS_SSMNonSecure
Definition: fsl_snvs_hp.h:130
@ kSNVS_SSMTrusted
Definition: fsl_snvs_hp.h:131
@ kSNVS_SSMCheck
Definition: fsl_snvs_hp.h:129
@ kSNVS_SSMInit
Definition: fsl_snvs_hp.h:125
@ kSNVS_SSMHardFail
Definition: fsl_snvs_hp.h:126
@ kSNVS_Violation4Flag
Definition: fsl_snvs_hp.h:80
@ kSNVS_Violation0Flag
Definition: fsl_snvs_hp.h:74
@ kSNVS_Violation1Flag
Definition: fsl_snvs_hp.h:75
@ kSNVS_SoftwareViolationFlag
Definition: fsl_snvs_hp.h:73
@ kSNVS_ZMK_EccFailFlag
Definition: fsl_snvs_hp.h:69
@ kSNVS_LP_ViolationFlag
Definition: fsl_snvs_hp.h:68
@ kSNVS_FatalSoftwareViolationFlag
Definition: fsl_snvs_hp.h:72
@ kSNVS_LP_SoftwareViolationFlag
Definition: fsl_snvs_hp.h:71
@ kSNVS_Violation5Flag
Definition: fsl_snvs_hp.h:81
@ kSNVS_Violation2Flag
Definition: fsl_snvs_hp.h:76
Definition: MIMXRT1052.h:41032
SNVS config structure.
Definition: fsl_snvs_hp.h:113
uint32_t rtcCalValue
Definition: fsl_snvs_hp.h:116
bool rtcCalEnable
Definition: fsl_snvs_hp.h:114
uint32_t periodicInterruptFreq
Definition: fsl_snvs_hp.h:118
Structure is used to hold the date and time.
Definition: fsl_snvs_hp.h:94
uint8_t hour
Definition: fsl_snvs_hp.h:98
uint8_t minute
Definition: fsl_snvs_hp.h:99
uint8_t day
Definition: fsl_snvs_hp.h:97
uint8_t month
Definition: fsl_snvs_hp.h:96
uint16_t year
Definition: fsl_snvs_hp.h:95
uint8_t second
Definition: fsl_snvs_hp.h:100
Definition: deflate.c:114