lib/sw_services/xilflash/src/xilflash_amd.c
static int WriteBuffer8(XFlash * InstancePtr, void *DestPtr,
			 void *SrcPtr, u32 Bytes)
{
	u8 *SourcePtr = (u8*)SrcPtr;
	u8 *DestinationPtr = (u8*)DestPtr;
	u32 BaseAddress;
	u32 Index = 0;
	int Status = (int)XST_FAILURE;
	XFlashVendorData_Amd *DevDataPtr;

	DevDataPtr = GET_PARTDATA(InstancePtr);
	BaseAddress = InstancePtr->Geometry.BaseAddress;

	/*
	 * Send the Unlock Bypass command.
	 */
	DevDataPtr->SendCmdSeq(BaseAddress,
				XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
				XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);

	DevDataPtr->SendCmd(BaseAddress,
				XFL_AMD_CMD1_ADDR,
				XFL_AMD_CMD_UNLOCK_BYPASS);

	Index = 0;
	while (Bytes != 0) {
		DevDataPtr->WriteFlash(BaseAddress,
			0, XFL_AMD_CMD_PROGRAM);

		DevDataPtr->WriteFlash(BaseAddress,
			(u32)DestinationPtr, SourcePtr[Index]);

		Status = DevDataPtr->PollSR(BaseAddress,
						(u32)DestinationPtr);
		if (Status != XFLASH_READY) {
			(void) XFlashAmd_ResetBank(InstancePtr, (u32)DestPtr,
					Bytes);
			return (Status);
		}
		DestinationPtr++;
		Index++;
		Bytes -= 1;
	}

	/*
	 * Unlock Bypass Reset.
	 */
	DevDataPtr->WriteFlash(BaseAddress, 0,
		XFL_AMD_CMD_UNLOCK_BYPASS_RESET1);
	DevDataPtr->WriteFlash(BaseAddress,0,
		XFL_AMD_CMD_UNLOCK_BYPASS_RESET2);

	return (XST_SUCCESS);
}
/*****************************************************************************/
/**
*
* This function is used to program the memory in signal bank. It does not erase
* the flash first and will fail if the block(s) are not erased first. The
* device(s) are programmed in parallel.
*
* @param	InstancePtr is the instance to work on.
* @param	DestPtr is the physical destination address in flash memory
*		space.
* @param	SrcPtr is the source data.
* @param	Bytes is the number of bytes to program.
*
* @return
*		- XST_SUCCESS if successful.
*		- XFLASH_ERROR if a write error occurred. This error is
*		  usually device specific.
*
* @note		None.
*
******************************************************************************/
This function is used to program the memory in signal bank. It does not erase
the flash first and will fail if the block(s) are not erased first. The
device(s) are programmed in parallel.
This function is used to program the memory in signal bank . It does not erase the flash first and will fail if the block ( s ) are not erased first . The device ( s ) are programmed in parallel .
static int WriteBuffer8(XFlash * InstancePtr, void *DestPtr,
			 void *SrcPtr, u32 Bytes)
{
	u8 *SourcePtr = (u8*)SrcPtr;
	u8 *DestinationPtr = (u8*)DestPtr;
	u32 BaseAddress;
	u32 Index = 0;
	int Status = (int)XST_FAILURE;
	XFlashVendorData_Amd *DevDataPtr;
	DevDataPtr = GET_PARTDATA(InstancePtr);
	BaseAddress = InstancePtr->Geometry.BaseAddress;
	DevDataPtr->SendCmdSeq(BaseAddress,
				XFL_AMD_CMD1_ADDR, XFL_AMD_CMD2_ADDR,
				XFL_AMD_CMD1_DATA, XFL_AMD_CMD2_DATA);
	DevDataPtr->SendCmd(BaseAddress,
				XFL_AMD_CMD1_ADDR,
				XFL_AMD_CMD_UNLOCK_BYPASS);
	Index = 0;
	while (Bytes != 0) {
		DevDataPtr->WriteFlash(BaseAddress,
			0, XFL_AMD_CMD_PROGRAM);
		DevDataPtr->WriteFlash(BaseAddress,
			(u32)DestinationPtr, SourcePtr[Index]);
		Status = DevDataPtr->PollSR(BaseAddress,
						(u32)DestinationPtr);
		if (Status != XFLASH_READY) {
			(void) XFlashAmd_ResetBank(InstancePtr, (u32)DestPtr,
					Bytes);
			return (Status);
		}
		DestinationPtr++;
		Index++;
		Bytes -= 1;
	}
	DevDataPtr->WriteFlash(BaseAddress, 0,
		XFL_AMD_CMD_UNLOCK_BYPASS_RESET1);
	DevDataPtr->WriteFlash(BaseAddress,0,
		XFL_AMD_CMD_UNLOCK_BYPASS_RESET2);
	return (XST_SUCCESS);
}
static int WriteBuffer8 ( XFlash * InstancePtr , void * DestPtr , void * SrcPtr , u32 Bytes ) { u8 * SourcePtr = ( u8 * ) SrcPtr ; u8 * DestinationPtr = ( u8 * ) DestPtr ; u32 BaseAddress ; u32 Index = 0 ; int Status = ( int ) XST_FAILURE ; XFlashVendorData_Amd * DevDataPtr ; DevDataPtr = GET_PARTDATA ( InstancePtr ) ; BaseAddress = InstancePtr -> Geometry . BaseAddress ; DevDataPtr -> SendCmdSeq ( BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD2_ADDR , XFL_AMD_CMD1_DATA , XFL_AMD_CMD2_DATA ) ; DevDataPtr -> SendCmd ( BaseAddress , XFL_AMD_CMD1_ADDR , XFL_AMD_CMD_UNLOCK_BYPASS ) ; Index = 0 ; while ( Bytes != 0 ) { DevDataPtr -> WriteFlash ( BaseAddress , 0 , XFL_AMD_CMD_PROGRAM ) ; DevDataPtr -> WriteFlash ( BaseAddress , ( u32 ) DestinationPtr , SourcePtr [ Index ] ) ; Status = DevDataPtr -> PollSR ( BaseAddress , ( u32 ) DestinationPtr ) ; if ( Status != XFLASH_READY ) { ( void ) XFlashAmd_ResetBank ( InstancePtr , ( u32 ) DestPtr , Bytes ) ; return ( Status ) ; } DestinationPtr ++ ; Index ++ ; Bytes -= 1 ; } DevDataPtr -> WriteFlash ( BaseAddress , 0 , XFL_AMD_CMD_UNLOCK_BYPASS_RESET1 ) ; DevDataPtr -> WriteFlash ( BaseAddress , 0 , XFL_AMD_CMD_UNLOCK_BYPASS_RESET2 ) ; return ( XST_SUCCESS ) ; }
This function is used to program the memory in signal bank.
This function is used to program the memory in signal bank .
/*
	 * Send the Unlock Bypass command.
	 */ /*
	 * Unlock Bypass Reset.
	 */