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
38 * This file contains interrupt related functions of Xilinx CSU_DMA core.
39 * Please see xcsudma.h for more details of the driver.
42 * MODIFICATION HISTORY:
44 * Ver Who Date Changes
45 * ----- ------ -------- ---------------------------------------------------
46 * 1.0 vnsld 22/10/14 First release
49 ******************************************************************************/
51 /***************************** Include Files *********************************/
55 /************************** Function Prototypes ******************************/
58 /************************** Function Definitions *****************************/
61 /*****************************************************************************/
64 * This function returns interrupt status read from Interrupt Status Register.
65 * Use the XCSUDMA_IXR_*_MASK constants defined in xcsudma_hw.h to interpret the
68 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
69 * @param Channel represents the type of channel either it is Source or
71 * Source channel - XCSUDMA_SRC_CHANNEL
72 * Destination Channel - XCSUDMA_DST_CHANNEL
74 * @return The pending interrupts of the CSU_DMA. Use th following masks
75 * to interpret the returned value.
76 * XCSUDMA_IXR_SRC_MASK - For Source channel
77 * XCSUDMA_IXR_DST_MASK - For Destination channel
81 ******************************************************************************/
82 u32 XCsuDma_IntrGetStatus(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
86 /* Verify arguments */
87 Xil_AssertNonvoid(InstancePtr != NULL);
88 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
89 (Channel == (XCSUDMA_DST_CHANNEL)));
91 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
92 (u32)(XCSUDMA_I_STS_OFFSET) +
93 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)));
99 /*****************************************************************************/
102 * This function clears interrupt(s). Every bit set in Interrupt Status
103 * Register indicates that a specific type of interrupt is occurring, and this
104 * function clears one or more interrupts by writing a bit mask to Interrupt
107 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
108 * @param Channel represents the type of channel either it is Source or
110 * Source channel - XCSUDMA_SRC_CHANNEL
111 * Destination Channel - XCSUDMA_DST_CHANNEL
112 * @param Mask is the mask to clear. Bit positions of 1 will be cleared.
113 * Bit positions of 0 will not change the previous interrupt
114 * status. This mask is formed by OR'ing XCSUDMA_IXR_* bits
115 * defined in xcsudma_hw.h.
119 ******************************************************************************/
120 void XCsuDma_IntrClear(XCsuDma *InstancePtr, XCsuDma_Channel Channel, u32 Mask)
124 /* Verify arguments */
125 Xil_AssertVoid(InstancePtr != NULL);
126 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
127 (Channel == (XCSUDMA_DST_CHANNEL)));
128 if (Channel == (XCSUDMA_SRC_CHANNEL)) {
129 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
130 (u32)(XCSUDMA_I_STS_OFFSET),
131 (Mask & (u32)(XCSUDMA_IXR_SRC_MASK)));
134 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
135 ((u32)(XCSUDMA_I_STS_OFFSET) +
136 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
137 (Mask & (u32)(XCSUDMA_IXR_DST_MASK)));
141 /*****************************************************************************/
144 * This function enables the interrupt(s). Use the XCSUDMA_IXR_*_MASK constants
145 * defined in xcsudma_hw.h to create the bit-mask to enable interrupts.
147 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
148 * @param Channel represents the type of channel either it is Source or
150 * Source channel - XCSUDMA_SRC_CHANNEL
151 * Destination Channel - XCSUDMA_DST_CHANNEL
152 * @param Mask contains interrupts to be enabled.
153 * - Bit positions of 1 will be enabled.
154 * This mask is formed by OR'ing XCSUDMA_IXR_*_MASK bits defined
161 ******************************************************************************/
162 void XCsuDma_EnableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
167 /* Verify arguments */
168 Xil_AssertVoid(InstancePtr != NULL);
169 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
170 (Channel == (XCSUDMA_DST_CHANNEL)));
172 if (Channel == (XCSUDMA_SRC_CHANNEL)) {
173 Data = Mask & (u32)(XCSUDMA_IXR_SRC_MASK);
176 Data = Mask & (u32)(XCSUDMA_IXR_DST_MASK);
179 * Write the mask to the IER Register
181 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
182 ((u32)(XCSUDMA_I_EN_OFFSET) +
183 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
187 /*****************************************************************************/
190 * This function disables the interrupt(s). Use the XCSUDMA_IXR_*_MASK constants
191 * defined in xcsudma_hw.h to create the bit-mask to disable interrupts.
193 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
194 * @param Channel represents the type of channel either it is Source or
196 * Source channel - XCSUDMA_SRC_CHANNEL
197 * Destination Channel - XCSUDMA_DST_CHANNEL
198 * @param Mask contains interrupts to be disabled.
199 * - Bit positions of 1 will be disabled.
200 * This mask is formed by OR'ing XCSUDMA_IXR_*_MASK bits defined
207 ******************************************************************************/
208 void XCsuDma_DisableIntr(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
213 /* Verify arguments */
214 Xil_AssertVoid(InstancePtr != NULL);
215 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
216 (Channel == (XCSUDMA_DST_CHANNEL)));
218 if (Channel == XCSUDMA_SRC_CHANNEL) {
219 Data = (Mask) & (u32)(XCSUDMA_IXR_SRC_MASK);
222 Data = (Mask) & (u32)(XCSUDMA_IXR_DST_MASK);
226 * Write the mask to the IDR Register
228 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
229 ((u32)(XCSUDMA_I_DIS_OFFSET) +
230 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
234 /*****************************************************************************/
237 * This function returns the interrupt mask to know which interrupts are
238 * enabled and which of them were disaled.
240 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
241 * @param Channel represents the type of channel either it is Source or
243 * Source channel - XCSUDMA_SRC_CHANNEL
244 * Destination Channel - XCSUDMA_DST_CHANNEL
246 * @return The current interrupt mask. The mask indicates which interrupts
247 * are enabled/disabled.
248 * 0 bit represents .....corresponding interrupt is enabled.
249 * 1 bit represents .....Corresponding interrupt is disabled.
250 * To interpret returned mask use
251 * XCSUDMA_IXR_SRC_MASK........For source channel
252 * XCSUDMA_IXR_DST_MASK........For destination channel
256 ******************************************************************************/
257 u32 XCsuDma_GetIntrMask(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
260 /* Verify arguments */
261 Xil_AssertNonvoid(InstancePtr != NULL);
262 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
263 (Channel == (XCSUDMA_DST_CHANNEL)));
266 * Read the Interrupt Mask register
268 return (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
269 ((u32)(XCSUDMA_I_MASK_OFFSET) +
270 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))));