XilinxProcessorIPLib/drivers/clockps/src/xclockps_mux.c
static XStatus XClock_MuxSetActiveParent(u8 MuxIndex, u8 SetParentIdx)
{
	u8  ParentType;
	u8  ParentIdx;
	u16 *ParentPtr;
	u32 Value;
	u32 ParentMask;

	/* Validate arguments */
	XCLOCK_VALIDATE_INDEX(MUX, MuxIndex);
	if (SetParentIdx > Muxes[MuxIndex].NumParents) {
		return XST_INVALID_PARAM;
	}

	ParentPtr = Muxes[MuxIndex].Parent;

	if (XCLOCK_INVALID_PARENT == ParentPtr[SetParentIdx]) {
		/* Invalid parent */
		return XST_INVALID_PARAM;
	}

	/* Enable the parent */
	if (XCLOCK_PARENT_EXTERNAL != ParentPtr[SetParentIdx]) {
		ParentType = XCLOCK_FETCH_PARENT_TYPE(ParentPtr[SetParentIdx]);
		ParentIdx = XCLOCK_FETCH_PARENT_INDEX(ParentPtr[SetParentIdx]);

		if (XST_SUCCESS !=
				XClock_EnableClkNode((XClock_Types)ParentType, ParentIdx)) {
			return XST_FAILURE;
		}
	}

	/* Set parent */
	if (XST_SUCCESS != XClock_ReadReg(Muxes[MuxIndex].CtrlReg, &Value)) {
		return XST_FAILURE;
	}

	ParentMask = ((1 << Muxes[MuxIndex].Width) - 1) <<
							Muxes[MuxIndex].Shift;
	Value &= ~(ParentMask);
	Value |= (SetParentIdx << Muxes[MuxIndex].Shift);
	if(XST_SUCCESS != XClock_WriteReg(Muxes[MuxIndex].CtrlReg, Value)) {
		return XST_FAILURE;
	}

	Muxes[MuxIndex].ActiveParent = SetParentIdx;

	return XST_SUCCESS;
}
/*****************************************************************************/
/*
*
* This function is used to set active parent for mux.
*
* @param	MuxIndex is the database index of mux to look parent for.
* @param	SetParentIndex is the index of parent to set for mux.
*
* @return	XST_SUCCESS if successful.
*		XCLOCK_INVALID_PARAM for invalid function arguments.
*		XST_FAILURE if read/write fails.
*
* @note		None.
*
******************************************************************************/
This function is used to set active parent for mux.
This function is used to set active parent for mux .
static XStatus XClock_MuxSetActiveParent(u8 MuxIndex, u8 SetParentIdx)
{
	u8  ParentType;
	u8  ParentIdx;
	u16 *ParentPtr;
	u32 Value;
	u32 ParentMask;
	XCLOCK_VALIDATE_INDEX(MUX, MuxIndex);
	if (SetParentIdx > Muxes[MuxIndex].NumParents) {
		return XST_INVALID_PARAM;
	}
	ParentPtr = Muxes[MuxIndex].Parent;
	if (XCLOCK_INVALID_PARENT == ParentPtr[SetParentIdx]) {
		return XST_INVALID_PARAM;
	}
	if (XCLOCK_PARENT_EXTERNAL != ParentPtr[SetParentIdx]) {
		ParentType = XCLOCK_FETCH_PARENT_TYPE(ParentPtr[SetParentIdx]);
		ParentIdx = XCLOCK_FETCH_PARENT_INDEX(ParentPtr[SetParentIdx]);
		if (XST_SUCCESS !=
				XClock_EnableClkNode((XClock_Types)ParentType, ParentIdx)) {
			return XST_FAILURE;
		}
	}
	if (XST_SUCCESS != XClock_ReadReg(Muxes[MuxIndex].CtrlReg, &Value)) {
		return XST_FAILURE;
	}
	ParentMask = ((1 << Muxes[MuxIndex].Width) - 1) <<
							Muxes[MuxIndex].Shift;
	Value &= ~(ParentMask);
	Value |= (SetParentIdx << Muxes[MuxIndex].Shift);
	if(XST_SUCCESS != XClock_WriteReg(Muxes[MuxIndex].CtrlReg, Value)) {
		return XST_FAILURE;
	}
	Muxes[MuxIndex].ActiveParent = SetParentIdx;
	return XST_SUCCESS;
}
static XStatus XClock_MuxSetActiveParent ( u8 MuxIndex , u8 SetParentIdx ) { u8 ParentType ; u8 ParentIdx ; u16 * ParentPtr ; u32 Value ; u32 ParentMask ; XCLOCK_VALIDATE_INDEX ( MUX , MuxIndex ) ; if ( SetParentIdx > Muxes [ MuxIndex ] . NumParents ) { return XST_INVALID_PARAM ; } ParentPtr = Muxes [ MuxIndex ] . Parent ; if ( XCLOCK_INVALID_PARENT == ParentPtr [ SetParentIdx ] ) { return XST_INVALID_PARAM ; } if ( XCLOCK_PARENT_EXTERNAL != ParentPtr [ SetParentIdx ] ) { ParentType = XCLOCK_FETCH_PARENT_TYPE ( ParentPtr [ SetParentIdx ] ) ; ParentIdx = XCLOCK_FETCH_PARENT_INDEX ( ParentPtr [ SetParentIdx ] ) ; if ( XST_SUCCESS != XClock_EnableClkNode ( ( XClock_Types ) ParentType , ParentIdx ) ) { return XST_FAILURE ; } } if ( XST_SUCCESS != XClock_ReadReg ( Muxes [ MuxIndex ] . CtrlReg , & Value ) ) { return XST_FAILURE ; } ParentMask = ( ( 1 << Muxes [ MuxIndex ] . Width ) - 1 ) << Muxes [ MuxIndex ] . Shift ; Value &= ~ ( ParentMask ) ; Value |= ( SetParentIdx << Muxes [ MuxIndex ] . Shift ) ; if ( XST_SUCCESS != XClock_WriteReg ( Muxes [ MuxIndex ] . CtrlReg , Value ) ) { return XST_FAILURE ; } Muxes [ MuxIndex ] . ActiveParent = SetParentIdx ; return XST_SUCCESS ; }
This function is used to set active parent for mux.
This function is used to set active parent for mux .
/* Validate arguments */ /* Invalid parent */ /* Enable the parent */ /* Set parent */