diff options
| author | Marian Balakowicz <m8@semihalf.com> | 2008-02-21 17:18:01 +0100 | 
|---|---|---|
| committer | Marian Balakowicz <m8@semihalf.com> | 2008-02-21 17:18:01 +0100 | 
| commit | 20c93959330aba8b5bbdbfde1ef319e99eba235d (patch) | |
| tree | ef82297e3aeb904f94584e6d136fac55ec32c317 /board/atmel/atstk1000/flash.c | |
| parent | 5cf746c303710329f8040d9c62ee354313e3e91f (diff) | |
| parent | 928d1d77f8623c120d8763e20e1ca58df9c5c4c6 (diff) | |
| download | olio-uboot-2014.01-20c93959330aba8b5bbdbfde1ef319e99eba235d.tar.xz olio-uboot-2014.01-20c93959330aba8b5bbdbfde1ef319e99eba235d.zip | |
Merge branch 'master' of /home/git/u-boot
Diffstat (limited to 'board/atmel/atstk1000/flash.c')
| -rw-r--r-- | board/atmel/atstk1000/flash.c | 31 | 
1 files changed, 22 insertions, 9 deletions
| diff --git a/board/atmel/atstk1000/flash.c b/board/atmel/atstk1000/flash.c index 93d790f17..40478258e 100644 --- a/board/atmel/atstk1000/flash.c +++ b/board/atmel/atstk1000/flash.c @@ -159,7 +159,7 @@ int __flashprog write_buff(flash_info_t *info, uchar *src,  {  	unsigned long flags;  	uint16_t *base, *p, *s, *end; -	uint16_t word, status; +	uint16_t word, status, status1;  	int ret = ERR_OK;  	if (addr < info->start[0] @@ -194,20 +194,33 @@ int __flashprog write_buff(flash_info_t *info, uchar *src,  		sync_write_buffer();  		/* Wait for completion */ +		status1 = readw(p);  		do {  			/* TODO: Timeout */ -			status = readw(p); -		} while ((status != word) && !(status & 0x28)); +			status = status1; +			status1 = readw(p); +		} while (((status ^ status1) & 0x40)	/* toggled */ +			 && !(status1 & 0x28));		/* error bits */ -		writew(0xf0, base); -		readw(base); - -		if (status != word) { -			printf("Flash write error at address 0x%p: 0x%02x\n", -			       p, status); +		/* +		 * We'll need to check once again for toggle bit +		 * because the toggle bit may stop toggling as I/O5 +		 * changes to "1" (ref at49bv642.pdf p9) +		 */ +		status1 = readw(p); +		status = readw(p); +		if ((status ^ status1) & 0x40) { +			printf("Flash write error at address 0x%p: " +			       "0x%02x != 0x%02x\n", +			       p, status,word);  			ret = ERR_PROG_ERROR; +			writew(0xf0, base); +			readw(base);  			break;  		} + +		writew(0xf0, base); +		readw(base);  	}  	if (flags) |