X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=board%2Fevb64260%2Fflash.c;h=825bbaf700edb580256e65d4edae82697c50030d;hb=a53f4a29ac62a2e83d35a4a7b6d6969cf95a5902;hp=c89739333a5a94d56e1d095e0dbd6cb06653fe2a;hpb=8bde7f776c77b343aca29b8c7b58464d915ac245;p=u-boot diff --git a/board/evb64260/flash.c b/board/evb64260/flash.c index c89739333a..825bbaf700 100644 --- a/board/evb64260/flash.c +++ b/board/evb64260/flash.c @@ -46,7 +46,7 @@ int flash_erase_intel(flash_info_t *info, int s_first, int s_last); int write_word_intel(bank_addr_t addr, bank_word_t value); -flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ +flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ /*----------------------------------------------------------------------- * Functions @@ -66,26 +66,38 @@ flash_init (void) unsigned long base, flash_size; /* Init: no FLASHes known */ - for (i=0; i>20, base); +#ifndef CONFIG_P3G4 + printf("["); + print_size (size, ""); + printf("@%08lX] ", base); +#endif if (flash_info[i].flash_id == FLASH_UNKNOWN) { if(i==1) { @@ -98,6 +110,22 @@ flash_init (void) base+=size; } +#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE + /* monitor protection ON by default */ + flash_protect(FLAG_PROTECT_SET, + CONFIG_SYS_MONITOR_BASE, + CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1, + flash_get_info(CONFIG_SYS_MONITOR_BASE)); +#endif + +#ifdef CONFIG_ENV_IS_IN_FLASH + /* ENV protection ON by default */ + flash_protect(FLAG_PROTECT_SET, + CONFIG_ENV_ADDR, + CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, + flash_get_info(CONFIG_ENV_ADDR)); +#endif + flash_size = size_b0 + size_b1; return flash_size; } @@ -146,6 +174,23 @@ flash_get_offsets (ulong base, flash_info_t *info) } } +/*----------------------------------------------------------------------- + */ + +flash_info_t *flash_get_info(ulong base) +{ + int i; + flash_info_t * info; + + for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i ++) { + info = & flash_info[i]; + if (info->start[0] <= base && base <= info->start[0] + info->size - 1) + break; + } + + return i == CONFIG_SYS_MAX_FLASH_BANKS ? 0 : info; +} + /*----------------------------------------------------------------------- */ void @@ -247,8 +292,11 @@ static inline void flash_cmd(int width, volatile unsigned char *addr, int offset /* 2x16 */ unsigned long cmd32=(cmd<<16)|cmd; *(volatile unsigned long *)(addr+offset*2)=cmd32; + } else if (width == 2) { + /* 1x16 */ + *(volatile unsigned short *)((unsigned short*)addr+offset)=cmd; } else { - /* 1x16 or 1x8 */ + /* 1x8 */ *(volatile unsigned char *)(addr+offset)=cmd; } } @@ -540,7 +588,7 @@ flash_get_size (int portwidth, vu_long *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { - volatile unsigned char *addr = (char *)(info->start[0]); + volatile unsigned char *addr = (uchar *)(info->start[0]); int flag, prot, sect, l_sect; ulong start, now, last; @@ -551,7 +599,7 @@ flash_erase (flash_info_t *info, int s_first, int s_last) if((info->flash_id & FLASH_TYPEMASK) == FLASH_RAM) { for (sect = s_first; sect<=s_last; sect++) { int sector_size=info->size/info->sector_count; - addr = (char *)(info->start[sect]); + addr = (uchar *)(info->start[sect]); memset((void *)addr, 0, sector_size); } return 0; @@ -609,7 +657,7 @@ flash_erase (flash_info_t *info, int s_first, int s_last) /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ - addr = (char *)(info->start[sect]); + addr = (uchar *)(info->start[sect]); flash_cmd(info->portwidth,addr,0,0x30); l_sect = sect; } @@ -633,7 +681,7 @@ flash_erase (flash_info_t *info, int s_first, int s_last) addr = (volatile unsigned char *)(info->start[l_sect]); /* broken for 2x16: TODO */ while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) { + if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -745,7 +793,7 @@ write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt) static int write_word (flash_info_t *info, ulong dest, ulong data) { - volatile unsigned char *addr = (char *)(info->start[0]); + volatile unsigned char *addr = (uchar *)(info->start[0]); ulong start; int flag, i; @@ -797,7 +845,7 @@ write_word (flash_info_t *info, ulong dest, ulong data) /* data polling for D7 */ start = get_timer (0); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CFG_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } }