XilinxProcessorIPLib/drivers/rfdc/src/xrfdc_clock.c
u32 XRFdc_GetPLLLockStatus(XRFdc *InstancePtr, u32 Type, u32 Tile_Id, u32 *LockStatusPtr)
{
	u32 BaseAddr;
	u32 ReadReg;
	u32 ClkSrc = 0U;
	u32 Status;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(LockStatusPtr != NULL);

	/*
	 * Get Tile clock source information
	 */
	if (XRFdc_GetClockSource(InstancePtr, Type, Tile_Id, &ClkSrc) != XRFDC_SUCCESS) {
		metal_log(METAL_LOG_ERROR, "\n Get clock source request %s %u failed in %s\r\n",
			  (Type == XRFDC_ADC_TILE) ? "ADC" : "DAC", Tile_Id, __func__);
		Status = XRFDC_FAILURE;
		goto RETURN_PATH;
	}

	if (ClkSrc == XRFDC_EXTERNAL_CLK) {
		metal_log(METAL_LOG_DEBUG, "\n %s %u uses external clock source in %s\r\n",
			  (Type == XRFDC_ADC_TILE) ? "ADC" : "DAC", Tile_Id, __func__);
		*LockStatusPtr = XRFDC_PLL_LOCKED;
	} else {
		if (Type == XRFDC_ADC_TILE) {
			BaseAddr = XRFDC_ADC_TILE_CTRL_STATS_ADDR(Tile_Id);
		} else {
			BaseAddr = XRFDC_DAC_TILE_CTRL_STATS_ADDR(Tile_Id);
		}

		ReadReg = XRFdc_RDReg(InstancePtr, BaseAddr, XRFDC_STATUS_OFFSET, XRFDC_PLL_LOCKED_MASK);
		if (ReadReg != 0U) {
			*LockStatusPtr = XRFDC_PLL_LOCKED;
		} else {
			*LockStatusPtr = XRFDC_PLL_UNLOCKED;
		}
	}

	Status = XRFDC_SUCCESS;
RETURN_PATH:
	return Status;
}
/*****************************************************************************/
/**
*
* This function gets PLL lock status
*
* @param    InstancePtr is a pointer to the XRfdc instance.
* @param    Type indicates ADC/DAC.
* @param    Tile_Id indicates Tile number (0-3).
* @param    LockStatusPtr Pointer to return the PLL lock status
*
* @return
*           - XRFDC_SUCCESS if successful.
*           - XRFDC_FAILURE if error occurs.
*
* @note     None.
*
******************************************************************************/
This function gets PLL lock status
This function gets PLL lock status
u32 XRFdc_GetPLLLockStatus(XRFdc *InstancePtr, u32 Type, u32 Tile_Id, u32 *LockStatusPtr)
{
	u32 BaseAddr;
	u32 ReadReg;
	u32 ClkSrc = 0U;
	u32 Status;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(LockStatusPtr != NULL);
	if (XRFdc_GetClockSource(InstancePtr, Type, Tile_Id, &ClkSrc) != XRFDC_SUCCESS) {
		metal_log(METAL_LOG_ERROR, "\n Get clock source request %s %u failed in %s\r\n",
			  (Type == XRFDC_ADC_TILE) ? "ADC" : "DAC", Tile_Id, __func__);
		Status = XRFDC_FAILURE;
		goto RETURN_PATH;
	}
	if (ClkSrc == XRFDC_EXTERNAL_CLK) {
		metal_log(METAL_LOG_DEBUG, "\n %s %u uses external clock source in %s\r\n",
			  (Type == XRFDC_ADC_TILE) ? "ADC" : "DAC", Tile_Id, __func__);
		*LockStatusPtr = XRFDC_PLL_LOCKED;
	} else {
		if (Type == XRFDC_ADC_TILE) {
			BaseAddr = XRFDC_ADC_TILE_CTRL_STATS_ADDR(Tile_Id);
		} else {
			BaseAddr = XRFDC_DAC_TILE_CTRL_STATS_ADDR(Tile_Id);
		}
		ReadReg = XRFdc_RDReg(InstancePtr, BaseAddr, XRFDC_STATUS_OFFSET, XRFDC_PLL_LOCKED_MASK);
		if (ReadReg != 0U) {
			*LockStatusPtr = XRFDC_PLL_LOCKED;
		} else {
			*LockStatusPtr = XRFDC_PLL_UNLOCKED;
		}
	}
	Status = XRFDC_SUCCESS;
RETURN_PATH:
	return Status;
}
u32 XRFdc_GetPLLLockStatus ( XRFdc * InstancePtr , u32 Type , u32 Tile_Id , u32 * LockStatusPtr ) { u32 BaseAddr ; u32 ReadReg ; u32 ClkSrc = 0U ; u32 Status ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( LockStatusPtr != NULL ) ; if ( XRFdc_GetClockSource ( InstancePtr , Type , Tile_Id , & ClkSrc ) != XRFDC_SUCCESS ) { metal_log ( METAL_LOG_ERROR , " \n \r \n " , ( Type == XRFDC_ADC_TILE ) ? " " : " " , Tile_Id , __func__ ) ; Status = XRFDC_FAILURE ; goto RETURN_PATH ; } if ( ClkSrc == XRFDC_EXTERNAL_CLK ) { metal_log ( METAL_LOG_DEBUG , " \n \r \n " , ( Type == XRFDC_ADC_TILE ) ? " " : " " , Tile_Id , __func__ ) ; * LockStatusPtr = XRFDC_PLL_LOCKED ; } else { if ( Type == XRFDC_ADC_TILE ) { BaseAddr = XRFDC_ADC_TILE_CTRL_STATS_ADDR ( Tile_Id ) ; } else { BaseAddr = XRFDC_DAC_TILE_CTRL_STATS_ADDR ( Tile_Id ) ; } ReadReg = XRFdc_RDReg ( InstancePtr , BaseAddr , XRFDC_STATUS_OFFSET , XRFDC_PLL_LOCKED_MASK ) ; if ( ReadReg != 0U ) { * LockStatusPtr = XRFDC_PLL_LOCKED ; } else { * LockStatusPtr = XRFDC_PLL_UNLOCKED ; } } Status = XRFDC_SUCCESS ; RETURN_PATH : return Status ; }
This function gets PLL lock status
This function gets PLL lock status
/*
	 * Get Tile clock source information
	 */