RTEMS 6.1-rc1
edma.h
Go to the documentation of this file.
1
9/*
10 * Copyright (C) 2008, 2020 embedded brains GmbH & Co. KG
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef LIBBSP_SHARED_FSL_EDMA_H
35#define LIBBSP_SHARED_FSL_EDMA_H
36
37#include <fsl/regs-edma.h>
38
39#include <rtems.h>
40#include <rtems/chain.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46#ifdef LIBBSP_ARM_IMXRT_BSP_H
47 #define EDMA_CHANNEL_COUNT 32U
48#elif MPC55XX_CHIP_FAMILY == 551
49 #define EDMA_CHANNEL_COUNT 16U
50#elif MPC55XX_CHIP_FAMILY == 564
51 #define EDMA_CHANNEL_COUNT 16U
52#elif MPC55XX_CHIP_FAMILY == 567
53 #define EDMA_CHANNEL_COUNT 96U
54#else
55 #define EDMA_CHANNEL_COUNT 64U
56#endif
57
58#define EDMA_MODULE_COUNT ((EDMA_CHANNEL_COUNT + 63U) / 64U)
59
60#define EDMA_CHANNELS_PER_MODULE 64U
61
62volatile struct fsl_edma_tcd *fsl_edma_tcd_of_channel_index(unsigned index);
63unsigned fsl_edma_channel_index_of_tcd(volatile struct fsl_edma_tcd *edma_tcd);
64
65#ifdef LIBBSP_POWERPC_MPC55XXEVB_BSP_H
66 #error Legacy stuff. Move to compatibility layer.
67 #if EDMA_MODULE_COUNT == 1
68 #define EDMA_TCD_BY_CHANNEL_INDEX(channel_index) \
69 (&EDMA.TCD[(channel_index)])
70 #elif EDMA_MODULE_COUNT == 2
71 #define EDMA_TCD_BY_CHANNEL_INDEX(channel_index) \
72 ((channel_index) < EDMA_CHANNELS_PER_MODULE ? \
73 &EDMA_A.TCD[(channel_index)] \
74 : &EDMA_B.TCD[(channel_index) - EDMA_CHANNELS_PER_MODULE])
75 #else
76 #error "unsupported module count"
77 #endif
78#endif
79
80#ifdef LIBBSP_POWERPC_MPC55XXEVB_BSP_H
81typedef enum {
82/* FIXME: These values are only valid for the MPC5566 and MPC5674F */
83 EDMA_EQADC_A_FISR0_CFFF0 = 0,
84 EDMA_EQADC_A_FISR0_RFDF0 = 1,
85 EDMA_EQADC_A_FISR1_CFFF1 = 2,
86 EDMA_EQADC_A_FISR1_RFDF1 = 3,
87 EDMA_EQADC_A_FISR2_CFFF2 = 4,
88 EDMA_EQADC_A_FISR2_RFDF2 = 5,
89 EDMA_EQADC_A_FISR3_CFFF3 = 6,
90 EDMA_EQADC_A_FISR3_RFDF3 = 7,
91 EDMA_EQADC_A_FISR4_CFFF4 = 8,
92 EDMA_EQADC_A_FISR4_RFDF4 = 9,
93 EDMA_EQADC_A_FISR5_CFFF5 = 10,
94 EDMA_EQADC_A_FISR5_RFDF5 = 11,
95 EDMA_DSPI_B_SR_TFFF = 12,
96 EDMA_DSPI_B_SR_RFDF = 13,
97 EDMA_DSPI_C_SR_TFFF = 14,
98 EDMA_DSPI_C_SR_RFDF = 15,
99 EDMA_DSPI_D_SR_TFFF = 16,
100 EDMA_DSPI_D_SR_RFDF = 17,
101 EDMA_ESCI_A_COMBTX = 18,
102 EDMA_ESCI_A_COMBRX = 19,
103 EDMA_EMIOS_GFR_F0 = 20,
104 EDMA_EMIOS_GFR_F1 = 21,
105 EDMA_EMIOS_GFR_F2 = 22,
106 EDMA_EMIOS_GFR_F3 = 23,
107 EDMA_EMIOS_GFR_F4 = 24,
108 EDMA_EMIOS_GFR_F8 = 25,
109 EDMA_EMIOS_GFR_F9 = 26,
110 EDMA_ETPU_CDTRSR_A_DTRS0 = 27,
111 EDMA_ETPU_CDTRSR_A_DTRS1 = 28,
112 EDMA_ETPU_CDTRSR_A_DTRS2 = 29,
113 EDMA_ETPU_CDTRSR_A_DTRS14 = 30,
114 EDMA_ETPU_CDTRSR_A_DTRS15 = 31,
115 EDMA_DSPI_A_SR_TFFF = 32,
116 EDMA_DSPI_A_SR_RFDF = 33,
117 EDMA_ESCI_B_COMBTX = 34,
118 EDMA_ESCI_B_COMBRX = 35,
119 EDMA_EMIOS_GFR_F6 = 36,
120 EDMA_EMIOS_GFR_F7 = 37,
121 EDMA_EMIOS_GFR_F10 = 38,
122 EDMA_EMIOS_GFR_F11 = 39,
123 EDMA_EMIOS_GFR_F16 = 40,
124 EDMA_EMIOS_GFR_F17 = 41,
125 EDMA_EMIOS_GFR_F18 = 42,
126 EDMA_EMIOS_GFR_F19 = 43,
127 EDMA_ETPU_CDTRSR_A_DTRS12 = 44,
128 EDMA_ETPU_CDTRSR_A_DTRS13 = 45,
129 EDMA_ETPU_CDTRSR_A_DTRS28 = 46,
130 EDMA_ETPU_CDTRSR_A_DTRS29 = 47,
131 EDMA_SIU_EISR_EIF0 = 48,
132 EDMA_SIU_EISR_EIF1 = 49,
133 EDMA_SIU_EISR_EIF2 = 50,
134 EDMA_SIU_EISR_EIF3 = 51,
135 EDMA_ETPU_CDTRSR_B_DTRS0 = 52,
136 EDMA_ETPU_CDTRSR_B_DTRS1 = 53,
137 EDMA_ETPU_CDTRSR_B_DTRS2 = 54,
138 EDMA_ETPU_CDTRSR_B_DTRS3 = 55,
139 EDMA_ETPU_CDTRSR_B_DTRS12 = 56,
140 EDMA_ETPU_CDTRSR_B_DTRS13 = 57,
141 EDMA_ETPU_CDTRSR_B_DTRS14 = 58,
142 EDMA_ETPU_CDTRSR_B_DTRS15 = 59,
143 EDMA_ETPU_CDTRSR_B_DTRS28 = 60,
144 EDMA_ETPU_CDTRSR_B_DTRS29 = 61,
145 EDMA_ETPU_CDTRSR_B_DTRS30 = 62,
146 EDMA_ETPU_CDTRSR_B_DTRS31 = 63
147 #if MPC55XX_CHIP_FAMILY == 567
148 ,
149 EDMA_EQADC_B_FISR0_CFFF0 = 64 + 0,
150 EDMA_EQADC_B_FISR0_RFDF0 = 64 + 1,
151 EDMA_EQADC_B_FISR1_CFFF1 = 64 + 2,
152 EDMA_EQADC_B_FISR1_RFDF1 = 64 + 3,
153 EDMA_EQADC_B_FISR2_CFFF2 = 64 + 4,
154 EDMA_EQADC_B_FISR2_RFDF2 = 64 + 5,
155 EDMA_EQADC_B_FISR3_CFFF3 = 64 + 6,
156 EDMA_EQADC_B_FISR3_RFDF3 = 64 + 7,
157 EDMA_EQADC_B_FISR4_CFFF4 = 64 + 8,
158 EDMA_EQADC_B_FISR4_RFDF4 = 64 + 9,
159 EDMA_EQADC_B_FISR5_CFFF5 = 64 + 10,
160 EDMA_EQADC_B_FISR5_RFDF5 = 64 + 11,
161 EDMA_DECFILTER_A_IB = 64 + 12,
162 EDMA_DECFILTER_A_OB = 64 + 13,
163 EDMA_DECFILTER_B_IB = 64 + 14,
164 EDMA_DECFILTER_B_OB = 64 + 15,
165 EDMA_DECFILTER_C_IB = 64 + 16,
166 EDMA_DECFILTER_C_OB = 64 + 17,
167 EDMA_DECFILTER_D_IB = 64 + 18,
168 EDMA_DECFILTER_D_OB = 64 + 19,
169 EDMA_DECFILTER_E_IB = 64 + 20,
170 EDMA_DECFILTER_E_OB = 64 + 21,
171 EDMA_DECFILTER_F_IB = 64 + 22,
172 EDMA_DECFILTER_F_OB = 64 + 23,
173 EDMA_DECFILTER_G_IB = 64 + 24,
174 EDMA_DECFILTER_G_OB = 64 + 25,
175 EDMA_DECFILTER_H_IB = 64 + 26,
176 EDMA_DECFILTER_H_OB = 64 + 27
177 #endif
178} fsl_edma_channel;
179#endif
180
182 rtems_chain_node node;
183 volatile struct fsl_edma_tcd *edma_tcd;
184 void (*done)(struct fsl_edma_channel_context *, uint32_t);
186
187void fsl_edma_init(void);
188
196 volatile struct fsl_edma_tcd *edma_tcd
197);
198
199void fsl_edma_release_channel_by_tcd(volatile struct fsl_edma_tcd *edma_tcd);
200
221 unsigned irq_priority
222);
223
243);
244
245void fsl_edma_release_channel(fsl_edma_channel_context *ctx);
246
256void fsl_edma_copy(
257 volatile struct fsl_edma_tcd *edma_tcd,
258 const struct fsl_edma_tcd *source_tcd
259);
260
268 volatile struct fsl_edma_tcd *edma_tcd,
269 const struct fsl_edma_tcd *source_tcd
270);
271
272void fsl_edma_sg_link(
273 volatile struct fsl_edma_tcd *edma_tcd,
274 const struct fsl_edma_tcd *source_tcd
275);
276
277static inline volatile struct fsl_edma *fsl_edma_by_tcd(
278 volatile struct fsl_edma_tcd *edma_tcd
279)
280{
281 return (volatile struct fsl_edma *)
282 ((uintptr_t) edma_tcd & ~(uintptr_t) 0x1fff);
283}
284
285static inline unsigned fsl_edma_channel_by_tcd(
286 volatile struct fsl_edma_tcd *edma_tcd
287)
288{
289 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
290
291 return edma_tcd - &edma->TCD[0];
292}
293
294static inline void fsl_edma_enable_hardware_requests(
295 volatile struct fsl_edma_tcd *edma_tcd
296)
297{
298 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
299 unsigned channel = edma_tcd - &edma->TCD[0];
300
301 edma->SERQR = (uint8_t) channel;
302}
303
304static inline void fsl_edma_disable_hardware_requests(
305 volatile struct fsl_edma_tcd *edma_tcd
306)
307{
308 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
309 unsigned channel = edma_tcd - &edma->TCD[0];
310
311 edma->CERQR = (uint8_t) channel;
312}
313
314static inline void fsl_edma_enable_error_interrupts(
315 volatile struct fsl_edma_tcd *edma_tcd
316)
317{
318 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
319 unsigned channel = edma_tcd - &edma->TCD[0];
320
321 edma->SEEIR = (uint8_t) channel;
322}
323
324static inline void fsl_edma_disable_error_interrupts(
325 volatile struct fsl_edma_tcd *edma_tcd
326)
327{
328 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
329 unsigned channel = edma_tcd - &edma->TCD[0];
330
331 edma->CEEIR = (uint8_t) channel;
332}
333
334static inline void fsl_edma_set_start(
335 volatile struct fsl_edma_tcd *edma_tcd
336)
337{
338 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
339 unsigned channel = edma_tcd - &edma->TCD[0];
340
341 edma->SSBR = (uint8_t) channel;
342}
343
344static inline void fsl_edma_clear_done(
345 volatile struct fsl_edma_tcd *edma_tcd
346)
347{
348 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
349 unsigned channel = edma_tcd - &edma->TCD[0];
350
351 edma->CDSBR = (uint8_t) channel;
352}
353
354static inline void fsl_edma_clear_interrupts(
355 volatile struct fsl_edma_tcd *edma_tcd
356)
357{
358 volatile struct fsl_edma *edma = fsl_edma_by_tcd(edma_tcd);
359 unsigned channel = edma_tcd - &edma->TCD[0];
360
361 edma->CIRQR = (uint8_t) channel;
362}
363
364static inline bool fsl_edma_is_done(
365 volatile struct fsl_edma_tcd *edma_tcd
366)
367{
368 return ((edma_tcd->BMF & EDMA_TCD_BMF_DONE) != 0);
369}
370
371#ifdef __cplusplus
372}
373#endif /* __cplusplus */
374
375#endif /* LIBBSP_SHARED_FSL_EDMA_H */
This header file provides the Chains API.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
void fsl_edma_copy(volatile struct fsl_edma_tcd *edma_tcd, const struct fsl_edma_tcd *source_tcd)
Copies a source TCD to an eDMA TCD.
Definition: fsl-edma.c:432
rtems_status_code fsl_edma_obtain_next_free_channel(fsl_edma_channel_context *ctx)
Obtains a free eDMA channel and registers the channel context.
Definition: fsl-edma.c:388
void fsl_edma_copy_and_enable_hardware_requests(volatile struct fsl_edma_tcd *edma_tcd, const struct fsl_edma_tcd *source_tcd)
Copies a source TCD to an eDMA TCD and enables hardware requests.
Definition: fsl-edma.c:450
rtems_status_code fsl_edma_obtain_channel_by_tcd(volatile struct fsl_edma_tcd *edma_tcd)
Obtains an eDMA channel.
Definition: fsl-edma.c:300
rtems_status_code fsl_edma_obtain_channel(fsl_edma_channel_context *ctx, unsigned irq_priority)
Obtains a specific eDMA channel and registers the channel context.
Definition: fsl-edma.c:375
This header file defines the RTEMS Classic API.
This structure represents a chain node.
Definition: chain.h:78
Definition: edma.h:181
Definition: regs-edma.h:95