From efe2a4d5cf96dd37bc4782ba1880cee4ed1117c5 Mon Sep 17 00:00:00 2001 From: wdenk Date: Thu, 16 Dec 2004 21:44:03 +0000 Subject: Code cleanup. --- board/esd/apc405/strataflash.c | 63 +++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 35 deletions(-) (limited to 'board/esd/apc405') diff --git a/board/esd/apc405/strataflash.c b/board/esd/apc405/strataflash.c index 6578ed9d5c..ad7a71dc4d 100644 --- a/board/esd/apc405/strataflash.c +++ b/board/esd/apc405/strataflash.c @@ -24,7 +24,7 @@ #include #include -#undef DEBUG_FLASH +#undef DEBUG_FLASH /* * This file implements a Common Flash Interface (CFI) driver for ppcboot. * The width of the port and the width of the chips are determined at initialization. @@ -85,12 +85,8 @@ #define FLASH_OFFSET_USER_PROTECTION 0x85 #define FLASH_OFFSET_INTEL_PROTECTION 0x81 - #define FLASH_MAN_CFI 0x01000000 - - - typedef union { unsigned char c; unsigned short w; @@ -107,13 +103,10 @@ typedef union { flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ - /*----------------------------------------------------------------------- * Functions */ - - static void flash_add_byte(flash_info_t *info, cfiword_t * cword, uchar c); static void flash_make_cmd(flash_info_t * info, uchar cmd, void * cmdbuf); static void flash_write_cmd(flash_info_t * info, int sect, uchar offset, uchar cmd); @@ -249,7 +242,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) flash_write_cmd(info, sect, 0, FLASH_CMD_CLEAR_STATUS); flash_write_cmd(info, sect, 0, FLASH_CMD_BLOCK_ERASE); flash_write_cmd(info, sect, 0, FLASH_CMD_ERASE_CONFIRM); - + if(flash_full_status_check(info, sect, info->erase_blk_tout, "erase")) { rcode = 1; } else @@ -277,7 +270,7 @@ void flash_print_info (flash_info_t *info) info->size >> 20, info->sector_count); printf(" Erase timeout %ld ms, write timeout %ld ms, buffer write timeout %ld ms, buffer size %d\n", info->erase_blk_tout, info->write_tout, info->buffer_write_tout, info->buffer_size); - + printf (" Sector Start Addresses:"); for (i=0; isector_count; ++i) { #ifdef CFG_FLASH_EMPTY_INFO @@ -286,28 +279,28 @@ void flash_print_info (flash_info_t *info) int erased; volatile unsigned long *flash; - /* - * Check if whole sector is erased - */ - if (i != (info->sector_count-1)) - size = info->start[i+1] - info->start[i]; - else - size = info->start[0] + info->size - info->start[i]; - erased = 1; - flash = (volatile unsigned long *)info->start[i]; - size = size >> 2; /* divide by 4 for longword access */ - for (k=0; ksector_count-1)) + size = info->start[i+1] - info->start[i]; + else + size = info->start[0] + info->size - info->start[i]; + erased = 1; + flash = (volatile unsigned long *)info->start[i]; + size = size >> 2; /* divide by 4 for longword access */ + for (k=0; kstart[i], erased ? " E" : " ", @@ -414,7 +407,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) else flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR); - if((retcode = flash_full_status_check(info, sector, info->erase_blk_tout, + if((retcode = flash_full_status_check(info, sector, info->erase_blk_tout, prot?"protect":"unprotect")) == 0) { info->protect[sector] = prot; @@ -464,7 +457,7 @@ static int flash_full_status_check(flash_info_t * info, ulong sector, ulong tout printf("Command Sequence Error.\n"); } else if(flash_isset(info, sector, 0, FLASH_STATUS_ECLBS)){ printf("Block Erase Error.\n"); - retcode = ERR_NOT_ERASED; + retcode = ERR_NOT_ERASED; } else if (flash_isset(info, sector, 0, FLASH_STATUS_PSLBS)) { printf("Locking Error\n"); } @@ -733,7 +726,7 @@ static int find_sector(flash_info_t *info, ulong addr) { int sector; for(sector = info->sector_count - 1; sector >= 0; sector--) { - if(addr >= info->start[sector]) + if(addr >= info->start[sector]) break; } return sector; @@ -741,7 +734,7 @@ static int find_sector(flash_info_t *info, ulong addr) static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp, int len) { - + int sector; int cnt; int retcode; @@ -789,8 +782,8 @@ static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp, in flash_write_cmd(info, sector, 0, FLASH_CMD_WRITE_BUFFER_CONFIRM); retcode = flash_full_status_check(info, sector, info->buffer_write_tout, "buffer write"); - } + } flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS); return retcode; -} +} #endif /* CFG_USE_FLASH_BUFFER_WRITE */ -- cgit v1.2.1