XilinxProcessorIPLib/drivers/nandps/src/xnandps.c
static int XNandPs_EccHwInit(XNandPs *InstancePtr)
{
	u32 PageSize;
	u32 EccConfig = 0;

	PageSize = InstancePtr->Geometry.BytesPerPage;
	/*
	 * Set the ECC mem command1 and ECC mem command2 register
	 */
	XNandPs_EccSetMemCmd1(InstancePtr, XNANDPS_ECC_CMD1);
	XNandPs_EccSetMemCmd2(InstancePtr, XNANDPS_ECC_CMD2);
	/*
	 * Configure HW ECC block
	 */
	switch(PageSize) {
		case XNANDPS_PAGE_SIZE_512:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_512);
			break;
		case XNANDPS_PAGE_SIZE_1024:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_1024);
			break;
		case XNANDPS_PAGE_SIZE_2048:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_2048);
			break;
		default:
			/*
			 * Page size 256 bytes & 4096 bytes not supported
			 * by ECC block
			 */
			return XST_FAILURE;
	}
	XNandPs_EccSetCfg(InstancePtr, EccConfig);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function initializes the HW ECC block based on flash.
*
* @param	InstancePtr is a pointer to the XNandPs instance.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if the flash is not supported.
*
* @note		None
*
*****************************************************************************/
This function initializes the HW ECC block based on flash.
This function initializes the HW ECC block based on flash .
static int XNandPs_EccHwInit(XNandPs *InstancePtr)
{
	u32 PageSize;
	u32 EccConfig = 0;
	PageSize = InstancePtr->Geometry.BytesPerPage;
	XNandPs_EccSetMemCmd1(InstancePtr, XNANDPS_ECC_CMD1);
	XNandPs_EccSetMemCmd2(InstancePtr, XNANDPS_ECC_CMD2);
	switch(PageSize) {
		case XNANDPS_PAGE_SIZE_512:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_512);
			break;
		case XNANDPS_PAGE_SIZE_1024:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_1024);
			break;
		case XNANDPS_PAGE_SIZE_2048:
			EccConfig = (XNANDPS_ECC_MEMCFG |
					XNANDPS_ECC_MEMCFG_PAGE_SIZE_2048);
			break;
		default:
			return XST_FAILURE;
	}
	XNandPs_EccSetCfg(InstancePtr, EccConfig);
	return XST_SUCCESS;
}
static int XNandPs_EccHwInit ( XNandPs * InstancePtr ) { u32 PageSize ; u32 EccConfig = 0 ; PageSize = InstancePtr -> Geometry . BytesPerPage ; XNandPs_EccSetMemCmd1 ( InstancePtr , XNANDPS_ECC_CMD1 ) ; XNandPs_EccSetMemCmd2 ( InstancePtr , XNANDPS_ECC_CMD2 ) ; switch ( PageSize ) { case XNANDPS_PAGE_SIZE_512 : EccConfig = ( XNANDPS_ECC_MEMCFG | XNANDPS_ECC_MEMCFG_PAGE_SIZE_512 ) ; break ; case XNANDPS_PAGE_SIZE_1024 : EccConfig = ( XNANDPS_ECC_MEMCFG | XNANDPS_ECC_MEMCFG_PAGE_SIZE_1024 ) ; break ; case XNANDPS_PAGE_SIZE_2048 : EccConfig = ( XNANDPS_ECC_MEMCFG | XNANDPS_ECC_MEMCFG_PAGE_SIZE_2048 ) ; break ; default : return XST_FAILURE ; } XNandPs_EccSetCfg ( InstancePtr , EccConfig ) ; return XST_SUCCESS ; }
This function initializes the HW ECC block based on flash.
This function initializes the HW ECC block based on flash .
/*
	 * Set the ECC mem command1 and ECC mem command2 register
	 */ /*
	 * Configure HW ECC block
	 */ /*
			 * Page size 256 bytes & 4096 bytes not supported
			 * by ECC block
			 */