XilinxProcessorIPLib/drivers/aienginev2/src/dma/xaie_dma.c
AieRC XAie_DmaWriteChannel(XAie_DevInst *DevInst,
		XAie_DmaChannelDesc *DmaChannelDesc, XAie_LocType Loc,
		u8 ChNum, XAie_DmaDirection Dir)
{
	u64 Addr;
	u32 Val;
	const XAie_DmaMod *DmaMod;

	if((DevInst == XAIE_NULL) || (DmaChannelDesc == XAIE_NULL) ||
			(DevInst->IsReady != XAIE_COMPONENT_IS_READY)) {
		XAIE_ERROR("Invalid arguments\n");
		return XAIE_INVALID_ARGS;
	}

	if(DevInst->DevProp.DevGen == XAIE_DEV_GEN_AIE) {
		XAIE_ERROR("Feature not supported\n");
		return XAIE_FEATURE_NOT_SUPPORTED;
	}

	if(Dir >= DMA_MAX) {
		XAIE_ERROR("Invalid DMA direction\n");
		return XAIE_INVALID_ARGS;
	}

	if((DmaChannelDesc->IsReady != XAIE_COMPONENT_IS_READY)) {
		XAIE_ERROR("Dma Channel descriptor not initilized\n");
		return XAIE_INVALID_DMA_DESC;
	}

	if(DmaChannelDesc->TileType != DevInst->DevOps->GetTTypefromLoc(DevInst, Loc)) {
		XAIE_ERROR("Tile type mismatch\n");
		return XAIE_INVALID_TILE;
	}

	DmaMod = DevInst->DevProp.DevMod[DmaChannelDesc->TileType].DmaMod;
	if(ChNum > DmaMod->NumChannels) {
		XAIE_ERROR("Invalid Channel number\n");
		return XAIE_INVALID_CHANNEL_NUM;
	}

	Addr = _XAie_GetTileAddr(DevInst, Loc.Row, Loc.Col) +
		DmaMod->ChCtrlBase + ChNum * DmaMod->ChIdxOffset +
		Dir * DmaMod->ChIdxOffset * DmaMod->NumChannels;

	Val = XAie_SetField(DmaChannelDesc->EnOutofOrderId, (DmaMod->ChProp->EnOutofOrder.Lsb),
			(DmaMod->ChProp->EnOutofOrder.Mask)) |
		XAie_SetField(DmaChannelDesc->EnCompression, (DmaMod->ChProp->EnCompression.Lsb),
			(DmaMod->ChProp->EnCompression.Mask)) |
		XAie_SetField(DmaChannelDesc->ControllerId, (DmaMod->ChProp->ControllerId.Lsb),
			(DmaMod->ChProp->ControllerId.Mask)) |
		XAie_SetField(DmaChannelDesc->FoTMode, (DmaMod->ChProp->FoTMode.Lsb),
			(DmaMod->ChProp->FoTMode.Mask));

	return XAie_Write32(DevInst, Addr, Val);
}
/*****************************************************************************/
/**
=======
* This API configures the Dma channel descriptor fields in the hardware for a
* particular tile location. This includes FoT mode, Controller id, out of order
* and Compression/Decompression.
*
*
* @param	DevInst: Device Instance.
* @param	DmaChannelDesc: Initialized Dma Channel Descriptor.
* @param	Loc: Location of AIE Tile
* @param	ChNum: Channel number of the DMA.
* @param	Dir: Direction of the DMA Channel. (MM2S or S2MM)
*
* @return	XAIE_OK on success, Error code on failure.
*
* @note		This API works only for AIE-ML and has no effect on AIE.
*
******************************************************************************/
This API configures the Dma channel descriptor fields in the hardware for a
particular tile location. This includes FoT mode, Controller id, out of order
and Compression/Decompression.
This API configures the Dma channel descriptor fields in the hardware for a particular tile location . This includes FoT mode Controller id out of order and Compression / Decompression .
AieRC XAie_DmaWriteChannel(XAie_DevInst *DevInst,
		XAie_DmaChannelDesc *DmaChannelDesc, XAie_LocType Loc,
		u8 ChNum, XAie_DmaDirection Dir)
{
	u64 Addr;
	u32 Val;
	const XAie_DmaMod *DmaMod;
	if((DevInst == XAIE_NULL) || (DmaChannelDesc == XAIE_NULL) ||
			(DevInst->IsReady != XAIE_COMPONENT_IS_READY)) {
		XAIE_ERROR("Invalid arguments\n");
		return XAIE_INVALID_ARGS;
	}
	if(DevInst->DevProp.DevGen == XAIE_DEV_GEN_AIE) {
		XAIE_ERROR("Feature not supported\n");
		return XAIE_FEATURE_NOT_SUPPORTED;
	}
	if(Dir >= DMA_MAX) {
		XAIE_ERROR("Invalid DMA direction\n");
		return XAIE_INVALID_ARGS;
	}
	if((DmaChannelDesc->IsReady != XAIE_COMPONENT_IS_READY)) {
		XAIE_ERROR("Dma Channel descriptor not initilized\n");
		return XAIE_INVALID_DMA_DESC;
	}
	if(DmaChannelDesc->TileType != DevInst->DevOps->GetTTypefromLoc(DevInst, Loc)) {
		XAIE_ERROR("Tile type mismatch\n");
		return XAIE_INVALID_TILE;
	}
	DmaMod = DevInst->DevProp.DevMod[DmaChannelDesc->TileType].DmaMod;
	if(ChNum > DmaMod->NumChannels) {
		XAIE_ERROR("Invalid Channel number\n");
		return XAIE_INVALID_CHANNEL_NUM;
	}
	Addr = _XAie_GetTileAddr(DevInst, Loc.Row, Loc.Col) +
		DmaMod->ChCtrlBase + ChNum * DmaMod->ChIdxOffset +
		Dir * DmaMod->ChIdxOffset * DmaMod->NumChannels;
	Val = XAie_SetField(DmaChannelDesc->EnOutofOrderId, (DmaMod->ChProp->EnOutofOrder.Lsb),
			(DmaMod->ChProp->EnOutofOrder.Mask)) |
		XAie_SetField(DmaChannelDesc->EnCompression, (DmaMod->ChProp->EnCompression.Lsb),
			(DmaMod->ChProp->EnCompression.Mask)) |
		XAie_SetField(DmaChannelDesc->ControllerId, (DmaMod->ChProp->ControllerId.Lsb),
			(DmaMod->ChProp->ControllerId.Mask)) |
		XAie_SetField(DmaChannelDesc->FoTMode, (DmaMod->ChProp->FoTMode.Lsb),
			(DmaMod->ChProp->FoTMode.Mask));
	return XAie_Write32(DevInst, Addr, Val);
}
AieRC XAie_DmaWriteChannel ( XAie_DevInst * DevInst , XAie_DmaChannelDesc * DmaChannelDesc , XAie_LocType Loc , u8 ChNum , XAie_DmaDirection Dir ) { u64 Addr ; u32 Val ; const XAie_DmaMod * DmaMod ; if ( ( DevInst == XAIE_NULL ) || ( DmaChannelDesc == XAIE_NULL ) || ( DevInst -> IsReady != XAIE_COMPONENT_IS_READY ) ) { XAIE_ERROR ( " \n " ) ; return XAIE_INVALID_ARGS ; } if ( DevInst -> DevProp . DevGen == XAIE_DEV_GEN_AIE ) { XAIE_ERROR ( " \n " ) ; return XAIE_FEATURE_NOT_SUPPORTED ; } if ( Dir >= DMA_MAX ) { XAIE_ERROR ( " \n " ) ; return XAIE_INVALID_ARGS ; } if ( ( DmaChannelDesc -> IsReady != XAIE_COMPONENT_IS_READY ) ) { XAIE_ERROR ( " \n " ) ; return XAIE_INVALID_DMA_DESC ; } if ( DmaChannelDesc -> TileType != DevInst -> DevOps -> GetTTypefromLoc ( DevInst , Loc ) ) { XAIE_ERROR ( " \n " ) ; return XAIE_INVALID_TILE ; } DmaMod = DevInst -> DevProp . DevMod [ DmaChannelDesc -> TileType ] . DmaMod ; if ( ChNum > DmaMod -> NumChannels ) { XAIE_ERROR ( " \n " ) ; return XAIE_INVALID_CHANNEL_NUM ; } Addr = _XAie_GetTileAddr ( DevInst , Loc . Row , Loc . Col ) + DmaMod -> ChCtrlBase + ChNum * DmaMod -> ChIdxOffset + Dir * DmaMod -> ChIdxOffset * DmaMod -> NumChannels ; Val = XAie_SetField ( DmaChannelDesc -> EnOutofOrderId , ( DmaMod -> ChProp -> EnOutofOrder . Lsb ) , ( DmaMod -> ChProp -> EnOutofOrder . Mask ) ) | XAie_SetField ( DmaChannelDesc -> EnCompression , ( DmaMod -> ChProp -> EnCompression . Lsb ) , ( DmaMod -> ChProp -> EnCompression . Mask ) ) | XAie_SetField ( DmaChannelDesc -> ControllerId , ( DmaMod -> ChProp -> ControllerId . Lsb ) , ( DmaMod -> ChProp -> ControllerId . Mask ) ) | XAie_SetField ( DmaChannelDesc -> FoTMode , ( DmaMod -> ChProp -> FoTMode . Lsb ) , ( DmaMod -> ChProp -> FoTMode . Mask ) ) ; return XAie_Write32 ( DevInst , Addr , Val ) ; }
This API configures the Dma channel descriptor fields in the hardware for a
particular tile location.
This API configures the Dma channel descriptor fields in the hardware for a particular tile location .