XilinxProcessorIPLib/drivers/nandps/src/xnandps.c
static int XNandPs_EccCalculate(XNandPs *InstancePtr, u8 *EccData)
{
	u32 EccReg;
	u32 EccValue;
	u32 EccByte;
	u32 EccStatus;

	/*
	 * Check the busy status of the ECC block
	 */
	while (XNandPs_ReadReg(InstancePtr->Config.SmcBase +
		XNANDPS_ECC_STATUS_OFFSET(XNANDPS_IF1_ECC_OFFSET)) &
		XNANDPS_ECC_STATUS_MASK);

	for(EccReg = 0; EccReg < 4; EccReg++) {

		EccValue = XNandPs_ReadReg(InstancePtr->Config.SmcBase +
			XNANDPS_ECC_VALUE0_OFFSET(XNANDPS_IF1_ECC_OFFSET +
				(EccReg * 4)));
		EccStatus = (EccValue >> 24) & 0xFF;

		/*
		 * Check if the ECC value not valid
		 */
		if ((EccStatus >> 6) & 0x1) {
			for(EccByte = 0; EccByte < 3; EccByte++) {
				*EccData = EccValue & 0xFF;
				EccValue = EccValue >> 8;
				EccData++;
			}
		} else {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function calculates the ECC value from the ECC registers.
*
* @param	InstancePtr is a pointer to the XNandPs instance.
* @param	EccData is the buffer to fill the ECC value.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if fail.
*
* @note		None
*
******************************************************************************/
This function calculates the ECC value from the ECC registers.
This function calculates the ECC value from the ECC registers .
static int XNandPs_EccCalculate(XNandPs *InstancePtr, u8 *EccData)
{
	u32 EccReg;
	u32 EccValue;
	u32 EccByte;
	u32 EccStatus;
	while (XNandPs_ReadReg(InstancePtr->Config.SmcBase +
		XNANDPS_ECC_STATUS_OFFSET(XNANDPS_IF1_ECC_OFFSET)) &
		XNANDPS_ECC_STATUS_MASK);
	for(EccReg = 0; EccReg < 4; EccReg++) {
		EccValue = XNandPs_ReadReg(InstancePtr->Config.SmcBase +
			XNANDPS_ECC_VALUE0_OFFSET(XNANDPS_IF1_ECC_OFFSET +
				(EccReg * 4)));
		EccStatus = (EccValue >> 24) & 0xFF;
		if ((EccStatus >> 6) & 0x1) {
			for(EccByte = 0; EccByte < 3; EccByte++) {
				*EccData = EccValue & 0xFF;
				EccValue = EccValue >> 8;
				EccData++;
			}
		} else {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
static int XNandPs_EccCalculate ( XNandPs * InstancePtr , u8 * EccData ) { u32 EccReg ; u32 EccValue ; u32 EccByte ; u32 EccStatus ; while ( XNandPs_ReadReg ( InstancePtr -> Config . SmcBase + XNANDPS_ECC_STATUS_OFFSET ( XNANDPS_IF1_ECC_OFFSET ) ) & XNANDPS_ECC_STATUS_MASK ) ; for ( EccReg = 0 ; EccReg < 4 ; EccReg ++ ) { EccValue = XNandPs_ReadReg ( InstancePtr -> Config . SmcBase + XNANDPS_ECC_VALUE0_OFFSET ( XNANDPS_IF1_ECC_OFFSET + ( EccReg * 4 ) ) ) ; EccStatus = ( EccValue >> 24 ) & 0xFF ; if ( ( EccStatus >> 6 ) & 0x1 ) { for ( EccByte = 0 ; EccByte < 3 ; EccByte ++ ) { * EccData = EccValue & 0xFF ; EccValue = EccValue >> 8 ; EccData ++ ; } } else { return XST_FAILURE ; } } return XST_SUCCESS ; }
This function calculates the ECC value from the ECC registers.
This function calculates the ECC value from the ECC registers .
/*
	 * Check the busy status of the ECC block
	 */ /*
		 * Check if the ECC value not valid
		 */