lib/sw_services/xilflash/src/xilflash_amd.c
static u16 EnqueueEraseBlocks(XFlash * InstancePtr, u16 *Region,
			      u16 *Block, u16 MaxBlocks)
{
	u32 BlockAddress;
	XFlashGeometry *GeomPtr;
	XFlashVendorData_Amd *DevDataPtr;
	volatile u16 FlashStatus;

	/*
	 * If for some reason the maximum number of blocks to enqueue is
	 * zero, then don't do anything.
	 */
	if (MaxBlocks == 0) {
		return (0);
	}

	GeomPtr = &InstancePtr->Geometry;
	DevDataPtr = GET_PARTDATA(InstancePtr);

	/*
	 * Get the physical address to write the command to and send command.
	 */
	(void) XFlashGeometry_ToAbsolute(GeomPtr, *Region, *Block, 0,
					 &BlockAddress);

	/* Send Status register clear command. */
	DevDataPtr->SendCmd(GeomPtr->BaseAddress,XFL_AMD_CMD1_ADDR,
				XFL_AMD_CMD_STATUS_REG_CLEAR);

	/* Write Block Erase command. */
	DevDataPtr->SendCmdSeq(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
			XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);
	DevDataPtr->SendCmd(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD_ERASE1);
	DevDataPtr->SendCmdSeq(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
			XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);

	DevDataPtr->WriteFlash(GeomPtr->BaseAddress, BlockAddress,
			XFL_AMD_CMD_ERASE_BLOCK);

	/* Increment Region/Block. */
	XFL_GEOMETRY_INCREMENT(GeomPtr, *Region, *Block);

	/* Return the number of blocks enqueued. */
	return (1);
}
/*****************************************************************************/
/**
*
* Sends commands to erase blocks.
*
* @param	InstancePtr is the pointer to xflash object to work on.
* @param	Region is the region which the first block appears.
* @param	Block is the starting block to erase.
* @param	MaxBlocks is the number of consecutive blocks to erase.
*
* @return	The number of blocks enqueued to the part's erase buffer.
*		Region and Block parameters are incremented the number of blocks
*		queued.
*
* @note		Limitation: Only support enqueuing one block at a time.
*
******************************************************************************/
Sends commands to erase blocks.
Sends commands to erase blocks .
static u16 EnqueueEraseBlocks(XFlash * InstancePtr, u16 *Region,
			      u16 *Block, u16 MaxBlocks)
{
	u32 BlockAddress;
	XFlashGeometry *GeomPtr;
	XFlashVendorData_Amd *DevDataPtr;
	volatile u16 FlashStatus;
	if (MaxBlocks == 0) {
		return (0);
	}
	GeomPtr = &InstancePtr->Geometry;
	DevDataPtr = GET_PARTDATA(InstancePtr);
	(void) XFlashGeometry_ToAbsolute(GeomPtr, *Region, *Block, 0,
					 &BlockAddress);
	DevDataPtr->SendCmd(GeomPtr->BaseAddress,XFL_AMD_CMD1_ADDR,
				XFL_AMD_CMD_STATUS_REG_CLEAR);
	DevDataPtr->SendCmdSeq(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
			XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);
	DevDataPtr->SendCmd(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD_ERASE1);
	DevDataPtr->SendCmdSeq(GeomPtr->BaseAddress,
			XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
			XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);
	DevDataPtr->WriteFlash(GeomPtr->BaseAddress, BlockAddress,
			XFL_AMD_CMD_ERASE_BLOCK);
	XFL_GEOMETRY_INCREMENT(GeomPtr, *Region, *Block);
	return (1);
}
static u16 EnqueueEraseBlocks ( XFlash * InstancePtr , u16 * Region , u16 * Block , u16 MaxBlocks ) { u32 BlockAddress ; XFlashGeometry * GeomPtr ; XFlashVendorData_Amd * DevDataPtr ; volatile u16 FlashStatus ; if ( MaxBlocks == 0 ) { return ( 0 ) ; } GeomPtr = & InstancePtr -> Geometry ; DevDataPtr = GET_PARTDATA ( InstancePtr ) ; ( void ) XFlashGeometry_ToAbsolute ( GeomPtr , * Region , * Block , 0 , & BlockAddress ) ; DevDataPtr -> SendCmd ( GeomPtr -> BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD_STATUS_REG_CLEAR ) ; DevDataPtr -> SendCmdSeq ( GeomPtr -> BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD2_ADDR , XFL_AMD_CMD1_DATA , XFL_AMD_CMD2_DATA ) ; DevDataPtr -> SendCmd ( GeomPtr -> BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD_ERASE1 ) ; DevDataPtr -> SendCmdSeq ( GeomPtr -> BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD2_ADDR , XFL_AMD_CMD1_DATA , XFL_AMD_CMD2_DATA ) ; DevDataPtr -> WriteFlash ( GeomPtr -> BaseAddress , BlockAddress , XFL_AMD_CMD_ERASE_BLOCK ) ; XFL_GEOMETRY_INCREMENT ( GeomPtr , * Region , * Block ) ; return ( 1 ) ; }
Sends commands to erase blocks.
Sends commands to erase blocks .
/*
	 * If for some reason the maximum number of blocks to enqueue is
	 * zero, then don't do anything.
	 */ /*
	 * Get the physical address to write the command to and send command.
	 */ /* Send Status register clear command. */ /* Write Block Erase command. */ /* Increment Region/Block. */ /* Return the number of blocks enqueued. */