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 /*****************************************************************************/
37 * @addtogroup csudma_v1_0
40 * This file contains the implementation of the interface functions for CSU_DMA
41 * driver. Refer to the header file xcsudma.h for more detailed information.
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 *****************************/
62 /*****************************************************************************/
65 * This function initializes an CSU_DMA core. This function must be called
66 * prior to using an CSU_DMA core. Initialization of an CSU_DMA includes setting
67 * up the instance data and ensuring the hardware is in a quiescent state.
69 * @param InstancePtr is a pointer to the XCsuDma instance.
70 * @param CfgPtr is a reference to a structure containing information
71 * about a specific XCsuDma instance.
72 * @param EffectiveAddr is the device base address in the virtual memory
73 * address space. The caller is responsible for keeping the
74 * address mapping from EffectiveAddr to the device physical
75 * base address unchanged once this function is invoked.
76 * Unexpected errors may occur if the address mapping changes
77 * after this function is called. If address translation is not
78 * used, pass in the physical address instead.
81 * - XST_SUCCESS if initialization was successful.
85 ******************************************************************************/
86 s32 XCsuDma_CfgInitialize(XCsuDma *InstancePtr, XCsuDma_Config *CfgPtr,
90 /* Verify arguments. */
91 Xil_AssertNonvoid(InstancePtr != NULL);
92 Xil_AssertNonvoid(CfgPtr != NULL);
93 Xil_AssertNonvoid(EffectiveAddr != ((u32)0x0));
95 /* Setup the instance */
96 (void)memcpy((void *)&(InstancePtr->Config), (const void *)CfgPtr,
97 sizeof(XCsuDma_Config));
98 InstancePtr->Config.BaseAddress = EffectiveAddr;
102 InstancePtr->IsReady = (u32)(XIL_COMPONENT_IS_READY);
104 return (XST_SUCCESS);
108 /*****************************************************************************/
111 * This function sets the starting address and amount(size) of the data to be
112 * transfered from/to the memory through the AXI interface.
114 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
115 * @param Channel represents the type of channel either it is Source or
117 * Source channel - XCSUDMA_SRC_CHANNEL
118 * Destination Channel - XCSUDMA_DST_CHANNEL
119 * @param Addr is a 64 bit variable which holds the starting address of
120 * data which needs to write into the memory(DST) (or read from
122 * @param Size is a 32 bit variable which represents the number of 4 byte
123 * words needs to be transfered from starting address.
124 * @param EnDataLast is to trigger an end of message. It will enable or
125 * disable data_inp_last signal to stream interface when current
126 * command is completed. It is applicable only to source channel
127 * and neglected for destination channel.
128 * - 1 - Asserts data_inp_last signal.
129 * - 0 - data_inp_last will not be asserted.
133 * @note Data_inp_last signal is asserted simultaneously with the
134 * data_inp_valid signal associated with the final 32-bit word
137 ******************************************************************************/
138 void XCsuDma_Transfer(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
139 UINTPTR Addr, u32 Size, u8 EnDataLast)
141 /* Verify arguments */
142 Xil_AssertVoid(InstancePtr != NULL);
143 Xil_AssertVoid(((Addr) & (u64)(XCSUDMA_ADDR_LSB_MASK)) == (u64)0x00);
144 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
145 (Channel == (XCSUDMA_DST_CHANNEL)));
146 Xil_AssertVoid(Size <= (u32)(XCSUDMA_SIZE_MAX));
147 Xil_AssertVoid(InstancePtr->IsReady == (u32)(XIL_COMPONENT_IS_READY));
149 /* Flushing cache memory */
150 if (Channel == (XCSUDMA_SRC_CHANNEL)) {
151 Xil_DCacheFlushRange(Addr, Size << (u32)(XCSUDMA_SIZE_SHIFT));
153 /* Invalidating cache memory */
155 Xil_DCacheInvalidateRange(Addr, Size <<
156 (u32)(XCSUDMA_SIZE_SHIFT));
159 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
160 ((u32)(XCSUDMA_ADDR_OFFSET) +
161 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
162 ((u32)(Addr) & (u32)(XCSUDMA_ADDR_MASK)));
164 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
165 ((u32)(XCSUDMA_ADDR_MSB_OFFSET) +
166 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
167 (((u64)Addr >> (u32)(XCSUDMA_MSB_ADDR_SHIFT)) &
168 (u32)(XCSUDMA_MSB_ADDR_MASK)));
170 if (EnDataLast == (u8)(XCSUDMA_LAST_WORD_MASK)) {
171 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
172 ((u32)(XCSUDMA_SIZE_OFFSET) +
173 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
174 ((Size << (u32)(XCSUDMA_SIZE_SHIFT)) |
175 (u32)(XCSUDMA_LAST_WORD_MASK)));
178 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
179 ((u32)(XCSUDMA_SIZE_OFFSET) +
180 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
181 (Size << (u32)(XCSUDMA_SIZE_SHIFT)));
185 /*****************************************************************************/
188 * This function returns the current address location of the memory, from where
189 * it has to read the data(SRC) or the location where it has to write the data
190 * (DST) based on the channel selection.
192 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
193 * @param Channel represents the type of channel either it is Source or
195 * Source channel - XCSUDMA_SRC_CHANNEL
196 * Destination Channel - XCSUDMA_DST_CHANNEL
198 * @return Address is a 64 bit variable which holds the current address.
199 * - From this location data has to be read(SRC)
200 * - At this location data has to be written(DST)
204 ******************************************************************************/
205 u64 XCsuDma_GetAddr(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
209 /* Verify arguments */
210 Xil_AssertNonvoid(InstancePtr != NULL);
211 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
212 (Channel == (XCSUDMA_DST_CHANNEL)));
214 FullAddr = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
215 ((u32)(XCSUDMA_ADDR_OFFSET) +
216 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))));
218 FullAddr |= (u64)((u64)XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
219 ((u32)(XCSUDMA_ADDR_MSB_OFFSET) +
220 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))) <<
221 (u64)(XCSUDMA_MSB_ADDR_SHIFT));
226 /*****************************************************************************/
229 * This function returns the size of the data yet to be transfered from memory
230 * to CSU_DMA or CSU_DMA to memory based on the channel selection.
232 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
233 * @param Channel represents the type of channel either it is Source or
235 * Source channel - XCSUDMA_SRC_CHANNEL
236 * Destination Channel - XCSUDMA_DST_CHANNEL
238 * @return Size is amount of data yet to be transfered.
242 ******************************************************************************/
243 u32 XCsuDma_GetSize(XCsuDma *InstancePtr, XCsuDma_Channel Channel)
247 /* Verify arguments. */
248 Xil_AssertNonvoid(InstancePtr != NULL);
249 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
250 (Channel == (XCSUDMA_DST_CHANNEL)));
252 Size = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
253 ((u32)(XCSUDMA_SIZE_OFFSET) +
254 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))) >>
255 (u32)(XCSUDMA_SIZE_SHIFT);
260 /*****************************************************************************/
263 * This function pause the Channel data tranfer to/from memory or to/from stream
264 * based on pause type.
266 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
267 * @param Channel represents the type of channel either it is Source or
269 * Source channel - XCSUDMA_SRC_CHANNEL
270 * Destination Channel - XCSUDMA_DST_CHANNEL
271 * @param Type is type of the pause to be enabled.
272 * - XCSUDMA_PAUSE_MEMORY(0) - Pause memory
273 * - SRC Stops issuing of new read commands to memory.
274 * - DST Stops issuing of new write commands to memory.
275 * - XCSUDMA_PAUSE_STREAM(1) - Pause stream
276 * - SRC Stops transfer of data from FIFO to Stream.
277 * - DST Stops transfer of data from stream to FIFO.
283 ******************************************************************************/
284 void XCsuDma_Pause(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
285 XCsuDma_PauseType Type)
287 /* Verify arguments. */
288 Xil_AssertVoid(InstancePtr != NULL);
289 Xil_AssertVoid((Type == (XCSUDMA_PAUSE_MEMORY)) ||
290 (Type == (XCSUDMA_PAUSE_STREAM)));
291 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
292 (Channel == (XCSUDMA_DST_CHANNEL)));
293 Xil_AssertVoid(InstancePtr->IsReady == (u32)(XIL_COMPONENT_IS_READY));
295 /* Pause Memory Read/Write/Stream operations */
296 if (Type == (XCSUDMA_PAUSE_MEMORY)) {
297 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
298 ((u32)(XCSUDMA_CTRL_OFFSET) +
299 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
300 (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
301 ((u32)(XCSUDMA_CTRL_OFFSET) +
302 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))) |
303 (u32)(XCSUDMA_CTRL_PAUSE_MEM_MASK)));
305 if (Type == (XCSUDMA_PAUSE_STREAM)) {
306 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
307 ((u32)(XCSUDMA_CTRL_OFFSET) +
308 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
309 (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
310 ((u32)(XCSUDMA_CTRL_OFFSET) +
311 (Channel * (u32)XCSUDMA_OFFSET_DIFF))) |
312 (u32)(XCSUDMA_CTRL_PAUSE_STRM_MASK)));
316 /*****************************************************************************/
319 * This functions checks whether Channel's memory or stream is paused or not
320 * based on the given pause type.
322 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
323 * @param Channel represents the type of channel either it is Source or
325 * Source channel - XCSUDMA_SRC_CHANNEL
326 * Destination Channel - XCSUDMA_DST_CHANNEL
327 * @param Type is type of the pause which needs to be checked.
328 * - XCSUDMA_PAUSE_MEMORY(0) - Pause memory
329 * - SRC Stops issuing of new read commands to memory.
330 * - DST Stops issuing of new write commands to memory.
331 * - XCSUDMA_PAUSE_STREAM(1) - Pause stream
332 * - SRC Stops transfer of data from FIFO to Stream.
333 * - DST Stops transfer of data from stream to FIFO.
335 * @return Returns the pause status.
336 * - TRUE if it is in paused state.
337 * - FALSE if it is not in pause state.
341 ******************************************************************************/
342 s32 XCsuDma_IsPaused(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
343 XCsuDma_PauseType Type)
349 /* Verify arguments. */
350 Xil_AssertNonvoid(InstancePtr != NULL);
351 Xil_AssertNonvoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
352 (Channel == (XCSUDMA_DST_CHANNEL)));
353 Xil_AssertNonvoid((Type == (XCSUDMA_PAUSE_MEMORY)) ||
354 (Type == (XCSUDMA_PAUSE_STREAM)));
356 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
357 ((u32)(XCSUDMA_CTRL_OFFSET) +
358 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))));
360 /* To know Pause condition of Memory Read/Write/Stream operations */
361 if (Type == (XCSUDMA_PAUSE_MEMORY)) {
362 if ((Data & (u32)(XCSUDMA_CTRL_PAUSE_MEM_MASK)) ==
364 PauseState = (s32)(FALSE);
367 PauseState = (s32)(TRUE);
371 if ((Data & (u32)(XCSUDMA_CTRL_PAUSE_STRM_MASK)) ==
373 PauseState = (s32)(FALSE);
376 PauseState = (s32)(TRUE);
380 return (s32)PauseState;
384 /*****************************************************************************/
387 * This function resumes the channel if it is in paused state and continues
388 * where it has left or no effect if it is not in paused state, based on the
391 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
392 * @param Channel represents the type of channel either it is Source or
394 * Source channel - XCSUDMA_SRC_CHANNEL
395 * Destination Channel - XCSUDMA_DST_CHANNEL
396 * @param Type is type of the pause to be Resume if it is in pause
398 * - XCSUDMA_PAUSE_MEMORY(0) - Pause memory
399 * - SRC Stops issuing of new read commands to memory.
400 * - DST Stops issuing of new write commands to memory.
401 * - XCSUDMA_PAUSE_STREAM(1) - Pause stream
402 * - SRC Stops transfer of data from FIFO to Stream.
403 * - DST Stops transfer of data from stream to FIFO.
409 ******************************************************************************/
410 void XCsuDma_Resume(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
411 XCsuDma_PauseType Type)
414 /* Verify arguments. */
415 Xil_AssertVoid(InstancePtr != NULL);
416 Xil_AssertVoid((Type == (XCSUDMA_PAUSE_MEMORY)) ||
417 (Type == (XCSUDMA_PAUSE_STREAM)));
418 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
419 (Channel == (XCSUDMA_DST_CHANNEL)));
420 Xil_AssertVoid(InstancePtr->IsReady == (u32)(XIL_COMPONENT_IS_READY));
422 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
423 ((u32)(XCSUDMA_CTRL_OFFSET) +
424 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))));
426 if (Type == (XCSUDMA_PAUSE_MEMORY)) {
427 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
428 ((u32)(XCSUDMA_CTRL_OFFSET) +
429 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))),
431 (~(XCSUDMA_CTRL_PAUSE_MEM_MASK))));
433 if (Type == (XCSUDMA_PAUSE_STREAM)) {
434 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
435 ((u32)(XCSUDMA_CTRL_OFFSET) +
436 (((u32)Channel) * (u32)(XCSUDMA_OFFSET_DIFF))),
438 (~(XCSUDMA_CTRL_PAUSE_STRM_MASK))));
442 /*****************************************************************************/
445 * This function returns the sum of all the data read from AXI memory. It is
446 * valid only one we use CSU_DMA source channel.
448 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
450 * @return Returns the sum of all the data read from memory.
452 * @note Before start of the transfer need to clear this register to get
453 * correct sum otherwise it adds to previous value which results
455 * Valid only for source channel
457 ******************************************************************************/
458 u32 XCsuDma_GetCheckSum(XCsuDma *InstancePtr)
462 /* Verify arguments. */
463 Xil_AssertNonvoid(InstancePtr != NULL);
464 Xil_AssertNonvoid(InstancePtr->IsReady ==
465 (u32)(XIL_COMPONENT_IS_READY));
467 ChkSum = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
468 (u32)(XCSUDMA_CRC_OFFSET));
473 /*****************************************************************************/
476 * This function clears the check sum of the data read from AXI memory. It is
477 * valid only for CSU_DMA source channel.
479 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
481 * @return Returns the sum of all the data read from memory.
483 * @note Before start of the transfer need to clear this register to get
484 * correct sum otherwise it adds to previous value which results
487 ******************************************************************************/
488 void XCsuDma_ClearCheckSum(XCsuDma *InstancePtr)
491 /* Verify arguments. */
492 Xil_AssertVoid(InstancePtr != NULL);
494 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
495 (u32)(XCSUDMA_CRC_OFFSET), (u32)(XCSUDMA_CRC_RESET_MASK));
498 /*****************************************************************************/
500 * This function cofigures all the values of CSU_DMA's Channels with the values
501 * of updated XCsuDma_Configure structure.
503 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
504 * @param Channel represents the type of channel either it is Source or
506 * Source channel - XCSUDMA_SRC_CHANNEL
507 * Destination Channel - XCSUDMA_DST_CHANNEL
508 * @param ConfigurValues is a pointer to the structure XCsuDma_Configure
509 * whose values are used to configure CSU_DMA core.
510 * - SssFifoThesh When the DST FIFO level >= this value,
511 * the SSS interface signal, "data_out_fifo_level_hit" will be
512 * asserted. This mechanism can be used by the SSS to flow
513 * control data that is being looped back from the SRC DMA.
514 * - Range is (0x10 to 0x7A) threshold is 17 to 123
516 * - It is valid only for DST CSU_DMA IP.
517 * - ApbErr When accessed to invalid APB the resulting
521 * - EndianType Type of endianness
522 * - 0 doesn't change order
523 * - 1 will flip the order.
524 * - AxiBurstType....Type of the burst
525 * - 0 will issue INCR type burst
526 * - 1 will issue FIXED type burst
527 * - TimeoutValue Time out value for timers
528 * - 0x000 to 0xFFE are valid inputs
529 * - 0xFFF clears both timers
530 * - FifoThresh......Programmed watermark value
531 * - Range is 0x00 to 0x80 (0 to 128 entries).
532 * - Acache Sets the AXI CACHE bits on the AXI Write/Read
534 * - Cacheable ARCACHE[1] for SRC Channel and AWCACHE[1]
535 * for DST channel are always 1, we need to configure
536 * remaining 3 signal support
537 * (Bufferable, Read allocate and Write allocate).
539 * - 0x000 - Cacheable, but do not allocate
540 * - 0x001 - Cacheable and bufferable, but do not allocate
541 * - 0x010 - Cacheable write-through, allocate on reads
543 * - 0x011 - Cacheable write-back, allocate on reads only
544 * - 0x100 - Cacheable write-through, allocate on writes
546 * - 0x101 - Cacheable write-back, allocate on writes only
547 * - 0x110 - Cacheable write-through, allocate on both
549 * - 0x111 - Cacheable write-back, allocate on both reads
551 * - RouteBit To select route
552 * - 0 : Command will be routed normally
553 * - 1 : Command will be routed to APU's cache controller
554 * - TimeoutEn To enable or disable time out counters
555 * - 0 : The 2 Timeout counters are disabled
556 * - 1 : The 2 Timeout counters are enabled
557 * - TimeoutPre Set the prescaler value for the timeout in
558 * clk (~2.5ns) cycles
559 * - Range is 0x000(Prescaler enables timer every cycles)
560 * to 0xFFF(Prescaler enables timer every 4096 cycles)
561 * - MaxOutCmds Controls the maximumum number of outstanding
562 * AXI read commands issued.
563 * - Range is 0x0(Up to 1 Outstanding Read command
564 * allowed) to 0x8 (Up to 9 Outstanding Read
569 * @note To use timers timeout value Timeout enable field should be
572 ******************************************************************************/
573 void XCsuDma_SetConfig(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
574 XCsuDma_Configure *ConfigurValues)
578 /* Verify arguments. */
579 Xil_AssertVoid(InstancePtr != NULL);
580 Xil_AssertVoid(InstancePtr->IsReady == (u32)(XIL_COMPONENT_IS_READY));
581 Xil_AssertVoid(ConfigurValues != NULL);
582 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
583 (Channel == (XCSUDMA_DST_CHANNEL)));
584 Xil_AssertVoid(XCsuDma_IsBusy(InstancePtr, Channel) != (s32)(TRUE));
586 Data = (((ConfigurValues->EndianType <<
587 (u32)(XCSUDMA_CTRL_ENDIAN_SHIFT)) &
588 (u32)(XCSUDMA_CTRL_ENDIAN_MASK)) |
589 ((ConfigurValues->ApbErr <<
590 (u32)(XCSUDMA_CTRL_APB_ERR_SHIFT)) &
591 (u32)(XCSUDMA_CTRL_APB_ERR_MASK)) |
592 ((ConfigurValues->AxiBurstType <<
593 (u32)(XCSUDMA_CTRL_BURST_SHIFT)) &
594 (u32)(XCSUDMA_CTRL_BURST_MASK)) |
595 ((ConfigurValues->TimeoutValue <<
596 (u32)(XCSUDMA_CTRL_TIMEOUT_SHIFT)) &
597 (u32)(XCSUDMA_CTRL_TIMEOUT_MASK)) |
598 ((ConfigurValues->FifoThresh <<
599 (u32)(XCSUDMA_CTRL_FIFO_THRESH_SHIFT)) &
600 (u32)(XCSUDMA_CTRL_FIFO_THRESH_MASK)));
601 if(Channel == XCSUDMA_DST_CHANNEL) {
602 Data = Data | (u32)((ConfigurValues->SssFifoThesh <<
603 (u32)(XCSUDMA_CTRL_SSS_FIFOTHRESH_SHIFT)) &
604 (u32)(XCSUDMA_CTRL_SSS_FIFOTHRESH_MASK));
607 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
608 ((u32)(XCSUDMA_CTRL_OFFSET) +
609 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
611 Data = (XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
612 ((u32)(XCSUDMA_CTRL2_OFFSET) +
613 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF)))) &
614 (u32)(XCSUDMA_CTRL2_RESERVED_MASK));
615 Data |= (((ConfigurValues->Acache <<
616 (u32)(XCSUDMA_CTRL2_ACACHE_SHIFT)) &
617 (u32)(XCSUDMA_CTRL2_ACACHE_MASK)) |
618 ((ConfigurValues->RouteBit <<
619 (u32)(XCSUDMA_CTRL2_ROUTE_SHIFT)) &
620 (u32)(XCSUDMA_CTRL2_ROUTE_MASK)) |
621 ((ConfigurValues->TimeoutEn <<
622 (u32)(XCSUDMA_CTRL2_TIMEOUT_EN_SHIFT)) &
623 (u32)(XCSUDMA_CTRL2_TIMEOUT_EN_MASK)) |
624 ((ConfigurValues->TimeoutPre <<
625 (u32)(XCSUDMA_CTRL2_TIMEOUT_PRE_SHIFT)) &
626 (u32)(XCSUDMA_CTRL2_TIMEOUT_PRE_MASK)) |
627 ((ConfigurValues->MaxOutCmds) &
628 (u32)(XCSUDMA_CTRL2_MAXCMDS_MASK)));
630 XCsuDma_WriteReg(InstancePtr->Config.BaseAddress,
631 ((u32)(XCSUDMA_CTRL2_OFFSET) +
632 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))), Data);
635 /*****************************************************************************/
638 * This function updates XCsuDma_Configure structure members with the cofigured
639 * values of CSU_DMA's Channel.
641 * @param InstancePtr is a pointer to XCsuDma instance to be worked on.
642 * @param Channel represents the type of channel either it is Source or
644 * Source channel - XCSUDMA_SRC_CHANNEL
645 * Destination Channel - XCSUDMA_DST_CHANNEL
646 * @param ConfigurValues is a pointer to the structure XCsuDma_Configure
647 * whose members are updated with configurations of CSU_DMA core.
648 * - SssFifoThesh When the DST FIFO level >= this value,
649 * the SSS interface signal, "data_out_fifo_level_hit" will be
650 * asserted. This mechanism can be used by the SSS to flow
651 * control data that is being looped back from the SRC DMA.
652 * - Range is (0x10 to 0x7A) threshold is 17 to 123
654 * - It is valid only for DST CSU_DMA IP.
655 * - ApbErr When accessed to invalid APB the resulting
659 * - EndianType Type of endianness
660 * - 0 doesn't change order
661 * - 1 will flip the order.
662 * - AxiBurstType....Type of the burst
663 * - 0 will issue INCR type burst
664 * - 1 will issue FIXED type burst
665 * - TimeoutValue Time out value for timers
666 * - 0x000 to 0xFFE are valid inputs
667 * - 0xFFF clears both timers
668 * - FifoThresh......Programmed watermark value
669 * - Range is 0x00 to 0x80 (0 to 128 entries).
670 * - Acache Sets the AXI CACHE bits on the AXI Write/Read
672 * - Cacheable ARCACHE[1] for SRC Channel and AWCACHE[1]
673 * for DST channel are always 1, we need to configure
674 * remaining 3 signal support
675 * (Bufferable, Read allocate and Write allocate).
677 * - 0x000 - Cacheable, but do not allocate
678 * - 0x001 - Cacheable and bufferable, but do not allocate
679 * - 0x010 - Cacheable write-through, allocate on reads
681 * - 0x011 - Cacheable write-back, allocate on reads only
682 * - 0x100 - Cacheable write-through, allocate on writes
684 * - 0x101 - Cacheable write-back, allocate on writes only
685 * - 0x110 - Cacheable write-through, allocate on both
687 * - 0x111 - Cacheable write-back, allocate on both reads
689 * - RouteBit To select route
690 * - 0 : Command will be routed based normally
691 * - 1 : Command will be routed to APU's cache controller
692 * - TimeoutEn To enable or disable time out counters
693 * - 0 : The 2 Timeout counters are disabled
694 * - 1 : The 2 Timeout counters are enabled
695 * - TimeoutPre Set the prescaler value for the timeout in
696 * clk (~2.5ns) cycles
697 * - Range is 0x000(Prescaler enables timer every cycles)
698 * to 0xFFF(Prescaler enables timer every 4096 cycles)
699 * - MaxOutCmds Controls the maximumum number of outstanding
700 * AXI read commands issued.
701 * - Range is 0x0(Up to 1 Outstanding Read command
702 * allowed) to 0x8 (Up to 9 Outstanding Read command
709 ******************************************************************************/
710 void XCsuDma_GetConfig(XCsuDma *InstancePtr, XCsuDma_Channel Channel,
711 XCsuDma_Configure *ConfigurValues)
715 /* Verify arguments. */
716 Xil_AssertVoid(InstancePtr != NULL);
717 Xil_AssertVoid(ConfigurValues != NULL);
718 Xil_AssertVoid((Channel == (XCSUDMA_SRC_CHANNEL)) ||
719 (Channel == (XCSUDMA_DST_CHANNEL)));
721 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
722 ((u32)(XCSUDMA_CTRL_OFFSET) +
723 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))));
725 if (Channel == (XCSUDMA_DST_CHANNEL)) {
726 ConfigurValues->SssFifoThesh =
728 (u32)(XCSUDMA_CTRL_SSS_FIFOTHRESH_MASK)) >>
729 (u32)(XCSUDMA_CTRL_SSS_FIFOTHRESH_SHIFT));
731 ConfigurValues->ApbErr =
732 (u8)((Data & (u32)(XCSUDMA_CTRL_APB_ERR_MASK)) >>
733 (u32)(XCSUDMA_CTRL_APB_ERR_SHIFT));
734 ConfigurValues->EndianType =
735 (u8)((Data & (u32)(XCSUDMA_CTRL_ENDIAN_MASK)) >>
736 (u32)(XCSUDMA_CTRL_ENDIAN_SHIFT));
737 ConfigurValues->AxiBurstType =
738 (u8)((Data & (u32)(XCSUDMA_CTRL_BURST_MASK)) >>
739 (u32)(XCSUDMA_CTRL_BURST_SHIFT));
740 ConfigurValues->TimeoutValue =
741 ((Data & (u32)(XCSUDMA_CTRL_TIMEOUT_MASK)) >>
742 (u32)(XCSUDMA_CTRL_TIMEOUT_SHIFT));
743 ConfigurValues->FifoThresh =
744 (u8)((Data & (u32)(XCSUDMA_CTRL_FIFO_THRESH_MASK)) >>
745 (u32)(XCSUDMA_CTRL_FIFO_THRESH_SHIFT));
747 Data = XCsuDma_ReadReg(InstancePtr->Config.BaseAddress,
748 ((u32)(XCSUDMA_CTRL2_OFFSET) +
749 ((u32)Channel * (u32)(XCSUDMA_OFFSET_DIFF))));
751 ConfigurValues->Acache =
752 (u8)((Data & (u32)(XCSUDMA_CTRL2_ACACHE_MASK)) >>
753 (u32)(XCSUDMA_CTRL2_ACACHE_SHIFT));
754 ConfigurValues->RouteBit =
755 (u8)((Data & (u32)(XCSUDMA_CTRL2_ROUTE_MASK)) >>
756 (u32)(XCSUDMA_CTRL2_ROUTE_SHIFT));
757 ConfigurValues->TimeoutEn =
758 (u8)((Data & (u32)(XCSUDMA_CTRL2_TIMEOUT_EN_MASK)) >>
759 (u32)(XCSUDMA_CTRL2_TIMEOUT_EN_SHIFT));
760 ConfigurValues->TimeoutPre =
761 (u16)((Data & (u32)(XCSUDMA_CTRL2_TIMEOUT_PRE_MASK)) >>
762 (u32)(XCSUDMA_CTRL2_TIMEOUT_PRE_SHIFT));
763 ConfigurValues->MaxOutCmds =
764 (u8)((Data & (u32)(XCSUDMA_CTRL2_MAXCMDS_MASK)));