dma: Add self-test API to the driver source files.
This patch modifies the axi dma and axi vdma driver to add the sefltest api to the driver source files and call this from the selftest example's. Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
This commit is contained in:
parent
8387de40a6
commit
82f9fb61a0
10 changed files with 279 additions and 76 deletions
|
@ -36,6 +36,6 @@
|
|||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
int XAxiDma_Selftest(u16 DeviceId);
|
||||
int AxiDMASelfTestExample(u16 DeviceId);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -93,7 +93,7 @@ proc gen_testfunc_call {swproj mhsinst} {
|
|||
{
|
||||
int status;
|
||||
|
||||
status = XAxiDma_Selftest(${deviceid});
|
||||
status = AxiDMASelfTestExample(${deviceid});
|
||||
|
||||
}"
|
||||
} else {
|
||||
|
@ -104,15 +104,15 @@ proc gen_testfunc_call {swproj mhsinst} {
|
|||
int status;
|
||||
|
||||
|
||||
print(\"\\r\\n Running XAxiDma_Selftest() for ${ipname}...\\r\\n\");
|
||||
print(\"\\r\\n Running AxiDMASelfTestExample() for ${ipname}...\\r\\n\");
|
||||
|
||||
status = XAxiDma_Selftest(${deviceid});
|
||||
status = AxiDMASelfTestExample(${deviceid});
|
||||
|
||||
if (status == 0) {
|
||||
print(\"XAxiDma_Selftest PASSED\\r\\n\");
|
||||
print(\"AxiDMASelfTestExample PASSED\\r\\n\");
|
||||
}
|
||||
else {
|
||||
print(\"XAxiDma_Selftest FAILED\\r\\n\");
|
||||
print(\"AxiDMASelfTestExample FAILED\\r\\n\");
|
||||
}
|
||||
}"
|
||||
}
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
#define DMA_DEV_ID XPAR_AXIDMA_0_DEVICE_ID
|
||||
#endif
|
||||
|
||||
#define XAXIDMA_RESET_TIMEOUT 500
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
|
@ -64,7 +62,7 @@
|
|||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XAxiDma_Selftest(u16 DeviceId);
|
||||
int AxiDMASelfTestExample(u16 DeviceId);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
/*
|
||||
|
@ -95,15 +93,15 @@ int main()
|
|||
xil_printf("\r\n--- Entering main() --- \r\n");
|
||||
|
||||
/* Run the poll example for simple transfer */
|
||||
Status = XAxiDma_Selftest(DMA_DEV_ID);
|
||||
Status = AxiDMASelfTestExample(DMA_DEV_ID);
|
||||
|
||||
if (Status != XST_SUCCESS) {
|
||||
|
||||
xil_printf("XAxiDma_Selftest: Failed\r\n");
|
||||
xil_printf("AxiDMASelfTestExample: Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("XAxiDma_Selftest: Passed\r\n");
|
||||
xil_printf("AxiDMASelfTestExample: Passed\r\n");
|
||||
|
||||
xil_printf("--- Exiting main() --- \r\n");
|
||||
|
||||
|
@ -125,11 +123,10 @@ int main()
|
|||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XAxiDma_Selftest(u16 DeviceId)
|
||||
int AxiDMASelfTestExample(u16 DeviceId)
|
||||
{
|
||||
XAxiDma_Config *CfgPtr;
|
||||
int Status = XST_SUCCESS;
|
||||
int TimeOut;
|
||||
|
||||
CfgPtr = XAxiDma_LookupConfig(DeviceId);
|
||||
if (!CfgPtr) {
|
||||
|
@ -141,20 +138,10 @@ int XAxiDma_Selftest(u16 DeviceId)
|
|||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Reset the engine so the hardware starts from a known state */
|
||||
XAxiDma_Reset(&AxiDma);
|
||||
Status = XAxiDma_Selftest(&AxiDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
TimeOut = XAXIDMA_RESET_TIMEOUT;
|
||||
|
||||
while (TimeOut) {
|
||||
if(XAxiDma_ResetIsDone(&AxiDma)) {
|
||||
break;
|
||||
}
|
||||
TimeOut -= 1;
|
||||
}
|
||||
|
||||
if (!TimeOut)
|
||||
return XST_FAILURE;
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -446,6 +446,8 @@
|
|||
* * XAxiDma_BdSetBufAddrMicroMode(XAxiDma_Bd*, u32)
|
||||
* 8.1 adk 20/01/15 Added support for peripheral test. Created the self
|
||||
* test example to include it on peripheral test's(CR#823144).
|
||||
* 8.1 adk 29/01/15 Added the sefltest api (XAxiDma_Selftest) to the driver source files
|
||||
* (xaxidma_selftest.c) and called this from the selftest example
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -722,6 +724,7 @@ int XAxiDma_SimpleTransfer(XAxiDma *InstancePtr, u32 BuffAddr, u32 Length,
|
|||
int Direction);
|
||||
int XAxiDma_SelectKeyHole(XAxiDma *InstancePtr, int Direction, int Select);
|
||||
int XAxiDma_SelectCyclicMode(XAxiDma *InstancePtr, int Direction, int Select);
|
||||
int XAxiDma_Selftest(XAxiDma * InstancePtr);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
112
XilinxProcessorIPLib/drivers/axidma/src/xaxidma_selftest.c
Normal file
112
XilinxProcessorIPLib/drivers/axidma/src/xaxidma_selftest.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xaxidma_selftest.c
|
||||
*
|
||||
* Contains diagnostic/self-test functions for the XAxiDma component.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 8.1 adk 29/01/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_io.h"
|
||||
#include "xaxidma.h"
|
||||
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define XAXIDMA_RESET_TIMEOUT 500
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Runs a self-test on the driver/device. This test perform a
|
||||
* reset of the DMA device and checks the device is coming out of reset or not
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XAxiDma instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if self-test was successful
|
||||
* - XST_FAILURE if the device is not coming out of reset.
|
||||
*
|
||||
* @note
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XAxiDma_Selftest(XAxiDma * InstancePtr)
|
||||
{
|
||||
int TimeOut;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
|
||||
XAxiDma_Reset(InstancePtr);
|
||||
|
||||
/* At the initialization time, hardware should finish reset quickly
|
||||
*/
|
||||
TimeOut = XAXIDMA_RESET_TIMEOUT;
|
||||
|
||||
while (TimeOut) {
|
||||
|
||||
if(XAxiDma_ResetIsDone(InstancePtr)) {
|
||||
break;
|
||||
}
|
||||
|
||||
TimeOut -= 1;
|
||||
|
||||
}
|
||||
|
||||
if (!TimeOut)
|
||||
return XST_FAILURE;
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -36,6 +36,6 @@
|
|||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
int XAxiVdma_Selftest(u16 DeviceId);
|
||||
int AxiVDMASelfTestExample(u16 DeviceId);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -93,7 +93,7 @@ proc gen_testfunc_call {swproj mhsinst} {
|
|||
{
|
||||
int status;
|
||||
|
||||
status = XAxiVdma_Selftest(${deviceid});
|
||||
status = AxiVDMASelfTestExample(${deviceid});
|
||||
|
||||
}"
|
||||
} else {
|
||||
|
@ -104,15 +104,15 @@ proc gen_testfunc_call {swproj mhsinst} {
|
|||
int status;
|
||||
|
||||
|
||||
print(\"\\r\\n Running XAxiVdma_Selftest() for ${ipname}...\\r\\n\");
|
||||
print(\"\\r\\n Running AxiVDMASelfTestExample() for ${ipname}...\\r\\n\");
|
||||
|
||||
status = XAxiVdma_Selftest(${deviceid});
|
||||
status = AxiVDMASelfTestExample(${deviceid});
|
||||
|
||||
if (status == 0) {
|
||||
print(\"XAxiVdma_Selftest PASSED\\r\\n\");
|
||||
print(\"AxiVDMASelfTestExample PASSED\\r\\n\");
|
||||
}
|
||||
else {
|
||||
print(\"XAxiVdma_Selftest FAILED\\r\\n\");
|
||||
print(\"AxiVDMASelfTestExample FAILED\\r\\n\");
|
||||
}
|
||||
}"
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#define DMA_DEVICE_ID XPAR_AXIVDMA_0_DEVICE_ID
|
||||
#endif
|
||||
|
||||
#define XAXIVDMA_RESET_TIMEOUT 500
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
@ -64,7 +63,7 @@
|
|||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XAxiVdma_Selftest(u16 DeviceId);
|
||||
int AxiVDMASelfTestExample(u16 DeviceId);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
/*
|
||||
|
@ -95,15 +94,15 @@ int main()
|
|||
xil_printf("\r\n--- Entering main() --- \r\n");
|
||||
|
||||
/* Run the poll example for simple transfer */
|
||||
Status = XAxiVdma_Selftest(DMA_DEV_ID);
|
||||
Status = AxiVDMASelfTestExample(DMA_DEV_ID);
|
||||
|
||||
if (Status != XST_SUCCESS) {
|
||||
|
||||
xil_printf("XAxiVdma_Selftest: Failed\r\n");
|
||||
xil_printf("AxiVDMASelfTestExample: Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("XAxiDma_Selftest: Passed\r\n");
|
||||
xil_printf("AxiVDMASelfTestExample: Passed\r\n");
|
||||
|
||||
xil_printf("--- Exiting main() --- \r\n");
|
||||
|
||||
|
@ -125,13 +124,10 @@ int main()
|
|||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XAxiVdma_Selftest(u16 DeviceId)
|
||||
int AxiVDMASelfTestExample(u16 DeviceId)
|
||||
{
|
||||
XAxiVdma_Config *Config;
|
||||
int Status = XST_SUCCESS;
|
||||
XAxiVdma_Channel *RdChannel;
|
||||
XAxiVdma_Channel *WrChannel;
|
||||
int Polls;
|
||||
|
||||
Config = XAxiVdma_LookupConfig(DeviceId);
|
||||
if (!Config) {
|
||||
|
@ -144,38 +140,9 @@ int XAxiVdma_Selftest(u16 DeviceId)
|
|||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
if (Config->HasMm2S) {
|
||||
RdChannel = XAxiVdma_GetChannel(&AxiVdma, XAXIVDMA_READ);
|
||||
RdChannel->ChanBase = Config->BaseAddress + XAXIVDMA_TX_OFFSET;
|
||||
RdChannel->InstanceBase = Config->BaseAddress;
|
||||
XAxiVdma_ChannelReset(RdChannel);
|
||||
Polls = XAXIVDMA_RESET_TIMEOUT;
|
||||
|
||||
while (Polls && XAxiVdma_ChannelResetNotDone(RdChannel)) {
|
||||
Polls -= 1;
|
||||
}
|
||||
|
||||
if (!Polls) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config->HasS2Mm) {
|
||||
WrChannel = XAxiVdma_GetChannel(&AxiVdma, XAXIVDMA_WRITE);
|
||||
WrChannel->ChanBase = Config->BaseAddress + XAXIVDMA_RX_OFFSET;
|
||||
WrChannel->InstanceBase = Config->BaseAddress;
|
||||
XAxiVdma_ChannelReset(WrChannel);
|
||||
|
||||
Polls = XAXIVDMA_RESET_TIMEOUT;
|
||||
|
||||
while (Polls && XAxiVdma_ChannelResetNotDone(WrChannel)) {
|
||||
Polls -= 1;
|
||||
}
|
||||
|
||||
if (!Polls) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XAxiVdma_Selftest(&AxiVdma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
|
|
@ -277,6 +277,8 @@
|
|||
* 5.0 adk 19/12/13 - Updated as per the New Tcl API's
|
||||
* 5.1 adk 20/01/15 Added support for peripheral test. Created the self
|
||||
* test example to include it on peripheral test's(CR#823144).
|
||||
* 5.1 adk 29/01/15 Added the sefltest api (XAxiVdma_Selftest) to the driver source files
|
||||
* (xaxivdma_selftest.c) and called this from the selftest example
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -583,6 +585,7 @@ void XAxiVdma_ReadIntrHandler(void * InstancePtr);
|
|||
void XAxiVdma_WriteIntrHandler(void * InstancePtr);
|
||||
int XAxiVdma_SetCallBack(XAxiVdma * InstancePtr, u32 HandlerType,
|
||||
void *CallBackFunc, void *CallBackRef, u16 Direction);
|
||||
int XAxiVdma_Selftest(XAxiVdma * InstancePtr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
131
XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma_selftest.c
Normal file
131
XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma_selftest.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xaxivdma_selftest.c
|
||||
*
|
||||
* Contains diagnostic/self-test functions for the XAxiVdma component.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 5.1 adk 29/01/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_io.h"
|
||||
#include "xaxivdma.h"
|
||||
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define XAXIVDMA_RESET_TIMEOUT 500
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Runs a self-test on the driver/device. This test perform a
|
||||
* reset of the VDMA device and checks the device is coming out of reset or not
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XAxiVdma instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if self-test was successful
|
||||
* - XST_FAILURE if the device is not coming out of reset.
|
||||
*
|
||||
* @note
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XAxiVdma_Selftest(XAxiVdma * InstancePtr)
|
||||
{
|
||||
XAxiVdma_Channel *RdChannel;
|
||||
XAxiVdma_Channel *WrChannel;
|
||||
int Polls;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
|
||||
RdChannel = XAxiVdma_GetChannel(InstancePtr, XAXIVDMA_READ);
|
||||
WrChannel = XAxiVdma_GetChannel(InstancePtr, XAXIVDMA_WRITE);
|
||||
|
||||
if (InstancePtr->HasMm2S) {
|
||||
RdChannel->ChanBase = InstancePtr->BaseAddr + XAXIVDMA_TX_OFFSET;
|
||||
RdChannel->InstanceBase = InstancePtr->BaseAddr;
|
||||
|
||||
XAxiVdma_ChannelReset(RdChannel);
|
||||
Polls = XAXIVDMA_RESET_TIMEOUT;
|
||||
|
||||
while (Polls && XAxiVdma_ChannelResetNotDone(RdChannel)) {
|
||||
Polls -= 1;
|
||||
}
|
||||
|
||||
if (!Polls) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (InstancePtr->HasS2Mm) {
|
||||
WrChannel->ChanBase = InstancePtr->BaseAddr + XAXIVDMA_RX_OFFSET;
|
||||
WrChannel->InstanceBase = InstancePtr->BaseAddr;
|
||||
XAxiVdma_ChannelReset(WrChannel);
|
||||
|
||||
Polls = XAXIVDMA_RESET_TIMEOUT;
|
||||
|
||||
while (Polls && XAxiVdma_ChannelResetNotDone(WrChannel)) {
|
||||
Polls -= 1;
|
||||
}
|
||||
|
||||
if (!Polls) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
Loading…
Add table
Reference in a new issue