RTEMS 6.1-rc2
Loading...
Searching...
No Matches
fsl_memory.h
1/*
2 * Copyright 2021 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _FSL_MEMORY_H_
8#define _FSL_MEMORY_H_
9
10#include "fsl_common.h"
11
12/*******************************************************************************
13 * Definitions
14 ******************************************************************************/
15/* Component ID definition, used by tools. */
16#ifndef FSL_COMPONENT_ID
17#define FSL_COMPONENT_ID "platform.drivers.memory"
18#endif
19/* The CM4 subsystem local TCM start address, refer to Reference Manual for detailed information */
20#define FSL_MEM_M4_TCM_BEGIN 0x1FFE0000U
21/* The CM4 subsystem local TCM end address, refer to Reference Manual for detailed information */
22#define FSL_MEM_M4_TCM_END 0x2001FFFFU
23
24#define FSL_MEM_M4_TCM_OFFSET 0x220000U
25
26typedef enum _mem_direction
27{
28 kMEMORY_Local2DMA = 0,
29 kMEMORY_DMA2Local,
30} mem_direction_t;
31
32/*******************************************************************************
33 * API
34 ******************************************************************************/
35#if defined(__cplusplus)
36extern "C" {
37#endif
48static inline uint32_t MEMORY_ConvertMemoryMapAddress(uint32_t addr, mem_direction_t direction)
49{
50 uint32_t dest;
51
52 switch (direction)
53 {
54 case kMEMORY_Local2DMA:
55 {
56 if ((addr >= FSL_MEM_M4_TCM_BEGIN) && (addr <= FSL_MEM_M4_TCM_END))
57 {
58 dest = addr + FSL_MEM_M4_TCM_OFFSET;
59 }
60 else
61 {
62 dest = addr;
63 }
64 break;
65 }
66 case kMEMORY_DMA2Local:
67 {
68 if ((addr >= (FSL_MEM_M4_TCM_BEGIN + FSL_MEM_M4_TCM_OFFSET)) &&
69 (addr <= (FSL_MEM_M4_TCM_END + FSL_MEM_M4_TCM_OFFSET)))
70 {
71 dest = addr - FSL_MEM_M4_TCM_OFFSET;
72 }
73 else
74 {
75 dest = addr;
76 }
77 break;
78 }
79 default:
80 dest = addr;
81 break;
82 }
83
84 return dest;
85}
86#if defined(__cplusplus)
87}
88#endif /* __cplusplus */
89#endif /* _FSL_MEMORY_H_ */