lib/sw_apps/zynqmp_fsbl/src/xfsbl_ddr_init.c
static void XFsbl_DdrCalcHifAddrVideo(struct DdrcInitData *DdrDataPtr,
		u32 *HifAddr, u32 VideoBuf)
{
	XFsbl_DimmParams *PDimmPtr = &DdrDataPtr->PDimm;
	u32 Position=0U;
	u32 Index;
	u32 BufWidth;
	u32 RemainingRow;

	/* Calculate Buffer Width based on Video Buffer Size */
	for (Index = 0U; Index <= 6U; Index++) {
		if (((u32)1U << Index) == VideoBuf) {
			BufWidth = Index + 20U;
			break;
		} else {
			BufWidth = 20U;
		}
	}

    if (PDimmPtr->BusWidth == 16U) {
	BufWidth = BufWidth + 2U;
    }

    if (PDimmPtr->BusWidth == 32U) {
	BufWidth = BufWidth + 1U;
    }

	if (PDimmPtr->MemType != SPD_MEMTYPE_DDR4) {
		/* Define Column positions in HIF Addresses */
		for (Index = 3U; Index < PDimmPtr->NumColAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_COLUMN(Index);
			Position++;
		}

		/* Define Row positions in HIF Addresses */
		for (Index = 0U; Index < (BufWidth - PDimmPtr->NumColAddr - 3U); Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index);
			Position++;
		}

		/* Define Bank positions in HIF Addresses */
		for (Index = 0U; Index < PDimmPtr->NumBankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_BANK(Index);
			Position++;
		}

		/* Define Remaining Row positions in HIF Addresses */
		RemainingRow = PDimmPtr->NumRowAddr - (BufWidth - PDimmPtr->NumColAddr - 3U);
		for (Index = 0U; Index < RemainingRow; Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index) + (BufWidth -
					PDimmPtr->NumColAddr - 4U);
			Position++;
		}

		/* Define Rank positions in HIF Addresses */
		for (Index = 0U; Index < PDimmPtr->NumRankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_RANK(Index);
			Position++;
		}
	} else {
		/* First four HIF addresses are fixed for Video Mapping */
		HifAddr[0U] = XFSBL_HIF_COLUMN(0U);
		HifAddr[1U] = XFSBL_HIF_COLUMN(1U);
		HifAddr[2U] = XFSBL_HIF_COLUMN(2U);
		HifAddr[3U] = XFSBL_HIF_BG(0U);

		Position = 4U;
		/* Define Column positions in HIF Addresses */
		for (Index = 3U; Index < PDimmPtr->NumColAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_COLUMN(Index);
			Position++;
		}

		/* Define Row positions in HIF Addresses */
		for (Index = 0U; Index < (BufWidth - PDimmPtr->NumColAddr - 4U); Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index);
			Position++;
		}

		/* Define Bank positions in HIF Addresses */
		for (Index = 0U; Index < PDimmPtr->NumBankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_BANK(Index);
			Position++;
		}

		/* Define Remaining Row positions in HIF Addresses */
		RemainingRow = PDimmPtr->NumRowAddr - (BufWidth - PDimmPtr->NumColAddr - 4U);
		for (Index = 0U; Index < RemainingRow; Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index) + (BufWidth -
					PDimmPtr->NumColAddr - 4U);
			Position++;
		}

		/* Define Rank positions in HIF Addresses */
		for (Index = 0U; Index < PDimmPtr->NumRankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_RANK(Index);
			Position++;
		}
	}
}
/*****************************************************************************/
/**
 * This function calculates the HIF Addresses for Video mapping mode
 *
 * @param	DdrDataPtr is pointer to DDR Initialization Data Structure
 * @param	HifAddr is the pointer to the HIF Addresses Array
 * @param	VideoBuf is size of Video Buffer used in the design
 *
 * @return	None
 *
 *****************************************************************************/
This function calculates the HIF Addresses for Video mapping mode
@param       DdrDataPtr is pointer to DDR Initialization Data Structure
@param       HifAddr is the pointer to the HIF Addresses Array
@param       VideoBuf is size of Video Buffer used in the design

