diff --git a/XilinxProcessorIPLib/drivers/dptx/src/xdptx.c b/XilinxProcessorIPLib/drivers/dptx/src/xdptx.c index a493faf9..3fae2b68 100644 --- a/XilinxProcessorIPLib/drivers/dptx/src/xdptx.c +++ b/XilinxProcessorIPLib/drivers/dptx/src/xdptx.c @@ -72,6 +72,8 @@ #define XDPTX_AUX_MAX_DEFER_COUNT 50 /* Error out if an AUX request times out more than 50 times awaiting a reply. */ #define XDPTX_AUX_MAX_TIMEOUT_COUNT 50 +/* Error out if checking for a connected device times out more than 50 times. */ +#define XDPTX_IS_CONNECTED_MAX_TIMEOUT_COUNT 50 /****************************** Type Definitions ******************************/ @@ -660,6 +662,38 @@ void XDptx_CfgTxPeLevel(XDptx *InstancePtr, u8 Level, u8 TxLevel) InstancePtr->BoardChar.TxPeLevels[Level] = TxLevel; } +/******************************************************************************/ +/** + * This function checks if there is a connected RX device. + * + * @param InstancePtr is a pointer to the XDptx instance. + * + * @return + * - TRUE if there is a connection. + * - FALSE if there is no connection. + * +*******************************************************************************/ +u32 XDptx_IsConnected(XDptx *InstancePtr) +{ + u32 Status; + u8 Retries = 0; + + do { + Status = XDptx_ReadReg(InstancePtr->Config.BaseAddr, + XDPTX_INTERRUPT_SIG_STATE) & + XDPTX_INTERRUPT_SIG_STATE_HPD_STATE_MASK; + + if (Retries > XDPTX_IS_CONNECTED_MAX_TIMEOUT_COUNT) { + return 0; + } + + Retries++; + XDptx_WaitUs(InstancePtr, 1000); + } while (Status == 0); + + return 1; +} + /******************************************************************************/ /** * This function issues a read request over the AUX channel. diff --git a/XilinxProcessorIPLib/drivers/dptx/src/xdptx.h b/XilinxProcessorIPLib/drivers/dptx/src/xdptx.h index 8cd39f99..0ab3b94e 100644 --- a/XilinxProcessorIPLib/drivers/dptx/src/xdptx.h +++ b/XilinxProcessorIPLib/drivers/dptx/src/xdptx.h @@ -214,26 +214,6 @@ #include "xil_assert.h" #include "xil_types.h" -/******************* Macros (Inline Functions) Definitions ********************/ - -/******************************************************************************/ -/** - * This macro checks if there is a connected RX device. - * - * @param InstancePtr is a pointer to the XDptx instance. - * - * @return - * - TRUE if there is a connection. - * - FALSE if there is no connection. - * - * @note C-style signature: - * void XDptx_IsConnected(XDptx *InstancePtr) - * -*******************************************************************************/ -#define XDptx_IsConnected(InstancePtr) \ - (XDptx_ReadReg(InstancePtr->Config.BaseAddr, \ - XDPTX_INTERRUPT_SIG_STATE) & XDPTX_INTERRUPT_SIG_STATE_HPD_STATE_MASK) - /****************************** Type Definitions ******************************/ /** @@ -797,6 +777,7 @@ u32 XDptx_SetLinkRate(XDptx *InstancePtr, u8 LinkRate); u32 XDptx_SetScrambler(XDptx *InstancePtr, u8 Enable); /* xdptx.c: General usage functions. */ +u32 XDptx_IsConnected(XDptx *InstancePtr); void XDptx_EnableMainLink(XDptx *InstancePtr); void XDptx_DisableMainLink(XDptx *InstancePtr); void XDptx_ResetPhy(XDptx *InstancePtr, u32 Reset);