1 /******************************************************************************
2 *
3 * Copyright (C) 2023 Analog Devices, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #ifndef LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_DMA_H_
20 #define LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_DMA_H_
21
22 /***** Includes *****/
23 #include <dma.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /*
30 * MAX32665, MAX32666 related mapping
31 */
32 #if defined(CONFIG_SOC_MAX32665) || (CONFIG_SOC_MAX32666)
33
34 #define ADI_MAX32_DMA_CTRL_DIS_IE MXC_F_DMA_CFG_CHDIEN
35 #define ADI_MAX32_DMA_CTRL_CTZIEN MXC_F_DMA_CFG_CTZIEN
36
37 #define ADI_MAX32_DMA_STATUS_IPEND MXC_F_DMA_ST_IPEND
38 #define ADI_MAX32_DMA_STATUS_BUS_ERR MXC_F_DMA_ST_BUS_ERR
39 #define ADI_MAX32_DMA_STATUS_TO_IF MXC_F_DMA_ST_TO_ST
40 #define ADI_MAX32_DMA_STATUS_ST MXC_F_DMA_ST_CH_ST
41
42 #define ADI_MAX32_DMA_CFG_REQ_POS MXC_F_DMA_CFG_REQSEL_POS
43
MXC_DMA_GetIntFlags(mxc_dma_regs_t * dma)44 static inline int MXC_DMA_GetIntFlags(mxc_dma_regs_t *dma)
45 {
46 return dma->intr;
47 }
48
Wrap_MXC_DMA_Init(mxc_dma_regs_t * dma)49 static inline int Wrap_MXC_DMA_Init(mxc_dma_regs_t *dma)
50 {
51 return MXC_DMA_Init(dma);
52 }
53
Wrap_MXC_DMA_DeInit(mxc_dma_regs_t * dma)54 static inline void Wrap_MXC_DMA_DeInit(mxc_dma_regs_t *dma)
55 {
56 MXC_DMA_DeInit(dma);
57 }
58
Wrap_MXC_DMA_AcquireChannel(mxc_dma_regs_t * dma)59 static inline int Wrap_MXC_DMA_AcquireChannel(mxc_dma_regs_t *dma)
60 {
61 return MXC_DMA_AcquireChannel(dma);
62 }
63
Wrap_MXC_DMA_Handler(mxc_dma_regs_t * dma)64 static inline void Wrap_MXC_DMA_Handler(mxc_dma_regs_t *dma)
65 {
66 MXC_DMA_Handler(dma);
67 }
68
Wrap_MXC_DMA_MemCpy(mxc_dma_regs_t * dma,void * dest,void * src,int len,mxc_dma_complete_cb_t callback)69 static inline int Wrap_MXC_DMA_MemCpy(mxc_dma_regs_t *dma, void *dest, void *src, int len,
70 mxc_dma_complete_cb_t callback)
71 {
72 return MXC_DMA_MemCpy(dma, dest, src, len, callback);
73 }
74
Wrap_MXC_DMA_DoTransfer(mxc_dma_regs_t * dma,mxc_dma_config_t config,mxc_dma_srcdst_t firstSrcDst,mxc_dma_trans_chain_t callback)75 static inline int Wrap_MXC_DMA_DoTransfer(mxc_dma_regs_t *dma, mxc_dma_config_t config,
76 mxc_dma_srcdst_t firstSrcDst,
77 mxc_dma_trans_chain_t callback)
78 {
79 return MXC_DMA_DoTransfer(dma, config, firstSrcDst, callback);
80 }
81
82 /*
83 * MAX32690, MAX32655 related mapping
84 */
85 #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \
86 (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \
87 (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX78002) || (CONFIG_SOC_MAX78000)
88
89 #define ADI_MAX32_DMA_CTRL_DIS_IE MXC_F_DMA_CTRL_DIS_IE
90 #define ADI_MAX32_DMA_CTRL_CTZIEN MXC_F_DMA_CTRL_CTZ_IE
91
92 #define ADI_MAX32_DMA_STATUS_IPEND MXC_F_DMA_STATUS_IPEND
93 #define ADI_MAX32_DMA_STATUS_BUS_ERR MXC_F_DMA_STATUS_BUS_ERR
94 #define ADI_MAX32_DMA_STATUS_TO_IF MXC_F_DMA_STATUS_TO_IF
95 #define ADI_MAX32_DMA_STATUS_ST MXC_F_DMA_STATUS_STATUS
96
97 #define ADI_MAX32_DMA_CFG_REQ_POS MXC_F_DMA_CTRL_REQUEST_POS
98
99 static inline int MXC_DMA_GetIntFlags(mxc_dma_regs_t *dma)
100 {
101 return dma->intfl;
102 }
103
104 static inline int Wrap_MXC_DMA_Init(mxc_dma_regs_t *dma)
105 {
106 (void)dma;
107 return MXC_DMA_Init();
108 }
109
110 static inline void Wrap_MXC_DMA_DeInit(mxc_dma_regs_t *dma)
111 {
112 (void)dma;
113 MXC_DMA_DeInit();
114 }
115
116 static inline int Wrap_MXC_DMA_AcquireChannel(mxc_dma_regs_t *dma)
117 {
118 (void)dma;
119 return MXC_DMA_AcquireChannel();
120 }
121
122 static inline void Wrap_MXC_DMA_Handler(mxc_dma_regs_t *dma)
123 {
124 (void)dma;
125 MXC_DMA_Handler();
126 }
127
128 static inline int Wrap_MXC_DMA_MemCpy(mxc_dma_regs_t *dma, void *dest, void *src, int len,
129 mxc_dma_complete_cb_t callback)
130 {
131 (void)dma;
132 return MXC_DMA_MemCpy(dest, src, len, callback);
133 }
134
135 static inline int Wrap_MXC_DMA_DoTransfer(mxc_dma_regs_t *dma, mxc_dma_config_t config,
136 mxc_dma_srcdst_t firstSrcDst,
137 mxc_dma_trans_chain_t callback)
138 {
139 (void)dma;
140 return MXC_DMA_DoTransfer(config, firstSrcDst, callback);
141 }
142
143 #endif // part number
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif // LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_DMA_H_
150