1 /*
2 * Copyright 2019-2021 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #ifndef _FSL_FLEXRAM_ALLOCATE_H_
10 #define _FSL_FLEXRAM_ALLOCATE_H_
11
12 #include "fsl_common.h"
13
14 /*!
15 * @addtogroup flexram
16 * @{
17 */
18
19 /******************************************************************************
20 * Definitions.
21 *****************************************************************************/
22
23 /*! @name Driver version */
24 /*@{*/
25 /*! @brief SOC_FLEXRAM_ALLOCATE driver version 2.0.2. */
26 #define FSL_SOC_FLEXRAM_ALLOCATE_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
27 /*@}*/
28
29 /*! @brief FLEXRAM bank type */
30 enum
31 {
32 kFLEXRAM_BankNotUsed = 0U, /*!< bank is not used */
33 kFLEXRAM_BankOCRAM = 1U, /*!< bank is OCRAM */
34 kFLEXRAM_BankDTCM = 2U, /*!< bank is DTCM */
35 kFLEXRAM_BankITCM = 3U, /*!< bank is ITCM */
36 };
37
38 /*! @brief FLEXRAM bank allocate source */
39 typedef enum _flexram_bank_allocate_src
40 {
41 kFLEXRAM_BankAllocateThroughHardwareFuse = 0U, /*!< allocate ram through hardware fuse value */
42 kFLEXRAM_BankAllocateThroughBankCfg = 1U, /*!< allocate ram through FLEXRAM_BANK_CFG */
43 } flexram_bank_allocate_src_t;
44
45 /*! @brief FLEXRAM allocates OCRAM, ITCM, DTCM size. */
46 typedef struct _flexram_allocate_ram
47 {
48 const uint8_t ocramBankNum; /*!< OCRAM banknumber which the SOC support. */
49 const uint8_t dtcmBankNum; /*!< DTCM bank number to allocate, the number should be power of 2. */
50 const uint8_t itcmBankNum; /*!< ITCM bank number to allocate, the number should be power of 2. */
51 } flexram_allocate_ram_t;
52
53 /*******************************************************************************
54 * APIs
55 ******************************************************************************/
56
57 #if defined(__cplusplus)
58 extern "C" {
59 #endif
60
61 /*!
62 * @brief FLEXRAM allocates an on-chip ram for OCRAM, ITCM and DTCM.
63 * This function is independent from FLEXRAM_Init, and can be called directly if ram re-allocate
64 * is needed.
65 * @param config Allocate configuration.
66 * @retval #kStatus_InvalidArgument When the argument is invalid.
67 * @retval #kStatus_Success Upon allocate success.
68 */
69 status_t FLEXRAM_AllocateRam(flexram_allocate_ram_t *config);
70
71 /*!
72 * @brief FLEXRAM set allocate on-chip ram source.
73 * @param src Bank config source select value.
74 */
FLEXRAM_SetAllocateRamSrc(flexram_bank_allocate_src_t src)75 static inline void FLEXRAM_SetAllocateRamSrc(flexram_bank_allocate_src_t src)
76 {
77 IOMUXC_GPR->GPR16 &= ~IOMUXC_GPR_GPR16_FLEXRAM_BANK_CFG_SEL_MASK;
78 IOMUXC_GPR->GPR16 |= IOMUXC_GPR_GPR16_FLEXRAM_BANK_CFG_SEL(src);
79 }
80
81 #if defined(__cplusplus)
82 }
83 #endif
84
85 /*! @}*/
86
87 #endif
88