XilinxProcessorIPLib/drivers/aiengine/src/pm/xaiepm_clock.c
u8 XAiePm_RequestTiles(XAieGbl *AieInst, u32 NumTiles, XAie_LocType *Loc)
{
	XAieGbl_Tile *TilePtr;
	u32 NumCols, NumRows;
	u8 status = XAIE_SUCCESS;

	XAie_AssertVoid(AieInst != XAIE_NULL);
	XAie_AssertVoid(AieInst->Config != XAIE_NULL);
	XAie_AssertVoid(AieInst->Tiles != XAIE_NULL);
	XAie_AssertVoid(AieInst->IsReady == XAIE_COMPONENT_IS_READY);
	XAie_AssertVoid(Loc != XAIE_NULL);

	NumCols = AieInst->Config->NumCols;
	NumRows = AieInst->Config->NumRows;
	XAie_AssertVoid(NumTiles <= NumCols * NumRows);

	/* mark all the input tiles as used using IsUsed field of its tileptr */
	for(u16 i = 0; i < NumTiles; i++) {
		XAie_AssertNonvoid(Loc[i].Row <= NumRows);
		XAie_AssertNonvoid(Loc[i].Col < NumCols);
		/*
		 * Since shim tile is always enabled, using IsUsed field of shim
		 * tile tileptr to mark the status of that col i.e. 1 if any
		 * tile in that col is used.
		 */
		TilePtr = AieInst->Tiles;
		TilePtr += Loc[i].Col * (NumRows + 1U);
		TilePtr->IsUsed = 1U;

		/* set the IsUsed field of tileptr for tile passed as input */
		TilePtr = AieInst->Tiles;
		TilePtr	+= Loc[i].Col * (NumRows + 1U) + Loc[i].Row;
		TilePtr->IsUsed = 1U;
	}

	/* gate all unused tiles */
	for(u8 j = 0; j < NumCols; j++){

		/* gate entire col if entire col is unused */
		TilePtr = AieInst->Tiles;
		TilePtr += j * (NumRows + 1);
		if(TilePtr->IsUsed != 1){
			status = _XAiePm_ClockGateColumn(TilePtr);
		}

		/* gate unused tile per col */
		else{
			for(u8 k = NumRows; k > 0; k--){
				TilePtr = AieInst->Tiles;
				TilePtr += j * (NumRows + 1U) + k;
				/*
				 * If a top tile in a col is in use, all the
				 * tiles below that tile in that col must not be
				 * gated.
				 */
				if(TilePtr->IsUsed == 1U)
					break;
				else{
					status = _XAiePm_ClockGateTile(AieInst, j, k);
				}
			}
		}
	}
	return status;
}
/*****************************************************************************/
/*
* This is an API to request tiles to use.
*
* @param	AieInst - Pointer to the Aie instance.
* @param	Loc - location of tiles in row, col.
* @param	NumTiles - total number of tiles requested.
*
* @return	XAIE_SUCCESS on success
*
* @note		This API assumes that all tiles' clock is enabled (not gated)
*		before calling this API.This API is not responsible if any
*		attempt to access any clock gated tile is made by the caller.
*
*******************************************************************************/
This is an API to request tiles to use.
This is an API to request tiles to use .
u8 XAiePm_RequestTiles(XAieGbl *AieInst, u32 NumTiles, XAie_LocType *Loc)
{
	XAieGbl_Tile *TilePtr;
	u32 NumCols, NumRows;
	u8 status = XAIE_SUCCESS;
	XAie_AssertVoid(AieInst != XAIE_NULL);
	XAie_AssertVoid(AieInst->Config != XAIE_NULL);
	XAie_AssertVoid(AieInst->Tiles != XAIE_NULL);
	XAie_AssertVoid(AieInst->IsReady == XAIE_COMPONENT_IS_READY);
	XAie_AssertVoid(Loc != XAIE_NULL);
	NumCols = AieInst->Config->NumCols;
	NumRows = AieInst->Config->NumRows;
	XAie_AssertVoid(NumTiles <= NumCols * NumRows);
	for(u16 i = 0; i < NumTiles; i++) {
		XAie_AssertNonvoid(Loc[i].Row <= NumRows);
		XAie_AssertNonvoid(Loc[i].Col < NumCols);
		TilePtr = AieInst->Tiles;
		TilePtr += Loc[i].Col * (NumRows + 1U);
		TilePtr->IsUsed = 1U;
		TilePtr = AieInst->Tiles;
		TilePtr	+= Loc[i].Col * (NumRows + 1U) + Loc[i].Row;
		TilePtr->IsUsed = 1U;
	}
	for(u8 j = 0; j < NumCols; j++){
		TilePtr = AieInst->Tiles;
		TilePtr += j * (NumRows + 1);
		if(TilePtr->IsUsed != 1){
			status = _XAiePm_ClockGateColumn(TilePtr);
		}
		else{
			for(u8 k = NumRows; k > 0; k--){
				TilePtr = AieInst->Tiles;
				TilePtr += j * (NumRows + 1U) + k;
				if(TilePtr->IsUsed == 1U)
					break;
				else{
					status = _XAiePm_ClockGateTile(AieInst, j, k);
				}
			}
		}
	}
	return status;
}
u8 XAiePm_RequestTiles ( XAieGbl * AieInst , u32 NumTiles , XAie_LocType * Loc ) { XAieGbl_Tile * TilePtr ; u32 NumCols , NumRows ; u8 status = XAIE_SUCCESS ; XAie_AssertVoid ( AieInst != XAIE_NULL ) ; XAie_AssertVoid ( AieInst -> Config != XAIE_NULL ) ; XAie_AssertVoid ( AieInst -> Tiles != XAIE_NULL ) ; XAie_AssertVoid ( AieInst -> IsReady == XAIE_COMPONENT_IS_READY ) ; XAie_AssertVoid ( Loc != XAIE_NULL ) ; NumCols = AieInst -> Config -> NumCols ; NumRows = AieInst -> Config -> NumRows ; XAie_AssertVoid ( NumTiles <= NumCols * NumRows ) ; for ( u16 i = 0 ; i < NumTiles ; i ++ ) { XAie_AssertNonvoid ( Loc [ i ] . Row <= NumRows ) ; XAie_AssertNonvoid ( Loc [ i ] . Col < NumCols ) ; TilePtr = AieInst -> Tiles ; TilePtr += Loc [ i ] . Col * ( NumRows + 1U ) ; TilePtr -> IsUsed = 1U ; TilePtr = AieInst -> Tiles ; TilePtr += Loc [ i ] . Col * ( NumRows + 1U ) + Loc [ i ] . Row ; TilePtr -> IsUsed = 1U ; } for ( u8 j = 0 ; j < NumCols ; j ++ ) { TilePtr = AieInst -> Tiles ; TilePtr += j * ( NumRows + 1 ) ; if ( TilePtr -> IsUsed != 1 ) { status = _XAiePm_ClockGateColumn ( TilePtr ) ; } else { for ( u8 k = NumRows ; k > 0 ; k -- ) { TilePtr = AieInst -> Tiles ; TilePtr += j * ( NumRows + 1U ) + k ; if ( TilePtr -> IsUsed == 1U ) break ; else { status = _XAiePm_ClockGateTile ( AieInst , j , k ) ; } } } } return status ; }
This is an API to request tiles to use.
This is an API to request tiles to use .
/* mark all the input tiles as used using IsUsed field of its tileptr */ /*
		 * Since shim tile is always enabled, using IsUsed field of shim
		 * tile tileptr to mark the status of that col i.e. 1 if any
		 * tile in that col is used.
		 */ /* set the IsUsed field of tileptr for tile passed as input */ /* gate all unused tiles */ /* gate entire col if entire col is unused */ /* gate unused tile per col */ /*
				 * If a top tile in a col is in use, all the
				 * tiles below that tile in that col must not be
				 * gated.
				 */