@return      None
This function calculates the HIF Addresses for Video mapping mode @param DdrDataPtr is pointer to DDR Initialization Data Structure @param HifAddr is the pointer to the HIF Addresses Array @param VideoBuf is size of Video Buffer used in the design @return None
static void XFsbl_DdrCalcHifAddrVideo(struct DdrcInitData *DdrDataPtr,
		u32 *HifAddr, u32 VideoBuf)
{
	XFsbl_DimmParams *PDimmPtr = &DdrDataPtr->PDimm;
	u32 Position=0U;
	u32 Index;
	u32 BufWidth;
	u32 RemainingRow;
	for (Index = 0U; Index <= 6U; Index++) {
		if (((u32)1U << Index) == VideoBuf) {
			BufWidth = Index + 20U;
			break;
		} else {
			BufWidth = 20U;
		}
	}
    if (PDimmPtr->BusWidth == 16U) {
	BufWidth = BufWidth + 2U;
    }
    if (PDimmPtr->BusWidth == 32U) {
	BufWidth = BufWidth + 1U;
    }
	if (PDimmPtr->MemType != SPD_MEMTYPE_DDR4) {
		for (Index = 3U; Index < PDimmPtr->NumColAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_COLUMN(Index);
			Position++;
		}
		for (Index = 0U; Index < (BufWidth - PDimmPtr->NumColAddr - 3U); Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index);
			Position++;
		}
		for (Index = 0U; Index < PDimmPtr->NumBankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_BANK(Index);
			Position++;
		}
		RemainingRow = PDimmPtr->NumRowAddr - (BufWidth - PDimmPtr->NumColAddr - 3U);
		for (Index = 0U; Index < RemainingRow; Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index) + (BufWidth -
					PDimmPtr->NumColAddr - 4U);
			Position++;
		}
		for (Index = 0U; Index < PDimmPtr->NumRankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_RANK(Index);
			Position++;
		}
	} else {
		HifAddr[0U] = XFSBL_HIF_COLUMN(0U);
		HifAddr[1U] = XFSBL_HIF_COLUMN(1U);
		HifAddr[2U] = XFSBL_HIF_COLUMN(2U);
		HifAddr[3U] = XFSBL_HIF_BG(0U);
		Position = 4U;
		for (Index = 3U; Index < PDimmPtr->NumColAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_COLUMN(Index);
			Position++;
		}
		for (Index = 0U; Index < (BufWidth - PDimmPtr->NumColAddr - 4U); Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index);
			Position++;
		}
		for (Index = 0U; Index < PDimmPtr->NumBankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_BANK(Index);
			Position++;
		}
		RemainingRow = PDimmPtr->NumRowAddr - (BufWidth - PDimmPtr->NumColAddr - 4U);
		for (Index = 0U; Index < RemainingRow; Index++) {
			HifAddr[Position] = XFSBL_HIF_ROW(Index) + (BufWidth -
					PDimmPtr->NumColAddr - 4U);
			Position++;
		}
		for (Index = 0U; Index < PDimmPtr->NumRankAddr; Index++) {
			HifAddr[Position] = XFSBL_HIF_RANK(Index);
			Position++;
		}
	}
}
static void XFsbl_DdrCalcHifAddrVideo ( struct DdrcInitData * DdrDataPtr , u32 * HifAddr , u32 VideoBuf ) { XFsbl_DimmParams * PDimmPtr = & DdrDataPtr -> PDimm ; u32 Position = 0U ; u32 Index ; u32 BufWidth ; u32 RemainingRow ; for ( Index = 0U ; Index <= 6U ; Index ++ ) { if ( ( ( u32 ) 1U << Index ) == VideoBuf ) { BufWidth = Index + 20U ; break ; } else { BufWidth = 20U ; } } if ( PDimmPtr -> BusWidth == 16U ) { BufWidth = BufWidth + 2U ; } if ( PDimmPtr -> BusWidth == 32U ) { BufWidth = BufWidth + 1U ; } if ( PDimmPtr -> MemType != SPD_MEMTYPE_DDR4 ) { for ( Index = 3U ; Index < PDimmPtr -> NumColAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_COLUMN ( Index ) ; Position ++ ; } for ( Index = 0U ; Index < ( BufWidth - PDimmPtr -> NumColAddr - 3U ) ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_ROW ( Index ) ; Position ++ ; } for ( Index = 0U ; Index < PDimmPtr -> NumBankAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_BANK ( Index ) ; Position ++ ; } RemainingRow = PDimmPtr -> NumRowAddr - ( BufWidth - PDimmPtr -> NumColAddr - 3U ) ; for ( Index = 0U ; Index < RemainingRow ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_ROW ( Index ) + ( BufWidth - PDimmPtr -> NumColAddr - 4U ) ; Position ++ ; } for ( Index = 0U ; Index < PDimmPtr -> NumRankAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_RANK ( Index ) ; Position ++ ; } } else { HifAddr [ 0U ] = XFSBL_HIF_COLUMN ( 0U ) ; HifAddr [ 1U ] = XFSBL_HIF_COLUMN ( 1U ) ; HifAddr [ 2U ] = XFSBL_HIF_COLUMN ( 2U ) ; HifAddr [ 3U ] = XFSBL_HIF_BG ( 0U ) ; Position = 4U ; for ( Index = 3U ; Index < PDimmPtr -> NumColAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_COLUMN ( Index ) ; Position ++ ; } for ( Index = 0U ; Index < ( BufWidth - PDimmPtr -> NumColAddr - 4U ) ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_ROW ( Index ) ; Position ++ ; } for ( Index = 0U ; Index < PDimmPtr -> NumBankAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_BANK ( Index ) ; Position ++ ; } RemainingRow = PDimmPtr -> NumRowAddr - ( BufWidth - PDimmPtr -> NumColAddr - 4U ) ; for ( Index = 0U ; Index < RemainingRow ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_ROW ( Index ) + ( BufWidth - PDimmPtr -> NumColAddr - 4U ) ; Position ++ ; } for ( Index = 0U ; Index < PDimmPtr -> NumRankAddr ; Index ++ ) { HifAddr [ Position ] = XFSBL_HIF_RANK ( Index ) ; Position ++ ; } } }
This function calculates the HIF Addresses for Video mapping mode
 @param       DdrDataPtr is pointer to DDR Initialization Data Structure
 @param       HifAddr is the pointer to the HIF Addresses Array
 @param       VideoBuf is size of Video Buffer used in the design
This function calculates the HIF Addresses for Video mapping mode @param DdrDataPtr is pointer to DDR Initialization Data Structure @param HifAddr is the pointer to the HIF Addresses Array @param VideoBuf is size of Video Buffer used in the design
/* Calculate Buffer Width based on Video Buffer Size */ /* Define Column positions in HIF Addresses */ /* Define Row positions in HIF Addresses */ /* Define Bank positions in HIF Addresses */ /* Define Remaining Row positions in HIF Addresses */ /* Define Rank positions in HIF Addresses */ /* First four HIF addresses are fixed for Video Mapping */ /* Define Column positions in HIF Addresses */ /* Define Row positions in HIF Addresses */ /* Define Bank positions in HIF Addresses */ /* Define Remaining Row positions in HIF Addresses */ /* Define Rank positions in HIF Addresses */