XilinxProcessorIPLib/drivers/avbuf/src/xavbuf_clk.c
static int XAVBuf_PllCalcParameterValues(XAVBuf_Pll *PllInstancePtr,
				     u64 FreqHz)
{
	u64 ExtDivider;
	u64 Vco;
	u64 VcoIntFrac;

	/* Instantiate input frequency. */
	PllInstancePtr->InputRefClk =  XAVBUF_Pss_Ref_Clk;
	PllInstancePtr->RefClkFreqhz =  XAVBUF_INPUT_REF_CLK;
	/* Turn on internal Divider*/
	PllInstancePtr->Divider = 1;
	PllInstancePtr->DomainSwitchDiv = 1;

	/* Estimate the total divider. */
	ExtDivider =  (XAVBUF_PLL_OUT_FREQ / FreqHz) /
			      PllInstancePtr->DomainSwitchDiv;
	if (ExtDivider > 63 && PllInstancePtr->ExtDividerCnt == 2) {
		PllInstancePtr->ExtDivider0 = 63;
		PllInstancePtr->ExtDivider1 = ExtDivider / 63;
	} else if (ExtDivider < 63) {
		PllInstancePtr->ExtDivider0 = ExtDivider;
		PllInstancePtr->ExtDivider1 = 1;
	} else
		return XST_FAILURE;

	Vco = FreqHz * (PllInstancePtr->ExtDivider1 *
		PllInstancePtr->ExtDivider0 * 2) *
		PllInstancePtr->DomainSwitchDiv;
	/* Calculate integer and fractional part. */
	VcoIntFrac = (Vco * XAVBUF_INPUT_FREQ_PRECISION *
		XAVBUF_SHIFT_DECIMAL) /
		PllInstancePtr->RefClkFreqhz;
	PllInstancePtr->Fractional = VcoIntFrac &  XAVBUF_DECIMAL;
	PllInstancePtr->FracIntegerFBDIV = VcoIntFrac >> XAVBUF_PRECISION;

	return XST_SUCCESS;
}
/******************************************************************************/
/**
 * This function calculates the parameters which are required to configure PLL
 * depending upon the requested frequency.
 *
 * @param	PllInstancePtr is pointer to the XAVBuf_Pll instance
 * @param	FreqHz is the requested frequency to  DP in Hz
 *
 * @return	XST_SUCCESS if parameters are calculated
 *		XST_FAILURE otherwise.
 *
 * @note	In order to avoid floating point usage we have a 16bit
 *		fractional fixed point arithmetic implementation
 *
*******************************************************************************/
This function calculates the parameters which are required to configure PLL
depending upon the requested frequency.

@param       PllInstancePtr is pointer to the XAVBuf_Pll instance
@param       FreqHz is the requested frequency to  DP in Hz

@return      XST_SUCCESS if parameters are calculated
XST_FAILURE otherwise.

@note        In order to avoid floating point usage we have a 16bit
fractional fixed point arithmetic implementation
This function calculates the parameters which are required to configure PLL depending upon the requested frequency . @param PllInstancePtr is pointer to the XAVBuf_Pll instance @param FreqHz is the requested frequency to DP in Hz @return XST_SUCCESS if parameters are calculated XST_FAILURE otherwise . @note In order to avoid floating point usage we have a 16bit fractional fixed point arithmetic implementation
static int XAVBuf_PllCalcParameterValues(XAVBuf_Pll *PllInstancePtr,
				     u64 FreqHz)
{
	u64 ExtDivider;
	u64 Vco;
	u64 VcoIntFrac;
	PllInstancePtr->InputRefClk =  XAVBUF_Pss_Ref_Clk;
	PllInstancePtr->RefClkFreqhz =  XAVBUF_INPUT_REF_CLK;
	PllInstancePtr->Divider = 1;
	PllInstancePtr->DomainSwitchDiv = 1;
	ExtDivider =  (XAVBUF_PLL_OUT_FREQ / FreqHz) /
			      PllInstancePtr->DomainSwitchDiv;
	if (ExtDivider > 63 && PllInstancePtr->ExtDividerCnt == 2) {
		PllInstancePtr->ExtDivider0 = 63;
		PllInstancePtr->ExtDivider1 = ExtDivider / 63;
	} else if (ExtDivider < 63) {
		PllInstancePtr->ExtDivider0 = ExtDivider;
		PllInstancePtr->ExtDivider1 = 1;
	} else
		return XST_FAILURE;
	Vco = FreqHz * (PllInstancePtr->ExtDivider1 *
		PllInstancePtr->ExtDivider0 * 2) *
		PllInstancePtr->DomainSwitchDiv;
	VcoIntFrac = (Vco * XAVBUF_INPUT_FREQ_PRECISION *
		XAVBUF_SHIFT_DECIMAL) /
		PllInstancePtr->RefClkFreqhz;
	PllInstancePtr->Fractional = VcoIntFrac &  XAVBUF_DECIMAL;
	PllInstancePtr->FracIntegerFBDIV = VcoIntFrac >> XAVBUF_PRECISION;
	return XST_SUCCESS;
}
static int XAVBuf_PllCalcParameterValues ( XAVBuf_Pll * PllInstancePtr , u64 FreqHz ) { u64 ExtDivider ; u64 Vco ; u64 VcoIntFrac ; PllInstancePtr -> InputRefClk = XAVBUF_Pss_Ref_Clk ; PllInstancePtr -> RefClkFreqhz = XAVBUF_INPUT_REF_CLK ; PllInstancePtr -> Divider = 1 ; PllInstancePtr -> DomainSwitchDiv = 1 ; ExtDivider = ( XAVBUF_PLL_OUT_FREQ / FreqHz ) / PllInstancePtr -> DomainSwitchDiv ; if ( ExtDivider > 63 && PllInstancePtr -> ExtDividerCnt == 2 ) { PllInstancePtr -> ExtDivider0 = 63 ; PllInstancePtr -> ExtDivider1 = ExtDivider / 63 ; } else if ( ExtDivider < 63 ) { PllInstancePtr -> ExtDivider0 = ExtDivider ; PllInstancePtr -> ExtDivider1 = 1 ; } else return XST_FAILURE ; Vco = FreqHz * ( PllInstancePtr -> ExtDivider1 * PllInstancePtr -> ExtDivider0 * 2 ) * PllInstancePtr -> DomainSwitchDiv ; VcoIntFrac = ( Vco * XAVBUF_INPUT_FREQ_PRECISION * XAVBUF_SHIFT_DECIMAL ) / PllInstancePtr -> RefClkFreqhz ; PllInstancePtr -> Fractional = VcoIntFrac & XAVBUF_DECIMAL ; PllInstancePtr -> FracIntegerFBDIV = VcoIntFrac >> XAVBUF_PRECISION ; return XST_SUCCESS ; }
This function calculates the parameters which are required to configure PLL
 depending upon the requested frequency.
This function calculates the parameters which are required to configure PLL depending upon the requested frequency .
/* Instantiate input frequency. */ /* Turn on internal Divider*/ /* Estimate the total divider. */ /* Calculate integer and fractional part. */