From 5d03fa54dac644c0c1c772e457ece095cb1cd8ff Mon Sep 17 00:00:00 2001 From: Andrei-Liviu Simion Date: Thu, 15 Jan 2015 15:54:55 -0800 Subject: [PATCH] dp: rx: Added function to wait for the PHY to be ready. Signed-off-by: Andrei-Liviu Simion --- XilinxProcessorIPLib/drivers/dp/src/xdprx.c | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/XilinxProcessorIPLib/drivers/dp/src/xdprx.c b/XilinxProcessorIPLib/drivers/dp/src/xdprx.c index 1246de9a..03986b1e 100644 --- a/XilinxProcessorIPLib/drivers/dp/src/xdprx.c +++ b/XilinxProcessorIPLib/drivers/dp/src/xdprx.c @@ -55,6 +55,11 @@ #include "microblaze_sleep.h" #endif +/**************************** Function Prototypes *****************************/ + +/* Miscellaneous functions. */ +static u32 XDprx_WaitPhyReady(XDprx *InstancePtr, u8 Mask); + /**************************** Function Definitions ****************************/ /******************************************************************************/ @@ -185,3 +190,38 @@ void XDprx_WaitUs(XDprx *InstancePtr, u32 MicroSeconds) usleep(MicroSeconds); #endif } + +/******************************************************************************/ +/** + * This function waits for the DisplayPort PHY to come out of reset. + * + * @param InstancePtr is a pointer to the XDprx instance. + * @param Mask specifies which bits to wait for the PHY to be ready on. + * + * @return + * - XST_ERROR_COUNT_MAX if the PHY failed to be ready. + * - XST_SUCCESS otherwise. + * + * @note None. + * +*******************************************************************************/ +static u32 XDprx_WaitPhyReady(XDprx *InstancePtr, u8 Mask) +{ + u32 Timeout = 100; + u32 PhyStatus; + + /* Wait until the PHY is ready. */ + do { + PhyStatus = XDprx_ReadReg(InstancePtr->Config.BaseAddr, + XDPRX_PHY_STATUS) & Mask; + + /* Protect against an infinite loop. */ + if (!Timeout--) { + return XST_ERROR_COUNT_MAX; + } + XDprx_WaitUs(InstancePtr, 20); + } + while (PhyStatus != Mask); + + return XST_SUCCESS; +}