diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_ambapp.c | 3 | ||||
-rw-r--r-- | common/cmd_bdinfo.c | 19 | ||||
-rw-r--r-- | common/cmd_bootldr.c | 3 | ||||
-rw-r--r-- | common/cmd_bootm.c | 14 | ||||
-rw-r--r-- | common/cmd_cplbinfo.c | 3 | ||||
-rw-r--r-- | common/cmd_cramfs.c | 4 | ||||
-rw-r--r-- | common/cmd_dataflash_mmc_mux.c | 5 | ||||
-rw-r--r-- | common/cmd_i2c.c | 17 | ||||
-rw-r--r-- | common/cmd_ide.c | 25 | ||||
-rw-r--r-- | common/cmd_license.c | 3 | ||||
-rw-r--r-- | common/cmd_mgdisk.c | 5 | ||||
-rw-r--r-- | common/cmd_mii.c | 2 | ||||
-rw-r--r-- | common/cmd_mmc.c | 7 | ||||
-rw-r--r-- | common/cmd_nand.c | 3 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 20 | ||||
-rw-r--r-- | common/cmd_otp.c | 3 | ||||
-rw-r--r-- | common/cmd_spibootldr.c | 3 | ||||
-rw-r--r-- | common/cmd_strings.c | 3 | ||||
-rw-r--r-- | common/cmd_ubi.c | 3 | ||||
-rw-r--r-- | common/cmd_ubifs.c | 6 | ||||
-rw-r--r-- | common/cmd_usb.c | 2 | ||||
-rw-r--r-- | common/cmd_ximg.c | 3 | ||||
-rw-r--r-- | common/env_nand.c | 2 | ||||
-rw-r--r-- | common/fdt_support.c | 83 | ||||
-rw-r--r-- | common/flash.c | 9 | ||||
-rw-r--r-- | common/image.c | 14 | ||||
-rw-r--r-- | common/main.c | 8 | ||||
-rw-r--r-- | common/miiphyutil.c | 155 | ||||
-rw-r--r-- | common/serial.c | 6 |
29 files changed, 245 insertions, 188 deletions
diff --git a/common/cmd_ambapp.c b/common/cmd_ambapp.c index 283c433376..fa7d7e280f 100644 --- a/common/cmd_ambapp.c +++ b/common/cmd_ambapp.c @@ -272,7 +272,8 @@ int ambapp_init_reloc(void) return 0; } -U_BOOT_CMD(ambapp, 1, 1, do_ambapp_print, +U_BOOT_CMD( + ambapp, 1, 1, do_ambapp_print, "list AMBA Plug&Play information", "ambapp\n" " - lists AMBA (AHB & APB) Plug&Play devices present on the system" diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index fbe73f1b3d..d43867f10b 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -348,6 +348,25 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } +#elif defined(CONFIG_SH) + +int do_bdinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + bd_t *bd = gd->bd; + print_num ("mem start ", (ulong)bd->bi_memstart); + print_lnum ("mem size ", (u64)bd->bi_memsize); + print_num ("flash start ", (ulong)bd->bi_flashstart); + print_num ("flash size ", (ulong)bd->bi_flashsize); + print_num ("flash offset ", (ulong)bd->bi_flashoffset); + +#if defined(CONFIG_CMD_NET) + print_eth(0); + printf ("ip_addr = %pI4\n", &bd->bi_ip_addr); +#endif + printf ("baudrate = %ld bps\n", (ulong)bd->bi_baudrate); + return 0; +} + #else #error "a case for this architecture does not exist!" #endif diff --git a/common/cmd_bootldr.c b/common/cmd_bootldr.c index c7f14d9e45..535b931ff3 100644 --- a/common/cmd_bootldr.c +++ b/common/cmd_bootldr.c @@ -167,7 +167,8 @@ int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(bootldr, 2, 0, do_bootldr, +U_BOOT_CMD( + bootldr, 2, 0, do_bootldr, "boot ldr image from memory", "[addr]\n" "" diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index adfa6cd18a..4c6ed48703 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -333,6 +333,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) ulong image_start = os.image_start; ulong image_len = os.image_len; uint unc_len = CONFIG_SYS_BOOTM_LEN; +#if defined(CONFIG_LZMA) || defined(CONFIG_LZO) + int ret; +#endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */ const char *type_name = genimg_get_type_name (os.type); @@ -386,12 +389,14 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) break; #endif /* CONFIG_BZIP2 */ #ifdef CONFIG_LZMA - case IH_COMP_LZMA: + case IH_COMP_LZMA: { + SizeT lzma_len = unc_len; printf (" Uncompressing %s ... ", type_name); - int ret = lzmaBuffToBuffDecompress( - (unsigned char *)load, &unc_len, + ret = lzmaBuffToBuffDecompress( + (unsigned char *)load, &lzma_len, (unsigned char *)image_start, image_len); + unc_len = lzma_len; if (ret != SZ_OK) { printf ("LZMA: uncompress or overwrite error %d " "- must RESET board to recover\n", ret); @@ -400,12 +405,13 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) } *load_end = load + unc_len; break; + } #endif /* CONFIG_LZMA */ #ifdef CONFIG_LZO case IH_COMP_LZO: printf (" Uncompressing %s ... ", type_name); - int ret = lzop_decompress((const unsigned char *)image_start, + ret = lzop_decompress((const unsigned char *)image_start, image_len, (unsigned char *)load, &unc_len); if (ret != LZO_E_OK) { diff --git a/common/cmd_cplbinfo.c b/common/cmd_cplbinfo.c index fc6abffe6e..ab5b3b5876 100644 --- a/common/cmd_cplbinfo.c +++ b/common/cmd_cplbinfo.c @@ -53,7 +53,8 @@ int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(cplbinfo, 1, 0, do_cplbinfo, +U_BOOT_CMD( + cplbinfo, 1, 0, do_cplbinfo, "display current CPLB tables", "" ); diff --git a/common/cmd_cramfs.c b/common/cmd_cramfs.c index ab10450a4c..8c86dc5bf1 100644 --- a/common/cmd_cramfs.c +++ b/common/cmd_cramfs.c @@ -199,14 +199,14 @@ int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /***************************************************/ U_BOOT_CMD( cramfsload, 3, 0, do_cramfs_load, - "cramfsload\t- load binary file from a filesystem image", + "load binary file from a filesystem image", "[ off ] [ filename ]\n" " - load binary file from address 'cramfsaddr'\n" " with offset 'off'\n" ); U_BOOT_CMD( cramfsls, 2, 1, do_cramfs_ls, - "cramfsls\t- list files in a directory (default /)", + "list files in a directory (default /)", "[ directory ]\n" " - list files in a directory.\n" ); diff --git a/common/cmd_dataflash_mmc_mux.c b/common/cmd_dataflash_mmc_mux.c index de4e676157..1678d6e466 100644 --- a/common/cmd_dataflash_mmc_mux.c +++ b/common/cmd_dataflash_mmc_mux.c @@ -41,8 +41,7 @@ int do_dataflash_mmc_mux (cmd_tbl_t *cmdtp, int flag, int argc, char * const arg AT91F_GetMuxStatus () ? "MMC" : "SPI"); return 0; default: - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; + return cmd_usage(cmdtp); } return 0; } @@ -59,7 +58,7 @@ static int mmc_nspi (const char *s) U_BOOT_CMD( dataflash_mmc_mux, 2, 1, do_dataflash_mmc_mux, - "dataflash_mmc_mux\t- enable or disable MMC or SPI\n", + "enable or disable MMC or SPI\n", "[mmc, spi]\n" " - enable or disable MMC or SPI" ); diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 371e022f79..1283c82afb 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -152,7 +152,7 @@ int i2c_set_bus_speed(unsigned int) /* * get_alen: small parser helper function to get address length - * returns the address length,or 0 on error + * returns the address length */ static uint get_alen(char *arg) { @@ -163,9 +163,6 @@ static uint get_alen(char *arg) for (j = 0; j < 8; j++) { if (arg[j] == '.') { alen = arg[j+1] - '0'; - if (alen > 3) { - return 0; - } break; } else if (arg[j] == '\0') break; @@ -198,7 +195,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv */ devaddr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); /* @@ -255,7 +252,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] */ addr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); /* @@ -337,7 +334,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] */ addr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); /* @@ -399,7 +396,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] */ addr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); /* @@ -477,7 +474,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg */ addr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); } @@ -621,7 +618,7 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] */ addr = simple_strtoul(argv[2], NULL, 16); alen = get_alen(argv[2]); - if (alen == 0) + if (alen > 3) return cmd_usage(cmdtp); /* diff --git a/common/cmd_ide.c b/common/cmd_ide.c index c0fb88dbc7..6aeca76784 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -25,6 +25,7 @@ /* * IDE support */ + #include <common.h> #include <config.h> #include <watchdog.h> @@ -45,6 +46,12 @@ #include <mpc5xxx.h> #endif +#ifdef CONFIG_ORION5X +#include <asm/arch/orion5x.h> +#elif defined CONFIG_KIRKWOOD +#include <asm/arch/kirkwood.h> +#endif + #include <ide.h> #include <ata.h> @@ -847,7 +854,7 @@ input_swap_data(int dev, ulong *sect_buf, int words) #endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */ -#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) +#if defined(CONFIG_IDE_SWAP_IO) static void output_data(int dev, ulong *sect_buf, int words) { @@ -891,15 +898,15 @@ output_data(int dev, ulong *sect_buf, int words) } #endif } -#else /* ! __PPC__ */ +#else /* ! CONFIG_IDE_SWAP_IO */ static void output_data(int dev, ulong *sect_buf, int words) { outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1); } -#endif /* __PPC__ */ +#endif /* CONFIG_IDE_SWAP_IO */ -#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) +#if defined(CONFIG_IDE_SWAP_IO) static void input_data(int dev, ulong *sect_buf, int words) { @@ -949,14 +956,14 @@ input_data(int dev, ulong *sect_buf, int words) } #endif } -#else /* ! __PPC__ */ +#else /* ! CONFIG_IDE_SWAP_IO */ static void input_data(int dev, ulong *sect_buf, int words) { insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1); } -#endif /* __PPC__ */ +#endif /* CONFIG_IDE_SWAP_IO */ /* ------------------------------------------------------------------------- */ @@ -1573,7 +1580,7 @@ int ide_device_present(int dev) * ATAPI Support */ -#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) +#if defined(CONFIG_IDE_SWAP_IO) /* since ATAPI may use commands with not 4 bytes alligned length * we have our own transfer functions, 2 bytes alligned */ static void @@ -1640,7 +1647,7 @@ input_data_shorts(int dev, ushort *sect_buf, int shorts) #endif } -#else /* ! __PPC__ */ +#else /* ! CONFIG_IDE_SWAP_IO */ static void output_data_shorts(int dev, ushort *sect_buf, int shorts) { @@ -1653,7 +1660,7 @@ input_data_shorts(int dev, ushort *sect_buf, int shorts) insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, shorts); } -#endif /* __PPC__ */ +#endif /* CONFIG_IDE_SWAP_IO */ /* * Wait until (Status & mask) == res, or timeout (in ms) diff --git a/common/cmd_license.c b/common/cmd_license.c index 90fd57e25d..70645d5ed2 100644 --- a/common/cmd_license.c +++ b/common/cmd_license.c @@ -49,7 +49,8 @@ int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(license, 1, 1, do_license, +U_BOOT_CMD( + license, 1, 1, do_license, "print GPL license text", "" ); diff --git a/common/cmd_mgdisk.c b/common/cmd_mgdisk.c index c2d5217703..d99af2d265 100644 --- a/common/cmd_mgdisk.c +++ b/common/cmd_mgdisk.c @@ -54,15 +54,14 @@ int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; break; default: - printf("Usage:\n%s\n", cmdtp->usage); - return 1; + return cmd_usage(cmdtp); } return 0; } U_BOOT_CMD( mgd, 5, 0, do_mg_disk_cmd, - "mgd - mgine m[g]flash command\n", + "mgine m[g]flash command\n", ": mgine mflash IO mode (disk) command\n" " - initialize : mgd init\n" " - random read : mgd read [from] [to] [size]\n" diff --git a/common/cmd_mii.c b/common/cmd_mii.c index bb941862db..3ea493ba49 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -299,7 +299,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) unsigned char addr, reg; unsigned short data; int rcode = 0; - char *devname; + const char *devname; if (argc < 2) return cmd_usage(cmdtp); diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index e5f5e944da..c0b30d8b86 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -130,8 +130,11 @@ int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(mmcinfo, 2, 0, do_mmcinfo, - "mmcinfo <dev num>-- display MMC info", +U_BOOT_CMD( + mmcinfo, 2, 0, do_mmcinfo, + "display MMC info", + "<dev num>\n" + " - device number of the device to dislay info of\n" "" ); diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 0f47a258ce..3f1d077ff7 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -579,7 +579,8 @@ usage: return cmd_usage(cmdtp); } -U_BOOT_CMD(nand, CONFIG_SYS_MAXARGS, 1, do_nand, +U_BOOT_CMD( + nand, CONFIG_SYS_MAXARGS, 1, do_nand, "NAND sub-system", "info - show available NAND devices\n" "nand device [dev] - show or set current device\n" diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 1198954bb5..fd5320d170 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -543,7 +543,7 @@ char *getenv (char *name) return (NULL); } -int getenv_r (char *name, char *buf, unsigned len) +int getenv_f(char *name, char *buf, unsigned len) { int i, nxt; @@ -557,13 +557,19 @@ int getenv_r (char *name, char *buf, unsigned len) } if ((val=envmatch((uchar *)name, i)) < 0) continue; + /* found; copy out */ - n = 0; - while ((len > n++) && (*buf++ = env_get_char(val++)) != '\0') - ; - if (len == n) - *buf = '\0'; - return (n); + for (n=0; n<len; ++n, ++buf) { + if ((*buf = env_get_char(val++)) == '\0') + return n; + } + + if (n) + *--buf = '\0'; + + printf("env_buf too small [%d]\n", len); + + return n; } return (-1); } diff --git a/common/cmd_otp.c b/common/cmd_otp.c index 43f7c69f78..56f08e0c05 100644 --- a/common/cmd_otp.c +++ b/common/cmd_otp.c @@ -223,7 +223,8 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return ret; } -U_BOOT_CMD(otp, 7, 0, do_otp, +U_BOOT_CMD( + otp, 7, 0, do_otp, "One-Time-Programmable sub-system", "read <addr> <page> [count] [half]\n" " - read 'count' half-pages starting at 'page' (offset 'half') to 'addr'\n" diff --git a/common/cmd_spibootldr.c b/common/cmd_spibootldr.c index 68aa618320..ca76dde1dd 100644 --- a/common/cmd_spibootldr.c +++ b/common/cmd_spibootldr.c @@ -30,7 +30,8 @@ int do_spibootldr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return bfrom_SpiBoot(addr, BFLAG_PERIPHERAL | 4, 0, NULL); } -U_BOOT_CMD(spibootldr, 2, 0, do_spibootldr, +U_BOOT_CMD( + spibootldr, 2, 0, do_spibootldr, "boot ldr image from spi", "[offset]\n" " - boot ldr image stored at offset into spi\n"); diff --git a/common/cmd_strings.c b/common/cmd_strings.c index 144a6c18d7..2986324bc0 100644 --- a/common/cmd_strings.c +++ b/common/cmd_strings.c @@ -38,7 +38,8 @@ int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(strings, 3, 1, do_strings, +U_BOOT_CMD( + strings, 3, 1, do_strings, "display strings", "<addr> [byte count]\n" " - display strings at <addr> for at least [byte count] or first double NUL" diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 77ca0a5f2e..7692ac7716 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -598,7 +598,8 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return -1; } -U_BOOT_CMD(ubi, 6, 1, do_ubi, +U_BOOT_CMD( + ubi, 6, 1, do_ubi, "ubi commands", "part [part] [offset]\n" " - Show or set current partition (with optional VID" diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c index 2cab793e6c..a0ec184486 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -131,13 +131,15 @@ U_BOOT_CMD( " - mount 'volume-name' volume" ); -U_BOOT_CMD(ubifsls, 2, 0, do_ubifs_ls, +U_BOOT_CMD( + ubifsls, 2, 0, do_ubifs_ls, "list files in a directory", "[directory]\n" " - list files in a 'directory' (default '/')" ); -U_BOOT_CMD(ubifsload, 4, 0, do_ubifs_load, +U_BOOT_CMD( + ubifsload, 4, 0, do_ubifs_load, "load file from an UBIFS filesystem", "<addr> <filename> [bytes]\n" " - load file 'filename' to address 'addr'" diff --git a/common/cmd_usb.c b/common/cmd_usb.c index dc63f244da..226ea0dacf 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -712,7 +712,7 @@ U_BOOT_CMD( "usb part [dev] - print partition table of one or all USB storage" " devices\n" "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n" - " to memory address `addr'" + " to memory address `addr'\n" "usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'\n" " from memory address `addr'" ); diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index 8a2cf835d8..dceb975498 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -262,7 +262,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 0; } -U_BOOT_CMD(imxtract, 4, 1, do_imgextract, +U_BOOT_CMD( + imxtract, 4, 1, do_imgextract, "extract a part of a multi-image", "addr part [dest]\n" " - extract <part> from legacy image at <addr> and copy to <dest>" diff --git a/common/env_nand.c b/common/env_nand.c index a5e1038315..d38bcca1b8 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -266,6 +266,8 @@ int readenv (size_t offset, u_char * buf) u_char *char_ptr; blocksize = nand_info[0].erasesize; + if (!blocksize) + return 1; len = min(blocksize, CONFIG_ENV_SIZE); while (amount_loaded < CONFIG_ENV_SIZE && offset < end) { diff --git a/common/fdt_support.c b/common/fdt_support.c index 718b635d99..aef4fe23e0 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -498,11 +498,12 @@ int fdt_resize(void *blob) /* * Calculate the actual size of the fdt - * plus the size needed for two fdt_add_mem_rsv, one - * for the fdt itself and one for a possible initrd + * plus the size needed for 5 fdt_add_mem_rsv, one + * for the fdt itself and 4 for a possible initrd + * ((initrd-start + initrd-end) * 2 (name & value)) */ actualsize = fdt_off_dt_strings(blob) + - fdt_size_dt_strings(blob) + 2*sizeof(struct fdt_reserve_entry); + fdt_size_dt_strings(blob) + 5 * sizeof(struct fdt_reserve_entry); /* Make it so the fdt ends on a page boundary */ actualsize = ALIGN(actualsize + ((uint)blob & 0xfff), 0x1000); @@ -873,35 +874,6 @@ static inline u64 of_read_number(const __be32 *cell, int size) return r; } -static int of_n_cells(const void *blob, int nodeoffset, const char *name) -{ - int np; - const int *ip; - - do { - np = fdt_parent_offset(blob, nodeoffset); - - if (np >= 0) - nodeoffset = np; - ip = (int *)fdt_getprop(blob, nodeoffset, name, NULL); - if (ip) - return be32_to_cpup(ip); - } while (np >= 0); - - /* No #<NAME>-cells property for the root node */ - return 1; -} - -int of_n_addr_cells(const void *blob, int nodeoffset) -{ - return of_n_cells(blob, nodeoffset, "#address-cells"); -} - -int of_n_size_cells(const void *blob, int nodeoffset) -{ - return of_n_cells(blob, nodeoffset, "#size-cells"); -} - #define PRu64 "%llx" /* Max address size we deal with */ @@ -927,7 +899,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na) { } struct of_bus { const char *name; const char *addresses; - void (*count_cells)(void *blob, int offset, + void (*count_cells)(void *blob, int parentoffset, int *addrc, int *sizec); u64 (*map)(u32 *addr, const u32 *range, int na, int ns, int pna); @@ -935,13 +907,26 @@ struct of_bus { }; /* Default translator (generic bus) */ -static void of_bus_default_count_cells(void *blob, int offset, +static void of_bus_default_count_cells(void *blob, int parentoffset, int *addrc, int *sizec) { - if (addrc) - *addrc = of_n_addr_cells(blob, offset); - if (sizec) - *sizec = of_n_size_cells(blob, offset); + const u32 *prop; + + if (addrc) { + prop = fdt_getprop(blob, parentoffset, "#address-cells", NULL); + if (prop) + *addrc = be32_to_cpup(prop); + else + *addrc = 2; + } + + if (sizec) { + prop = fdt_getprop(blob, parentoffset, "#size-cells", NULL); + if (prop) + *sizec = be32_to_cpup(prop); + else + *sizec = 1; + } } static u64 of_bus_default_map(u32 *addr, const u32 *range, @@ -1067,7 +1052,7 @@ u64 __of_translate_address(void *blob, int node_offset, const u32 *in_addr, bus = &of_busses[0]; /* Cound address cells & copy address locally */ - bus->count_cells(blob, node_offset, &na, &ns); + bus->count_cells(blob, parent, &na, &ns); if (!OF_CHECK_COUNTS(na, ns)) { printf("%s: Bad cell count for %s\n", __FUNCTION__, fdt_get_name(blob, node_offset, NULL)); @@ -1094,7 +1079,7 @@ u64 __of_translate_address(void *blob, int node_offset, const u32 *in_addr, /* Get new parent bus and counts */ pbus = &of_busses[0]; - pbus->count_cells(blob, node_offset, &pna, &pns); + pbus->count_cells(blob, parent, &pna, &pns); if (!OF_CHECK_COUNTS(pna, pns)) { printf("%s: Bad cell count for %s\n", __FUNCTION__, fdt_get_name(blob, node_offset, NULL)); @@ -1151,4 +1136,22 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat, return -FDT_ERR_NOTFOUND; } +/** + * fdt_alloc_phandle: Return next free phandle value + * + * @blob: ptr to device tree + */ +int fdt_alloc_phandle(void *blob) +{ + int offset, len, phandle = 0; + const u32 *val; + for (offset = fdt_next_node(blob, -1, NULL); offset >= 0; + offset = fdt_next_node(blob, offset, NULL)) { + val = fdt_getprop(blob, offset, "linux,phandle", &len); + if (val) + phandle = max(*val, phandle); + } + + return phandle + 1; +} diff --git a/common/flash.c b/common/flash.c index eb4b2f5ff1..683978e473 100644 --- a/common/flash.c +++ b/common/flash.c @@ -43,15 +43,18 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ void flash_protect (int flag, ulong from, ulong to, flash_info_t *info) { - ulong b_end = info->start[0] + info->size - 1; /* bank end address */ - short s_end = info->sector_count - 1; /* index of last sector */ + ulong b_end; + short s_end; int i; /* Do nothing if input data is bad. */ - if (info->sector_count == 0 || info->size == 0 || to < from) { + if (!info || info->sector_count == 0 || info->size == 0 || to < from) { return; } + s_end = info->sector_count - 1; /* index of last sector */ + b_end = info->start[0] + info->size - 1; /* bank end address */ + debug ("flash_protect %s: from 0x%08lX to 0x%08lX\n", (flag & FLAG_PROTECT_SET) ? "ON" : (flag & FLAG_PROTECT_CLEAR) ? "OFF" : "???", diff --git a/common/image.c b/common/image.c index 6d8833e814..fcb938b08e 100644 --- a/common/image.c +++ b/common/image.c @@ -433,17 +433,23 @@ ulong getenv_bootm_low(void) phys_size_t getenv_bootm_size(void) { + phys_size_t tmp; char *s = getenv ("bootm_size"); if (s) { - phys_size_t tmp; tmp = (phys_size_t)simple_strtoull (s, NULL, 16); return tmp; } + s = getenv("bootm_low"); + if (s) + tmp = (phys_size_t)simple_strtoull (s, NULL, 16); + else + tmp = 0; + #if defined(CONFIG_ARM) - return gd->bd->bi_dram[0].size; + return gd->bd->bi_dram[0].size - tmp; #else - return gd->bd->bi_memsize; + return gd->bd->bi_memsize - tmp; #endif } @@ -1178,6 +1184,7 @@ static int fit_check_fdt (const void *fit, int fdt_noffset, int verify) * 0 - success * 1 - failure */ +#if defined(CONFIG_SYS_BOOTMAPSZ) int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, char **of_flat_tree, ulong *of_size) { @@ -1257,6 +1264,7 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, error: return 1; } +#endif /* CONFIG_SYS_BOOTMAPSZ */ /** * boot_get_fdt - main fdt handling routine diff --git a/common/main.c b/common/main.c index 54ef79e264..8d548dbc85 100644 --- a/common/main.c +++ b/common/main.c @@ -643,12 +643,10 @@ static void cread_print_hist_list(void) #define ERASE_TO_EOL() { \ if (num < eol_num) { \ - int tmp; \ - for (tmp = num; tmp < eol_num; tmp++) \ - getcmd_putch(' '); \ - while (tmp-- > num) \ + printf("%*s", (int)(eol_num - num), ""); \ + do { \ getcmd_putch(CTL_BACKSPACE); \ - eol_num = num; \ + } while (--eol_num > num); \ } \ } diff --git a/common/miiphyutil.c b/common/miiphyutil.c index 4b186dd28c..9cf845f605 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -46,21 +46,45 @@ struct mii_dev { struct list_head link; - char *name; - int (*read) (char *devname, unsigned char addr, + const char *name; + int (*read) (const char *devname, unsigned char addr, unsigned char reg, unsigned short *value); - int (*write) (char *devname, unsigned char addr, + int (*write) (const char *devname, unsigned char addr, unsigned char reg, unsigned short value); }; static struct list_head mii_devs; static struct mii_dev *current_mii; +/* + * Lookup the mii_dev struct by the registered device name. + */ +static struct mii_dev *miiphy_get_dev_by_name(const char *devname, int quiet) +{ + struct list_head *entry; + struct mii_dev *dev; + + if (!devname) { + printf("NULL device name!\n"); + return NULL; + } + + list_for_each(entry, &mii_devs) { + dev = list_entry(entry, struct mii_dev, link); + if (strcmp(dev->name, devname) == 0) + return dev; + } + + if (!quiet) + printf("No such device: %s\n", devname); + return NULL; +} + /***************************************************************************** * * Initialize global data. Need to be called before any other miiphy routine. */ -void miiphy_init () +void miiphy_init(void) { INIT_LIST_HEAD (&mii_devs); current_mii = NULL; @@ -70,25 +94,21 @@ void miiphy_init () * * Register read and write MII access routines for the device <name>. */ -void miiphy_register (char *name, - int (*read) (char *devname, unsigned char addr, +void miiphy_register(const char *name, + int (*read) (const char *devname, unsigned char addr, unsigned char reg, unsigned short *value), - int (*write) (char *devname, unsigned char addr, + int (*write) (const char *devname, unsigned char addr, unsigned char reg, unsigned short value)) { - struct list_head *entry; struct mii_dev *new_dev; - struct mii_dev *miidev; unsigned int name_len; + char *new_name; /* check if we have unique name */ - list_for_each (entry, &mii_devs) { - miidev = list_entry (entry, struct mii_dev, link); - if (strcmp (miidev->name, name) == 0) { - printf ("miiphy_register: non unique device name " - "'%s'\n", name); - return; - } + new_dev = miiphy_get_dev_by_name(name, 1); + if (new_dev) { + printf("miiphy_register: non unique device name '%s'\n", name); + return; } /* allocate memory */ @@ -107,9 +127,9 @@ void miiphy_register (char *name, INIT_LIST_HEAD (&new_dev->link); new_dev->read = read; new_dev->write = write; - new_dev->name = (char *)(new_dev + 1); - strncpy (new_dev->name, name, name_len); - new_dev->name[name_len] = '\0'; + new_dev->name = new_name = (char *)(new_dev + 1); + strncpy (new_name, name, name_len); + new_name[name_len] = '\0'; debug ("miiphy_register: added '%s', read=0x%08lx, write=0x%08lx\n", new_dev->name, new_dev->read, new_dev->write); @@ -121,25 +141,20 @@ void miiphy_register (char *name, current_mii = new_dev; } -int miiphy_set_current_dev (char *devname) +int miiphy_set_current_dev(const char *devname) { - struct list_head *entry; struct mii_dev *dev; - list_for_each (entry, &mii_devs) { - dev = list_entry (entry, struct mii_dev, link); - - if (strcmp (devname, dev->name) == 0) { - current_mii = dev; - return 0; - } + dev = miiphy_get_dev_by_name(devname, 0); + if (dev) { + current_mii = dev; + return 0; } - printf ("No such device: %s\n", devname); return 1; } -char *miiphy_get_current_dev () +const char *miiphy_get_current_dev(void) { if (current_mii) return current_mii->name; @@ -147,6 +162,20 @@ char *miiphy_get_current_dev () return NULL; } +static struct mii_dev *miiphy_get_active_dev(const char *devname) +{ + /* If the current mii is the one we want, return it */ + if (current_mii) + if (strcmp(current_mii->name, devname) == 0) + return current_mii; + + /* Otherwise, set the active one to the one we want */ + if (miiphy_set_current_dev(devname)) + return NULL; + else + return current_mii; +} + /***************************************************************************** * * Read to variable <value> from the PHY attached to device <devname>, @@ -155,33 +184,16 @@ char *miiphy_get_current_dev () * Returns: * 0 on success */ -int miiphy_read (char *devname, unsigned char addr, unsigned char reg, +int miiphy_read(const char *devname, unsigned char addr, unsigned char reg, unsigned short *value) { - struct list_head *entry; struct mii_dev *dev; - int found_dev = 0; - int read_ret = 0; - - if (!devname) { - printf ("NULL device name!\n"); - return 1; - } - - list_for_each (entry, &mii_devs) { - dev = list_entry (entry, struct mii_dev, link); - - if (strcmp (devname, dev->name) == 0) { - found_dev = 1; - read_ret = dev->read (devname, addr, reg, value); - break; - } - } - if (found_dev == 0) - printf ("No such device: %s\n", devname); + dev = miiphy_get_active_dev(devname); + if (dev) + return dev->read(devname, addr, reg, value); - return ((found_dev) ? read_ret : 1); + return 1; } /***************************************************************************** @@ -192,33 +204,16 @@ int miiphy_read (char *devname, unsigned char addr, unsigned char reg, * Returns: * 0 on success */ -int miiphy_write (char *devname, unsigned char addr, unsigned char reg, +int miiphy_write(const char *devname, unsigned char addr, unsigned char reg, unsigned short value) { - struct list_head *entry; struct mii_dev *dev; - int found_dev = 0; - int write_ret = 0; - - if (!devname) { - printf ("NULL device name!\n"); - return 1; - } - - list_for_each (entry, &mii_devs) { - dev = list_entry (entry, struct mii_dev, link); - - if (strcmp (devname, dev->name) == 0) { - found_dev = 1; - write_ret = dev->write (devname, addr, reg, value); - break; - } - } - if (found_dev == 0) - printf ("No such device: %s\n", devname); + dev = miiphy_get_active_dev(devname); + if (dev) + return dev->write(devname, addr, reg, value); - return ((found_dev) ? write_ret : 1); + return 1; } /***************************************************************************** @@ -252,7 +247,7 @@ void miiphy_listdev (void) * Returns: * 0 on success */ -int miiphy_info (char *devname, unsigned char addr, unsigned int *oui, +int miiphy_info(const char *devname, unsigned char addr, unsigned int *oui, unsigned char *model, unsigned char *rev) { unsigned int reg = 0; @@ -290,7 +285,7 @@ int miiphy_info (char *devname, unsigned char addr, unsigned int *oui, * Returns: * 0 on success */ -int miiphy_reset (char *devname, unsigned char addr) +int miiphy_reset(const char *devname, unsigned char addr) { unsigned short reg; int timeout = 500; @@ -332,7 +327,7 @@ int miiphy_reset (char *devname, unsigned char addr) * * Determine the ethernet speed (10/100/1000). Return 10 on error. */ -int miiphy_speed (char *devname, unsigned char addr) +int miiphy_speed(const char *devname, unsigned char addr) { u16 bmcr, anlpar; @@ -386,7 +381,7 @@ miiphy_read_failed: * * Determine full/half duplex. Return half on error. */ -int miiphy_duplex (char *devname, unsigned char addr) +int miiphy_duplex(const char *devname, unsigned char addr) { u16 bmcr, anlpar; @@ -446,7 +441,7 @@ miiphy_read_failed: * Return 1 if PHY supports 1000BASE-X, 0 if PHY supports 10BASE-T/100BASE-TX/ * 1000BASE-T, or on error. */ -int miiphy_is_1000base_x (char *devname, unsigned char addr) +int miiphy_is_1000base_x(const char *devname, unsigned char addr) { #if defined(CONFIG_PHY_GIGE) u16 exsr; @@ -467,7 +462,7 @@ int miiphy_is_1000base_x (char *devname, unsigned char addr) * * Determine link status */ -int miiphy_link (char *devname, unsigned char addr) +int miiphy_link(const char *devname, unsigned char addr) { unsigned short reg; diff --git a/common/serial.c b/common/serial.c index 9e5759ecf5..1345c08aef 100644 --- a/common/serial.c +++ b/common/serial.c @@ -40,9 +40,9 @@ struct serial_device *__default_serial_console (void) return &serial_scc_device; #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \ || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \ - || defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC83xx) \ - || defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) \ - || defined(CONFIG_SYS_SC520) + || defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) \ + || defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) \ + || defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) #if defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL) #if (CONFIG_CONS_INDEX==1) return &eserial1_device; |