1 |
4 |
kuzmi4 |
/******************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* Copyright (C) 2015 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 |
|
|
* @file xaxidma_selftest.c
|
36 |
|
|
* @addtogroup axidma_v9_0
|
37 |
|
|
* @{
|
38 |
|
|
*
|
39 |
|
|
* Contains diagnostic/self-test functions for the XAxiDma component.
|
40 |
|
|
*
|
41 |
|
|
* <pre>
|
42 |
|
|
* MODIFICATION HISTORY:
|
43 |
|
|
*
|
44 |
|
|
* Ver Who Date Changes
|
45 |
|
|
* ----- ---- -------- -----------------------------------------------
|
46 |
|
|
* 8.1 adk 29/01/15 First release
|
47 |
|
|
* </pre>
|
48 |
|
|
*
|
49 |
|
|
******************************************************************************/
|
50 |
|
|
|
51 |
|
|
/***************************** Include Files *********************************/
|
52 |
|
|
|
53 |
|
|
#include "xil_io.h"
|
54 |
|
|
#include "xaxidma.h"
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
/************************** Constant Definitions *****************************/
|
58 |
|
|
#define XAXIDMA_RESET_TIMEOUT 500
|
59 |
|
|
|
60 |
|
|
/**************************** Type Definitions *******************************/
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/***************** Macros (Inline Functions) Definitions *********************/
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
/************************** Function Prototypes ******************************/
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/************************** Variable Definitions *****************************/
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
/*****************************************************************************/
|
73 |
|
|
/**
|
74 |
|
|
*
|
75 |
|
|
* Runs a self-test on the driver/device. This test perform a
|
76 |
|
|
* reset of the DMA device and checks the device is coming out of reset or not
|
77 |
|
|
*
|
78 |
|
|
* @param InstancePtr is a pointer to the XAxiDma instance.
|
79 |
|
|
*
|
80 |
|
|
* @return
|
81 |
|
|
* - XST_SUCCESS if self-test was successful
|
82 |
|
|
* - XST_FAILURE if the device is not coming out of reset.
|
83 |
|
|
*
|
84 |
|
|
* @note
|
85 |
|
|
* None.
|
86 |
|
|
*
|
87 |
|
|
******************************************************************************/
|
88 |
|
|
int XAxiDma_Selftest(XAxiDma * InstancePtr)
|
89 |
|
|
{
|
90 |
|
|
int TimeOut;
|
91 |
|
|
|
92 |
|
|
Xil_AssertNonvoid(InstancePtr != NULL);
|
93 |
|
|
|
94 |
|
|
XAxiDma_Reset(InstancePtr);
|
95 |
|
|
|
96 |
|
|
/* At the initialization time, hardware should finish reset quickly
|
97 |
|
|
*/
|
98 |
|
|
TimeOut = XAXIDMA_RESET_TIMEOUT;
|
99 |
|
|
|
100 |
|
|
while (TimeOut) {
|
101 |
|
|
|
102 |
|
|
if(XAxiDma_ResetIsDone(InstancePtr)) {
|
103 |
|
|
break;
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
TimeOut -= 1;
|
107 |
|
|
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
if (!TimeOut)
|
111 |
|
|
return XST_FAILURE;
|
112 |
|
|
|
113 |
|
|
return XST_SUCCESS;
|
114 |
|
|
}
|
115 |
|
|
/** @} */
|