XilinxProcessorIPLib/drivers/nandps/src/xnandps.c
static int XNandPs_ReadPage(XNandPs *InstancePtr, u8 *DstPtr)
{
	u32 Status;
	u32 ZeroCommand;
	u32 BytesPerPage;
	u16 SpareBytesPerPage;
	u32 DataPhaseAddr;
	u8 *Ptr = DstPtr;
	u8 *SparePtr = InstancePtr->SpareBufPtr;

	BytesPerPage = InstancePtr->Geometry.BytesPerPage;
	SpareBytesPerPage = InstancePtr->Geometry.SpareBytesPerPage;

	/*
	 * Check ONFI Status Register
	 */
	Status = Onfi_CmdReadStatus(InstancePtr);
	if (Status & ONFI_STATUS_FAIL) {
		return XST_FAILURE;
	}

	/*
	 * ONFI : Reissue the 0x00 on the command line to start
	 * reading data
	 */
	ZeroCommand = InstancePtr->Config.FlashBase |
			(0 << XNANDPS_ADDR_CYCLES_SHIFT)|
			(0 << XNANDPS_END_CMD_VALID_SHIFT)|
			(XNANDPS_COMMAND_PHASE_MASK)|
			(0 << XNANDPS_END_CMD_SHIFT)|
			(0 << XNANDPS_START_CMD_SHIFT);

	/*
	 * AXI transaction for sending command 0x00 to the flash
	 */
	Xil_Out32(ZeroCommand, 0x00);

	/*
	 * Read page data
	 */
	XNandPs_ReadBuf(InstancePtr, Ptr, BytesPerPage);

	/*
	 * Read spare bytes in one less AXI data width
	 */
	XNandPs_ReadBuf(InstancePtr, SparePtr,
			(SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH));

	/*
	 * Clear chip select for last AXI transaction
	 */
	DataPhaseAddr = InstancePtr->DataPhaseAddr;
	DataPhaseAddr |= XNANDPS_CLR_CS;
	InstancePtr->DataPhaseAddr = DataPhaseAddr;
	SparePtr += (SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH);
	XNandPs_ReadBuf(InstancePtr, SparePtr, XNANDPS_AXI_DATA_WIDTH);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function reads a specific page from NAND device. This doesn't use the
* HW ECC block for checking ECC errors.
*
* @param	InstancePtr is a pointer to the XNandPs instance.
* @param	DstPtr is a pointer to the destination buffer.
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if fail.
*
* @note		None
*
******************************************************************************/
This function reads a specific page from NAND device. This doesn't use the
HW ECC block for checking ECC errors.
This function reads a specific page from NAND device . This doesn ' t use the HW ECC block for checking ECC errors .
static int XNandPs_ReadPage(XNandPs *InstancePtr, u8 *DstPtr)
{
	u32 Status;
	u32 ZeroCommand;
	u32 BytesPerPage;
	u16 SpareBytesPerPage;
	u32 DataPhaseAddr;
	u8 *Ptr = DstPtr;
	u8 *SparePtr = InstancePtr->SpareBufPtr;
	BytesPerPage = InstancePtr->Geometry.BytesPerPage;
	SpareBytesPerPage = InstancePtr->Geometry.SpareBytesPerPage;
	Status = Onfi_CmdReadStatus(InstancePtr);
	if (Status & ONFI_STATUS_FAIL) {
		return XST_FAILURE;
	}
	ZeroCommand = InstancePtr->Config.FlashBase |
			(0 << XNANDPS_ADDR_CYCLES_SHIFT)|
			(0 << XNANDPS_END_CMD_VALID_SHIFT)|
			(XNANDPS_COMMAND_PHASE_MASK)|
			(0 << XNANDPS_END_CMD_SHIFT)|
			(0 << XNANDPS_START_CMD_SHIFT);
	Xil_Out32(ZeroCommand, 0x00);
	XNandPs_ReadBuf(InstancePtr, Ptr, BytesPerPage);
	XNandPs_ReadBuf(InstancePtr, SparePtr,
			(SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH));
	DataPhaseAddr = InstancePtr->DataPhaseAddr;
	DataPhaseAddr |= XNANDPS_CLR_CS;
	InstancePtr->DataPhaseAddr = DataPhaseAddr;
	SparePtr += (SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH);
	XNandPs_ReadBuf(InstancePtr, SparePtr, XNANDPS_AXI_DATA_WIDTH);
	return XST_SUCCESS;
}
static int XNandPs_ReadPage ( XNandPs * InstancePtr , u8 * DstPtr ) { u32 Status ; u32 ZeroCommand ; u32 BytesPerPage ; u16 SpareBytesPerPage ; u32 DataPhaseAddr ; u8 * Ptr = DstPtr ; u8 * SparePtr = InstancePtr -> SpareBufPtr ; BytesPerPage = InstancePtr -> Geometry . BytesPerPage ; SpareBytesPerPage = InstancePtr -> Geometry . SpareBytesPerPage ; Status = Onfi_CmdReadStatus ( InstancePtr ) ; if ( Status & ONFI_STATUS_FAIL ) { return XST_FAILURE ; } ZeroCommand = InstancePtr -> Config . FlashBase | ( 0 << XNANDPS_ADDR_CYCLES_SHIFT ) | ( 0 << XNANDPS_END_CMD_VALID_SHIFT ) | ( XNANDPS_COMMAND_PHASE_MASK ) | ( 0 << XNANDPS_END_CMD_SHIFT ) | ( 0 << XNANDPS_START_CMD_SHIFT ) ; Xil_Out32 ( ZeroCommand , 0x00 ) ; XNandPs_ReadBuf ( InstancePtr , Ptr , BytesPerPage ) ; XNandPs_ReadBuf ( InstancePtr , SparePtr , ( SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH ) ) ; DataPhaseAddr = InstancePtr -> DataPhaseAddr ; DataPhaseAddr |= XNANDPS_CLR_CS ; InstancePtr -> DataPhaseAddr = DataPhaseAddr ; SparePtr += ( SpareBytesPerPage - XNANDPS_AXI_DATA_WIDTH ) ; XNandPs_ReadBuf ( InstancePtr , SparePtr , XNANDPS_AXI_DATA_WIDTH ) ; return XST_SUCCESS ; }
This function reads a specific page from NAND device.
This function reads a specific page from NAND device .
/*
	 * Check ONFI Status Register
	 */ /*
	 * ONFI : Reissue the 0x00 on the command line to start
	 * reading data
	 */ /*
	 * AXI transaction for sending command 0x00 to the flash
	 */ /*
	 * Read page data
	 */ /*
	 * Read spare bytes in one less AXI data width
	 */ /*
	 * Clear chip select for last AXI transaction
	 */