]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/csudma_v1_1/src/xcsudma_intr.c
Update Zynq MPSoC hardware definition and BSP files to be those shipped with the...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / csudma_v1_1 / src / xcsudma_intr.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32
33 /*****************************************************************************/
34 /**
35 *
36 * @file xcsudma_intr.c
37 * @addtogroup csudma_v1_0
38 * @{
39 *
40 * This file contains interrupt related functions of Xilinx CSU_DMA core.
41 * Please see xcsudma.h for more details of the driver.
42 *
43 * <pre>
44 * MODIFICATION HISTORY:
45 *
46 * Ver   Who     Date     Changes
47 * ----- ------  -------- ---------------------------------------------------
48 * 1.0   vnsld  22/10/14  First release
49 * </pre>
50 *
51 ******************************************************************************/
52
53 /***************************** Include Files *********************************/
54
55 #include "xcsudma.h"
56
57 /************************** Function Prototypes ******************************/
58
59
60 /************************** Function Definitions *****************************/
61
62
63 /*****************************************************************************/
64 /**
65 *
66 * This function returns interrupt status read from Interrupt Status Register.
67 * Use the XCSUDMA_IXR_*_MASK constants defined in xcsudma_hw.h to interpret the
68 * returned value.
69 *
70 * @param        InstancePtr is a pointer to XCsuDma instance to be worked on.
71 * @param        Channel represents the type of channel either it is Source or
72 *               Destination.
73 *               Source channel      - XCSUDMA_SRC_CHANNEL
74 *               Destination Channel - XCSUDMA_DST_CHANNEL
75 *
76 * @return       The pending interrupts of the CSU_DMA. Use th following masks
77 *               to interpret the returned value.
78 *               XCSUDMA_IXR_SRC_MASK   - For Source channel
79 *               XCSUDMA_IXR_DST_MASK   - For Destination channel
80 *
81 * @note         None.
82 *
83 ******************************************************************************/
84 u32 XCsuDma_IntrGetStatus(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
85 {
86         u32 Data;
87
88         /* Verify arguments */
89         Xil_AssertNonvoid(InstancePtr != NULL);
90         Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
91                                 (Channel == (XCSUDMA_DST_CHANNEL)));
92
93         Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
94                                 (u32)(XCSUDMA_I_STS_OFFSET) +
95                         ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)));
96
97         return Data;
98
99 }
100
101 /*****************************************************************************/
102 /**
103 *
104 * This function clears interrupt(s). Every bit set in Interrupt Status
105 * Register indicates that a specific type of interrupt is occurring, and this
106 * function clears one or more interrupts by writing a bit mask to Interrupt
107 * Clear Register.
108 *
109 * @param        InstancePtr is a pointer to XCsuDma instance to be worked on.
110 * @param        Channel represents the type of channel either it is Source or
111 *               Destination.
112 *               Source channel      - XCSUDMA_SRC_CHANNEL
113 *               Destination Channel - XCSUDMA_DST_CHANNEL
114 * @param        Mask is the mask to clear. Bit positions of 1 will be cleared.
115 *               Bit positions of 0 will not change the previous interrupt
116 *               status. This mask is formed by OR'ing XCSUDMA_IXR_* bits
117 *               defined in xcsudma_hw.h.
118 *
119 * @note         None.
120 *
121 ******************************************************************************/
122 void XCsuDma_IntrClear(XCsuDma *InstancePtr, XCsuDma_Channel Channel, u32 Mask)
123 {
124
125
126         /* Verify arguments */
127         Xil_AssertVoid(InstancePtr != NULL);
128         Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
129                                 (Channel == (XCSUDMA_DST_CHANNEL)));
130         if (Channel == (XCSUDMA_SRC_CHANNEL)) {
131                 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
132                         (u32)(XCSUDMA_I_STS_OFFSET),
133                                 (Mask & (u32)(XCSUDMA_IXR_SRC_MASK)));
134         }
135         else {
136                 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
137                         ((u32)(XCSUDMA_I_STS_OFFSET) +
138                         ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
139                                 (Mask & (u32)(XCSUDMA_IXR_DST_MASK)));
140         }
141 }
142
143 /*****************************************************************************/
144 /**
145 *
146 * This function enables the interrupt(s). Use the XCSUDMA_IXR_*_MASK constants
147 * defined in xcsudma_hw.h to create the bit-mask to enable interrupts.
148 *
149 * @param        InstancePtr is a pointer to XCsuDma instance to be worked on.
150 * @param        Channel represents the type of channel either it is Source or
151 *               Destination.
152 *               Source channel      - XCSUDMA_SRC_CHANNEL
153 *               Destination Channel - XCSUDMA_DST_CHANNEL
154 * @param        Mask contains interrupts to be enabled.
155 *               - Bit positions of 1 will be enabled.
156 *               This mask is formed by OR'ing XCSUDMA_IXR_*_MASK bits defined
157 *               in xcsudma_hw.h.
158 *
159 * @return       None.
160 *
161 * @note         None.
162 *
163 ******************************************************************************/
164 void XCsuDma_EnableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
165                                                         u32 Mask)
166 {
167         u32 Data;
168
169         /* Verify arguments */
170         Xil_AssertVoid(InstancePtr != NULL);
171         Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
172                                 (Channel == (XCSUDMA_DST_CHANNEL)));
173
174         if (Channel == (XCSUDMA_SRC_CHANNEL)) {
175                 Data = Mask & (u32)(XCSUDMA_IXR_SRC_MASK);
176         }
177         else {
178                 Data = Mask & (u32)(XCSUDMA_IXR_DST_MASK);
179         }
180         /*
181          * Write the mask to the IER Register
182          */
183         XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
184                 ((u32)(XCSUDMA_I_EN_OFFSET) +
185                 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
186
187 }
188
189 /*****************************************************************************/
190 /**
191 *
192 * This function disables the interrupt(s). Use the XCSUDMA_IXR_*_MASK constants
193 * defined in xcsudma_hw.h to create the bit-mask to disable interrupts.
194 *
195 * @param        InstancePtr is a pointer to XCsuDma instance to be worked on.
196 * @param        Channel represents the type of channel either it is Source or
197 *               Destination.
198 *               Source channel      - XCSUDMA_SRC_CHANNEL
199 *               Destination Channel - XCSUDMA_DST_CHANNEL
200 * @param        Mask contains interrupts to be disabled.
201 *               - Bit positions of 1 will be disabled.
202 *               This mask is formed by OR'ing XCSUDMA_IXR_*_MASK bits defined
203 *               in xcsudma_hw.h.
204 *
205 * @return       None.
206 *
207 * @note         None.
208 *
209 ******************************************************************************/
210 void XCsuDma_DisableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
211                                                                 u32 Mask)
212 {
213         u32 Data;
214
215         /* Verify arguments */
216         Xil_AssertVoid(InstancePtr != NULL);
217         Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
218                         (Channel == (XCSUDMA_DST_CHANNEL)));
219
220         if (Channel == XCSUDMA_SRC_CHANNEL) {
221                 Data = (Mask) & (u32)(XCSUDMA_IXR_SRC_MASK);
222         }
223         else {
224                 Data = (Mask) & (u32)(XCSUDMA_IXR_DST_MASK);
225         }
226
227         /*
228          * Write the mask to the IDR Register
229          */
230         XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
231                 ((u32)(XCSUDMA_I_DIS_OFFSET) +
232                 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
233
234 }
235
236 /*****************************************************************************/
237 /**
238 *
239 * This function returns the interrupt mask to know which interrupts are
240 * enabled and which of them were disaled.
241 *
242 * @param        InstancePtr is a pointer to XCsuDma instance to be worked on.
243 * @param        Channel represents the type of channel either it is Source or
244 *               Destination.
245 *               Source channel      - XCSUDMA_SRC_CHANNEL
246 *               Destination Channel - XCSUDMA_DST_CHANNEL
247 *
248 * @return       The current interrupt mask. The mask indicates which interrupts
249 *               are enabled/disabled.
250 *               0 bit represents .....corresponding interrupt is enabled.
251 *               1 bit represents .....Corresponding interrupt is disabled.
252 *               To interpret returned mask use
253 *               XCSUDMA_IXR_SRC_MASK........For source channel
254 *               XCSUDMA_IXR_DST_MASK........For destination channel
255 *
256 * @note         None.
257 *
258 ******************************************************************************/
259 u32 XCsuDma_GetIntrMask(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
260 {
261
262         /* Verify arguments */
263         Xil_AssertNonvoid(InstancePtr != NULL);
264         Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
265                                         (Channel == (XCSUDMA_DST_CHANNEL)));
266
267         /*
268          * Read the Interrupt Mask register
269          */
270         return (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
271                         ((u32)(XCSUDMA_I_MASK_OFFSET) +
272                         ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))));
273 }
274 /** @} */