wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <video_fb.h> |
| 11 | #include "common_util.h" |
| 12 | #include <asm/processor.h> |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 13 | #include <asm/byteorder.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 14 | #include <i2c.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 15 | #include <pci.h> |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 16 | #include <malloc.h> |
| 17 | #include <bzlib.h> |
Simon Glass | 88ecb9b | 2016-10-17 20:12:54 -0600 | [diff] [blame] | 18 | #include <video.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 19 | |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 20 | #ifdef CONFIG_PIP405 |
| 21 | #include "../pip405/pip405.h" |
Stefan Roese | ca8725f | 2007-10-03 15:01:02 +0200 | [diff] [blame] | 22 | #include <asm/4xx_pci.h> |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 23 | #endif |
Tom Rini | 45ae673 | 2016-09-19 21:55:34 -0400 | [diff] [blame] | 24 | #if defined(CONFIG_TARGET_MIP405) || defined(CONFIG_TARGET_MIP405T) |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 25 | #include "../mip405/mip405.h" |
Stefan Roese | ca8725f | 2007-10-03 15:01:02 +0200 | [diff] [blame] | 26 | #include <asm/4xx_pci.h> |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 27 | #endif |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 28 | |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 31 | extern int mem_test(ulong start, ulong ramsize, int quiet); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 33 | #define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 34 | #define IMAGE_SIZE CONFIG_SYS_MONITOR_LEN /* ugly, but it works for now */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 35 | |
Tom Rini | 45ae673 | 2016-09-19 21:55:34 -0400 | [diff] [blame] | 36 | #if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) \ |
| 37 | || defined(CONFIG_TARGET_MIP405T) |
David Müller | b4a931e | 2011-12-22 13:38:19 +0100 | [diff] [blame] | 38 | /*----------------------------------------------------------------------- |
| 39 | * On PIP/MIP405 we have 3 (4) possible boot mode |
| 40 | * |
| 41 | * - Boot from Flash (Flash CS = CS0, MPS CS = CS1) |
| 42 | * - Boot from MPS (Flash CS = CS1, MPS CS = CS0) |
| 43 | * - Boot from PCI with Flash map (Flash CS = CS0, MPS CS = CS1) |
| 44 | * - Boot from PCI with MPS map (Flash CS = CS1, MPS CS = CS0) |
| 45 | * The flash init is the first board specific routine which is called |
| 46 | * after code relocation (running from SDRAM) |
| 47 | * The first thing we do is to map the Flash CS to the Flash area and |
| 48 | * the MPS CS to the MPS area. Since the flash size is unknown at this |
| 49 | * point, we use the max flash size and the lowest flash address as base. |
| 50 | * |
| 51 | * After flash detection we adjust the size of the CS area accordingly. |
| 52 | * update_flash_size() will fix in wrong values in the flash_info structure, |
| 53 | * misc_init_r() will fix the values in the board info structure |
| 54 | */ |
| 55 | int get_boot_mode(void) |
| 56 | { |
| 57 | unsigned long pbcr; |
| 58 | int res = 0; |
| 59 | pbcr = mfdcr(CPC0_PSR); |
| 60 | if ((pbcr & PSR_ROM_WIDTH_MASK) == 0) |
| 61 | /* boot via MPS or MPS mapping */ |
| 62 | res = BOOT_MPS; |
| 63 | if (pbcr & PSR_ROM_LOC) |
| 64 | /* boot via PCI.. */ |
| 65 | res |= BOOT_PCI; |
| 66 | return res; |
| 67 | } |
| 68 | |
| 69 | /* Map the flash high (in boot area) |
| 70 | This code can only be executed from SDRAM (after relocation). |
| 71 | */ |
| 72 | void setup_cs_reloc(void) |
| 73 | { |
| 74 | int mode; |
| 75 | /* |
| 76 | * since we are relocated, we can set-up the CS finaly |
| 77 | * but first of all, switch off PCI mapping (in case it |
| 78 | * was a PCI boot) |
| 79 | */ |
| 80 | out32r(PMM0MA, 0L); |
| 81 | /* get boot mode */ |
| 82 | mode = get_boot_mode(); |
| 83 | /* |
| 84 | * we map the flash high in every case |
| 85 | * first find out to which CS the flash is attached to |
| 86 | */ |
| 87 | if (mode & BOOT_MPS) { |
| 88 | /* map flash high on CS1 and MPS on CS0 */ |
| 89 | mtdcr(EBC0_CFGADDR, PB0AP); |
| 90 | mtdcr(EBC0_CFGDATA, MPS_AP); |
| 91 | mtdcr(EBC0_CFGADDR, PB0CR); |
| 92 | mtdcr(EBC0_CFGDATA, MPS_CR); |
| 93 | /* |
| 94 | * we use the default values (max values) for the flash |
| 95 | * because its real size is not yet known |
| 96 | */ |
| 97 | mtdcr(EBC0_CFGADDR, PB1AP); |
| 98 | mtdcr(EBC0_CFGDATA, FLASH_AP); |
| 99 | mtdcr(EBC0_CFGADDR, PB1CR); |
| 100 | mtdcr(EBC0_CFGDATA, FLASH_CR_B); |
| 101 | } else { |
| 102 | /* map flash high on CS0 and MPS on CS1 */ |
| 103 | mtdcr(EBC0_CFGADDR, PB1AP); |
| 104 | mtdcr(EBC0_CFGDATA, MPS_AP); |
| 105 | mtdcr(EBC0_CFGADDR, PB1CR); |
| 106 | mtdcr(EBC0_CFGDATA, MPS_CR); |
| 107 | /* |
| 108 | * we use the default values (max values) for the flash |
| 109 | * because its real size is not yet known |
| 110 | */ |
| 111 | mtdcr(EBC0_CFGADDR, PB0AP); |
| 112 | mtdcr(EBC0_CFGDATA, FLASH_AP); |
| 113 | mtdcr(EBC0_CFGADDR, PB0CR); |
| 114 | mtdcr(EBC0_CFGDATA, FLASH_CR_B); |
| 115 | } |
| 116 | } |
Tom Rini | 45ae673 | 2016-09-19 21:55:34 -0400 | [diff] [blame] | 117 | #endif /* #if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) */ |
David Müller | b4a931e | 2011-12-22 13:38:19 +0100 | [diff] [blame] | 118 | |
| 119 | #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE |
| 120 | /* adjust flash start and protection info */ |
| 121 | int update_flash_size(int flash_size) |
| 122 | { |
| 123 | int i = 0, mode; |
| 124 | flash_info_t *info = &flash_info[0]; |
| 125 | unsigned long flashcr; |
| 126 | unsigned long flash_base = (0 - flash_size) & 0xFFF00000; |
| 127 | |
| 128 | if (flash_size > 128*1024*1024) { |
| 129 | printf("\n ### ERROR, wrong flash size: %X, reset board ###\n", |
| 130 | flash_size); |
| 131 | hang(); |
| 132 | } |
| 133 | |
| 134 | if ((flash_size >> 20) != 0) |
| 135 | i = __ilog2(flash_size >> 20); |
| 136 | |
| 137 | /* set up flash CS according to the size */ |
| 138 | mode = get_boot_mode(); |
| 139 | if (mode & BOOT_MPS) { |
| 140 | /* flash is on CS1 */ |
| 141 | mtdcr(EBC0_CFGADDR, PB1CR); |
| 142 | flashcr = mfdcr(EBC0_CFGDATA); |
| 143 | /* we map the flash high in every case */ |
| 144 | flashcr &= 0x0001FFFF; /* mask out address bits */ |
| 145 | flashcr |= flash_base; /* start addr */ |
| 146 | flashcr |= (i << 17); /* size addr */ |
| 147 | mtdcr(EBC0_CFGADDR, PB1CR); |
| 148 | mtdcr(EBC0_CFGDATA, flashcr); |
| 149 | } else { |
| 150 | /* flash is on CS0 */ |
| 151 | mtdcr(EBC0_CFGADDR, PB0CR); |
| 152 | flashcr = mfdcr(EBC0_CFGDATA); |
| 153 | /* we map the flash high in every case */ |
| 154 | flashcr &= 0x0001FFFF; /* mask out address bits */ |
| 155 | flashcr |= flash_base; /* start addr */ |
| 156 | flashcr |= (i << 17); /* size addr */ |
| 157 | mtdcr(EBC0_CFGADDR, PB0CR); |
| 158 | mtdcr(EBC0_CFGDATA, flashcr); |
| 159 | } |
| 160 | |
| 161 | for (i = 0; i < info->sector_count; i++) |
| 162 | /* adjust sector start address */ |
| 163 | info->start[i] = flash_base + |
| 164 | (info->start[i] - CONFIG_SYS_FLASH_BASE); |
| 165 | |
| 166 | /* unprotect all sectors */ |
| 167 | flash_protect(FLAG_PROTECT_CLEAR, |
| 168 | info->start[0], |
| 169 | 0xFFFFFFFF, |
| 170 | info); |
| 171 | flash_protect_default(); |
| 172 | /* protect reset vector too*/ |
| 173 | flash_protect(FLAG_PROTECT_SET, |
| 174 | info->start[info->sector_count-1], |
| 175 | 0xFFFFFFFF, |
| 176 | info); |
| 177 | |
| 178 | return 0; |
| 179 | } |
| 180 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 181 | |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 182 | static int |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 183 | mpl_prg(uchar *src, ulong size) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 184 | { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 185 | ulong start; |
David Müller | b4a931e | 2011-12-22 13:38:19 +0100 | [diff] [blame] | 186 | flash_info_t *info = &flash_info[0]; |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 187 | int i, rc; |
Heiko Schocher | d4def9b | 2017-06-07 17:33:11 +0200 | [diff] [blame] | 188 | #if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) || \ |
| 189 | defined(CONFIG_TARGET_MIP405T) |
wdenk | e39c284 | 2003-06-04 15:05:30 +0000 | [diff] [blame] | 190 | char *copystr = (char *)src; |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 191 | ulong *magic = (ulong *)src; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 192 | |
Marian Balakowicz | d7c88a4 | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 193 | if (uimage_to_cpu (magic[0]) != IH_MAGIC) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 194 | puts("Bad Magic number\n"); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 195 | return -1; |
| 196 | } |
wdenk | e39c284 | 2003-06-04 15:05:30 +0000 | [diff] [blame] | 197 | /* some more checks before we delete the Flash... */ |
| 198 | /* Checking the ISO_STRING prevents to program a |
| 199 | * wrong Firmware Image into the flash. |
| 200 | */ |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 201 | i = 4; /* skip Magic number */ |
| 202 | while (1) { |
| 203 | if (strncmp(©str[i], "MEV-", 4) == 0) |
wdenk | e39c284 | 2003-06-04 15:05:30 +0000 | [diff] [blame] | 204 | break; |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 205 | if (i++ >= 0x100) { |
| 206 | puts("Firmware Image for unknown Target\n"); |
wdenk | e39c284 | 2003-06-04 15:05:30 +0000 | [diff] [blame] | 207 | return -1; |
| 208 | } |
| 209 | } |
| 210 | /* we have the ISO STRING, check */ |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 211 | if (strncmp(©str[i], CONFIG_ISO_STRING, sizeof(CONFIG_ISO_STRING)-1) != 0) { |
| 212 | printf("Wrong Firmware Image: %s\n", ©str[i]); |
wdenk | e39c284 | 2003-06-04 15:05:30 +0000 | [diff] [blame] | 213 | return -1; |
| 214 | } |
| 215 | start = 0 - size; |
David Müller | b4a931e | 2011-12-22 13:38:19 +0100 | [diff] [blame] | 216 | |
| 217 | /* unprotect sectors used by u-boot */ |
| 218 | flash_protect(FLAG_PROTECT_CLEAR, |
| 219 | start, |
| 220 | 0xFFFFFFFF, |
| 221 | info); |
| 222 | |
| 223 | /* search start sector */ |
| 224 | for (i = info->sector_count-1; i > 0; i--) |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 225 | if (start >= info->start[i]) |
| 226 | break; |
David Müller | b4a931e | 2011-12-22 13:38:19 +0100 | [diff] [blame] | 227 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 228 | /* now erase flash */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 229 | printf("Erasing at %lx (sector %d) (start %lx)\n", |
| 230 | start,i,info->start[i]); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 231 | if ((rc = flash_erase (info, i, info->sector_count-1)) != 0) { |
| 232 | puts("ERROR "); |
| 233 | flash_perror(rc); |
| 234 | return (1); |
| 235 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 236 | #endif |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 237 | printf("flash erased, programming from 0x%lx 0x%lx Bytes\n", |
| 238 | (ulong)src, size); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 239 | if ((rc = flash_write ((char *)src, start, size)) != 0) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 240 | puts("ERROR "); |
| 241 | flash_perror(rc); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 242 | return (1); |
| 243 | } |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 244 | puts("OK programming done\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 249 | static int |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 250 | mpl_prg_image(uchar *ld_addr) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 251 | { |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 252 | unsigned long len; |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 253 | uchar *data; |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 254 | image_header_t *hdr = (image_header_t *)ld_addr; |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 255 | int rc; |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 256 | |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 257 | #if defined(CONFIG_FIT) |
Marian Balakowicz | d7c88a4 | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 258 | if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 259 | puts ("Non legacy image format not supported\n"); |
| 260 | return -1; |
| 261 | } |
| 262 | #endif |
| 263 | |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 264 | if (!image_check_magic (hdr)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 265 | puts("Bad Magic Number\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 266 | return 1; |
| 267 | } |
Marian Balakowicz | a1cc147 | 2008-02-21 17:27:41 +0100 | [diff] [blame] | 268 | image_print_contents (hdr); |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 269 | if (!image_check_os (hdr, IH_OS_U_BOOT)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 270 | puts("No U-Boot Image\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 271 | return 1; |
| 272 | } |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 273 | if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 274 | puts("No Firmware Image\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 275 | return 1; |
| 276 | } |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 277 | if (!image_check_hcrc (hdr)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 278 | puts("Bad Header Checksum\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 279 | return 1; |
| 280 | } |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 281 | puts("Verifying Checksum ... "); |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 282 | if (!image_check_dcrc (hdr)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 283 | puts("Bad Data CRC\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 284 | return 1; |
| 285 | } |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 286 | puts("OK\n"); |
| 287 | |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 288 | data = (uchar *)image_get_data (hdr); |
| 289 | len = image_get_data_size (hdr); |
| 290 | |
| 291 | if (image_get_comp (hdr) != IH_COMP_NONE) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 292 | uchar *buf; |
| 293 | /* reserve space for uncompressed image */ |
| 294 | if ((buf = malloc(IMAGE_SIZE)) == NULL) { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 295 | puts("Insufficient space for decompression\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 296 | return 1; |
| 297 | } |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 298 | |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 299 | switch (image_get_comp (hdr)) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 300 | case IH_COMP_GZIP: |
| 301 | puts("Uncompressing (GZIP) ... "); |
wdenk | a0ebde5 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 302 | rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 303 | if (rc != 0) { |
| 304 | puts("GUNZIP ERROR\n"); |
| 305 | free(buf); |
| 306 | return 1; |
| 307 | } |
| 308 | puts("OK\n"); |
| 309 | break; |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 310 | #ifdef CONFIG_BZIP2 |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 311 | case IH_COMP_BZIP2: |
| 312 | puts("Uncompressing (BZIP2) ... "); |
| 313 | { |
| 314 | uint retlen = IMAGE_SIZE; |
| 315 | rc = BZ2_bzBuffToBuffDecompress ((char *)(buf), &retlen, |
| 316 | (char *)data, len, 0, 0); |
| 317 | len = retlen; |
| 318 | } |
| 319 | if (rc != BZ_OK) { |
| 320 | printf ("BUNZIP2 ERROR: %d\n", rc); |
| 321 | free(buf); |
| 322 | return 1; |
| 323 | } |
| 324 | puts("OK\n"); |
| 325 | break; |
| 326 | #endif |
| 327 | default: |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 328 | printf ("Unimplemented compression type %d\n", |
| 329 | image_get_comp (hdr)); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 330 | free(buf); |
| 331 | return 1; |
| 332 | } |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 333 | |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 334 | rc = mpl_prg(buf, len); |
| 335 | free(buf); |
| 336 | } else { |
| 337 | rc = mpl_prg(data, len); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 338 | } |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 339 | |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 340 | return(rc); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 341 | } |
| 342 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 343 | void get_backup_values(backup_t *buf) |
| 344 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 345 | i2c_read(CONFIG_SYS_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | void set_backup_values(int overwrite) |
| 349 | { |
| 350 | backup_t back; |
| 351 | int i; |
| 352 | |
| 353 | get_backup_values(&back); |
| 354 | if(!overwrite) { |
| 355 | if(strncmp(back.signature,"MPL\0",4)==0) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 356 | puts("Not possible to write Backup\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 357 | return; |
| 358 | } |
| 359 | } |
| 360 | memcpy(back.signature,"MPL\0",4); |
Wolfgang Denk | 76af278 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 361 | i = getenv_f("serial#",back.serial_name,16); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 362 | if(i < 0) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 363 | puts("Not possible to write Backup\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 364 | return; |
| 365 | } |
| 366 | back.serial_name[16]=0; |
Wolfgang Denk | 76af278 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 367 | i = getenv_f("ethaddr",back.eth_addr,20); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 368 | if(i < 0) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 369 | puts("Not possible to write Backup\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 370 | return; |
| 371 | } |
| 372 | back.eth_addr[20]=0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 373 | i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | void clear_env_values(void) |
| 377 | { |
| 378 | backup_t back; |
| 379 | unsigned char env_crc[4]; |
| 380 | |
| 381 | memset(&back,0xff,sizeof(backup_t)); |
| 382 | memset(env_crc,0x00,4); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 383 | i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); |
| 384 | i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR,CONFIG_ENV_OFFSET,2,(void *)env_crc,4); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* |
| 388 | * check crc of "older" environment |
| 389 | */ |
| 390 | int check_env_old_size(ulong oldsize) |
| 391 | { |
| 392 | ulong crc, len, new; |
| 393 | unsigned off; |
| 394 | uchar buf[64]; |
| 395 | |
| 396 | /* read old CRC */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 397 | eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 398 | CONFIG_ENV_OFFSET, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 399 | (uchar *)&crc, sizeof(ulong)); |
| 400 | |
| 401 | new = 0; |
| 402 | len = oldsize; |
| 403 | off = sizeof(long); |
| 404 | len = oldsize-off; |
| 405 | while (len > 0) { |
| 406 | int n = (len > sizeof(buf)) ? sizeof(buf) : len; |
| 407 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 408 | eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 409 | new = crc32 (new, buf, n); |
| 410 | len -= n; |
| 411 | off += n; |
| 412 | } |
| 413 | |
| 414 | return (crc == new); |
| 415 | } |
| 416 | |
| 417 | static ulong oldsizes[] = { |
| 418 | 0x200, |
| 419 | 0x800, |
| 420 | 0 |
| 421 | }; |
| 422 | |
| 423 | void copy_old_env(ulong size) |
| 424 | { |
| 425 | uchar name_buf[64]; |
| 426 | uchar value_buf[0x800]; |
| 427 | uchar c; |
| 428 | ulong len; |
| 429 | unsigned off; |
| 430 | uchar *name, *value; |
| 431 | |
Wolfgang Denk | dc770c7 | 2008-07-14 15:19:07 +0200 | [diff] [blame] | 432 | name = &name_buf[0]; |
| 433 | value = &value_buf[0]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 434 | len=size; |
| 435 | off = sizeof(long); |
| 436 | while (len > off) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 437 | eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, &c, 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 438 | if(c != '=') { |
| 439 | *name++=c; |
| 440 | off++; |
| 441 | } |
| 442 | else { |
| 443 | *name++='\0'; |
| 444 | off++; |
| 445 | do { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 446 | eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, &c, 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 447 | *value++=c; |
| 448 | off++; |
| 449 | if(c == '\0') |
| 450 | break; |
| 451 | } while(len > off); |
Wolfgang Denk | dc770c7 | 2008-07-14 15:19:07 +0200 | [diff] [blame] | 452 | name = &name_buf[0]; |
| 453 | value = &value_buf[0]; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 454 | if(strncmp((char *)name,"baudrate",8)!=0) { |
| 455 | setenv((char *)name,(char *)value); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | |
| 463 | void check_env(void) |
| 464 | { |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 465 | char *s; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 466 | int i=0; |
| 467 | char buf[32]; |
| 468 | backup_t back; |
| 469 | |
| 470 | s=getenv("serial#"); |
| 471 | if(!s) { |
| 472 | while(oldsizes[i]) { |
| 473 | if(check_env_old_size(oldsizes[i])) |
| 474 | break; |
| 475 | i++; |
| 476 | } |
| 477 | if(!oldsizes[i]) { |
| 478 | /* no old environment has been found */ |
| 479 | get_backup_values (&back); |
| 480 | if (strncmp (back.signature, "MPL\0", 4) == 0) { |
| 481 | sprintf (buf, "%s", back.serial_name); |
| 482 | setenv ("serial#", buf); |
| 483 | sprintf (buf, "%s", back.eth_addr); |
| 484 | setenv ("ethaddr", buf); |
| 485 | printf ("INFO: serial# and ethaddr recovered, use saveenv\n"); |
| 486 | return; |
| 487 | } |
| 488 | } |
| 489 | else { |
| 490 | copy_old_env(oldsizes[i]); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 491 | puts("INFO: old environment ajusted, use saveenv\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | else { |
| 495 | /* check if back up is set */ |
| 496 | get_backup_values(&back); |
| 497 | if(strncmp(back.signature,"MPL\0",4)!=0) { |
| 498 | set_backup_values(0); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 503 | int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 504 | { |
Peter Tyser | e9b1b49 | 2010-10-05 23:48:47 -0500 | [diff] [blame] | 505 | ulong ld_addr; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 506 | int result; |
Peter Tyser | e9b1b49 | 2010-10-05 23:48:47 -0500 | [diff] [blame] | 507 | ulong size = IMAGE_SIZE; |
| 508 | ulong src = MULTI_PURPOSE_SOCKET_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 509 | backup_t back; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 510 | |
| 511 | if (strcmp(argv[1], "flash") == 0) |
| 512 | { |
Jon Loeliger | 145318c | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 513 | #if defined(CONFIG_CMD_FDC) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 514 | if (strcmp(argv[2], "floppy") == 0) { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 515 | char *local_args[3]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 516 | extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 517 | puts("\nupdating bootloader image from floppy\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 518 | local_args[0] = argv[0]; |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 519 | if(argc==4) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 520 | local_args[1] = argv[3]; |
| 521 | local_args[2] = NULL; |
| 522 | ld_addr=simple_strtoul(argv[3], NULL, 16); |
| 523 | result=do_fdcboot(cmdtp, 0, 2, local_args); |
| 524 | } |
| 525 | else { |
| 526 | local_args[1] = NULL; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 527 | ld_addr=CONFIG_SYS_LOAD_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 528 | result=do_fdcboot(cmdtp, 0, 1, local_args); |
| 529 | } |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 530 | result=mpl_prg_image((uchar *)ld_addr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 531 | return result; |
| 532 | } |
Jon Loeliger | 145318c | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 533 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 534 | if (strcmp(argv[2], "mem") == 0) { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 535 | if(argc==4) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 536 | ld_addr=simple_strtoul(argv[3], NULL, 16); |
| 537 | } |
| 538 | else { |
| 539 | ld_addr=load_addr; |
| 540 | } |
| 541 | printf ("\nupdating bootloader image from memory at %lX\n",ld_addr); |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 542 | result=mpl_prg_image((uchar *)ld_addr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 543 | return result; |
| 544 | } |
| 545 | if (strcmp(argv[2], "mps") == 0) { |
wdenk | 4ea537d | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 546 | puts("\nupdating bootloader image from MPS\n"); |
| 547 | result=mpl_prg((uchar *)src,size); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 548 | return result; |
| 549 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 550 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 551 | if (strcmp(argv[1], "clearenvvalues") == 0) |
| 552 | { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 553 | if (strcmp(argv[2], "yes") == 0) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 554 | { |
| 555 | clear_env_values(); |
| 556 | return 0; |
| 557 | } |
| 558 | } |
| 559 | if (strcmp(argv[1], "getback") == 0) { |
| 560 | get_backup_values(&back); |
| 561 | back.signature[3]=0; |
| 562 | back.serial_name[16]=0; |
| 563 | back.eth_addr[20]=0; |
| 564 | printf("GetBackUp: signature: %s\n",back.signature); |
| 565 | printf(" serial#: %s\n",back.serial_name); |
| 566 | printf(" ethaddr: %s\n",back.eth_addr); |
| 567 | return 0; |
| 568 | } |
| 569 | if (strcmp(argv[1], "setback") == 0) { |
| 570 | set_backup_values(1); |
| 571 | return 0; |
| 572 | } |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 573 | return cmd_usage(cmdtp); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 574 | } |
| 575 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 576 | #ifdef CONFIG_VIDEO |
| 577 | /****************************************************** |
| 578 | * Routines to display the Board information |
| 579 | * to the screen (since the VGA will be initialized as last, |
| 580 | * we must resend the infos) |
| 581 | */ |
| 582 | |
| 583 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 584 | extern GraphicDevice ctfb; |
wdenk | 2c9b05d | 2003-09-10 22:30:53 +0000 | [diff] [blame] | 585 | extern int get_boot_mode(void); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 586 | |
| 587 | void video_get_info_str (int line_number, char *info) |
| 588 | { |
| 589 | /* init video info strings for graphic console */ |
Stefan Roese | edd73f2 | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 590 | PPC4xx_SYS_INFO sys_info; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 591 | char rev; |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 592 | int i,boot; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 593 | unsigned long pvr; |
| 594 | char buf[64]; |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 595 | char buf1[32], buf2[32], buf3[32], buf4[32]; |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 596 | char cpustr[16]; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 597 | char *s, *e, bc; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 598 | switch (line_number) |
| 599 | { |
| 600 | case 2: |
| 601 | /* CPU and board infos */ |
| 602 | pvr=get_pvr(); |
| 603 | get_sys_info (&sys_info); |
| 604 | switch (pvr) { |
| 605 | case PVR_405GP_RB: rev='B'; break; |
| 606 | case PVR_405GP_RC: rev='C'; break; |
| 607 | case PVR_405GP_RD: rev='D'; break; |
| 608 | case PVR_405GP_RE: rev='E'; break; |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 609 | case PVR_405GPR_RB: rev='B'; break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 610 | default: rev='?'; break; |
| 611 | } |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 612 | if(pvr==PVR_405GPR_RB) |
| 613 | sprintf(cpustr,"PPC405GPr %c",rev); |
| 614 | else |
| 615 | sprintf(cpustr,"PPC405GP %c",rev); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 616 | /* Board info */ |
| 617 | i=0; |
| 618 | s=getenv ("serial#"); |
| 619 | #ifdef CONFIG_PIP405 |
| 620 | if (!s || strncmp (s, "PIP405", 6)) { |
Ben Whitten | 34fd6c9 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 621 | strcpy(buf,"### No HW ID - assuming PIP405"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 622 | } |
| 623 | #endif |
Tom Rini | 45ae673 | 2016-09-19 21:55:34 -0400 | [diff] [blame] | 624 | #if defined(CONFIG_TARGET_MIP405) || defined(CONFIG_TARGET_MIP405T) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 625 | if (!s || strncmp (s, "MIP405", 6)) { |
Ben Whitten | 34fd6c9 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 626 | strcpy(buf,"### No HW ID - assuming MIP405"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 627 | } |
| 628 | #endif |
| 629 | else { |
| 630 | for (e = s; *e; ++e) { |
| 631 | if (*e == ' ') |
| 632 | break; |
| 633 | } |
| 634 | for (; s < e; ++s) { |
| 635 | if (*s == '_') { |
| 636 | ++s; |
| 637 | break; |
| 638 | } |
Wolfgang Denk | dc770c7 | 2008-07-14 15:19:07 +0200 | [diff] [blame] | 639 | buf[i++] = *s; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 640 | } |
Ben Whitten | 34fd6c9 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 641 | strcpy(&buf[i]," SN "); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 642 | i+=4; |
| 643 | for (; s < e; ++s) { |
Wolfgang Denk | dc770c7 | 2008-07-14 15:19:07 +0200 | [diff] [blame] | 644 | buf[i++] = *s; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 645 | } |
| 646 | buf[i++]=0; |
| 647 | } |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 648 | sprintf (info," %s %s %s MHz (%s/%s/%s MHz)", |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 649 | buf, cpustr, |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 650 | strmhz (buf1, gd->cpu_clk), |
| 651 | strmhz (buf2, sys_info.freqPLB), |
| 652 | strmhz (buf3, sys_info.freqPLB / sys_info.pllOpbDiv), |
| 653 | strmhz (buf4, sys_info.freqPLB / sys_info.pllExtBusDiv)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 654 | return; |
| 655 | case 3: |
| 656 | /* Memory Info */ |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 657 | boot = get_boot_mode(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 658 | bc = in8 (CONFIG_PORT_ADDR); |
| 659 | sprintf(info, " %luMB RAM, %luMB Flash Cfg 0x%02X %s %s", |
| 660 | gd->bd->bi_memsize / 0x100000, |
| 661 | gd->bd->bi_flashsize / 0x100000, |
| 662 | bc, |
wdenk | 7d07641 | 2003-05-23 11:38:58 +0000 | [diff] [blame] | 663 | (boot & BOOT_MPS) ? "MPS boot" : "Flash boot", |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 664 | ctfb.modeIdent); |
| 665 | return; |
| 666 | case 1: |
Ben Whitten | 34fd6c9 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 667 | strcpy(buf, CONFIG_IDENT_STRING); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 668 | sprintf (info, " %s", &buf[1]); |
| 669 | return; |
| 670 | } |
| 671 | /* no more info lines */ |
| 672 | *info = 0; |
| 673 | return; |
| 674 | } |
| 675 | #endif /* CONFIG_CONSOLE_EXTRA_INFO */ |
| 676 | |
| 677 | #endif /* CONFIG_VIDEO */ |