XilinxProcessorIPLib/drivers/avbuf/src/xavbuf_clk.c
int XAVBuf_SetAudioClock(u64 FreqHz)
{
	u32 Flag;
	u32 PllAssigned;
	u8 Pll;
	u8 CrossDomain;
	XAVBuf_Pll XAVBuf_RPllInstancePtr;

	/*Verify Input Arguments*/
	Flag = (FreqHz == (XAVBUF_AUDIO_SAMPLE_RATE_44_1 *
		XAVBUF_AUDIO_SAMPLES)) ||
		(FreqHz == (XAVBUF_AUDIO_SAMPLE_RATE_48_0 *
		XAVBUF_AUDIO_SAMPLES));
	Xil_AssertNonvoid(Flag);

	PllAssigned = XAVBuf_ReadReg(XAVBUF_CLK_FPD_BASEADDR,
		XAVBUF_AUDIO_REF_CTRL) &
		XAVBUF_AUDIO_REF_CTRL_SRCSEL_MASK;

	switch (PllAssigned) {
		case XAVBUF_VPLL_SRC_SEL:
				Pll = VPLL;
				CrossDomain = 0;
				break;
		case XAVBUF_DPLL_SRC_SEL:
				Pll = DPLL;
				CrossDomain = 0;
				break;
		case XAVBUF_RPLL_TO_FPD_SRC_SEL:
				Pll = RPLL;
				CrossDomain = 1;
				break;
		default:
				return XST_FAILURE;
	}

	/*Calculate configure PLL and External Divider*/
	XAVBuf_PllInitialize(&XAVBuf_RPllInstancePtr, Pll, CrossDomain,
		XAVBUF_EXTERNAL_DIVIDER);
	Flag = XAVBuf_PllCalcParameterValues(&XAVBuf_RPllInstancePtr, FreqHz);
	if (Flag != 0)
		return XST_FAILURE;
	Flag = XAVBuf_ConfigurePll(&XAVBuf_RPllInstancePtr);
	if (Flag != 0)
		return XST_FAILURE;
	XAVBuf_ConfigureExtDivider(&XAVBuf_RPllInstancePtr,
		XAVBUF_CLK_FPD_BASEADDR, XAVBUF_AUDIO_REF_CTRL);

	return XST_SUCCESS;
}
/******************************************************************************/
/**
 * This function calls API to calculate and configure PLL with desired
 * frequency for Audio.
 *
 * @param	FreqHz is the desired frequency in Hz.
 *
 * @return	XST_SUCCESS if PLL is configured without an error.
 *		    XST_FAILURE otherwise.
 *
 * @note	The Pll used is design specific.
 *
*******************************************************************************/
This function calls API to calculate and configure PLL with desired
frequency for Audio.

@param       FreqHz is the desired frequency in Hz.

@return      XST_SUCCESS if PLL is configured without an error.

@note        The Pll used is design specific.
This function calls API to calculate and configure PLL with desired frequency for Audio . @param FreqHz is the desired frequency in Hz . @return XST_SUCCESS if PLL is configured without an error . @note The Pll used is design specific .
int XAVBuf_SetAudioClock(u64 FreqHz)
{
	u32 Flag;
	u32 PllAssigned;
	u8 Pll;
	u8 CrossDomain;
	XAVBuf_Pll XAVBuf_RPllInstancePtr;
	Flag = (FreqHz == (XAVBUF_AUDIO_SAMPLE_RATE_44_1 *
		XAVBUF_AUDIO_SAMPLES)) ||
		(FreqHz == (XAVBUF_AUDIO_SAMPLE_RATE_48_0 *
		XAVBUF_AUDIO_SAMPLES));
	Xil_AssertNonvoid(Flag);
	PllAssigned = XAVBuf_ReadReg(XAVBUF_CLK_FPD_BASEADDR,
		XAVBUF_AUDIO_REF_CTRL) &
		XAVBUF_AUDIO_REF_CTRL_SRCSEL_MASK;
	switch (PllAssigned) {
		case XAVBUF_VPLL_SRC_SEL:
				Pll = VPLL;
				CrossDomain = 0;
				break;
		case XAVBUF_DPLL_SRC_SEL:
				Pll = DPLL;
				CrossDomain = 0;
				break;
		case XAVBUF_RPLL_TO_FPD_SRC_SEL:
				Pll = RPLL;
				CrossDomain = 1;
				break;
		default:
				return XST_FAILURE;
	}
	XAVBuf_PllInitialize(&XAVBuf_RPllInstancePtr, Pll, CrossDomain,
		XAVBUF_EXTERNAL_DIVIDER);
	Flag = XAVBuf_PllCalcParameterValues(&XAVBuf_RPllInstancePtr, FreqHz);
	if (Flag != 0)
		return XST_FAILURE;
	Flag = XAVBuf_ConfigurePll(&XAVBuf_RPllInstancePtr);
	if (Flag != 0)
		return XST_FAILURE;
	XAVBuf_ConfigureExtDivider(&XAVBuf_RPllInstancePtr,
		XAVBUF_CLK_FPD_BASEADDR, XAVBUF_AUDIO_REF_CTRL);
	return XST_SUCCESS;
}
int XAVBuf_SetAudioClock ( u64 FreqHz ) { u32 Flag ; u32 PllAssigned ; u8 Pll ; u8 CrossDomain ; XAVBuf_Pll XAVBuf_RPllInstancePtr ; Flag = ( FreqHz == ( XAVBUF_AUDIO_SAMPLE_RATE_44_1 * XAVBUF_AUDIO_SAMPLES ) ) || ( FreqHz == ( XAVBUF_AUDIO_SAMPLE_RATE_48_0 * XAVBUF_AUDIO_SAMPLES ) ) ; Xil_AssertNonvoid ( Flag ) ; PllAssigned = XAVBuf_ReadReg ( XAVBUF_CLK_FPD_BASEADDR , XAVBUF_AUDIO_REF_CTRL ) & XAVBUF_AUDIO_REF_CTRL_SRCSEL_MASK ; switch ( PllAssigned ) { case XAVBUF_VPLL_SRC_SEL : Pll = VPLL ; CrossDomain = 0 ; break ; case XAVBUF_DPLL_SRC_SEL : Pll = DPLL ; CrossDomain = 0 ; break ; case XAVBUF_RPLL_TO_FPD_SRC_SEL : Pll = RPLL ; CrossDomain = 1 ; break ; default : return XST_FAILURE ; } XAVBuf_PllInitialize ( & XAVBuf_RPllInstancePtr , Pll , CrossDomain , XAVBUF_EXTERNAL_DIVIDER ) ; Flag = XAVBuf_PllCalcParameterValues ( & XAVBuf_RPllInstancePtr , FreqHz ) ; if ( Flag != 0 ) return XST_FAILURE ; Flag = XAVBuf_ConfigurePll ( & XAVBuf_RPllInstancePtr ) ; if ( Flag != 0 ) return XST_FAILURE ; XAVBuf_ConfigureExtDivider ( & XAVBuf_RPllInstancePtr , XAVBUF_CLK_FPD_BASEADDR , XAVBUF_AUDIO_REF_CTRL ) ; return XST_SUCCESS ; }
This function calls API to calculate and configure PLL with desired
 frequency for Audio.
This function calls API to calculate and configure PLL with desired frequency for Audio .
/*Verify Input Arguments*/ /*Calculate configure PLL and External Divider*/