diff options
Diffstat (limited to 'board/mpl/common')
-rw-r--r-- | board/mpl/common/common_util.c | 50 | ||||
-rw-r--r-- | board/mpl/common/flash.c | 38 |
2 files changed, 73 insertions, 15 deletions
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c index 9c98c93..5117394 100644 --- a/board/mpl/common/common_util.c +++ b/board/mpl/common/common_util.c @@ -42,6 +42,9 @@ #include "../mip405/mip405.h" #include <405gp_pci.h> #endif +#if defined(CONFIG_PATI) +#define FIRM_START 0xFFF00000 +#endif extern int gunzip(void *, int, uchar *, int *); extern int mem_test(ulong start, ulong ramsize, int quiet); @@ -60,14 +63,17 @@ mpl_prg(uchar *src, ulong size) ulong start; flash_info_t *info; int i, rc; -#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) +#if defined(CONFIG_PATI) + int start_sect; +#endif +#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI) char *copystr = (char *)src; ulong *magic = (ulong *)src; #endif info = &flash_info[0]; -#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) +#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI) if (ntohl(magic[0]) != IH_MAGIC) { puts("Bad Magic number\n"); return -1; @@ -90,6 +96,7 @@ mpl_prg(uchar *src, ulong size) printf("Wrong Firmware Image: %s\n", ©str[i]); return -1; } +#if !defined(CONFIG_PATI) start = 0 - size; for (i = info->sector_count-1; i > 0; i--) { info->protect[i] = 0; /* unprotect this sector */ @@ -106,6 +113,36 @@ mpl_prg(uchar *src, ulong size) return (1); } +#else /* #if !defined(CONFIG_PATI */ + start = FIRM_START; + start_sect = -1; + for (i = 0; i < info->sector_count; i++) { + if (start < info->start[i]) { + start_sect = i - 1; + break; + } + } + + info->protect[i - 1] = 0; /* unprotect this sector */ + for (; i < info->sector_count; i++) { + if ((start + size) < info->start[i]) + break; + info->protect[i] = 0; /* unprotect this sector */ + } + + i--; + /* set-up flash location */ + /* now erase flash */ + printf ("Erasing at %lx to %lx (sector %d to %d) (%lx to %lx)\n", + start, start + size, start_sect, i, + info->start[start_sect], info->start[i]); + if ((rc = flash_erase (info, start_sect, i)) != 0) { + puts ("ERROR "); + flash_perror (rc); + return (1); + } +#endif /* defined(CONFIG_PATI) */ + #elif defined(CONFIG_VCMA9) start = 0; for (i = 0; i <info->sector_count; i++) { @@ -227,7 +264,7 @@ mpl_prg_image(uchar *ld_addr) return(rc); } - +#if !defined(CONFIG_PATI) void get_backup_values(backup_t *buf) { i2c_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t)); @@ -417,14 +454,17 @@ void show_stdio_dev(void) } } +#endif /* #if !defined(CONFIG_PATI) */ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong size,src,ld_addr; int result; +#if !defined(CONFIG_PATI) backup_t back; src = MULTI_PURPOSE_SOCKET_ADDR; size = IMAGE_SIZE; +#endif if (strcmp(argv[1], "flash") == 0) { @@ -460,11 +500,13 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) result=mpl_prg_image((uchar *)ld_addr); return result; } +#if !defined(CONFIG_PATI) if (strcmp(argv[2], "mps") == 0) { puts("\nupdating bootloader image from MPS\n"); result=mpl_prg((uchar *)src,size); return result; } +#endif /* #if !defined(CONFIG_PATI) */ } if (strcmp(argv[1], "mem") == 0) { @@ -490,6 +532,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }while(result); return 0; } +#if !defined(CONFIG_PATI) if (strcmp(argv[1], "clearenvvalues") == 0) { if (strcmp(argv[2], "yes") == 0) @@ -512,6 +555,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) set_backup_values(1); return 0; } +#endif printf("Usage:\n%s\n", cmdtp->usage); return 1; } diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c index 5f50200..fd43008 100644 --- a/board/mpl/common/flash.c +++ b/board/mpl/common/flash.c @@ -36,6 +36,8 @@ */ #include <common.h> + +#if !defined(CONFIG_PATI) #include <ppc4xx.h> #include <asm/processor.h> #include "common_util.h" @@ -46,6 +48,9 @@ #include "../pip405/pip405.h" #endif #include <405gp_pci.h> +#else /* defined(CONFIG_PATI) */ +#include <mpc5xx.h> +#endif flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ /*----------------------------------------------------------------------- @@ -56,22 +61,15 @@ static int write_word (flash_info_t *info, ulong dest, ulong data); void unlock_intel_sectors(flash_info_t *info,ulong addr,ulong cnt); - -#ifdef CONFIG_PIP405 #define ADDR0 0x5555 #define ADDR1 0x2aaa #define FLASH_WORD_SIZE unsigned short -#endif - -#ifdef CONFIG_MIP405 -#define ADDR0 0x5555 -#define ADDR1 0x2aaa -#define FLASH_WORD_SIZE unsigned short -#endif #define FALSE 0 #define TRUE 1 +#if !defined(CONFIG_PATI) + /*----------------------------------------------------------------------- * Some CS switching routines: * @@ -151,11 +149,16 @@ void setup_cs_reloc(void) } } +#endif /* #if !defined(CONFIG_PATI) */ unsigned long flash_init (void) { - unsigned long size_b0, size_b1,flashcr, size_reg; - int mode, i; + unsigned long size_b0; + int i; + +#if !defined(CONFIG_PATI) + unsigned long size_b1,flashcr,size_reg; + int mode; extern char version_string; char *p=&version_string; @@ -169,6 +172,7 @@ unsigned long flash_init (void) else printf("(%s Boot) ",(mode & BOOT_MPS) ? "MPS" : "Flash"); +#endif /* #if !defined(CONFIG_PATI) */ /* Init: no FLASHes known */ for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) { flash_info[i].flash_id = FLASH_UNKNOWN; @@ -190,6 +194,7 @@ unsigned long flash_init (void) CFG_MONITOR_BASE+monitor_flash_len-1, &flash_info[0]); #endif +#if !defined(CONFIG_PATI) /* protect reset vector */ flash_info[0].protect[flash_info[0].sector_count-1] = 1; size_b1 = 0 ; @@ -233,7 +238,7 @@ unsigned long flash_init (void) mtdcr(ebccfgd, flashcr); } #if 0 - /* enable this if you want to test if + /* enable this (PIP405/MIP405 only) if you want to test if the relocation has be done ok. This will disable both Chipselects */ mtdcr (ebccfga, pb0cr); @@ -250,6 +255,15 @@ unsigned long flash_init (void) } p++; } +#else /* #if !defined(CONFIG_PATI) */ +#ifdef CFG_ENV_IS_IN_FLASH + /* ENV protection ON by default */ + flash_protect(FLAG_PROTECT_SET, + CFG_ENV_ADDR, + CFG_ENV_ADDR+CFG_ENV_SECT_SIZE-1, + &flash_info[0]); +#endif +#endif /* #if !defined(CONFIG_PATI) */ return (size_b0); } |