RTEMS 6.1-rc2
Loading...
Searching...
No Matches
fsl_flexram.h
1/*
2 * Copyright 2017-2022 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_FLEXRAM_H_
10#define _FSL_FLEXRAM_H_
11
12#include "fsl_common.h"
13#include "fsl_flexram_allocate.h"
14
20/******************************************************************************
21 * Definitions.
22 *****************************************************************************/
23
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 \
33 0U /* Define to zero means get raw ECC error information, which needs parse it by user. */
34#endif
35
37enum
38{
41};
42
44enum
45{
46 kFLEXRAM_OCRAMAccessError = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK,
47 kFLEXRAM_DTCMAccessError = FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK,
48 kFLEXRAM_ITCMAccessError = FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK,
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,
64
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,
73#else
74 kFLEXRAM_InterruptStatusAll = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_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,
77#endif /* FSL_FEATURE_FLEXRAM_HAS_ECC */
78
80#else
81 kFLEXRAM_InterruptStatusAll = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK |
82 FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK,
83#endif /* FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR */
84
85};
86
95{
99
101enum
102{
103 kFLEXRAM_TCMSize32KB = 32 * 1024U,
104 kFLEXRAM_TCMSize64KB = 64 * 1024U,
105 kFLEXRAM_TCMSize128KB = 128 * 1024U,
106 kFLEXRAM_TCMSize256KB = 256 * 1024U,
107 kFLEXRAM_TCMSize512KB = 512 * 1024U,
108};
109
110#if (defined(FSL_FEATURE_FLEXRAM_HAS_ECC) && FSL_FEATURE_FLEXRAM_HAS_ECC)
112typedef enum _flexram_memory_type
113{
114 kFLEXRAM_OCRAM = 0U,
115 kFLEXRAM_ITCM = 1U,
116 kFLEXRAM_D0TCM = 2U,
117 kFLEXRAM_D1TCM = 3U,
118} flexram_memory_type_t;
119
121typedef struct _flexram_ecc_error_type
122{
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;
133
135typedef struct _flexram_ocram_ecc_single_error_info
136{
137#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
138 uint8_t OcramSingleErrorECCCipher;
139 uint8_t OcramSingleErrorECCSyndrome;
141#else
142 uint32_t OcramSingleErrorInfo;
143#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
144 uint32_t OcramSingleErrorAddr;
145 uint32_t OcramSingleErrorDataLSB;
146 uint32_t OcramSingleErrorDataMSB;
147} flexram_ocram_ecc_single_error_info_t;
148
151typedef struct _flexram_ocram_ecc_multi_error_info
152{
153#if defined(FLEXRAM_ECC_ERROR_DETAILED_INFO) && FLEXRAM_ECC_ERROR_DETAILED_INFO
154 uint8_t OcramMultiErrorECCCipher;
155#else
156 uint32_t OcramMultiErrorInfo;
157#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
158 uint32_t OcramMultiErrorAddr;
159 uint32_t OcramMultiErrorDataLSB;
160 uint32_t OcramMultiErrorDataMSB;
161} flexram_ocram_ecc_multi_error_info_t;
162
164typedef struct _flexram_itcm_ecc_single_error_info
165{
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;
176#else
177 uint32_t ItcmSingleErrorInfo;
178#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
179 uint32_t ItcmSingleErrorAddr;
180 uint32_t ItcmSingleErrorDataLSB;
181 uint32_t ItcmSingleErrorDataMSB;
182} flexram_itcm_ecc_single_error_info_t;
183
186typedef struct _flexram_itcm_ecc_multi_error_info
187{
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;
199#else
200 uint32_t ItcmMultiErrorInfo;
201#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
202 uint32_t ItcmMultiErrorAddr;
203 uint32_t ItcmMultiErrorDataLSB;
204 uint32_t ItcmMultiErrorDataMSB;
205} flexram_itcm_ecc_multi_error_info_t;
206
208typedef struct _flexram_dtcm_ecc_single_error_info
209{
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;
220#else
221 uint32_t DtcmSingleErrorInfo;
222#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
223 uint32_t DtcmSingleErrorAddr;
224 uint32_t DtcmSingleErrorData;
225} flexram_dtcm_ecc_single_error_info_t;
226
229typedef struct _flexram_dtcm_ecc_multi_error_info
230{
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;
242#else
243 uint32_t DtcmMultiErrorInfo;
244#endif /*FLEXRAM_ECC_ERROR_DETAILED_INFO*/
245 uint32_t DtcmMultiErrorAddr;
246 uint32_t DtcmMultiErrorData;
247} flexram_dtcm_ecc_multi_error_info_t;
248
249#endif /* FSL_FEATURE_FLEXRAM_HAS_ECC */
250
251/*******************************************************************************
252 * APIs
253 ******************************************************************************/
254
255#if defined(__cplusplus)
256extern "C" {
257#endif
258
269void FLEXRAM_Init(FLEXRAM_Type *base);
270
275void FLEXRAM_Deinit(FLEXRAM_Type *base);
276
277/* @} */
278
288static inline uint32_t FLEXRAM_GetInterruptStatus(FLEXRAM_Type *base)
289{
290 return base->INT_STATUS & (uint32_t)kFLEXRAM_InterruptStatusAll;
291}
292
299static inline void FLEXRAM_ClearInterruptStatus(FLEXRAM_Type *base, uint32_t status)
300{
301 base->INT_STATUS |= status;
302}
303
310static inline void FLEXRAM_EnableInterruptStatus(FLEXRAM_Type *base, uint32_t status)
311{
312 base->INT_STAT_EN |= status;
313}
314
321static inline void FLEXRAM_DisableInterruptStatus(FLEXRAM_Type *base, uint32_t status)
322{
323 base->INT_STAT_EN &= ~status;
324}
325
326/* @} */
327
339static inline void FLEXRAM_EnableInterruptSignal(FLEXRAM_Type *base, uint32_t status)
340{
341 base->INT_SIG_EN |= status;
342}
343
350static inline void FLEXRAM_DisableInterruptSignal(FLEXRAM_Type *base, uint32_t status)
351{
352 base->INT_SIG_EN &= ~status;
353}
354/* @} */
355
362static inline void FLEXRAM_SetTCMReadAccessMode(FLEXRAM_Type *base, flexram_tcm_access_mode_t mode)
363{
364 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_RWAIT_EN_MASK;
365 base->TCM_CTRL |= (uint32_t)mode;
366}
367
374static inline void FLEXRAM_SetTCMWriteAccessMode(FLEXRAM_Type *base, flexram_tcm_access_mode_t mode)
375{
376 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_WWAIT_EN_MASK;
377 base->TCM_CTRL |= (uint32_t)mode;
378}
379
386static inline void FLEXRAM_EnableForceRamClockOn(FLEXRAM_Type *base, bool enable)
387{
388 if (enable)
389 {
390 base->TCM_CTRL |= FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
391 }
392 else
393 {
394 base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
395 }
396}
397
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)
407{
408 base->OCRAM_MAGIC_ADDR = FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_WR_RD_SEL(rwSel) |
409 FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
410}
411
419static inline void FLEXRAM_SetDTCMMagicAddr(FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
420{
421 base->DTCM_MAGIC_ADDR = FLEXRAM_DTCM_MAGIC_ADDR_DTCM_WR_RD_SEL(rwSel) |
422 FLEXRAM_DTCM_MAGIC_ADDR_DTCM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
423}
424
432static inline void FLEXRAM_SetITCMMagicAddr(FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
433{
434 base->ITCM_MAGIC_ADDR = FLEXRAM_ITCM_MAGIC_ADDR_ITCM_WR_RD_SEL(rwSel) |
435 FLEXRAM_ITCM_MAGIC_ADDR_ITCM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
436}
437#endif /* FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR */
438
439#if (defined(FSL_FEATURE_FLEXRAM_HAS_ECC) && FSL_FEATURE_FLEXRAM_HAS_ECC)
446void FLEXRAM_EnableECC(FLEXRAM_Type *base, bool OcramECCEnable, bool TcmECCEnable);
447
454void FLEXRAM_ErrorInjection(FLEXRAM_Type *base, flexram_memory_type_t memory, flexram_ecc_error_type_t *error);
455
461void FLEXRAM_GetOcramSingleErroInfo(FLEXRAM_Type *base, flexram_ocram_ecc_single_error_info_t *info);
462
468void FLEXRAM_GetOcramMultiErroInfo(FLEXRAM_Type *base, flexram_ocram_ecc_multi_error_info_t *info);
469
475void FLEXRAM_GetItcmSingleErroInfo(FLEXRAM_Type *base, flexram_itcm_ecc_single_error_info_t *info);
476
482void FLEXRAM_GetItcmMultiErroInfo(FLEXRAM_Type *base, flexram_itcm_ecc_multi_error_info_t *info);
483
490void FLEXRAM_GetDtcmSingleErroInfo(FLEXRAM_Type *base, flexram_dtcm_ecc_single_error_info_t *info, uint8_t bank);
491
498void FLEXRAM_GetDtcmMultiErroInfo(FLEXRAM_Type *base, flexram_dtcm_ecc_multi_error_info_t *info, uint8_t bank);
499
500#endif /* FSL_FEATURE_FLEXRAM_HAS_ECC */
501
502#if defined(__cplusplus)
503}
504#endif
505
508#endif
#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