1 /******************************************************************************
3 * Copyright (C) 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
33 /*****************************************************************************/
36 * @file xcsudma_intr.c
37 * @addtogroup csudma_v1_0
40 * This file contains interrupt related functions of Xilinx CSU_DMA core.
41 * Please see xcsudma.h for more details of the driver.
44 * MODIFICATION HISTORY:
46 * Ver Who Date Changes
47 * ----- ------ -------- ---------------------------------------------------
48 * 1.0 vnsld 22/10/14 First release
51 ******************************************************************************/
53 /***************************** Include Files *********************************/
57 /************************** Function Prototypes ******************************/
60 /************************** Function Definitions *****************************/
63 /*****************************************************************************/
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
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
73 * Source channel - XCSUDMA_SRC_CHANNEL
74 * Destination Channel - XCSUDMA_DST_CHANNEL
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
83 ******************************************************************************/
84 u32 XCsuDma_IntrGetStatus(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
88 /* Verify arguments */
89 Xil_AssertNonvoid(InstancePtr != NULL);
90 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
91 (Channel == (XCSUDMA_DST_CHANNEL)));
93 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
94 (u32)(XCSUDMA_I_STS_OFFSET) +
95 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)));
101 /*****************************************************************************/
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
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
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.
121 ******************************************************************************/
122 void XCsuDma_IntrClear(XCsuDma *InstancePtr, XCsuDma_Channel Channel, u32 Mask)
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)));
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)));
143 /*****************************************************************************/
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.
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
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
163 ******************************************************************************/
164 void XCsuDma_EnableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
169 /* Verify arguments */
170 Xil_AssertVoid(InstancePtr != NULL);
171 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
172 (Channel == (XCSUDMA_DST_CHANNEL)));
174 if (Channel == (XCSUDMA_SRC_CHANNEL)) {
175 Data = Mask & (u32)(XCSUDMA_IXR_SRC_MASK);
178 Data = Mask & (u32)(XCSUDMA_IXR_DST_MASK);
181 * Write the mask to the IER Register
183 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
184 ((u32)(XCSUDMA_I_EN_OFFSET) +
185 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
189 /*****************************************************************************/
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.
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
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
209 ******************************************************************************/
210 void XCsuDma_DisableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
215 /* Verify arguments */
216 Xil_AssertVoid(InstancePtr != NULL);
217 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
218 (Channel == (XCSUDMA_DST_CHANNEL)));
220 if (Channel == XCSUDMA_SRC_CHANNEL) {
221 Data = (Mask) & (u32)(XCSUDMA_IXR_SRC_MASK);
224 Data = (Mask) & (u32)(XCSUDMA_IXR_DST_MASK);
228 * Write the mask to the IDR Register
230 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
231 ((u32)(XCSUDMA_I_DIS_OFFSET) +
232 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
236 /*****************************************************************************/
239 * This function returns the interrupt mask to know which interrupts are
240 * enabled and which of them were disaled.
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
245 * Source channel - XCSUDMA_SRC_CHANNEL
246 * Destination Channel - XCSUDMA_DST_CHANNEL
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
258 ******************************************************************************/
259 u32 XCsuDma_GetIntrMask(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
262 /* Verify arguments */
263 Xil_AssertNonvoid(InstancePtr != NULL);
264 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
265 (Channel == (XCSUDMA_DST_CHANNEL)));
268 * Read the Interrupt Mask register
270 return (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
271 ((u32)(XCSUDMA_I_MASK_OFFSET) +
272 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))));