10#define _FSL_FLEXRAM_H_
12#include "fsl_common.h"
13#include "fsl_flexram_allocate.h"
27#define FSL_FLEXRAM_DRIVER_VERSION (MAKE_VERSION(2U, 2U, 0U))
31#ifndef FLEXRAM_ECC_ERROR_DETAILED_INFO
32#define FLEXRAM_ECC_ERROR_DETAILED_INFO \
50#if defined(FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR) && FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR
51 kFLEXRAM_OCRAMMagicAddrMatch = FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK,
52 kFLEXRAM_DTCMMagicAddrMatch = FLEXRAM_INT_STATUS_DTCM_MAM_STATUS_MASK,
53 kFLEXRAM_ITCMMagicAddrMatch = FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK,
55#if defined(FSL_FEATURE_FLEXRAM_HAS_ECC) && FSL_FEATURE_FLEXRAM_HAS_ECC
56 kFLEXRAM_OCRAMECCMultiError = FLEXRAM_INT_STATUS_OCRAM_ECC_ERRM_INT_MASK,
57 kFLEXRAM_OCRAMECCSingleError = FLEXRAM_INT_STATUS_OCRAM_ECC_ERRS_INT_MASK,
58 kFLEXRAM_ITCMECCMultiError = FLEXRAM_INT_STATUS_ITCM_ECC_ERRM_INT_MASK,
59 kFLEXRAM_ITCMECCSingleError = FLEXRAM_INT_STATUS_ITCM_ECC_ERRS_INT_MASK,
60 kFLEXRAM_D0TCMECCMultiError = FLEXRAM_INT_STATUS_D0TCM_ECC_ERRM_INT_MASK,
61 kFLEXRAM_D0TCMECCSingleError = FLEXRAM_INT_STATUS_D0TCM_ECC_ERRS_INT_MASK,
62 kFLEXRAM_D1TCMECCMultiError = FLEXRAM_INT_STATUS_D1TCM_ECC_ERRM_INT_MASK,
63 kFLEXRAM_D1TCMECCSingleError = FLEXRAM_INT_STATUS_D1TCM_ECC_ERRS_INT_MASK,
66 FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK |
67 FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK |
68 FLEXRAM_INT_STATUS_DTCM_MAM_STATUS_MASK | FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK |
69 FLEXRAM_INT_STATUS_OCRAM_ECC_ERRM_INT_MASK | FLEXRAM_INT_STATUS_OCRAM_ECC_ERRS_INT_MASK |
70 FLEXRAM_INT_STATUS_ITCM_ECC_ERRM_INT_MASK | FLEXRAM_INT_STATUS_ITCM_ECC_ERRS_INT_MASK |
71 FLEXRAM_INT_STATUS_D0TCM_ECC_ERRM_INT_MASK | FLEXRAM_INT_STATUS_D0TCM_ECC_ERRS_INT_MASK |
72 FLEXRAM_INT_STATUS_D1TCM_ECC_ERRM_INT_MASK | FLEXRAM_INT_STATUS_D1TCM_ECC_ERRS_INT_MASK,
75 FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK |
76 FLEXRAM_INT_STATUS_DTCM_MAM_STATUS_MASK | FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK,
82 FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK,
110#if (defined(FSL_FEATURE_FLEXRAM_HAS_ECC) && FSL_FEATURE_FLEXRAM_HAS_ECC)
112typedef enum _flexram_memory_type
118} flexram_memory_type_t;
121typedef struct _flexram_ecc_error_type
123 uint8_t SingleBitPos;
124 uint8_t SecondBitPos;
125 bool Fource1BitDataInversion;
126 bool FourceOneNCDataInversion;
128 bool FourceConti1BitDataInversion;
130 bool FourceContiNCDataInversion;
132} flexram_ecc_error_type_t;
135typedef struct _flexram_ocram_ecc_single_error_info
137#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
138 uint8_t OcramSingleErrorECCCipher;
139 uint8_t OcramSingleErrorECCSyndrome;
142 uint32_t OcramSingleErrorInfo;
144 uint32_t OcramSingleErrorAddr;
145 uint32_t OcramSingleErrorDataLSB;
146 uint32_t OcramSingleErrorDataMSB;
147} flexram_ocram_ecc_single_error_info_t;
151typedef struct _flexram_ocram_ecc_multi_error_info
153#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
154 uint8_t OcramMultiErrorECCCipher;
156 uint32_t OcramMultiErrorInfo;
158 uint32_t OcramMultiErrorAddr;
159 uint32_t OcramMultiErrorDataLSB;
160 uint32_t OcramMultiErrorDataMSB;
161} flexram_ocram_ecc_multi_error_info_t;
164typedef struct _flexram_itcm_ecc_single_error_info
166#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
167 uint8_t ItcmSingleErrorTCMWriteRead;
169 uint8_t ItcmSingleErrorTCMAccessSize;
171 uint8_t ItcmSingleErrorTCMMaster;
173 uint8_t ItcmSingleErrorTCMPrivilege;
175 uint8_t ItcmSingleErrorBitPostion;
177 uint32_t ItcmSingleErrorInfo;
179 uint32_t ItcmSingleErrorAddr;
180 uint32_t ItcmSingleErrorDataLSB;
181 uint32_t ItcmSingleErrorDataMSB;
182} flexram_itcm_ecc_single_error_info_t;
186typedef struct _flexram_itcm_ecc_multi_error_info
188#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
189 uint8_t ItcmMultiErrorTCMWriteRead;
191 uint8_t ItcmMultiErrorTCMAccessSize;
193 uint8_t ItcmMultiErrorTCMMaster;
195 uint8_t ItcmMultiErrorTCMPrivilege;
197 uint8_t ItcmMultiErrorECCSyndrome;
200 uint32_t ItcmMultiErrorInfo;
202 uint32_t ItcmMultiErrorAddr;
203 uint32_t ItcmMultiErrorDataLSB;
204 uint32_t ItcmMultiErrorDataMSB;
205} flexram_itcm_ecc_multi_error_info_t;
208typedef struct _flexram_dtcm_ecc_single_error_info
210#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
211 uint8_t DtcmSingleErrorTCMWriteRead;
213 uint8_t DtcmSingleErrorTCMAccessSize;
215 uint8_t DtcmSingleErrorTCMMaster;
217 uint8_t DtcmSingleErrorTCMPrivilege;
219 uint8_t DtcmSingleErrorBitPostion;
221 uint32_t DtcmSingleErrorInfo;
223 uint32_t DtcmSingleErrorAddr;
224 uint32_t DtcmSingleErrorData;
225} flexram_dtcm_ecc_single_error_info_t;
229typedef struct _flexram_dtcm_ecc_multi_error_info
231#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
232 uint8_t DtcmMultiErrorTCMWriteRead;
234 uint8_t DtcmMultiErrorTCMAccessSize;
236 uint8_t DtcmMultiErrorTCMMaster;
238 uint8_t DtcmMultiErrorTCMPrivilege;
240 uint8_t DtcmMultiErrorECCSyndrome;
243 uint32_t DtcmMultiErrorInfo;
245 uint32_t DtcmMultiErrorAddr;
246 uint32_t DtcmMultiErrorData;
247} flexram_dtcm_ecc_multi_error_info_t;
255#if defined(__cplusplus)
288static inline uint32_t FLEXRAM_GetInterruptStatus(
FLEXRAM_Type *base)
299static inline void FLEXRAM_ClearInterruptStatus(
FLEXRAM_Type *base, uint32_t status)
301 base->INT_STATUS |= status;
310static inline void FLEXRAM_EnableInterruptStatus(
FLEXRAM_Type *base, uint32_t status)
312 base->INT_STAT_EN |= status;
321static inline void FLEXRAM_DisableInterruptStatus(
FLEXRAM_Type *base, uint32_t status)
323 base->INT_STAT_EN &= ~status;
339static inline void FLEXRAM_EnableInterruptSignal(
FLEXRAM_Type *base, uint32_t status)
341 base->INT_SIG_EN |= status;
350static inline void FLEXRAM_DisableInterruptSignal(
FLEXRAM_Type *base, uint32_t status)
352 base->INT_SIG_EN &= ~status;
364 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_RWAIT_EN_MASK;
365 base->TCM_CTRL |= (uint32_t)mode;
376 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_WWAIT_EN_MASK;
377 base->TCM_CTRL |= (uint32_t)mode;
386static inline void FLEXRAM_EnableForceRamClockOn(
FLEXRAM_Type *base,
bool enable)
390 base->TCM_CTRL |= FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
394 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
398#if defined(FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR) && FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR
406static inline void FLEXRAM_SetOCRAMMagicAddr(
FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
419static inline void FLEXRAM_SetDTCMMagicAddr(
FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
432static inline void FLEXRAM_SetITCMMagicAddr(
FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
439#if (defined(FSL_FEATURE_FLEXRAM_HAS_ECC) && FSL_FEATURE_FLEXRAM_HAS_ECC)
446void FLEXRAM_EnableECC(
FLEXRAM_Type *base,
bool OcramECCEnable,
bool TcmECCEnable);
454void FLEXRAM_ErrorInjection(
FLEXRAM_Type *base, flexram_memory_type_t memory, flexram_ecc_error_type_t *error);
461void FLEXRAM_GetOcramSingleErroInfo(
FLEXRAM_Type *base, flexram_ocram_ecc_single_error_info_t *info);
468void FLEXRAM_GetOcramMultiErroInfo(
FLEXRAM_Type *base, flexram_ocram_ecc_multi_error_info_t *info);
475void FLEXRAM_GetItcmSingleErroInfo(
FLEXRAM_Type *base, flexram_itcm_ecc_single_error_info_t *info);
482void FLEXRAM_GetItcmMultiErroInfo(
FLEXRAM_Type *base, flexram_itcm_ecc_multi_error_info_t *info);
490void FLEXRAM_GetDtcmSingleErroInfo(
FLEXRAM_Type *base, flexram_dtcm_ecc_single_error_info_t *info, uint8_t bank);
498void FLEXRAM_GetDtcmMultiErroInfo(
FLEXRAM_Type *base, flexram_dtcm_ecc_multi_error_info_t *info, uint8_t bank);
502#if defined(__cplusplus)
#define FLEXRAM_DTCM_MAGIC_ADDR_DTCM_WR_RD_SEL(x)
Definition: MIMXRT1166_cm4.h:38603
#define FLEXRAM_ITCM_MAGIC_ADDR_ITCM_WR_RD_SEL(x)
Definition: MIMXRT1166_cm4.h:38627
#define FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_WR_RD_SEL(x)
Definition: MIMXRT1166_cm4.h:38579
#define FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_MAGIC_ADDR(x)
Definition: MIMXRT1166_cm4.h:38585
#define FLEXRAM_DTCM_MAGIC_ADDR_DTCM_MAGIC_ADDR(x)
Definition: MIMXRT1166_cm4.h:38609
#define FLEXRAM_ITCM_MAGIC_ADDR_ITCM_MAGIC_ADDR(x)
Definition: MIMXRT1166_cm4.h:38633
enum _flexram_tcm_access_mode flexram_tcm_access_mode_t
FLEXRAM TCM access mode. Fast access mode expected to be finished in 1-cycle; Wait access mode expect...
_flexram_tcm_access_mode
FLEXRAM TCM access mode. Fast access mode expected to be finished in 1-cycle; Wait access mode expect...
Definition: fsl_flexram.h:95
void FLEXRAM_Deinit(FLEXRAM_Type *base)
De-initializes the FLEXRAM.
Definition: fsl_flexram.c:101
void FLEXRAM_Init(FLEXRAM_Type *base)
FLEXRAM module initialization function.
Definition: fsl_flexram.c:82
@ kFLEXRAM_ITCMAccessError
Definition: fsl_flexram.h:48
@ kFLEXRAM_InterruptStatusAll
Definition: fsl_flexram.h:81
@ kFLEXRAM_OCRAMAccessError
Definition: fsl_flexram.h:46
@ kFLEXRAM_DTCMAccessError
Definition: fsl_flexram.h:47
@ kFLEXRAM_TCMAccessWaitMode
Definition: fsl_flexram.h:97
@ kFLEXRAM_TCMAccessFastMode
Definition: fsl_flexram.h:96
@ kFLEXRAM_TCMSize64KB
Definition: fsl_flexram.h:104
@ kFLEXRAM_TCMSize256KB
Definition: fsl_flexram.h:106
@ kFLEXRAM_TCMSize32KB
Definition: fsl_flexram.h:103
@ kFLEXRAM_TCMSize128KB
Definition: fsl_flexram.h:105
@ kFLEXRAM_TCMSize512KB
Definition: fsl_flexram.h:107
@ kFLEXRAM_Write
Definition: fsl_flexram.h:40
@ kFLEXRAM_Read
Definition: fsl_flexram.h:39
Definition: MIMXRT1052.h:21139