diff --git a/XilinxProcessorIPLib/drivers/axidma/data/axidma_header.h b/XilinxProcessorIPLib/drivers/axidma/data/axidma_header.h index 9497da6d..43a7e0b3 100644 --- a/XilinxProcessorIPLib/drivers/axidma/data/axidma_header.h +++ b/XilinxProcessorIPLib/drivers/axidma/data/axidma_header.h @@ -36,6 +36,6 @@ #include "xil_assert.h" #include "xstatus.h" -int XAxiDma_Selftest(u16 DeviceId); +int AxiDMASelfTestExample(u16 DeviceId); #endif diff --git a/XilinxProcessorIPLib/drivers/axidma/data/axidma_tapp.tcl b/XilinxProcessorIPLib/drivers/axidma/data/axidma_tapp.tcl index ef197953..f49e68a7 100755 --- a/XilinxProcessorIPLib/drivers/axidma/data/axidma_tapp.tcl +++ b/XilinxProcessorIPLib/drivers/axidma/data/axidma_tapp.tcl @@ -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\"); } }" } diff --git a/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_selftest.c b/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_selftest.c index feb0ba19..023582dd 100644 --- a/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_selftest.c +++ b/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_selftest.c @@ -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; } diff --git a/XilinxProcessorIPLib/drivers/axidma/src/xaxidma.h b/XilinxProcessorIPLib/drivers/axidma/src/xaxidma.h index 5aaa73b1..a940c320 100644 --- a/XilinxProcessorIPLib/drivers/axidma/src/xaxidma.h +++ b/XilinxProcessorIPLib/drivers/axidma/src/xaxidma.h @@ -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 * * * @@ -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 diff --git a/XilinxProcessorIPLib/drivers/axidma/src/xaxidma_selftest.c b/XilinxProcessorIPLib/drivers/axidma/src/xaxidma_selftest.c new file mode 100644 index 00000000..2b22a71d --- /dev/null +++ b/XilinxProcessorIPLib/drivers/axidma/src/xaxidma_selftest.c @@ -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. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ----------------------------------------------- +* 8.1 adk 29/01/15 First release +*+* +******************************************************************************/ + +/***************************** 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; +} diff --git a/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_header.h b/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_header.h index 0fc01c93..b477c67f 100644 --- a/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_header.h +++ b/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_header.h @@ -36,6 +36,6 @@ #include "xil_assert.h" #include "xstatus.h" -int XAxiVdma_Selftest(u16 DeviceId); +int AxiVDMASelfTestExample(u16 DeviceId); #endif diff --git a/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_tapp.tcl b/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_tapp.tcl index 91507251..0e72600d 100755 --- a/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_tapp.tcl +++ b/XilinxProcessorIPLib/drivers/axivdma/data/axivdma_tapp.tcl @@ -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\"); } }" } diff --git a/XilinxProcessorIPLib/drivers/axivdma/examples/xaxivdma_example_selftest.c b/XilinxProcessorIPLib/drivers/axivdma/examples/xaxivdma_example_selftest.c index 3e698877..01891271 100644 --- a/XilinxProcessorIPLib/drivers/axivdma/examples/xaxivdma_example_selftest.c +++ b/XilinxProcessorIPLib/drivers/axivdma/examples/xaxivdma_example_selftest.c @@ -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; diff --git a/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma.h b/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma.h index 58ad1e73..295f2e69 100644 --- a/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma.h +++ b/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma.h @@ -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 * * * @@ -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 } diff --git a/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma_selftest.c b/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma_selftest.c new file mode 100644 index 00000000..f12756ae --- /dev/null +++ b/XilinxProcessorIPLib/drivers/axivdma/src/xaxivdma_selftest.c @@ -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. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- ---- -------- ----------------------------------------------- +* 5.1 adk 29/01/15 First release +*+* +******************************************************************************/ + +/***************************** 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; +}