XilinxProcessorIPLib/drivers/aiengine/src/lib/xaielib.c
u32 XAieLib_NPIMaskPoll(u64 Addr, u32 Mask, u32 Value, u32 TimeOutUs)
{
	u32 Ret = XAIELIB_FAILURE;

#ifdef __AIESIM__
	if (XAieSim_NPIMaskPoll(Addr, Mask, Value, TimeOutUs) == XAIESIM_SUCCESS) {
		Ret = XAIELIB_SUCCESS;
	}
#else
	u32 Count, MinTimeOutUs;

	/*
	 * Any value less than 200 us becomes noticable overhead. This is based
	 * on some profiling, and it may vary between platforms.
	 */
	MinTimeOutUs = 200;
	Count = ((u64)TimeOutUs + MinTimeOutUs - 1) / MinTimeOutUs;

	while (Count > 0U) {
		if ((XAieLib_NPIRead32(Addr) & Mask) == Value) {
			Ret = XAIELIB_SUCCESS;
			break;
		}
		XAieLib_usleep(MinTimeOutUs);
		Count--;
	}

	/* Check for the break from timed-out loop */
	if ((Ret == XAIELIB_FAILURE) &&
			((XAieLib_NPIRead32(Addr) & Mask) == Value)) {
		Ret = XAIELIB_SUCCESS;
	}
#endif
	return Ret;
}
/*****************************************************************************/
/**
*
* This is the NPI IO function to poll until the value at the address to be given
* masked value.
*
* @param	Addr: Address to write to.
* @param	Mask: Mask to be applied to read data.
* @param	Value: The expected value
* @param	TimeOutUs: Minimum timeout in usec.
*
* @return	XAIELIB_SUCCESS on success, otherwise XAIELIB_FAILURE
*
* @note		This only work if NPI is accessble.
*
*******************************************************************************/
This is the NPI IO function to poll until the value at the address to be given
masked value.
This is the NPI IO function to poll until the value at the address to be given masked value .
u32 XAieLib_NPIMaskPoll(u64 Addr, u32 Mask, u32 Value, u32 TimeOutUs)
{
	u32 Ret = XAIELIB_FAILURE;
#ifdef __AIESIM__
	if (XAieSim_NPIMaskPoll(Addr, Mask, Value, TimeOutUs) == XAIESIM_SUCCESS) {
		Ret = XAIELIB_SUCCESS;
	}
#else
	u32 Count, MinTimeOutUs;
	MinTimeOutUs = 200;
	Count = ((u64)TimeOutUs + MinTimeOutUs - 1) / MinTimeOutUs;
	while (Count > 0U) {
		if ((XAieLib_NPIRead32(Addr) & Mask) == Value) {
			Ret = XAIELIB_SUCCESS;
			break;
		}
		XAieLib_usleep(MinTimeOutUs);
		Count--;
	}
	if ((Ret == XAIELIB_FAILURE) &&
			((XAieLib_NPIRead32(Addr) & Mask) == Value)) {
		Ret = XAIELIB_SUCCESS;
	}
#endif
	return Ret;
}
u32 XAieLib_NPIMaskPoll ( u64 Addr , u32 Mask , u32 Value , u32 TimeOutUs ) { u32 Ret = XAIELIB_FAILURE ; #ifdef __AIESIM__ if ( XAieSim_NPIMaskPoll ( Addr , Mask , Value , TimeOutUs ) == XAIESIM_SUCCESS ) { Ret = XAIELIB_SUCCESS ; } #else u32 Count , MinTimeOutUs ; MinTimeOutUs = 200 ; Count = ( ( u64 ) TimeOutUs + MinTimeOutUs - 1 ) / MinTimeOutUs ; while ( Count > 0U ) { if ( ( XAieLib_NPIRead32 ( Addr ) & Mask ) == Value ) { Ret = XAIELIB_SUCCESS ; break ; } XAieLib_usleep ( MinTimeOutUs ) ; Count -- ; } if ( ( Ret == XAIELIB_FAILURE ) && ( ( XAieLib_NPIRead32 ( Addr ) & Mask ) == Value ) ) { Ret = XAIELIB_SUCCESS ; } #endif return Ret ; }
This is the NPI IO function to poll until the value at the address to be given
masked value.
This is the NPI IO function to poll until the value at the address to be given masked value .
/*
	 * Any value less than 200 us becomes noticable overhead. This is based
	 * on some profiling, and it may vary between platforms.
	 */ /* Check for the break from timed-out loop */