diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM4/drivers/fsl_memory.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM4/drivers/fsl_memory.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM4/drivers/fsl_memory.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM4/drivers/fsl_memory.h new file mode 100644 index 000000000..2c4942d1d --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM4/drivers/fsl_memory.h | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * Copyright 2018 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #ifndef _FSL_MEMORY_H_ | ||
9 | #define _FSL_MEMORY_H_ | ||
10 | |||
11 | #include "fsl_common.h" | ||
12 | |||
13 | /******************************************************************************* | ||
14 | * Definitions | ||
15 | ******************************************************************************/ | ||
16 | /* Component ID definition, used by tools. */ | ||
17 | #ifndef FSL_COMPONENT_ID | ||
18 | #define FSL_COMPONENT_ID "platform.drivers.memory" | ||
19 | #endif | ||
20 | |||
21 | /*! @name Driver version */ | ||
22 | /*@{*/ | ||
23 | /*! @brief IMEMORY driver version 2.0.0. */ | ||
24 | #define FSL_MEMORY_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) | ||
25 | /*@}*/ | ||
26 | |||
27 | /* The CM4 subsystem local TCM start address, refer to Reference Manual for detailed information */ | ||
28 | #define FSL_MEM_M4_TCM_BEGIN 0x1FFE0000U | ||
29 | /* The CM4 subsystem local TCM end address, refer to Reference Manual for detailed information */ | ||
30 | #define FSL_MEM_M4_TCM_END 0x2001FFFFU | ||
31 | |||
32 | /* The CM4 subsystem local OCRAM start address, refer to Reference Manual for detailed information */ | ||
33 | #define FSL_MEM_M4_OCRAM_BEGIN 0x20200000U | ||
34 | /* The CM4 subsystem local OCRAM end address, refer to Reference Manual for detailed information */ | ||
35 | #define FSL_MEM_M4_OCRAM_END 0x2021FFFFU | ||
36 | |||
37 | /* The CM4 subsystem local OCRAMS start address, refer to Reference Manual for detailed information */ | ||
38 | #define FSL_MEM_M4_OCRAMS_BEGIN 0x20180000U | ||
39 | /* The CM4 subsystem local OCRAMS end address, refer to Reference Manual for detailed information */ | ||
40 | #define FSL_MEM_M4_OCRAMS_END 0x20187FFFU | ||
41 | |||
42 | /* System level TCM memory address = CM4 subsystem local TCM address - FSL_FEATURE_TCM_OFFSET */ | ||
43 | #define FSL_MEM_M4_TCM_OFFSET 0x1F800000U | ||
44 | /* System level OCRAM memory address = CM4 subsystem local OCRAM address - FSL_MEM_M4_OCRAM_OFFSET */ | ||
45 | #define FSL_MEM_M4_OCRAM_OFFSET 0x1F900000U | ||
46 | /* System level OCRAMS memory address = CM4 subsystem local OCRAMS address - FSL_MEM_M4_OCRAMS_OFFSET */ | ||
47 | #define FSL_MEM_M4_OCRAMS_OFFSET 0x20000000U | ||
48 | |||
49 | typedef enum _mem_direction | ||
50 | { | ||
51 | kMEMORY_Local2DMA = 0, | ||
52 | kMEMORY_DMA2Local, | ||
53 | } mem_direction_t; | ||
54 | |||
55 | /******************************************************************************* | ||
56 | * API | ||
57 | ******************************************************************************/ | ||
58 | #if defined(__cplusplus) | ||
59 | extern "C" { | ||
60 | #endif | ||
61 | /*! | ||
62 | * @brief Convert the memory map address. | ||
63 | * | ||
64 | * This function convert the address between system mapped address and native mapped address. | ||
65 | * There maybe offset between subsystem native address and system address for some memory, | ||
66 | * this funciton convert the address to different memory map. | ||
67 | * @param addr address need to be converted. | ||
68 | * @param direction convert direction. | ||
69 | * @return the converted address | ||
70 | */ | ||
71 | static inline uint32_t MEMORY_ConvertMemoryMapAddress(uint32_t addr, mem_direction_t direction) | ||
72 | { | ||
73 | uint32_t dest; | ||
74 | |||
75 | switch (direction) | ||
76 | { | ||
77 | case kMEMORY_Local2DMA: | ||
78 | { | ||
79 | if ((addr >= FSL_MEM_M4_TCM_BEGIN) && (addr <= FSL_MEM_M4_TCM_END)) | ||
80 | { | ||
81 | dest = addr - FSL_MEM_M4_TCM_OFFSET; | ||
82 | } | ||
83 | else if ((addr >= FSL_MEM_M4_OCRAM_BEGIN) && (addr <= FSL_MEM_M4_OCRAM_END)) | ||
84 | { | ||
85 | dest = addr - FSL_MEM_M4_OCRAM_OFFSET; | ||
86 | } | ||
87 | else if ((addr >= FSL_MEM_M4_OCRAMS_BEGIN) && (addr <= FSL_MEM_M4_OCRAMS_END)) | ||
88 | { | ||
89 | dest = addr - FSL_MEM_M4_OCRAMS_OFFSET; | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | dest = addr; | ||
94 | } | ||
95 | break; | ||
96 | } | ||
97 | case kMEMORY_DMA2Local: | ||
98 | { | ||
99 | if ((addr >= (FSL_MEM_M4_TCM_BEGIN - FSL_MEM_M4_TCM_OFFSET)) && | ||
100 | (addr <= (FSL_MEM_M4_TCM_END - FSL_MEM_M4_TCM_OFFSET))) | ||
101 | { | ||
102 | dest = addr + FSL_MEM_M4_TCM_OFFSET; | ||
103 | } | ||
104 | else if ((addr >= (FSL_MEM_M4_OCRAM_BEGIN - FSL_MEM_M4_OCRAM_OFFSET)) && | ||
105 | (addr <= (FSL_MEM_M4_OCRAM_END - FSL_MEM_M4_OCRAM_OFFSET))) | ||
106 | { | ||
107 | dest = addr + FSL_MEM_M4_OCRAM_OFFSET; | ||
108 | } | ||
109 | else if ((addr >= (FSL_MEM_M4_OCRAMS_BEGIN - FSL_MEM_M4_OCRAMS_OFFSET)) && | ||
110 | (addr <= (FSL_MEM_M4_OCRAMS_END - FSL_MEM_M4_OCRAMS_OFFSET))) | ||
111 | { | ||
112 | dest = addr + FSL_MEM_M4_OCRAMS_OFFSET; | ||
113 | } | ||
114 | else | ||
115 | { | ||
116 | dest = addr; | ||
117 | } | ||
118 | break; | ||
119 | } | ||
120 | default: | ||
121 | dest = addr; | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | return dest; | ||
126 | } | ||
127 | #if defined(__cplusplus) | ||
128 | } | ||
129 | #endif /* __cplusplus */ | ||
130 | #endif /* _FSL_MEMORY_H_ */ | ||