diff options
| author | Ollie Lho <ollie@sis.com.tw> | 2004-12-08 02:10:33 +0000 | 
|---|---|---|
| committer | Ollie Lho <ollie@sis.com.tw> | 2004-12-08 02:10:33 +0000 | 
| commit | 1b8b66000f6c8f18193cd93fff1e852faaa9715f (patch) | |
| tree | 243aa40ddfcb6c075f1c4dc329e003b341033091 | |
| parent | d11f36180814c45b82142b168c95c6515278a926 (diff) | |
| download | flashrom-1b8b66000f6c8f18193cd93fff1e852faaa9715f.tar.gz flashrom-1b8b66000f6c8f18193cd93fff1e852faaa9715f.tar.bz2 flashrom-1b8b66000f6c8f18193cd93fff1e852faaa9715f.zip | |
Add retry to write_byte_program_jedec(), 99% success rate
Corresponding to flashrom svn r29 and coreboot v2 svn r1814.
| -rw-r--r-- | flash_rom.c | 13 | ||||
| -rw-r--r-- | jedec.c | 8 | ||||
| -rw-r--r-- | sst_fwhub.c | 25 | ||||
| -rw-r--r-- | sst_fwhub.h | 40 | 
4 files changed, 12 insertions, 74 deletions
| diff --git a/flash_rom.c b/flash_rom.c index c01f5314..bf338ccb 100644 --- a/flash_rom.c +++ b/flash_rom.c @@ -200,19 +200,6 @@ int main(int argc, char *argv[])          unsigned int exclude_start_position=0, exclude_end_position=0; // [x,y)  	char *tempstr=NULL; -#if 0 - -#if 1 -	/* Keep fallback image */ -	exclude_start_position = 0x60000; -	exclude_end_position = 0x80000; -#else  -	/* Keep DMI etc. */ -        exclude_start_position = 0x60000; -        exclude_end_position = 0x70000; -#endif - -#endif  	if (argc > 1) {  		/* Yes, print them. */ @@ -176,11 +176,14 @@ int write_page_write_jedec(volatile unsigned char *bios, unsigned char *src,  int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,  			     volatile unsigned char *dst)  { +	int tried = 0; +  	/* If the data is 0xFF, don't program it */  	if (*src == 0xFF) {  		return 0;  	} +retry:  	/* Issue JEDEC Byte Program command */  	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;  	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55; @@ -188,9 +191,12 @@ int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,  	/* transfer data from source to destination */  	*dst = *src; -  	toggle_ready_jedec(bios); +	if (*dst != *src && tried++ < 0x10) { + 		goto retry; + 	} +  	return 0;  } diff --git a/sst_fwhub.c b/sst_fwhub.c index 71f5d338..d9dd4670 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -79,10 +79,8 @@ int probe_sst_fwhub(struct flashchip *flash)  	myusec_delay(10); -	// we need to mmap the write-protect space.  -	printf("mapping control register at %x\n", 0 - 0x400000 -size);  	bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED, -		    flash->fd_mem, (off_t) (0 - 0x400000 - size)); +		    flash->fd_mem, (off_t) (0xFFFFFFFF - 0x400000 - size + 1));  	if (bios == MAP_FAILED) {  		// it's this part but we can't map it ...  		perror("Error MMAP /dev/mem"); @@ -101,23 +99,16 @@ unsigned char wait_sst_fwhub(volatile unsigned char *bios)  int erase_sst_fwhub_block(struct flashchip *flash, int offset)  { -	volatile unsigned char *bios = flash->virt_addr + offset; -	volatile unsigned char *wrprotect = -	    flash->virt_addr_2 + offset + 2; +	volatile unsigned char *wrprotect = flash->virt_addr_2 + offset + 2;  	unsigned char status; -	// clear status register -	printf("Erase at %p\n", bios); +	//printf("Erase at %p\n", bios);  	// clear write protect -	printf("write protect is at %p\n", (wrprotect)); -	printf("write protect is 0x%x\n", *(wrprotect));  	*(wrprotect) = 0; -	printf("write protect is 0x%x\n", *(wrprotect));  	erase_block_jedec(flash->virt_addr, offset);  	status = wait_sst_fwhub(flash->virt_addr); -	//print_sst_fwhub_status(status); -	printf("DONE BLOCK 0x%x\n", offset); +  	return (0);  } @@ -126,11 +117,8 @@ int erase_sst_fwhub(struct flashchip *flash)  	int i;  	unsigned int total_size = flash->total_size * 1024; -	printf("total_size is %d; flash->page_size is %d\n", -	       total_size, flash->page_size);  	for (i = 0; i < total_size; i += flash->page_size)  		erase_sst_fwhub_block(flash, i); -	printf("DONE ERASE\n");  	return (0);  } @@ -145,7 +133,6 @@ void write_page_sst_fwhub(volatile char *bios, char *src,  		src++;  		dst++;  	} -  }  int write_sst_fwhub(struct flashchip *flash, unsigned char *buf) @@ -165,10 +152,8 @@ int write_sst_fwhub(struct flashchip *flash, unsigned char *buf)  		printf("%04d at address: 0x%08x", i, i * page_size);  		write_page_sst_fwhub(bios, buf + i * page_size,  				     bios + i * page_size, page_size); -		printf -		    ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); +		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");  	}  	printf("\n"); -	protect_sst_fwhub(bios);  	return (0);  } diff --git a/sst_fwhub.h b/sst_fwhub.h index 35691305..eb2b364e 100644 --- a/sst_fwhub.h +++ b/sst_fwhub.h @@ -5,44 +5,4 @@ extern int probe_sst_fwhub(struct flashchip *flash);  extern int erase_sst_fwhub(struct flashchip *flash);  extern int write_sst_fwhub(struct flashchip *flash, unsigned char *buf); -extern __inline__ void toggle_ready_sst_fwhub(volatile char *dst) -{ -	unsigned int i = 0; -	char tmp1, tmp2; - -	tmp1 = *dst & 0x40; - -	while (i++ < 0xFFFFFF) { -		tmp2 = *dst & 0x40; -		if (tmp1 == tmp2) { -			break; -		} -		tmp1 = tmp2; -	} -} - -extern __inline__ void data_polling_sst_fwhub(volatile char *dst, char data) -{ -	unsigned int i = 0; -	char tmp; - -	data &= 0x80; - -	while (i++ < 0xFFFFFF) { -		tmp = *dst & 0x80; -		if (tmp == data) { -			break; -		} -	} -} - -extern __inline__ void protect_sst_fwhub(volatile char *bios) -{ -	*(volatile char *) (bios + 0x5555) = 0xAA; -	*(volatile char *) (bios + 0x2AAA) = 0x55; -	*(volatile char *) (bios + 0x5555) = 0xA0; - -	usleep(200); -} -  #endif				/* !__SST_FWHUB_H__ */ | 
