lib/sw_services/xilflash/src/xilflash_amd.c
static int PollSR16(u32 BaseAddr, u32 BlockAddr)
{
	volatile u16 StatusReg1;
	volatile u16 StatusReg2;

	while(TRUE) {
		/* Read DQ5 and DQ6 (into word). */
		StatusReg1 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);

		/* Read DQ6 (into another word). */
		StatusReg2 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);

		/*
		 * If DQ6 did not toggle between two reads then return
		 * Flash_Success.
		 */
		if((StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK) ==
			(StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK)) {
			/* DQ6 == NO Toggle. */
			return (XFLASH_READY);
		}

		/* If DQ5 is zero then operation is not yet complete. */
		if((StatusReg2 & XFL_AMD_SR_ERASE_ERROR_MASK) !=
			XFL_AMD_SR_ERASE_ERROR_MASK) {
			continue;
		}

		/* Else (DQ5 == 1), read DQ6 twice. */
		StatusReg1 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);
		StatusReg2 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);

		/*
		 * If DQ6 did not toggle between two reads then return
		 * Flash_Success.
		 */
		if((StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK) ==
			(StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK)) {
			/* DQ6 == NO Toggle. */
			return (XFLASH_READY);
		}
		else {
			/*
			 * Else return Flash_ToggleFail; DQ6 == Toggle here
			 * means fail.
			 */
		        return (XFLASH_ERROR);
		}
	}
}
/*****************************************************************************/
/**
*
* Polls the status register until the erase or program operation is completed.
* The device(s) are polled by repeatedly reading the status register.
*
* @param	BaseAddr contains base address of the part.
* @param	BlockAddr contains address of block on which erase or program
*		operation is performed.
*
* @return	- XFLASH_READY if erase operation successful is ready.
*		- XFLASH_ERROR if error occurs.
*
* @note		It is assumed that the status register is currently visible.
*
******************************************************************************/
Polls the status register until the erase or program operation is completed.
The device(s) are polled by repeatedly reading the status register.
Polls the status register until the erase or program operation is completed . The device ( s ) are polled by repeatedly reading the status register .
static int PollSR16(u32 BaseAddr, u32 BlockAddr)
{
	volatile u16 StatusReg1;
	volatile u16 StatusReg2;
	while(TRUE) {
		StatusReg1 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);
		StatusReg2 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);
		if((StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK) ==
			(StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK)) {
			return (XFLASH_READY);
		}
		if((StatusReg2 & XFL_AMD_SR_ERASE_ERROR_MASK) !=
			XFL_AMD_SR_ERASE_ERROR_MASK) {
			continue;
		}
		StatusReg1 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);
		StatusReg2 = READ_FLASH_16(((volatile u16*)BaseAddr) +
				BlockAddr);
		if((StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK) ==
			(StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK)) {
			return (XFLASH_READY);
		}
		else {
		        return (XFLASH_ERROR);
		}
	}
}
static int PollSR16 ( u32 BaseAddr , u32 BlockAddr ) { volatile u16 StatusReg1 ; volatile u16 StatusReg2 ; while ( TRUE ) { StatusReg1 = READ_FLASH_16 ( ( ( volatile u16 * ) BaseAddr ) + BlockAddr ) ; StatusReg2 = READ_FLASH_16 ( ( ( volatile u16 * ) BaseAddr ) + BlockAddr ) ; if ( ( StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK ) == ( StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK ) ) { return ( XFLASH_READY ) ; } if ( ( StatusReg2 & XFL_AMD_SR_ERASE_ERROR_MASK ) != XFL_AMD_SR_ERASE_ERROR_MASK ) { continue ; } StatusReg1 = READ_FLASH_16 ( ( ( volatile u16 * ) BaseAddr ) + BlockAddr ) ; StatusReg2 = READ_FLASH_16 ( ( ( volatile u16 * ) BaseAddr ) + BlockAddr ) ; if ( ( StatusReg1 & XFL_AMD_SR_ERASE_COMPL_MASK ) == ( StatusReg2 & XFL_AMD_SR_ERASE_COMPL_MASK ) ) { return ( XFLASH_READY ) ; } else { return ( XFLASH_ERROR ) ; } } }
Polls the status register until the erase or program operation is completed.
Polls the status register until the erase or program operation is completed .
/* Read DQ5 and DQ6 (into word). */ /* Read DQ6 (into another word). */ /*
		 * If DQ6 did not toggle between two reads then return
		 * Flash_Success.
		 */ /* DQ6 == NO Toggle. */ /* If DQ5 is zero then operation is not yet complete. */ /* Else (DQ5 == 1), read DQ6 twice. */ /*
		 * If DQ6 did not toggle between two reads then return
		 * Flash_Success.
		 */ /* DQ6 == NO Toggle. */ /*
			 * Else return Flash_ToggleFail; DQ6 == Toggle here
			 * means fail.
			 */