From d972cf8c186de569f3bdda58b184f0967385bf9c Mon Sep 17 00:00:00 2001 From: Andrei-Liviu Simion Date: Tue, 4 Aug 2015 01:38:21 -0700 Subject: [PATCH] dp: tx: Added link configuration and training callbacks. New callbacks for: - Link rate changes. - Lane count changes. - Pre-emphasis and voltage swing adjust request. Signed-off-by: Andrei-Liviu Simion Reviewed-by: Hyun Kwon --- XilinxProcessorIPLib/drivers/dp/src/xdp.c | 106 ++++++++++++++++++++++ XilinxProcessorIPLib/drivers/dp/src/xdp.h | 37 ++++++++ 2 files changed, 143 insertions(+) diff --git a/XilinxProcessorIPLib/drivers/dp/src/xdp.c b/XilinxProcessorIPLib/drivers/dp/src/xdp.c index 8d4a9a4d..e6295aea 100644 --- a/XilinxProcessorIPLib/drivers/dp/src/xdp.c +++ b/XilinxProcessorIPLib/drivers/dp/src/xdp.c @@ -47,6 +47,8 @@ * ----- ---- -------- ----------------------------------------------- * 1.0 als 01/20/15 Initial release. TX code merged from the dptx driver. * 2.0 als 06/08/15 Updated RX initialization with MST support. + * Added callbacks for lane count changes, link rate changes + * and pre-emphasis + voltage swing adjust requests. * * *******************************************************************************/ @@ -1060,6 +1062,12 @@ u32 XDp_TxSetLaneCount(XDp *InstancePtr, u8 LaneCount) return XST_FAILURE; } + /* Invoke callback, if defined. */ + if (InstancePtr->TxInstance.LaneCountChangeCallback) { + InstancePtr->TxInstance.LaneCountChangeCallback( + InstancePtr->TxInstance.LaneCountChangeCallbackRef); + } + return XST_SUCCESS; } @@ -1134,6 +1142,12 @@ u32 XDp_TxSetLinkRate(XDp *InstancePtr, u8 LinkRate) return XST_FAILURE; } + /* Invoke callback, if defined. */ + if (InstancePtr->TxInstance.LinkRateChangeCallback) { + InstancePtr->TxInstance.LinkRateChangeCallback( + InstancePtr->TxInstance.LinkRateChangeCallbackRef); + } + return XST_SUCCESS; } @@ -1703,6 +1717,92 @@ void XDp_WaitUs(XDp *InstancePtr, u32 MicroSeconds) #endif } +/******************************************************************************/ +/** + * This function installs a callback function for when the driver's lane count + * change function is called either directly by the user or during link + * training. + * + * @param InstancePtr is a pointer to the XDp instance. + * @param CallbackFunc is the address to the callback function. + * @param CallbackRef is the user data item that will be passed to the + * callback function when it is invoked. + * + * @return None. + * + * @note None. + * +*******************************************************************************/ +void XDp_TxSetLaneCountChangeCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(XDp_GetCoreType(InstancePtr) == XDP_TX); + Xil_AssertVoid(CallbackFunc != NULL); + Xil_AssertVoid(CallbackRef != NULL); + + InstancePtr->TxInstance.LaneCountChangeCallback = CallbackFunc; + InstancePtr->TxInstance.LaneCountChangeCallbackRef = CallbackRef; +} + +/******************************************************************************/ +/** + * This function installs a callback function for when the driver's link rate + * change function is called either directly by the user or during link + * training. + * + * @param InstancePtr is a pointer to the XDp instance. + * @param CallbackFunc is the address to the callback function. + * @param CallbackRef is the user data item that will be passed to the + * callback function when it is invoked. + * + * @return None. + * + * @note None. + * +*******************************************************************************/ +void XDp_TxSetLinkRateChangeCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(XDp_GetCoreType(InstancePtr) == XDP_TX); + Xil_AssertVoid(CallbackFunc != NULL); + Xil_AssertVoid(CallbackRef != NULL); + + InstancePtr->TxInstance.LinkRateChangeCallback = CallbackFunc; + InstancePtr->TxInstance.LinkRateChangeCallbackRef = CallbackRef; +} + +/******************************************************************************/ +/** + * This function installs a callback function for when the driver's link rate + * change function is called during link training. + * + * @param InstancePtr is a pointer to the XDp instance. + * @param CallbackFunc is the address to the callback function. + * @param CallbackRef is the user data item that will be passed to the + * callback function when it is invoked. + * + * @return None. + * + * @note None. + * +*******************************************************************************/ +void XDp_TxSetPeVsAdjustCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef) +{ + /* Verify arguments. */ + Xil_AssertVoid(InstancePtr != NULL); + Xil_AssertVoid(XDp_GetCoreType(InstancePtr) == XDP_TX); + Xil_AssertVoid(CallbackFunc != NULL); + Xil_AssertVoid(CallbackRef != NULL); + + InstancePtr->TxInstance.PeVsAdjustCallback = CallbackFunc; + InstancePtr->TxInstance.PeVsAdjustCallbackRef = CallbackRef; +} + /******************************************************************************/ /** * This function prepares the DisplayPort TX core for use. @@ -2638,6 +2738,12 @@ static u32 XDp_TxAdjVswingPreemp(XDp *InstancePtr) return XST_FAILURE; } + /* Invoke callback, if defined. */ + if (InstancePtr->TxInstance.PeVsAdjustCallback) { + InstancePtr->TxInstance.PeVsAdjustCallback( + InstancePtr->TxInstance.PeVsAdjustCallbackRef); + } + return XST_SUCCESS; } diff --git a/XilinxProcessorIPLib/drivers/dp/src/xdp.h b/XilinxProcessorIPLib/drivers/dp/src/xdp.h index e600ae09..b6855f96 100644 --- a/XilinxProcessorIPLib/drivers/dp/src/xdp.h +++ b/XilinxProcessorIPLib/drivers/dp/src/xdp.h @@ -345,6 +345,8 @@ * 'u32 Guid[4]' changed to 'u8 Guid[16]' * Added handlers and setter functions for HDCP and unplug * events. + * Added callbacks for lane count changes, link rate changes + * and pre-emphasis + voltage swing adjust requests. * * *******************************************************************************/ @@ -808,6 +810,35 @@ typedef struct { void *HpdPulseCallbackRef; /**< A pointer to the user data passed to the HPD pulse callback function. */ + XDp_IntrHandler LaneCountChangeCallback; /** Callback function to be + invoked once a lane + count change has + occurred within the + driver. */ + void *LaneCountChangeCallbackRef; /** A pointer to the user data + passed to the lane count + change callback + function. */ + XDp_IntrHandler LinkRateChangeCallback; /**< Callback function to be + invoked once a link + rate change has + occurred within the + driver. */ + void *LinkRateChangeCallbackRef; /** A pointer to the user data + passed to the link rate + change callback + function. */ + XDp_IntrHandler PeVsAdjustCallback; /** Callback function to be + invoked once a voltage + swing and pre-emphasis + adjust request has been + handled within the + driver. */ + void *PeVsAdjustCallbackRef; /** A pointer to the user data + passed to the voltage + swing and pre-emphasis + adjust request callback + function. */ } XDp_Tx; /** @@ -1037,6 +1068,12 @@ void XDp_TxSetHasRedriverInPath(XDp *InstancePtr, u8 Set); void XDp_TxCfgTxVsOffset(XDp *InstancePtr, u8 Offset); void XDp_TxCfgTxVsLevel(XDp *InstancePtr, u8 Level, u8 TxLevel); void XDp_TxCfgTxPeLevel(XDp *InstancePtr, u8 Level, u8 TxLevel); +void XDp_TxSetLaneCountChangeCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef); +void XDp_TxSetLinkRateChangeCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef); +void XDp_TxSetPeVsAdjustCallback(XDp *InstancePtr, + XDp_IntrHandler CallbackFunc, void *CallbackRef); /* xdp.c: TX AUX transaction functions. */ u32 XDp_TxAuxRead(XDp *InstancePtr, u32 DpcdAddress, u32 BytesToRead,