XilinxProcessorIPLib/drivers/nandps/src/xnandps.c
int XNandPs_EraseBlock(XNandPs *InstancePtr, u32 BlockNum)
{
	u8 OnfiStatus;
	u32 Status;
	u32 Page;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(BlockNum < InstancePtr->Geometry.NumBlocks);

	/*
	 * Check if the flash is write protected
	 */
	OnfiStatus = Onfi_CmdReadStatus(InstancePtr);
	if (!(OnfiStatus & ONFI_STATUS_WP)) {
		return XST_NAND_WRITE_PROTECTED;
	}

	Page = BlockNum * InstancePtr->Geometry.PagesPerBlock;
	XNandPs_SendCommand(InstancePtr, &OnfiCommands[BLOCK_ERASE], Page,
			XNANDPS_COLUMN_NOT_VALID);

	/*
	 * Poll the Memory controller status register
	 */
	while (XNandPs_IsBusy(InstancePtr) == TRUE) {
	}

	/*
	 * Clear the interrupt condition
	 */
	XNandPs_WriteReg((InstancePtr->Config.SmcBase +
				XNANDPS_MEMC_CLR_CONFIG_OFFSET),
			XNANDPS_MEMC_CLR_CONFIG_INT_CLR1_MASK);

	/*
	 * Check the SR[0] whether the erase operation is successful or not
	 */
	Status = Onfi_CmdReadStatus(InstancePtr);
	if (Status & ONFI_STATUS_FAIL) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function erases a specific block in the NAND device.
*
* @param	InstancePtr is a pointer to the XNandPs instance.
* @param	BlockNum is the block number of the device.
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if fail.
*		- XST_NAND_WRITE_PROTECTED if the flash is write
*			protected.
*
* @note		None
*
******************************************************************************/
This function erases a specific block in the NAND device.
This function erases a specific block in the NAND device .
int XNandPs_EraseBlock(XNandPs *InstancePtr, u32 BlockNum)
{
	u8 OnfiStatus;
	u32 Status;
	u32 Page;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(BlockNum < InstancePtr->Geometry.NumBlocks);
	OnfiStatus = Onfi_CmdReadStatus(InstancePtr);
	if (!(OnfiStatus & ONFI_STATUS_WP)) {
		return XST_NAND_WRITE_PROTECTED;
	}
	Page = BlockNum * InstancePtr->Geometry.PagesPerBlock;
	XNandPs_SendCommand(InstancePtr, &OnfiCommands[BLOCK_ERASE], Page,
			XNANDPS_COLUMN_NOT_VALID);
	while (XNandPs_IsBusy(InstancePtr) == TRUE) {
	}
	XNandPs_WriteReg((InstancePtr->Config.SmcBase +
				XNANDPS_MEMC_CLR_CONFIG_OFFSET),
			XNANDPS_MEMC_CLR_CONFIG_INT_CLR1_MASK);
	Status = Onfi_CmdReadStatus(InstancePtr);
	if (Status & ONFI_STATUS_FAIL) {
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int XNandPs_EraseBlock ( XNandPs * InstancePtr , u32 BlockNum ) { u8 OnfiStatus ; u32 Status ; u32 Page ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; Xil_AssertNonvoid ( BlockNum < InstancePtr -> Geometry . NumBlocks ) ; OnfiStatus = Onfi_CmdReadStatus ( InstancePtr ) ; if ( ! ( OnfiStatus & ONFI_STATUS_WP ) ) { return XST_NAND_WRITE_PROTECTED ; } Page = BlockNum * InstancePtr -> Geometry . PagesPerBlock ; XNandPs_SendCommand ( InstancePtr , & OnfiCommands [ BLOCK_ERASE ] , Page , XNANDPS_COLUMN_NOT_VALID ) ; while ( XNandPs_IsBusy ( InstancePtr ) == TRUE ) { } XNandPs_WriteReg ( ( InstancePtr -> Config . SmcBase + XNANDPS_MEMC_CLR_CONFIG_OFFSET ) , XNANDPS_MEMC_CLR_CONFIG_INT_CLR1_MASK ) ; Status = Onfi_CmdReadStatus ( InstancePtr ) ; if ( Status & ONFI_STATUS_FAIL ) { return XST_FAILURE ; } return XST_SUCCESS ; }
This function erases a specific block in the NAND device.
This function erases a specific block in the NAND device .
/*
	 * Check if the flash is write protected
	 */ /*
	 * Poll the Memory controller status register
	 */ /*
	 * Clear the interrupt condition
	 */ /*
	 * Check the SR[0] whether the erase operation is successful or not
	 */