diff options
Diffstat (limited to 'common')
75 files changed, 1114 insertions, 720 deletions
diff --git a/common/cmd_ambapp.c b/common/cmd_ambapp.c index 43427bb..06531f1 100644 --- a/common/cmd_ambapp.c +++ b/common/cmd_ambapp.c @@ -273,6 +273,6 @@ int ambapp_init_reloc(void) } U_BOOT_CMD(ambapp, 1, 1, do_ambapp_print, - "ambapp - list AMBA Plug&Play information\n", + "list AMBA Plug&Play information", "ambapp\n" " - lists AMBA (AHB & APB) Plug&Play devices present on the system\n"); diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c index 4517ac8..e5a9bc0 100644 --- a/common/cmd_autoscript.c +++ b/common/cmd_autoscript.c @@ -230,7 +230,7 @@ do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( autoscr, 2, 0, do_autoscript, - "autoscr - run script from memory\n", + "run script from memory", "[addr] - run script starting at addr" " - A valid autoscr header must be present\n" #if defined(CONFIG_FIT) diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index b660d2a..8e9251d 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -444,6 +444,6 @@ static void print_str(const char *name, const char *str) U_BOOT_CMD( bdinfo, 1, 1, do_bdinfo, - "bdinfo - print Board Info structure\n", + "print Board Info structure", NULL ); diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c index e6277c9..cd9e720 100644 --- a/common/cmd_bedbug.c +++ b/common/cmd_bedbug.c @@ -85,7 +85,7 @@ int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) len = dis_last_len; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -107,7 +107,7 @@ int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_dis */ U_BOOT_CMD (ds, 3, 1, do_bedbug_dis, - "ds - disassemble memory\n", + "disassemble memory", "ds <address> [# instructions]\n"); /* ====================================================================== @@ -126,7 +126,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int rcode = 0; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -160,7 +160,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_asm */ U_BOOT_CMD (as, 2, 0, do_bedbug_asm, - "as - assemble memory\n", "as <address>\n"); + "assemble memory", "as <address>\n"); /* ====================================================================== * Used to set a break point from the interpreter. Simply calls into the @@ -177,7 +177,7 @@ int do_bedbug_break (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_break */ U_BOOT_CMD (break, 3, 0, do_bedbug_break, - "break - set or clear a breakpoint\n", + "set or clear a breakpoint", " - Set or clear a breakpoint\n" "break <address> - Break at an address\n" "break off <bp#> - Disable breakpoint.\n" @@ -277,7 +277,7 @@ int do_bedbug_continue (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_continue */ U_BOOT_CMD (continue, 1, 0, do_bedbug_continue, - "continue- continue from a breakpoint\n", + "continue from a breakpoint", " - continue from a breakpoint.\n"); /* ====================================================================== @@ -308,7 +308,7 @@ int do_bedbug_step (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_step */ U_BOOT_CMD (step, 1, 1, do_bedbug_step, - "step - single step execution.\n", + "single step execution.", " - single step execution.\n"); /* ====================================================================== @@ -339,7 +339,7 @@ int do_bedbug_next (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_next */ U_BOOT_CMD (next, 1, 1, do_bedbug_next, - "next - single step execution, stepping over subroutines.\n", + "single step execution, stepping over subroutines.", " - single step execution, stepping over subroutines.\n"); /* ====================================================================== @@ -384,7 +384,7 @@ int do_bedbug_stack (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_stack */ U_BOOT_CMD (where, 1, 1, do_bedbug_stack, - "where - Print the running stack.\n", + "Print the running stack.", " - Print the running stack.\n"); /* ====================================================================== @@ -405,7 +405,7 @@ int do_bedbug_rdump (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* do_bedbug_rdump */ U_BOOT_CMD (rdump, 1, 1, do_bedbug_rdump, - "rdump - Show registers.\n", " - Show registers.\n"); + "Show registers.", " - Show registers.\n"); /* ====================================================================== */ diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index bc08b26..abbb070 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -120,7 +120,7 @@ int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) y = simple_strtoul(argv[4], NULL, 10); break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -132,14 +132,14 @@ int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else if (strncmp(argv[1],"display",1) == 0) { return (bmp_display(addr, x, y)); } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } } U_BOOT_CMD( bmp, 5, 1, do_bmp, - "bmp - manipulate BMP image data\n", + "manipulate BMP image data", "info <imageAddr> - display image info\n" "bmp display <imageAddr> [x y] - display image at x,y\n" ); diff --git a/common/cmd_boot.c b/common/cmd_boot.c index 6024ffe..efc1a02 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -41,7 +41,7 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int rcode = 0; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -64,7 +64,7 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( go, CONFIG_SYS_MAXARGS, 1, do_go, - "go - start application at address 'addr'\n", + "start application at address 'addr'", "addr [arg ...]\n - start application at address 'addr'\n" " passing 'arg' as arguments\n" ); @@ -73,6 +73,6 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( reset, 1, 0, do_reset, - "reset - Perform RESET of the CPU\n", + "Perform RESET of the CPU", NULL ); diff --git a/common/cmd_bootldr.c b/common/cmd_bootldr.c index e6474aa..48d113f 100644 --- a/common/cmd_bootldr.c +++ b/common/cmd_bootldr.c @@ -16,6 +16,125 @@ #include <asm/blackfin.h> #include <asm/mach-common/bits/bootrom.h> +/* Simple sanity check on the specified address to make sure it contains + * an LDR image of some sort. + */ +static bool ldr_valid_signature(uint8_t *data) +{ +#if defined(__ADSPBF561__) + + /* BF56x has a 4 byte global header */ + if (data[3] == 0xA0) + return true; + +#elif defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \ + defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) || \ + defined(__ADSPBF538__) || defined(__ADSPBF539__) + + /* all the BF53x should start at this address mask */ + uint32_t addr; + memmove(&addr, data, sizeof(addr)); + if ((addr & 0xFF0FFF0F) == 0xFF000000) + return true; +#else + + /* everything newer has a magic byte */ + uint32_t count; + memmove(&count, data + 8, sizeof(count)); + if (data[3] == 0xAD && count == 0) + return true; + +#endif + + return false; +} + +/* If the Blackfin is new enough, the Blackfin on-chip ROM supports loading + * LDRs from random memory addresses. So whenever possible, use that. In + * the older cases (BF53x/BF561), parse the LDR format ourselves. + */ +#define ZEROFILL 0x0001 +#define RESVECT 0x0002 +#define INIT 0x0008 +#define IGNORE 0x0010 +#define FINAL 0x8000 +static void ldr_load(uint8_t *base_addr) +{ +#if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \ + /*defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) ||*/\ + defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__) + + uint32_t addr; + uint32_t count; + uint16_t flags; + + /* the bf56x has a 4 byte global header ... but it is useless to + * us when booting an LDR from a memory address, so skip it + */ +# ifdef __ADSPBF561__ + base_addr += 4; +# endif + + memmove(&flags, base_addr + 8, sizeof(flags)); + bfin_write_EVT1(flags & RESVECT ? 0xFFA00000 : 0xFFA08000); + + do { + /* block header may not be aligned */ + memmove(&addr, base_addr, sizeof(addr)); + memmove(&count, base_addr+4, sizeof(count)); + memmove(&flags, base_addr+8, sizeof(flags)); + base_addr += sizeof(addr) + sizeof(count) + sizeof(flags); + + printf("loading to 0x%08x (0x%x bytes) flags: 0x%04x\n", + addr, count, flags); + + if (!(flags & IGNORE)) { + if (flags & ZEROFILL) + memset((void *)addr, 0x00, count); + else + memcpy((void *)addr, base_addr, count); + + if (flags & INIT) { + void (*init)(void) = (void *)addr; + init(); + } + } + + if (!(flags & ZEROFILL)) + base_addr += count; + } while (!(flags & FINAL)); + +#endif +} + +/* For BF537, we use the _BOOTROM_BOOT_DXE_FLASH funky ROM function. + * For all other BF53x/BF56x, we just call the entry point. + * For everything else (newer), we use _BOOTROM_MEMBOOT ROM function. + */ +static void ldr_exec(void *addr) +{ +#if defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) + + /* restore EVT1 to reset value as this is what the bootrom uses as + * the default entry point when booting the final block of LDRs + */ + bfin_write_EVT1(L1_INST_SRAM); + __asm__("call (%0);" : : "a"(_BOOTROM_MEMBOOT), "q7"(addr) : "RETS", "memory"); + +#elif defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \ + defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__) + + void (*ldr_entry)(void) = (void *)bfin_read_EVT1(); + ldr_entry(); + +#else + + int32_t (*BOOTROM_MEM)(void *, int32_t, int32_t, void *) = (void *)_BOOTROM_MEMBOOT; + BOOTROM_MEM(addr, 0, 0, NULL); + +#endif +} + /* * the bootldr command loads an address, checks to see if there * is a Boot stream that the on-chip BOOTROM can understand, @@ -23,11 +142,9 @@ * to also add booting from SPI, or TWI, but this function does * not currently support that. */ - int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { void *addr; - uint32_t *data; /* Get the address */ if (argc < 2) @@ -36,22 +153,14 @@ int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) addr = (void *)simple_strtoul(argv[1], NULL, 16); /* Check if it is a LDR file */ - data = addr; -#if defined(__ADSPBF54x__) || defined(__ADSPBF52x__) - if ((*data & 0xFF000000) == 0xAD000000 && data[2] == 0x00000000) { -#else - if (*data == 0xFF800060 || *data == 0xFF800040 || *data == 0xFF800020) { -#endif - /* We want to boot from FLASH or SDRAM */ + if (ldr_valid_signature(addr)) { printf("## Booting ldr image at 0x%p ...\n", addr); + ldr_load(addr); icache_disable(); dcache_disable(); - __asm__( - "jump (%1);" - : - : "q7" (addr), "a" (_BOOTROM_MEMBOOT)); + ldr_exec(addr); } else printf("## No ldr image at address 0x%p\n", addr); @@ -59,6 +168,6 @@ int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(bootldr, 2, 0, do_bootldr, - "bootldr - boot ldr image from memory\n", + "boot ldr image from memory", "[addr]\n" " - boot ldr image stored in memory\n"); diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index a8f85e9..07f6c6b 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -350,7 +350,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) printf (" Uncompressing %s ... ", type_name); if (gunzip ((void *)load, unc_len, (uchar *)image_start, &image_len) != 0) { - puts ("GUNZIP: uncompress or overwrite error " + puts ("GUNZIP: uncompress, out-of-mem or overwrite error " "- must RESET board to recover\n"); if (boot_progress) show_boot_progress (-6); @@ -454,13 +454,13 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } /* Unrecognized command */ else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } if (images.state >= state) { printf ("Trying to execute a command out of order\n"); - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -913,7 +913,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] U_BOOT_CMD( bootm, CONFIG_SYS_MAXARGS, 1, do_bootm, - "bootm - boot application image from memory\n", + "boot application image from memory", "[addr [arg ...]]\n - boot application image stored in memory\n" "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n" "\t'arg' can be the address of an initrd image\n" @@ -970,14 +970,14 @@ int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( boot, 1, 1, do_bootd, - "boot - boot default, i.e., run 'bootcmd'\n", + "boot default, i.e., run 'bootcmd'", NULL ); /* keep old command name "bootd" for backward compatibility */ U_BOOT_CMD( bootd, 1, 1, do_bootd, - "bootd - boot default, i.e., run 'bootcmd'\n", + "boot default, i.e., run 'bootcmd'", NULL ); @@ -1062,7 +1062,7 @@ static int image_info (ulong addr) U_BOOT_CMD( iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo, - "iminfo - print header information for application image\n", + "print header information for application image", "addr [addr ...]\n" " - print header information for application image starting at\n" " address 'addr' in memory; this includes verification of the\n" @@ -1130,7 +1130,7 @@ next_bank: ; U_BOOT_CMD( imls, 1, 1, do_imls, - "imls - list all images found in flash\n", + "list all images found in flash", "\n" " - Prints information about all images found at sector\n" " boundaries in flash.\n" diff --git a/common/cmd_cache.c b/common/cmd_cache.c index 675d43f..c0f2cba 100644 --- a/common/cmd_cache.c +++ b/common/cmd_cache.c @@ -37,7 +37,7 @@ int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) case 2: /* on / off */ switch (on_off(argv[1])) { #if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */ - default: printf ("Usage:\n%s\n", cmdtp->usage); + default: cmd_usage(cmdtp); return; #endif case 0: icache_disable(); @@ -51,7 +51,7 @@ int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) icache_status() ? "ON" : "OFF"); return 0; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } return 0; @@ -63,7 +63,7 @@ int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) case 2: /* on / off */ switch (on_off(argv[1])) { #if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */ - default: printf ("Usage:\n%s\n", cmdtp->usage); + default: cmd_usage(cmdtp); return; #endif case 0: dcache_disable(); @@ -77,7 +77,7 @@ int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dcache_status() ? "ON" : "OFF"); return 0; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } return 0; @@ -97,14 +97,14 @@ static int on_off (const char *s) U_BOOT_CMD( icache, 2, 1, do_icache, - "icache - enable or disable instruction cache\n", + "enable or disable instruction cache", "[on, off]\n" " - enable or disable instruction cache\n" ); U_BOOT_CMD( dcache, 2, 1, do_dcache, - "dcache - enable or disable data cache\n", + "enable or disable data cache", "[on, off]\n" " - enable or disable data (writethrough) cache\n" ); diff --git a/common/cmd_console.c b/common/cmd_console.c index e2bc2a3..f861f83 100644 --- a/common/cmd_console.c +++ b/common/cmd_console.c @@ -65,6 +65,6 @@ int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[]) U_BOOT_CMD( coninfo, 3, 1, do_coninfo, - "coninfo - print console devices and information\n", + "print console devices and information", "" ); diff --git a/common/cmd_cplbinfo.c b/common/cmd_cplbinfo.c index b2bbec1..56e70d6 100644 --- a/common/cmd_cplbinfo.c +++ b/common/cmd_cplbinfo.c @@ -26,11 +26,11 @@ static const char *cplb_page_size(uint32_t data) */ static void show_cplb_table(uint32_t *addr, uint32_t *data) { - size_t i; + int i; printf(" Address Data Size Valid Locked\n"); for (i = 1; i <= 16; ++i) { printf(" %2i 0x%p 0x%05X %s %c %c\n", - i, *addr, *data, + i, (void *)*addr, *data, cplb_page_size(*data), (*data & CPLB_VALID ? 'Y' : 'N'), (*data & CPLB_LOCK ? 'Y' : 'N')); @@ -54,6 +54,6 @@ int do_cplbinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(cplbinfo, 1, 0, do_cplbinfo, - "cplbinfo- display current CPLB tables\n", + "display current CPLB tables", "\n" " - display current CPLB tables\n"); diff --git a/common/cmd_date.c b/common/cmd_date.c index b4d9649..3d78be2 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -89,7 +89,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rcode = 1; } @@ -214,7 +214,7 @@ int mk_date (char *datestr, struct rtc_time *tmp) U_BOOT_CMD( date, 2, 1, do_date, - "date - get/set/reset date & time\n", + "get/set/reset date & time", "[MMDDhhmm[[CC]YY][.ss]]\ndate reset\n" " - without arguments: print date & time\n" " - with numeric argument: set the system date & time\n" diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c index 439d07a..7aed06c 100644 --- a/common/cmd_dcr.c +++ b/common/cmd_dcr.c @@ -45,7 +45,7 @@ int do_getdcr ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ) /* Validate arguments */ if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -74,7 +74,7 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /* Validate arguments */ if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -121,7 +121,7 @@ int do_getidcr (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* Validate arguments */ if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -177,7 +177,7 @@ int do_setidcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /* Validate arguments */ if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -223,23 +223,23 @@ int do_setidcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( getdcr, 2, 1, do_getdcr, - "getdcr - Get an AMCC PPC 4xx DCR's value\n", + "Get an AMCC PPC 4xx DCR's value", "dcrn - return a DCR's value.\n" ); U_BOOT_CMD( setdcr, 2, 1, do_setdcr, - "setdcr - Set an AMCC PPC 4xx DCR's value\n", + "Set an AMCC PPC 4xx DCR's value", "dcrn - set a DCR's value.\n" ); U_BOOT_CMD( getidcr, 3, 1, do_getidcr, - "getidcr - Get a register value via indirect DCR addressing\n", + "Get a register value via indirect DCR addressing", "adr_dcrn[.dat_dcrn] offset - write offset to adr_dcrn, read value from dat_dcrn.\n" ); U_BOOT_CMD( setidcr, 4, 1, do_setidcr, - "setidcr - Set a register value via indirect DCR addressing\n", + "Set a register value via indirect DCR addressing", "adr_dcrn[.dat_dcrn] offset value - write offset to adr_dcrn, write value to dat_dcrn.\n" ); diff --git a/common/cmd_df.c b/common/cmd_df.c index 5f65044..d64f900 100644 --- a/common/cmd_df.c +++ b/common/cmd_df.c @@ -27,11 +27,11 @@ static int do_df(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } usage: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } U_BOOT_CMD( sf, 2, 1, do_serial_flash, - "sf - Serial flash sub-system\n", + "Serial flash sub-system", "probe [bus:]cs - init flash device on given SPI bus and CS\n") diff --git a/common/cmd_diag.c b/common/cmd_diag.c index 13d4225..c2a6175 100644 --- a/common/cmd_diag.c +++ b/common/cmd_diag.c @@ -66,7 +66,7 @@ int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( diag, CONFIG_SYS_MAXARGS, 0, do_diag, - "diag - perform board diagnostics\n", + "perform board diagnostics", " - print list of available tests\n" "diag [test1 [test2]]\n" " - print information about specified tests\n" diff --git a/common/cmd_display.c b/common/cmd_display.c index 982e09d..4102424 100644 --- a/common/cmd_display.c +++ b/common/cmd_display.c @@ -71,7 +71,7 @@ int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( display, CONFIG_SYS_MAXARGS, 1, do_display, - "display- display string on dot matrix display\n", + "display string on dot matrix display", "[<string>]\n" " - with <string> argument: display <string> on dot matrix display\n" " - without arguments: clear dot matrix display\n" diff --git a/common/cmd_doc.c b/common/cmd_doc.c index 02502cc..e2d4a42 100644 --- a/common/cmd_doc.c +++ b/common/cmd_doc.c @@ -96,7 +96,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 0: case 1: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: if (strcmp(argv[1],"info") == 0) { @@ -121,7 +121,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) doc_print(&doc_dev_desc[curr_device]); return 0; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strcmp(argv[1],"device") == 0) { @@ -146,7 +146,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -182,7 +182,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return ret; } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rcode = 1; } @@ -191,7 +191,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD( doc, 5, 1, do_doc, - "doc - Disk-On-Chip sub-system\n", + "Disk-On-Chip sub-system", "info - show available DOC devices\n" "doc device [dev] - show or set current device\n" "doc read addr off size\n" @@ -235,7 +235,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) offset = simple_strtoul(argv[3], NULL, 16); break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); show_boot_progress (-35); return 1; } @@ -337,7 +337,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( docboot, 4, 1, do_docboot, - "docboot - boot from DOC device\n", + "boot from DOC device", "loadAddr dev\n" ); diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c index c5b1d4d..7783c88 100644 --- a/common/cmd_dtt.c +++ b/common/cmd_dtt.c @@ -55,6 +55,6 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( dtt, 1, 1, do_dtt, - "dtt - Digital Thermometer and Thermostat\n", + "Digital Thermometer and Thermostat", " - Read temperature from digital thermometer and thermostat.\n" ); diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index 2451bef..e598bf1 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -104,7 +104,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } #endif @@ -425,7 +425,7 @@ void eeprom_init (void) #ifdef CONFIG_SYS_I2C_MULTI_EEPROMS U_BOOT_CMD( eeprom, 6, 1, do_eeprom, - "eeprom - EEPROM sub-system\n", + "EEPROM sub-system", "read devaddr addr off cnt\n" "eeprom write devaddr addr off cnt\n" " - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'\n" @@ -433,7 +433,7 @@ U_BOOT_CMD( #else /* One EEPROM */ U_BOOT_CMD( eeprom, 5, 1, do_eeprom, - "eeprom - EEPROM sub-system\n", + "EEPROM sub-system", "read addr off cnt\n" "eeprom write addr off cnt\n" " - read/write `cnt' bytes at EEPROM offset `off'\n" diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 27a4b73..19e1249 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -310,12 +310,12 @@ unsigned long load_elf_image (unsigned long addr) /* ====================================================================== */ U_BOOT_CMD( bootelf, 2, 0, do_bootelf, - "bootelf - Boot from an ELF image in memory\n", + "Boot from an ELF image in memory", " [address] - load address of ELF image.\n" ); U_BOOT_CMD( bootvx, 2, 0, do_bootvx, - "bootvx - Boot vxWorks from an ELF image\n", + "Boot vxWorks from an ELF image", " [address] - load address of vxWorks ELF image.\n" ); diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index 9c43792..c2dcc64 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -66,7 +66,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int part_length; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return(1); } dev = (int)simple_strtoul (argv[2], &ep, 16); @@ -116,7 +116,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( ext2ls, 4, 1, do_ext2ls, - "ext2ls - list files in a directory (default /)\n", + "list files in a directory (default /)", "<interface> <dev[:part]> [directory]\n" " - list files from 'dev' on 'interface' in a 'directory'\n" ); @@ -164,7 +164,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return(1); } @@ -252,7 +252,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( ext2load, 6, 0, do_ext2load, - "ext2load- load binary file from a Ext2 filesystem\n", + "load binary file from a Ext2 filesystem", "<interface> <dev[:part]> [addr] [filename] [bytes]\n" " - load binary file 'filename' from 'dev' on 'interface'\n" " to address 'addr' from ext2 filesystem\n" diff --git a/common/cmd_fat.c b/common/cmd_fat.c index ebe9e09..4a26b80 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -88,7 +88,7 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( fatload, 6, 0, do_fat_fsload, - "fatload - load binary file from a dos filesystem\n", + "load binary file from a dos filesystem", "<interface> <dev[:part]> <addr> <filename> [bytes]\n" " - load binary file 'filename' from 'dev' on 'interface'\n" " to address 'addr' from dos filesystem\n" @@ -136,7 +136,7 @@ int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( fatls, 4, 1, do_fat_ls, - "fatls - list files in a directory (default /)\n", + "list files in a directory (default /)", "<interface> <dev[:part]> [directory]\n" " - list files from 'dev' on 'interface' in a 'directory'\n" ); @@ -174,7 +174,7 @@ int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( fatinfo, 3, 1, do_fat_fsinfo, - "fatinfo - print information about filesystem\n", + "print information about filesystem", "<interface> <dev[:part]>\n" " - print information about filesystem from 'dev' on 'interface'\n" ); diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index d995ff2..c043b97 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -801,7 +801,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_drive=simple_strtoul(argv[2], NULL, 10); break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } /* setup FDC and scan for drives */ @@ -902,7 +902,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( fdcboot, 3, 1, do_fdcboot, - "fdcboot - boot from floppy device\n", + "boot from floppy device", "loadAddr drive\n" ); #endif diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c index aa13b52..bcf98d9 100644 --- a/common/cmd_fdos.c +++ b/common/cmd_fdos.c @@ -73,7 +73,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) name = argv [2]; break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); break; } @@ -142,12 +142,12 @@ int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( fdosboot, 3, 0, do_fdosboot, - "fdosboot- boot from a dos floppy file\n", + "boot from a dos floppy file", "[loadAddr] [filename]\n" ); U_BOOT_CMD( fdosls, 2, 0, do_fdosls, - "fdosls - list files in a directory\n", + "list files in a directory", "[directory]\n" ); diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 4274a77..0947b72 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -66,7 +66,7 @@ void set_working_fdt_addr(void *addr) int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -125,7 +125,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int err; if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -179,7 +179,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * Parameters: Node path, new node to be appended to the path. */ if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -217,7 +217,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * Parameters: Node path, property, optional value. */ if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -427,7 +427,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } } else { /* Unrecognized command */ - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } } @@ -441,7 +441,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) unsigned long initrd_start = 0, initrd_end = 0; if ((argc != 2) && (argc != 4)) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -459,7 +459,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else { /* Unrecognized command */ - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -819,7 +819,7 @@ static int fdt_print(const char *pathp, char *prop, int depth) U_BOOT_CMD( fdt, 255, 0, do_fdt, - "fdt - flattened device tree utility commands\n", + "flattened device tree utility commands", "addr <addr> [<length>] - Set the fdt location to <addr>\n" #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 93eefa9..510654e 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -333,7 +333,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int rcode = 0; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -384,7 +384,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif if (argc != 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -407,7 +407,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (addr_first >= addr_last) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -481,7 +481,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -490,7 +490,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else if (strcmp(argv[1], "on") == 0) { p = 1; } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -591,7 +591,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif if (argc != 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -633,7 +633,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (addr_first >= addr_last) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } rcode = flash_sect_protect (p, addr_first, addr_last); @@ -710,14 +710,14 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last) U_BOOT_CMD( flinfo, 2, 1, do_flinfo, - "flinfo - print FLASH memory information\n", + "print FLASH memory information", "\n - print information for all FLASH memory banks\n" "flinfo N\n - print information for FLASH memory bank # N\n" ); U_BOOT_CMD( erase, 3, 0, do_flerase, - "erase - erase FLASH memory\n", + "erase FLASH memory", "start end\n" " - erase FLASH from addr 'start' to addr 'end'\n" "erase start +len\n" @@ -731,7 +731,7 @@ U_BOOT_CMD( U_BOOT_CMD( protect, 4, 0, do_protect, - "protect - enable or disable FLASH write protection\n", + "enable or disable FLASH write protection", "on start end\n" " - protect FLASH from addr 'start' to addr 'end'\n" "protect on start +len\n" diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index dcbbc99..362bffd 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -320,7 +320,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) static void fpga_usage (cmd_tbl_t * cmdtp) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); } /* @@ -350,7 +350,7 @@ static int fpga_get_op (char *opstr) } U_BOOT_CMD (fpga, 6, 1, do_fpga, - "fpga - loadable FPGA image support\n", + "loadable FPGA image support", "fpga [operation type] [device number] [image address] [image size]\n" "fpga operations:\n" "\tinfo\tlist known device information\n" diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 448f2fe..16439ac 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -159,7 +159,7 @@ int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) length = i2c_dp_last_length; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -184,7 +184,7 @@ int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argv[2][j] == '.') { alen = argv[2][j+1] - '0'; if (alen > 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } break; @@ -269,7 +269,7 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int j; if ((argc < 4) || (argc > 5)) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -287,7 +287,7 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argv[2][j] == '.') { alen = argv[2][j+1] - '0'; if (alen > 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } break; @@ -355,7 +355,7 @@ int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int j; if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -373,7 +373,7 @@ int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argv[2][j] == '.') { alen = argv[2][j+1] - '0'; if (alen > 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } break; @@ -427,7 +427,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) extern char console_buffer[]; if (argc != 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -463,7 +463,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) if (argv[2][j] == '.') { alen = argv[2][j+1] - '0'; if (alen > 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } break; @@ -601,7 +601,7 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int j; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -619,7 +619,7 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argv[2][j] == '.') { alen = argv[2][j+1] - '0'; if (alen > 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } break; @@ -764,7 +764,7 @@ int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) }; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } /* @@ -1293,7 +1293,7 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return do_sdram(cmdtp, flag, --argc, ++argv); #endif else - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 0; } #endif /* CONFIG_I2C_CMD_TREE */ @@ -1303,7 +1303,7 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #if defined(CONFIG_I2C_CMD_TREE) U_BOOT_CMD( i2c, 6, 1, do_i2c, - "i2c - I2C sub-system\n", + "I2C sub-system", #if defined(CONFIG_I2C_MUX) "bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes.\n" #endif /* CONFIG_I2C_MUX */ @@ -1326,37 +1326,37 @@ U_BOOT_CMD( #endif /* CONFIG_I2C_CMD_TREE */ U_BOOT_CMD( imd, 4, 1, do_i2c_md, \ - "imd - i2c memory display\n", \ + "i2c memory display", \ "chip address[.0, .1, .2] [# of objects]\n - i2c memory display\n" \ ); U_BOOT_CMD( imm, 3, 1, do_i2c_mm, - "imm - i2c memory modify (auto-incrementing)\n", + "i2c memory modify (auto-incrementing)", "chip address[.0, .1, .2]\n" " - memory modify, auto increment address\n" ); U_BOOT_CMD( inm, 3, 1, do_i2c_nm, - "inm - memory modify (constant address)\n", + "memory modify (constant address)", "chip address[.0, .1, .2]\n - memory modify, read and keep address\n" ); U_BOOT_CMD( imw, 5, 1, do_i2c_mw, - "imw - memory write (fill)\n", + "memory write (fill)", "chip address[.0, .1, .2] value [count]\n - memory write (fill)\n" ); U_BOOT_CMD( icrc32, 5, 1, do_i2c_crc, - "icrc32 - checksum calculation\n", + "checksum calculation", "chip address[.0, .1, .2] count\n - compute CRC32 checksum\n" ); U_BOOT_CMD( iprobe, 1, 1, do_i2c_probe, - "iprobe - probe to discover valid I2C chip addresses\n", + "probe to discover valid I2C chip addresses", "\n -discover valid I2C chip addresses\n" ); @@ -1365,7 +1365,7 @@ U_BOOT_CMD( */ U_BOOT_CMD( iloop, 5, 1, do_i2c_loop, - "iloop - infinite loop on address range\n", + "infinite loop on address range", "chip address[.0, .1, .2] [# of objects]\n" " - loop, reading a set of addresses\n" ); @@ -1373,7 +1373,7 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_SDRAM) U_BOOT_CMD( isdram, 2, 1, do_sdram, - "isdram - print SDRAM configuration information\n", + "print SDRAM configuration information", "chip\n - print SDRAM configuration information\n" " (valid chip values 50..57)\n" ); diff --git a/common/cmd_ide.c b/common/cmd_ide.c index db05f76..c9b9a47 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -188,7 +188,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 0: case 1: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: if (strncmp(argv[1],"res",3) == 0) { @@ -238,7 +238,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return rcode; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strncmp(argv[1],"dev",3) == 0) { @@ -287,7 +287,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -347,7 +347,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rcode = 1; } @@ -383,7 +383,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_device = argv[2]; break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); show_boot_progress (-42); return 1; } @@ -2140,7 +2140,7 @@ ulong atapi_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer) U_BOOT_CMD( ide, 5, 1, do_ide, - "ide - IDE sub-system\n", + "IDE sub-system", "reset - reset IDE controller\n" "ide info - show available IDE devices\n" "ide device [dev] - show or set current device\n" @@ -2153,6 +2153,6 @@ U_BOOT_CMD( U_BOOT_CMD( diskboot, 3, 1, do_diskboot, - "diskboot- boot from IDE device\n", + "boot from IDE device", "loadAddr dev:part\n" ); diff --git a/common/cmd_immap.c b/common/cmd_immap.c index 13ad94e..c8367f0 100644 --- a/common/cmd_immap.c +++ b/common/cmd_immap.c @@ -614,105 +614,105 @@ do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( siuinfo, 1, 1, do_siuinfo, - "siuinfo - print System Interface Unit (SIU) registers\n", + "print System Interface Unit (SIU) registers", NULL ); U_BOOT_CMD( memcinfo, 1, 1, do_memcinfo, - "memcinfo- print Memory Controller registers\n", + "print Memory Controller registers", NULL ); U_BOOT_CMD( sitinfo, 1, 1, do_sitinfo, - "sitinfo - print System Integration Timers (SIT) registers\n", + "print System Integration Timers (SIT) registers", NULL ); #ifdef CONFIG_8260 U_BOOT_CMD( icinfo, 1, 1, do_icinfo, - "icinfo - print Interrupt Controller registers\n", + "print Interrupt Controller registers", NULL ); #endif U_BOOT_CMD( carinfo, 1, 1, do_carinfo, - "carinfo - print Clocks and Reset registers\n", + "print Clocks and Reset registers", NULL ); U_BOOT_CMD( iopinfo, 1, 1, do_iopinfo, - "iopinfo - print I/O Port registers\n", + "print I/O Port registers", NULL ); U_BOOT_CMD( iopset, 5, 0, do_iopset, - "iopset - set I/O Port registers\n", + "set I/O Port registers", "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1" ); U_BOOT_CMD( dmainfo, 1, 1, do_dmainfo, - "dmainfo - print SDMA/IDMA registers\n", + "print SDMA/IDMA registers", NULL ); U_BOOT_CMD( fccinfo, 1, 1, do_fccinfo, - "fccinfo - print FCC registers\n", + "print FCC registers", NULL ); U_BOOT_CMD( brginfo, 1, 1, do_brginfo, - "brginfo - print Baud Rate Generator (BRG) registers\n", + "print Baud Rate Generator (BRG) registers", NULL ); U_BOOT_CMD( i2cinfo, 1, 1, do_i2cinfo, - "i2cinfo - print I2C registers\n", + "print I2C registers", NULL ); U_BOOT_CMD( sccinfo, 1, 1, do_sccinfo, - "sccinfo - print SCC registers\n", + "print SCC registers", NULL ); U_BOOT_CMD( smcinfo, 1, 1, do_smcinfo, - "smcinfo - print SMC registers\n", + "print SMC registers", NULL ); U_BOOT_CMD( spiinfo, 1, 1, do_spiinfo, - "spiinfo - print Serial Peripheral Interface (SPI) registers\n", + "print Serial Peripheral Interface (SPI) registers", NULL ); U_BOOT_CMD( muxinfo, 1, 1, do_muxinfo, - "muxinfo - print CPM Multiplexing registers\n", + "print CPM Multiplexing registers", NULL ); U_BOOT_CMD( siinfo, 1, 1, do_siinfo, - "siinfo - print Serial Interface (SI) registers\n", + "print Serial Interface (SI) registers", NULL ); U_BOOT_CMD( mccinfo, 1, 1, do_mccinfo, - "mccinfo - print MCC registers\n", + "print MCC registers", NULL ); diff --git a/common/cmd_irq.c b/common/cmd_irq.c index 04914c6..a21aede 100644 --- a/common/cmd_irq.c +++ b/common/cmd_irq.c @@ -28,7 +28,7 @@ int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -44,7 +44,7 @@ int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( interrupts, 5, 0, do_interrupts, - "interrupts - enable or disable interrupts\n", + "enable or disable interrupts", "[on, off]\n" " - enable or disable interrupts\n" ); diff --git a/common/cmd_itest.c b/common/cmd_itest.c index 9e77fa9..309b08b 100644 --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -161,7 +161,7 @@ int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ) /* Validate arguments */ if ((argc != 4)){ - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -190,6 +190,6 @@ int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ) U_BOOT_CMD( itest, 4, 0, do_itest, - "itest\t- return true/false on integer compare\n", + "return true/false on integer compare", "[.b, .w, .l, .s] [*]value1 <op> [*]value2\n" ); diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index 7866c80..d0a7cea 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -1778,6 +1778,96 @@ int mtdparts_init(void) */ /** + * Calculate sector size. + * + * @return sector size + */ +static inline u32 get_part_sector_size_nand(struct mtdids *id) +{ +#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) +#if defined(CONFIG_NAND_LEGACY) + extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE]; + + return nand_dev_desc[id->num].erasesize; +#else + nand_info_t *nand; + + nand = &nand_info[id->num]; + + return nand->erasesize; +#endif +#else + BUG(); + return 0; +#endif +} + +static inline u32 get_part_sector_size_nor(struct mtdids *id, struct part_info *part) +{ +#if defined(CONFIG_CMD_FLASH) + extern flash_info_t flash_info[]; + + u32 end_phys, start_phys, sector_size = 0, size = 0; + int i; + flash_info_t *flash; + + flash = &flash_info[id->num]; + + start_phys = flash->start[0] + part->offset; + end_phys = start_phys + part->size; + + for (i = 0; i < flash->sector_count; i++) { + if (flash->start[i] >= end_phys) + break; + + if (flash->start[i] >= start_phys) { + if (i == flash->sector_count - 1) { + size = flash->start[0] + flash->size - flash->start[i]; + } else { + size = flash->start[i+1] - flash->start[i]; + } + + if (sector_size < size) + sector_size = size; + } + } + + return sector_size; +#else + BUG(); + return 0; +#endif +} + +static inline u32 get_part_sector_size_onenand(void) +{ +#if defined(CONFIG_CMD_ONENAND) + struct mtd_info *mtd; + + mtd = &onenand_mtd; + + return mtd->erasesize; +#else + BUG(); + return 0; +#endif +} + +static inline u32 get_part_sector_size(struct mtdids *id, struct part_info *part) +{ + if (id->type == MTD_DEV_TYPE_NAND) + return get_part_sector_size_nand(id); + else if (id->type == MTD_DEV_TYPE_NOR) + return get_part_sector_size_nor(id, part); + else if (id->type == MTD_DEV_TYPE_ONENAND) + return get_part_sector_size_onenand(); + else + DEBUGF("Error: Unknown device type.\n"); + + return 0; +} + +/** * Parse and initialize global mtdids mapping and create global * device/partition list. * @@ -1846,6 +1936,8 @@ int mtdparts_init(void) part->offset = 0x00000000; #endif + part->sector_size = get_part_sector_size(id, part); + part->dev = current_dev; INIT_LIST_HEAD(&part->link); @@ -2197,7 +2289,7 @@ int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return delete_partition(argv[2]); } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } #endif /* #ifdef CONFIG_JFFS2_CMDLINE */ @@ -2205,35 +2297,35 @@ int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /***************************************************/ U_BOOT_CMD( fsload, 3, 0, do_jffs2_fsload, - "fsload\t- load binary file from a filesystem image\n", + "load binary file from a filesystem image", "[ off ] [ filename ]\n" " - load binary file from flash bank\n" " with offset 'off'\n" ); U_BOOT_CMD( ls, 2, 1, do_jffs2_ls, - "ls\t- list files in a directory (default /)\n", + "list files in a directory (default /)", "[ directory ]\n" " - list files in a directory.\n" ); U_BOOT_CMD( fsinfo, 1, 1, do_jffs2_fsinfo, - "fsinfo\t- print information about filesystems\n", + "print information about filesystems", " - print information about filesystems\n" ); #ifdef CONFIG_JFFS2_CMDLINE U_BOOT_CMD( chpart, 2, 0, do_jffs2_chpart, - "chpart\t- change active partition\n", + "change active partition", "part-id\n" " - change active partition (e.g. part-id = nand0,1)\n" ); U_BOOT_CMD( mtdparts, 6, 0, do_jffs2_mtdparts, - "mtdparts- define flash/nand partitions\n", + "define flash/nand partitions", "\n" " - list partition table\n" "mtdparts delall\n" diff --git a/common/cmd_license.c b/common/cmd_license.c index 301af8d..c3c3496 100644 --- a/common/cmd_license.c +++ b/common/cmd_license.c @@ -53,7 +53,7 @@ int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(license, 1, 1, do_license, - "license - print GPL license text\n", + "print GPL license text", NULL); #endif /* CONFIG_CMD_LICENSE */ diff --git a/common/cmd_load.c b/common/cmd_load.c index 65a4d69..88fba88 100644 --- a/common/cmd_load.c +++ b/common/cmd_load.c @@ -1045,7 +1045,7 @@ static ulong load_serial_ymodem (ulong offset) #ifdef CONFIG_SYS_LOADS_BAUD_CHANGE U_BOOT_CMD( loads, 3, 0, do_load_serial, - "loads - load S-Record file over serial line\n", + "load S-Record file over serial line", "[ off ] [ baud ]\n" " - load S-Record file over serial line" " with offset 'off' and baudrate 'baud'\n" @@ -1054,7 +1054,7 @@ U_BOOT_CMD( #else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ U_BOOT_CMD( loads, 2, 0, do_load_serial, - "loads - load S-Record file over serial line\n", + "load S-Record file over serial line", "[ off ]\n" " - load S-Record file over serial line with offset 'off'\n" ); @@ -1069,7 +1069,7 @@ U_BOOT_CMD( #ifdef CONFIG_SYS_LOADS_BAUD_CHANGE U_BOOT_CMD( saves, 4, 0, do_save_serial, - "saves - save S-Record file over serial line\n", + "save S-Record file over serial line", "[ off ] [size] [ baud ]\n" " - save S-Record file over serial line" " with offset 'off', size 'size' and baudrate 'baud'\n" @@ -1077,7 +1077,7 @@ U_BOOT_CMD( #else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ U_BOOT_CMD( saves, 3, 0, do_save_serial, - "saves - save S-Record file over serial line\n", + "save S-Record file over serial line", "[ off ] [size]\n" " - save S-Record file over serial line with offset 'off' and size 'size'\n" ); @@ -1089,7 +1089,7 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_LOADB) U_BOOT_CMD( loadb, 3, 0, do_load_serial_bin, - "loadb - load binary file over serial line (kermit mode)\n", + "load binary file over serial line (kermit mode)", "[ off ] [ baud ]\n" " - load binary file over serial line" " with offset 'off' and baudrate 'baud'\n" @@ -1097,7 +1097,7 @@ U_BOOT_CMD( U_BOOT_CMD( loady, 3, 0, do_load_serial_bin, - "loady - load binary file over serial line (ymodem mode)\n", + "load binary file over serial line (ymodem mode)", "[ off ] [ baud ]\n" " - load binary file over serial line" " with offset 'off' and baudrate 'baud'\n" @@ -1119,7 +1119,7 @@ int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (strcmp(argv[1], "on") == 0) hwflow_onoff(1); else - printf("Usage: %s\n", cmdtp->usage); + cmd_usage(cmdtp); } printf("RTS/CTS hardware flow control: %s\n", hwflow_onoff(0) ? "on" : "off"); return 0; @@ -1129,7 +1129,7 @@ int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( hwflow, 2, 0, do_hwflow, - "hwflow - turn the harwdare flow control on/off\n", + "turn the harwdare flow control on/off", "[on|off]\n - change RTS/CTS hardware flow control over serial line\n" ); diff --git a/common/cmd_log.c b/common/cmd_log.c index febdb90..a03835d 100644 --- a/common/cmd_log.c +++ b/common/cmd_log.c @@ -241,18 +241,18 @@ int do_log (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return 0; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } } U_BOOT_CMD( log, 255, 1, do_log, - "log - manipulate logbuffer\n", + "manipulate logbuffer", "info - show pointer details\n" "log reset - clear contents\n" "log show - show contents\n" diff --git a/common/cmd_mac.c b/common/cmd_mac.c index 4453299..cf601e4 100644 --- a/common/cmd_mac.c +++ b/common/cmd_mac.c @@ -28,7 +28,7 @@ extern int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( mac, 3, 1, do_mac, - "mac - display and program the system ID and MAC addresses in EEPROM\n", + "display and program the system ID and MAC addresses in EEPROM", "[read|save|id|num|errata|date|ports|0|1|2|3|4|5|6|7]\n" "read\n" " - show content of EEPROM\n" diff --git a/common/cmd_mem.c b/common/cmd_mem.c index c209d62..a203e0d 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -77,7 +77,7 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) length = dp_last_length; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -173,7 +173,7 @@ int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int size; if ((argc < 3) || (argc > 4)) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -217,7 +217,7 @@ int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong count; if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -246,7 +246,7 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong count; if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -277,7 +277,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int rcode = 0; if (argc != 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -361,7 +361,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int size; if (argc != 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -525,7 +525,7 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) volatile u_char *cp; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -596,7 +596,7 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) volatile u_char *cp; if (argc < 4) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -1001,7 +1001,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) extern char console_buffer[]; if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -1106,7 +1106,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong *ptr; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -1142,7 +1142,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argc < 3) { usage: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -1202,7 +1202,7 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dst = simple_strtoul(argv[2], NULL, 16); break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -1214,39 +1214,39 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /**************************************************/ U_BOOT_CMD( md, 3, 1, do_mem_md, - "md - memory display\n", + "memory display", "[.b, .w, .l] address [# of objects]\n - memory display\n" ); U_BOOT_CMD( mm, 2, 1, do_mem_mm, - "mm - memory modify (auto-incrementing)\n", + "memory modify (auto-incrementing)", "[.b, .w, .l] address\n" " - memory modify, auto increment address\n" ); U_BOOT_CMD( nm, 2, 1, do_mem_nm, - "nm - memory modify (constant address)\n", + "memory modify (constant address)", "[.b, .w, .l] address\n - memory modify, read and keep address\n" ); U_BOOT_CMD( mw, 4, 1, do_mem_mw, - "mw - memory write (fill)\n", + "memory write (fill)", "[.b, .w, .l] address value [count]\n - write memory\n" ); U_BOOT_CMD( cp, 4, 1, do_mem_cp, - "cp - memory copy\n", + "memory copy", "[.b, .w, .l] source target count\n - copy memory\n" ); U_BOOT_CMD( cmp, 4, 1, do_mem_cmp, - "cmp - memory compare\n", + "memory compare", "[.b, .w, .l] addr1 addr2 count\n - compare memory\n" ); @@ -1254,7 +1254,7 @@ U_BOOT_CMD( U_BOOT_CMD( crc32, 4, 1, do_mem_crc, - "crc32 - checksum calculation\n", + "checksum calculation", "address count [addr]\n - compute CRC32 checksum [save at addr]\n" ); @@ -1262,7 +1262,7 @@ U_BOOT_CMD( U_BOOT_CMD( crc32, 5, 1, do_mem_crc, - "crc32 - checksum calculation\n", + "checksum calculation", "address count [addr]\n - compute CRC32 checksum [save at addr]\n" "-v address count crc\n - verify crc of memory area\n" ); @@ -1271,14 +1271,14 @@ U_BOOT_CMD( U_BOOT_CMD( base, 2, 1, do_mem_base, - "base - print or set address offset\n", + "print or set address offset", "\n - print address offset for memory commands\n" "base off\n - set address offset for memory commands to 'off'\n" ); U_BOOT_CMD( loop, 3, 1, do_mem_loop, - "loop - infinite loop on address range\n", + "infinite loop on address range", "[.b, .w, .l] address number_of_objects\n" " - loop on a set of addresses\n" ); @@ -1286,7 +1286,7 @@ U_BOOT_CMD( #ifdef CONFIG_LOOPW U_BOOT_CMD( loopw, 4, 1, do_mem_loopw, - "loopw - infinite write loop on address range\n", + "infinite write loop on address range", "[.b, .w, .l] address number_of_objects data_to_write\n" " - loop on a set of addresses\n" ); @@ -1294,7 +1294,7 @@ U_BOOT_CMD( U_BOOT_CMD( mtest, 5, 1, do_mem_mtest, - "mtest - simple RAM test\n", + "simple RAM test", "[start [end [pattern [iterations]]]]\n" " - simple RAM read/write test\n" ); @@ -1302,13 +1302,13 @@ U_BOOT_CMD( #ifdef CONFIG_MX_CYCLIC U_BOOT_CMD( mdc, 4, 1, do_mem_mdc, - "mdc - memory display cyclic\n", + "memory display cyclic", "[.b, .w, .l] address count delay(ms)\n - memory display cyclic\n" ); U_BOOT_CMD( mwc, 4, 1, do_mem_mwc, - "mwc - memory write cyclic\n", + "memory write cyclic", "[.b, .w, .l] address value delay(ms)\n - memory write cyclic\n" ); #endif /* CONFIG_MX_CYCLIC */ @@ -1316,7 +1316,7 @@ U_BOOT_CMD( #ifdef CONFIG_CMD_UNZIP U_BOOT_CMD( unzip, 4, 1, do_unzip, - "unzip - unzip a memory region\n", + "unzip a memory region", "srcaddr dstaddr [dstsize]\n" ); #endif /* CONFIG_CMD_UNZIP */ diff --git a/common/cmd_mfsl.c b/common/cmd_mfsl.c index c2442ee..6470bac 100644 --- a/common/cmd_mfsl.c +++ b/common/cmd_mfsl.c @@ -38,7 +38,7 @@ int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) unsigned int blocking; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -46,7 +46,7 @@ int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16); if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { puts ("Bad number of FSL\n"); - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -196,7 +196,7 @@ int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) unsigned int blocking; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -204,7 +204,7 @@ int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) num = (unsigned int)simple_strtoul (argv[2], NULL, 16); blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16); if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { - printf ("Bad number of FSL\nUsage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -354,7 +354,7 @@ int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) unsigned int val = 0; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } reg = (unsigned int)simple_strtoul (argv[1], NULL, 16); @@ -389,7 +389,7 @@ int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /***************************************************/ U_BOOT_CMD (frd, 3, 1, do_frd, - "frd - read data from FSL\n", + "read data from FSL", "- [fslnum [0|1|2|3]]\n" " 0 - non blocking data read\n" " 1 - non blocking control read\n" @@ -398,7 +398,7 @@ U_BOOT_CMD (frd, 3, 1, do_frd, U_BOOT_CMD (fwr, 4, 1, do_fwr, - "fwr - write data to FSL\n", + "write data to FSL", "- [fslnum [0|1|2|3]]\n" " 0 - non blocking data write\n" " 1 - non blocking control write\n" @@ -406,7 +406,7 @@ U_BOOT_CMD (fwr, 4, 1, do_fwr, " 3 - blocking control write\n"); U_BOOT_CMD (rspr, 3, 1, do_rspr, - "rspr - read/write special purpose register\n", + "read/write special purpose register", "- reg_num [write value] read/write special purpose register\n" " 1 - MSR - Machine status register\n" " 3 - EAR - Exception address register\n" diff --git a/common/cmd_mii.c b/common/cmd_mii.c index bcbd7aa..d70031a 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -302,7 +302,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) char *devname; if (argc < 2) { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -431,7 +431,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) else miiphy_set_current_dev (argv[2]); } else { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -453,7 +453,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( mii, 5, 1, do_mii, - "mii - MII utility commands\n", + "MII utility commands", "device - list available devices\n" "mii device <devname> - set current device\n" "mii info <addr> - display MII PHY info\n" diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 3ea8ee0..024299a 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -33,7 +33,7 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong delay; if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -55,14 +55,14 @@ int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( irqinfo, 1, 1, do_irqinfo, - "irqinfo - print information about IRQs\n", + "print information about IRQs", NULL ); #endif U_BOOT_CMD( sleep , 2, 1, do_sleep, - "sleep - delay execution for some time\n", + "delay execution for some time", "N\n" " - delay execution for N seconds (N is _decimal_ !!!)\n" ); diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 25c9702..473825e 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -36,6 +36,6 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( mmcinit, 1, 0, do_mmc, - "mmcinit - init mmc card\n", + "init mmc card", NULL ); diff --git a/common/cmd_mp.c b/common/cmd_mp.c index f3a7f49..a0839c2 100644 --- a/common/cmd_mp.c +++ b/common/cmd_mp.c @@ -29,7 +29,7 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) unsigned long cpuid; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -47,7 +47,7 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else if (strncmp(argv[2], "status", 6) == 0) { cpu_status(cpuid); } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } return 0; @@ -55,12 +55,12 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* 4 or greater, make sure its release */ if (strncmp(argv[2], "release", 7) != 0) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } if (cpu_release(cpuid, argc - 3, argv + 3)) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -83,7 +83,7 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd, - "cpu - Multiprocessor CPU boot manipulation and release\n", + "Multiprocessor CPU boot manipulation and release", "<num> reset - Reset cpu <num>\n" "cpu <num> status - Status of cpu <num>\n" "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]\n" diff --git a/common/cmd_nand.c b/common/cmd_nand.c index aedf8a6..11f9096 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -463,12 +463,12 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #endif usage: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } U_BOOT_CMD(nand, 5, 1, do_nand, - "nand - NAND sub-system\n", + "NAND sub-system", "info - show available NAND devices\n" "nand device [dev] - show or set current device\n" "nand read - addr off|partition size\n" @@ -638,7 +638,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) usage: #endif - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); show_boot_progress(-53); return 1; } @@ -664,7 +664,7 @@ usage: } U_BOOT_CMD(nboot, 4, 1, do_nandboot, - "nboot - boot from NAND device\n", + "boot from NAND device", "[partition] | [[[loadAddr] dev] offset]\n"); #endif @@ -751,7 +751,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 0: case 1: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: if (strcmp (argv[1], "info") == 0) { @@ -789,7 +789,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 0; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strcmp (argv[1], "device") == 0) { @@ -828,7 +828,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return ret; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -877,7 +877,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } #endif /* CONFIG_SYS_NAND_SKIP_BAD_DOT_I */ else if (cmdtail) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -913,7 +913,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return ret; } else { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rcode = 1; } @@ -923,7 +923,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( nand, 5, 1, do_nand, - "nand - legacy NAND sub-system\n", + "legacy NAND sub-system", "info - show available NAND devices\n" "nand device [dev] - show or set current device\n" "nand read[.jffs2[s]] addr off size\n" @@ -970,7 +970,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) offset = simple_strtoul(argv[3], NULL, 16); break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); show_boot_progress (-53); return 1; } @@ -1072,7 +1072,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( nboot, 4, 1, do_nandboot, - "nboot - boot from NAND device\n", + "boot from NAND device", "loadAddr dev\n" ); diff --git a/common/cmd_net.c b/common/cmd_net.c index c053d7b..a687849 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -39,7 +39,7 @@ int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( bootp, 3, 1, do_bootp, - "bootp\t- boot image via network using BOOTP/TFTP protocol\n", + "boot image via network using BOOTP/TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]\n" ); @@ -50,7 +50,7 @@ int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( tftpboot, 3, 1, do_tftpb, - "tftpboot- boot image via network using TFTP protocol\n", + "boot image via network using TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]\n" ); @@ -61,7 +61,7 @@ int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( rarpboot, 3, 1, do_rarpb, - "rarpboot- boot image via network using RARP/TFTP protocol\n", + "boot image via network using RARP/TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]\n" ); @@ -73,7 +73,7 @@ int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( dhcp, 3, 1, do_dhcp, - "dhcp\t- boot image via network using DHCP/TFTP protocol\n", + "boot image via network using DHCP/TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]\n" ); #endif @@ -86,7 +86,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( nfs, 3, 1, do_nfs, - "nfs\t- boot image via network using NFS protocol\n", + "boot image via network using NFS protocol", "[loadAddress] [[hostIPaddr:]bootfilename]\n" ); #endif @@ -186,7 +186,7 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) break; - default: printf ("Usage:\n%s\n", cmdtp->usage); + default: cmd_usage(cmdtp); show_boot_progress (-80); return 1; } @@ -251,7 +251,7 @@ int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) NetPingIP = string_to_ip(argv[1]); if (NetPingIP == 0) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return -1; } @@ -267,7 +267,7 @@ int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( ping, 2, 1, do_ping, - "ping\t- send ICMP ECHO_REQUEST to network host\n", + "send ICMP ECHO_REQUEST to network host", "pingAddress\n" ); #endif @@ -311,7 +311,7 @@ int do_cdp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( cdp, 1, 1, do_cdp, - "cdp\t- Perform CDP network configuration\n", + "Perform CDP network configuration", ); #endif @@ -348,7 +348,7 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( sntp, 2, 1, do_sntp, - "sntp\t- synchronize RTC via network\n", + "synchronize RTC via network", "[NTP server IP]\n" ); #endif diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 85025da..1fcb4c9 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -408,7 +408,7 @@ void forceenv (char *varname, char *varvalue) int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -434,13 +434,13 @@ int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) local_args[3] = NULL; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } /* Check the syntax */ switch (argc) { case 1: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: /* askenv envname */ @@ -546,11 +546,8 @@ int getenv_r (char *name, char *buf, unsigned len) return (-1); } -#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CONFIG_ENV_IS_NOWHERE)) +#if defined(CONFIG_CMD_ENV) && !defined(CONFIG_ENV_IS_NOWHERE) + int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { extern char * env_name_spec; @@ -560,6 +557,12 @@ int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return (saveenv() ? 1 : 0); } +U_BOOT_CMD( + saveenv, 1, 0, do_saveenv, + "save environment variables to persistent storage", + NULL +); + #endif @@ -587,7 +590,7 @@ int envmatch (uchar *s1, int i2) U_BOOT_CMD( printenv, CONFIG_SYS_MAXARGS, 1, do_printenv, - "printenv- print environment variables\n", + "print environment variables", "\n - print values of all environment variables\n" "printenv name ...\n" " - print value of environment variable 'name'\n" @@ -595,31 +598,18 @@ U_BOOT_CMD( U_BOOT_CMD( setenv, CONFIG_SYS_MAXARGS, 0, do_setenv, - "setenv - set environment variables\n", + "set environment variables", "name value ...\n" " - set environment variable 'name' to 'value ...'\n" "setenv name\n" " - delete environment variable 'name'\n" ); -#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CONFIG_ENV_IS_NOWHERE)) -U_BOOT_CMD( - saveenv, 1, 0, do_saveenv, - "saveenv - save environment variables to persistent storage\n", - NULL -); - -#endif - #if defined(CONFIG_CMD_ASKENV) U_BOOT_CMD( askenv, CONFIG_SYS_MAXARGS, 1, do_askenv, - "askenv - get environment variables from stdin\n", + "get environment variables from stdin", "name [message] [size]\n" " - get environment variable 'name' from stdin (max 'size' chars)\n" "askenv name\n" @@ -636,7 +626,7 @@ U_BOOT_CMD( int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( run, CONFIG_SYS_MAXARGS, 1, do_run, - "run - run commands in an environment variable\n", + "run commands in an environment variable", "var [...]\n" " - run the commands in the environment variable(s) 'var'\n" ); diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index 6a2c924..5832ff8 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -465,13 +465,13 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 0; usage: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } U_BOOT_CMD( onenand, 6, 1, do_onenand, - "onenand - OneNAND sub-system\n", + "OneNAND sub-system", "info - show available OneNAND devices\n" "onenand bad - show bad blocks\n" "onenand read[.oob] addr off size\n" diff --git a/common/cmd_otp.c b/common/cmd_otp.c index 825fa34..6523290 100644 --- a/common/cmd_otp.c +++ b/common/cmd_otp.c @@ -6,7 +6,7 @@ * Licensed under the GPL-2 or later. */ -/* There are 512 128-bit "pages" (0x000 to 0x1FF). +/* There are 512 128-bit "pages" (0x000 through 0x1FF). * The pages are accessable as 64-bit "halfpages" (an upper and lower half). * The pages are not part of the memory map. There is an OTP controller which * handles scanning in/out of bits. While access is done through OTP MMRs, @@ -17,8 +17,6 @@ #include <common.h> #include <command.h> -#ifdef CONFIG_CMD_OTP - #include <asm/blackfin.h> #include <asm/mach-common/bits/otp.h> @@ -40,30 +38,87 @@ static const char *otp_strerror(uint32_t err) #define lowup(x) ((x) % 2 ? "upper" : "lower") -int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +static int check_voltage(void) +{ + /* Make sure voltage limits are within datasheet spec */ + uint16_t vr_ctl = bfin_read_VR_CTL(); + +#ifdef __ADSPBF54x__ + /* 0.9V <= VDDINT <= 1.1V */ + if ((vr_ctl & 0xc) && (vr_ctl & 0xc0) == 0xc0) + return 1; +#else + /* for the parts w/out qualification yet */ + (void)vr_ctl; +#endif + + return 0; +} + +static void set_otp_timing(bool write) { - bool force = false; - if (!strcmp(argv[1], "--force")) { - force = true; - argv[1] = argv[0]; - argv++; - --argc; + static uint32_t timing; + if (!timing) { + uint32_t tp1, tp2, tp3; + /* OTP_TP1 = 1000 / sclk_period (in nanoseconds) + * OTP_TP1 = 1000 / (1 / get_sclk() * 10^9) + * OTP_TP1 = (1000 * get_sclk()) / 10^9 + * OTP_TP1 = get_sclk() / 10^6 + */ + tp1 = get_sclk() / 1000000; + /* OTP_TP2 = 400 / (2 * sclk_period) + * OTP_TP2 = 400 / (2 * 1 / get_sclk() * 10^9) + * OTP_TP2 = (400 * get_sclk()) / (2 * 10^9) + * OTP_TP2 = (2 * get_sclk()) / 10^7 + */ + tp2 = (2 * get_sclk() / 10000000) << 8; + /* OTP_TP3 = magic constant */ + tp3 = (0x1401) << 15; + timing = tp1 | tp2 | tp3; } + bfrom_OtpCommand(OTP_INIT, write ? timing : timing & ~(-1 << 15)); +} + +int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + uint32_t ret, base_flags; + bool prompt_user, force_read; uint32_t (*otp_func)(uint32_t page, uint32_t flags, uint64_t *page_content); - if (!strcmp(argv[1], "read")) - otp_func = otp_read; - else if (!strcmp(argv[1], "write")) - otp_func = otp_write; - else { + + if (argc < 4) { usage: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } + prompt_user = false; + base_flags = 0; + if (!strcmp(argv[1], "read")) + otp_func = bfrom_OtpRead; + else if (!strcmp(argv[1], "dump")) { + otp_func = bfrom_OtpRead; + force_read = true; + } else if (!strcmp(argv[1], "write")) { + otp_func = bfrom_OtpWrite; + base_flags = OTP_CHECK_FOR_PREV_WRITE; + if (!strcmp(argv[2], "--force")) { + argv[2] = argv[1]; + argv++; + --argc; + } else + prompt_user = false; + } else if (!strcmp(argv[1], "lock")) { + if (argc != 4) + goto usage; + otp_func = bfrom_OtpWrite; + base_flags = OTP_LOCK; + } else + goto usage; + uint64_t *addr = (uint64_t *)simple_strtoul(argv[2], NULL, 16); uint32_t page = simple_strtoul(argv[3], NULL, 16); - uint32_t flags, ret; + uint32_t flags; size_t i, count; ulong half; @@ -81,14 +136,21 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else half = 0; + /* "otp lock" has slightly different semantics */ + if (base_flags & OTP_LOCK) { + count = page; + page = (uint32_t)addr; + addr = NULL; + } + /* do to the nature of OTP, make sure users are sure */ - if (!force && otp_func == otp_write) { + if (prompt_user) { printf( "Writing one time programmable memory\n" "Make sure your operating voltages and temperature are within spec\n" " source address: 0x%p\n" - " OTP destination: %s page 0x%03X - %s page 0x%03X\n" - " number to write: %ld halfpages\n" + " OTP destination: %s page 0x%03X - %s page 0x%03lX\n" + " number to write: %lu halfpages\n" " type \"YES\" (no quotes) to confirm: ", addr, lowup(half), page, @@ -111,30 +173,42 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } } } - - /* Only supported in newer silicon ... enable writing */ -#if (0) - otp_command(OTP_INIT, ...); -#else - *pOTP_TIMING = 0x32149485; -#endif } - printf("OTP memory %s: addr 0x%08lx page 0x%03X count %ld ... ", + printf("OTP memory %s: addr 0x%p page 0x%03X count %zu ... ", argv[1], addr, page, count); + set_otp_timing(otp_func == bfrom_OtpWrite); + if (otp_func == bfrom_OtpWrite && check_voltage()) { + puts("ERROR: VDDINT voltage is out of spec for writing\n"); + return -1; + } + + /* Do the actual reading/writing stuff */ ret = 0; for (i = half; i < count + half; ++i) { - flags = (i % 2) ? OTP_UPPER_HALF : OTP_LOWER_HALF; + flags = base_flags | (i % 2 ? OTP_UPPER_HALF : OTP_LOWER_HALF); + try_again: ret = otp_func(page, flags, addr); - if (ret & 0x1) - break; - else if (ret) + if (ret & OTP_MASTER_ERROR) { + if (force_read) { + if (flags & OTP_NO_ECC) + break; + else + flags |= OTP_NO_ECC; + puts("E"); + goto try_again; + } else + break; + } else if (ret) puts("W"); else puts("."); - ++addr; - if (i % 2) + if (!(base_flags & OTP_LOCK)) { + ++addr; + if (i % 2) + ++page; + } else ++page; } if (ret & 0x1) @@ -143,21 +217,20 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) else puts(" done\n"); - if (otp_func == otp_write) - /* Only supported in newer silicon ... disable writing */ -#if (0) - otp_command(OTP_INIT, ...); -#else - *pOTP_TIMING = 0x1485; -#endif + /* Make sure we disable writing */ + set_otp_timing(false); + bfrom_OtpCommand(OTP_CLOSE, 0); return ret; } -U_BOOT_CMD(otp, 6, 0, do_otp, - "otp - One-Time-Programmable sub-system\n", +U_BOOT_CMD(otp, 7, 0, do_otp, + "One-Time-Programmable sub-system\n", "read <addr> <page> [count] [half]\n" + " - read 'count' half-pages starting at 'page' (offset 'half') to 'addr'\n" + "otp dump <addr> <page> [count] [half]\n" + " - like 'otp read', but skip read errors\n" "otp write [--force] <addr> <page> [count] [half]\n" - " - read/write 'count' half-pages starting at page 'page' (offset 'half')\n"); - -#endif + " - write 'count' half-pages starting at 'page' (offset 'half') from 'addr'\n" + "otp lock <page> <count>\n" + " - lock 'count' pages starting at 'page'\n"); diff --git a/common/cmd_pci.c b/common/cmd_pci.c index 67ff2fb..4a9317f 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -534,7 +534,7 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; usage: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -543,7 +543,7 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( pci, 5, 1, do_pci, - "pci - list and access PCI Configuration Space\n", + "list and access PCI Configuration Space", "[bus] [long]\n" " - short or long list of PCI devices on bus 'bus'\n" "pci header b.d.f\n" diff --git a/common/cmd_pcmcia.c b/common/cmd_pcmcia.c index 23fad3b..e448456 100644 --- a/common/cmd_pcmcia.c +++ b/common/cmd_pcmcia.c @@ -88,7 +88,7 @@ int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( pinit, 2, 0, do_pinit, - "pinit - PCMCIA sub-system\n", + "PCMCIA sub-system", "on - power on PCMCIA socket\n" "pinit off - power off PCMCIA socket\n" ); diff --git a/common/cmd_portio.c b/common/cmd_portio.c index c88fcd5..41b1991 100644 --- a/common/cmd_portio.c +++ b/common/cmd_portio.c @@ -44,7 +44,7 @@ int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) uint value = out_last_value; if (argc != 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -93,7 +93,7 @@ int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( out, 3, 1, do_portio_out, - "out - write datum to IO port\n", + "write datum to IO port", "[.b, .w, .l] port value\n - output to IO port\n" ); @@ -103,7 +103,7 @@ int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) uint size = in_last_size; if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -157,7 +157,7 @@ int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( in, 2, 1, do_portio_in, - "in - read data from an IO port\n", + "read data from an IO port", "[.b, .w, .l] port\n" " - read datum from IO port\n" ); diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c index 4c8e61a..0e28c05 100644 --- a/common/cmd_reginfo.c +++ b/common/cmd_reginfo.c @@ -382,6 +382,6 @@ int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #if defined(CONFIG_CMD_REGINFO) U_BOOT_CMD( reginfo, 2, 1, do_reginfo, - "reginfo - print register information\n", + "print register information", ); #endif diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c index 4f4117e..14e4bd4 100644 --- a/common/cmd_reiser.c +++ b/common/cmd_reiser.c @@ -57,7 +57,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int part_length; if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } dev = (int)simple_strtoul (argv[2], &ep, 16); @@ -102,7 +102,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( reiserls, 4, 1, do_reiserls, - "reiserls- list files in a directory (default /)\n", + "list files in a directory (default /)", "<interface> <dev[:part]> [directory]\n" " - list files from 'dev' on 'interface' in a 'directory'\n" ); @@ -150,7 +150,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -232,7 +232,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( reiserload, 6, 0, do_reiserload, - "reiserload- load binary file from a Reiser filesystem\n", + "load binary file from a Reiser filesystem", "<interface> <dev[:part]> [addr] [filename] [bytes]\n" " - load binary file 'filename' from 'dev' on 'interface'\n" " to address 'addr' from dos filesystem\n" diff --git a/common/cmd_sata.c b/common/cmd_sata.c index dd6f1d9..e849778 100644 --- a/common/cmd_sata.c +++ b/common/cmd_sata.c @@ -31,7 +31,7 @@ int curr_device = -1; block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; -int sata_initialize(void) +int __sata_initialize(void) { int rc; int i; @@ -55,6 +55,7 @@ int sata_initialize(void) curr_device = 0; return rc; } +int sata_initialize(void) __attribute__((weak,alias("__sata_initialize"))); block_dev_desc_t *sata_get_dev(int dev) { @@ -65,10 +66,18 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int rc = 0; + if (argc == 2 && strcmp(argv[1], "init") == 0) + return sata_initialize(); + + /* If the user has not yet run `sata init`, do it now */ + if (curr_device == -1) + if (sata_initialize()) + return 1; + switch (argc) { case 0: case 1: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: if (strncmp(argv[1],"inf", 3) == 0) { @@ -106,7 +115,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return rc; } - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strncmp(argv[1], "dev", 3) == 0) { @@ -138,7 +147,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return rc; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -175,7 +184,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) n, (n == cnt) ? "OK" : "ERROR"); return (n == cnt) ? 0 : 1; } else { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rc = 1; } @@ -185,7 +194,8 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( sata, 5, 1, do_sata, - "sata - SATA sub system\n", + "SATA sub system", + "sata init - init SATA sub system\n" "sata info - show available SATA devices\n" "sata device [dev] - show or set current device\n" "sata part [dev] - print partition table\n" diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index 066fd80..dd2c1ae 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -229,7 +229,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_device = argv[2]; break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -346,7 +346,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { switch (argc) { case 0: - case 1: printf ("Usage:\n%s\n", cmdtp->usage); return 1; + case 1: cmd_usage(cmdtp); return 1; case 2: if (strncmp(argv[1],"res",3) == 0) { printf("\nReset SCSI\n"); @@ -392,7 +392,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf("\nno SCSI devices available\n"); return 1; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strncmp(argv[1],"dev",3) == 0) { @@ -421,7 +421,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return 1; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -437,7 +437,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } } /* switch */ - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -616,7 +616,7 @@ void scsi_setup_inquiry(ccb * pccb) U_BOOT_CMD( scsi, 5, 1, do_scsi, - "scsi - SCSI sub-system\n", + "SCSI sub-system", "reset - reset SCSI controller\n" "scsi info - show available SCSI devices\n" "scsi scan - (re-)scan SCSI bus\n" @@ -628,6 +628,6 @@ U_BOOT_CMD( U_BOOT_CMD( scsiboot, 3, 1, do_scsiboot, - "scsiboot- boot from SCSI device\n", + "boot from SCSI device", "loadAddr dev:part\n" ); diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c index 2e49b6d..9a5e720 100644 --- a/common/cmd_setexpr.c +++ b/common/cmd_setexpr.c @@ -35,7 +35,7 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* Validate arguments */ if ((argc != 5) || (strlen(argv[3]) != 1)) { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -63,7 +63,7 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( setexpr, 5, 0, do_setexpr, - "setexpr - set environment variable as the result of eval expression\n", + "set environment variable as the result of eval expression", "name value1 <op> value2\n" " - set environment variable 'name' to the result of the evaluated\n" " express specified by <op>. <op> can be &, |, ^, +, -, *, /, %\n" diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 8c0a751..6a60b16 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -175,13 +175,13 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return do_spi_flash_erase(argc - 1, argv + 1); usage: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } U_BOOT_CMD( sf, 5, 1, do_spi_flash, - "sf - SPI flash sub-system\n", + "SPI flash sub-system", "probe [bus:]cs [hz] [mode] - init flash device on given SPI bus\n" " and chip select\n" "sf read addr offset len - read `len' bytes starting at\n" diff --git a/common/cmd_spi.c b/common/cmd_spi.c index 1f0727b..746d14f 100644 --- a/common/cmd_spi.c +++ b/common/cmd_spi.c @@ -138,7 +138,7 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( sspi, 5, 1, do_spi, - "sspi - SPI utility commands\n", + "SPI utility commands", "<device> <bit_len> <dout> - Send <bit_len> bits from <dout> out the SPI\n" "<device> - Identifies the chip select of the device\n" "<bit_len> - Number of bits to send (base 10)\n" diff --git a/common/cmd_strings.c b/common/cmd_strings.c index 7d05cf8..4517ba2 100644 --- a/common/cmd_strings.c +++ b/common/cmd_strings.c @@ -15,7 +15,7 @@ static char *start_addr, *last_addr; int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { if (argc == 1) { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -41,6 +41,6 @@ int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(strings, 3, 1, do_strings, - "strings - display strings\n", + "display strings", "<addr> [byte count]\n" " - display strings at <addr> for at least [byte count] or first double NUL\n"); diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c index 67a2546..fd3dd48 100644 --- a/common/cmd_terminal.c +++ b/common/cmd_terminal.c @@ -87,6 +87,6 @@ int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[]) U_BOOT_CMD( terminal, 3, 1, do_terminal, - "terminal - start terminal emulator\n", + "start terminal emulator", "" ); diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 5c31f7b..b99fd58 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -441,7 +441,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int err = 0; if (argc < 2) { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -459,7 +459,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } if (argc < 4) { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -600,7 +600,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(ubi, 6, 1, do_ubi, - "ubi - ubi commands\n", + "ubi commands", "part [nand|nor|onenand] [part]" " - Show or set current partition\n" "ubi info [l[ayout]]" diff --git a/common/cmd_universe.c b/common/cmd_universe.c index ea97782..bfb91b5 100644 --- a/common/cmd_universe.c +++ b/common/cmd_universe.c @@ -364,7 +364,7 @@ int do_universe(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( universe, 8, 1, do_universe, - "universe- initialize and configure Turndra Universe\n", + "initialize and configure Turndra Universe", "init\n" " - initialize universe\n" "universe vme [vme_addr] [pci_addr] [size] [vam] [pms]\n" diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 8b19240..a18e16e 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -264,6 +264,16 @@ void usb_display_config(struct usb_device *dev) printf("\n"); } +static inline char *portspeed(int speed) +{ + if (speed == USB_SPEED_HIGH) + return "480 Mb/s"; + else if (speed == USB_SPEED_LOW) + return "1.5 Mb/s"; + else + return "12 Mb/s"; +} + /* shows the device tree recursively */ void usb_show_tree_graph(struct usb_device *dev, char *pre) { @@ -310,7 +320,7 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre) pre[index] = 0; printf(" %s (%s, %dmA)\n", usb_get_class_desc( dev->config.if_desc[0].bInterfaceClass), - dev->slow ? "1.5MBit/s" : "12MBit/s", + portspeed(dev->speed), dev->config.MaxPower * 2); if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial)) printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial); @@ -366,7 +376,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_device = argv[2]; break; default: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -659,14 +669,14 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } #endif /* CONFIG_USB_STORAGE */ - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } #ifdef CONFIG_USB_STORAGE U_BOOT_CMD( usb, 5, 1, do_usb, - "usb - USB sub-system\n", + "USB sub-system", "reset - reset (rescan) USB controller\n" "usb stop [f] - stop USB [f]=force stop\n" "usb tree - show USB device tree\n" @@ -682,14 +692,14 @@ U_BOOT_CMD( U_BOOT_CMD( usbboot, 3, 1, do_usbboot, - "usbboot - boot from USB device\n", + "boot from USB device", "loadAddr dev:part\n" ); #else U_BOOT_CMD( usb, 5, 1, do_usb, - "usb - USB sub-system\n", + "USB sub-system", "reset - reset (rescan) USB controller\n" "usb tree - show USB device tree\n" "usb info [dev] - show available USB devices\n" diff --git a/common/cmd_vfd.c b/common/cmd_vfd.c index 45f4271..84d9530 100644 --- a/common/cmd_vfd.c +++ b/common/cmd_vfd.c @@ -50,7 +50,7 @@ int do_vfd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong bitmap; if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } @@ -67,7 +67,7 @@ int do_vfd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( vfd, 2, 0, do_vfd, - "vfd - load a bitmap to the VFDs on TRAB\n", + "load a bitmap to the VFDs on TRAB", "/N\n" " - load bitmap N to the VFDs (N is _decimal_ !!!)\n" "vfd ADDR\n" diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index 2753389..a45d248 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -180,7 +180,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD(imxtract, 4, 1, do_imgextract, - "imxtract- extract a part of a multi-image\n", + "extract a part of a multi-image", "addr part [dest]\n" " - extract <part> from legacy image at <addr> and copy to <dest>\n" #if defined(CONFIG_FIT) diff --git a/common/cmd_yaffs2.c b/common/cmd_yaffs2.c index 3732f7f..c47ea76 100644 --- a/common/cmd_yaffs2.c +++ b/common/cmd_yaffs2.c @@ -142,72 +142,72 @@ int do_ydump (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( ymount, 3, 0, do_ymount, - "ymount\t- mount yaffs\n", + "mount yaffs", "\n" ); U_BOOT_CMD( yumount, 3, 0, do_yumount, - "yumount\t- unmount yaffs\n", + "unmount yaffs", "\n" ); U_BOOT_CMD( yls, 4, 0, do_yls, - "yls\t- yaffs ls\n", + "yaffs ls", "[-l] name\n" ); U_BOOT_CMD( yrd, 2, 0, do_yrd, - "yrd\t- read file from yaffs\n", + "read file from yaffs", "filename\n" ); U_BOOT_CMD( ywr, 4, 0, do_ywr, - "ywr\t- write file to yaffs\n", + "write file to yaffs", "filename value num_vlues\n" ); U_BOOT_CMD( yrdm, 3, 0, do_yrdm, - "yrdm\t- read file to memory from yaffs\n", + "read file to memory from yaffs", "filename offset\n" ); U_BOOT_CMD( ywrm, 4, 0, do_ywrm, - "ywrm\t- write file from memory to yaffs\n", + "write file from memory to yaffs", "filename offset size\n" ); U_BOOT_CMD( ymkdir, 2, 0, do_ymkdir, - "ymkdir\t- YAFFS mkdir\n", + "YAFFS mkdir", "dirname\n" ); U_BOOT_CMD( yrmdir, 2, 0, do_yrmdir, - "yrmdir\t- YAFFS rmdir\n", + "YAFFS rmdir", "dirname\n" ); U_BOOT_CMD( yrm, 2, 0, do_yrm, - "yrm\t- YAFFS rm\n", + "YAFFS rm", "path\n" ); U_BOOT_CMD( ymv, 4, 0, do_ymv, - "ymv\t- YAFFS mv\n", + "YAFFS mv", "oldPath newPath\n" ); U_BOOT_CMD( ydump, 2, 0, do_ydump, - "ydump\t- YAFFS device struct\n", + "YAFFS device struct", "dirname\n" ); diff --git a/common/command.c b/common/command.c index a4a978c..3b9ccc9 100644 --- a/common/command.c +++ b/common/command.c @@ -38,7 +38,7 @@ do_version (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( version, 1, 1, do_version, - "version - print monitor version\n", + "print monitor version", NULL ); @@ -71,7 +71,7 @@ do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( echo, CONFIG_SYS_MAXARGS, 1, do_echo, - "echo - echo args to console\n", + "echo args to console", "[args..]\n" " - echo args to console; \\c suppresses newline\n" ); @@ -203,7 +203,7 @@ do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( test, CONFIG_SYS_MAXARGS, 1, do_test, - "test - minimal test like /bin/sh\n", + "minimal test like /bin/sh", "[args..]\n" " - test functionality\n" ); @@ -222,7 +222,7 @@ do_exit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( exit, 2, 1, do_exit, - "exit - exit script\n", + "exit script", " - exit functionality\n" ); @@ -277,7 +277,8 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 1; if (usage == NULL) continue; - puts (usage); + printf("%-*s- %s\n", CONFIG_SYS_HELP_CMD_WIDTH, + cmd_array[i]->name, usage); } return 0; } @@ -299,7 +300,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) putc ('\n'); #else /* no long help available */ if (cmdtp->usage) - puts (cmdtp->usage); + printf ("%s - %s\n", cmdtp->name, cmdtp->usage); #endif /* CONFIG_SYS_LONGHELP */ } else { printf ("Unknown command '%s' - try 'help'" @@ -315,7 +316,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( help, CONFIG_SYS_MAXARGS, 1, do_help, - "help - print online help\n", + "print online help", "[command ...]\n" " - show help information (for 'command')\n" "'help' prints online help for the monitor commands.\n\n" @@ -328,13 +329,13 @@ U_BOOT_CMD( #ifdef CONFIG_SYS_LONGHELP cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = { "?", CONFIG_SYS_MAXARGS, 1, do_help, - "? - alias for 'help'\n", + "alias for 'help'", NULL }; #else cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = { "?", CONFIG_SYS_MAXARGS, 1, do_help, - "? - alias for 'help'\n" + "alias for 'help'" }; #endif /* CONFIG_SYS_LONGHELP */ @@ -379,6 +380,11 @@ cmd_tbl_t *find_cmd (const char *cmd) return find_cmd_tbl(cmd, &__u_boot_cmd_start, len); } +void cmd_usage(cmd_tbl_t *cmdtp) +{ + printf("Usage:\n%s - %s\n\n", cmdtp->name, cmdtp->usage); +} + #ifdef CONFIG_AUTO_COMPLETE int var_complete(int argc, char *argv[], char last_char, int maxv, char *cmdv[]) diff --git a/common/devices.c b/common/devices.c index ce3b7a0..38f1bbc 100644 --- a/common/devices.c +++ b/common/devices.c @@ -240,6 +240,9 @@ int devices_init (void) #ifdef CONFIG_NETCONSOLE drv_nc_init (); #endif +#ifdef CONFIG_JTAG_CONSOLE + drv_jtag_console_init (); +#endif return (0); } diff --git a/common/hush.c b/common/hush.c index 9aef6e4..01b74d7 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1696,7 +1696,7 @@ static int run_pipe_real(struct pipe *pi) #endif /* found - check max args */ if ((child->argc - i) > cmdtp->maxargs) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return -1; } #endif @@ -3625,7 +3625,7 @@ int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( showvar, CONFIG_SYS_MAXARGS, 1, do_showvar, - "showvar- print local hushshell variables\n", + "print local hushshell variables", "\n - print values of all hushshell variables\n" "showvar name ...\n" " - print value of hushshell variable 'name'\n" diff --git a/common/kgdb.c b/common/kgdb.c index adc15dd..888b96b 100644 --- a/common/kgdb.c +++ b/common/kgdb.c @@ -575,7 +575,7 @@ do_kgdb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( kgdb, CONFIG_SYS_MAXARGS, 1, do_kgdb, - "kgdb - enter gdb remote debug mode\n", + "enter gdb remote debug mode", "[arg0 arg1 .. argN]\n" " - executes a breakpoint so that kgdb mode is\n" " entered via the exception handler. To return\n" diff --git a/common/lcd.c b/common/lcd.c index ae79051..5f73247 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -426,7 +426,7 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( cls, 1, 1, lcd_clear, - "cls - clear screen\n", + "clear screen", NULL ); diff --git a/common/main.c b/common/main.c index 4c4f780..905d40f 100644 --- a/common/main.c +++ b/common/main.c @@ -1371,7 +1371,7 @@ int run_command (const char *cmd, int flag) /* found - check max args */ if (argc > cmdtp->maxargs) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rc = -1; continue; } @@ -1415,7 +1415,7 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int i; if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; } diff --git a/common/usb.c b/common/usb.c index ee18152..87fca70 100644 --- a/common/usb.c +++ b/common/usb.c @@ -681,7 +681,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) err = usb_string_sub(dev, 0, 0, tbuf); if (err < 0) { USB_PRINTF("error getting string descriptor 0 " \ - "(error=%x)\n", dev->status); + "(error=%lx)\n", dev->status); return -1; } else if (tbuf[0] < 4) { USB_PRINTF("string descriptor 0 too short\n"); @@ -939,8 +939,10 @@ void usb_scan_devices(void) dev_index = 0; /* device 0 is always present (root hub, so let it analyze) */ dev = usb_alloc_new_device(); - usb_new_device(dev); - printf("%d USB Device(s) found\n", dev_index); + if (usb_new_device(dev)) + printf("No USB Device found\n"); + else + printf("%d USB Device(s) found\n", dev_index); /* insert "driver" if possible */ #ifdef CONFIG_USB_KEYBOARD drv_usb_kbd_init(); @@ -1041,6 +1043,16 @@ struct usb_hub_device *usb_hub_allocate(void) #define MAX_TRIES 5 +static inline char *portspeed(int portstatus) +{ + if (portstatus & (1 << USB_PORT_FEAT_HIGHSPEED)) + return "480 Mb/s"; + else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED)) + return "1.5 Mb/s"; + else + return "12 Mb/s"; +} + static int hub_port_reset(struct usb_device *dev, int port, unsigned short *portstat) { @@ -1061,10 +1073,11 @@ static int hub_port_reset(struct usb_device *dev, int port, } portstatus = le16_to_cpu(portsts.wPortStatus); portchange = le16_to_cpu(portsts.wPortChange); + USB_HUB_PRINTF("portstatus %x, change %x, %s\n", portstatus, portchange, - portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? \ - "Low Speed" : "High Speed"); + portspeed(portstatus)); + USB_HUB_PRINTF("STAT_C_CONNECTION = %d STAT_CONNECTION = %d" \ " USB_PORT_STAT_ENABLE %d\n", (portchange & USB_PORT_STAT_C_CONNECTION) ? 1 : 0, @@ -1109,9 +1122,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) portstatus = le16_to_cpu(portsts.wPortStatus); portchange = le16_to_cpu(portsts.wPortChange); USB_HUB_PRINTF("portstatus %x, change %x, %s\n", - portstatus, portchange, - portstatus&(1 << USB_PORT_FEAT_LOWSPEED) ? \ - "Low Speed" : "High Speed"); + portstatus, portchange, portspeed(portstatus)); /* Clear the connection change status */ usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_CONNECTION); @@ -1136,7 +1147,13 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) /* Allocate a new device struct for it */ usb = usb_alloc_new_device(); - usb->slow = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0; + + if (portstatus & USB_PORT_STAT_HIGH_SPEED) + usb->speed = USB_SPEED_HIGH; + else if (portstatus & USB_PORT_STAT_LOW_SPEED) + usb->speed = USB_SPEED_LOW; + else + usb->speed = USB_SPEED_FULL; dev->children[port] = usb; usb->parent = dev; diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 89e6ee7..e0d006c 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -183,6 +183,7 @@ int drv_usb_kbd_init(void) usb_kbd_dev.puts = NULL; usb_kbd_dev.getc = usb_kbd_getc; usb_kbd_dev.tstc = usb_kbd_testc; + usb_kbd_dev.priv = (void *)dev; error = device_register (&usb_kbd_dev); if(error==0) { /* check if this is the standard input device */ diff --git a/common/usb_storage.c b/common/usb_storage.c index 94f659f..51f0789 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -45,8 +45,6 @@ * New Note: * Support for USB Mass Storage Devices (BBB) has been added. It has * only been tested with USB memory sticks. - * Nota bene: if you are using the BBB support with a little-endian - * CPU then you MUST define LITTLEENDIAN in the configuration file! */ @@ -63,9 +61,9 @@ #undef BBB_XPORT_TRACE #ifdef USB_STOR_DEBUG -#define USB_STOR_PRINTF(fmt,args...) printf (fmt ,##args) +#define USB_STOR_PRINTF(fmt, args...) printf(fmt , ##args) #else -#define USB_STOR_PRINTF(fmt,args...) +#define USB_STOR_PRINTF(fmt, args...) #endif #include <scsi.h> @@ -110,7 +108,7 @@ typedef struct { __u8 CBWCDB[CBWCDBLENGTH]; } umass_bbb_cbw_t; #define UMASS_BBB_CBW_SIZE 31 -static __u32 CBWTag = 0; +static __u32 CBWTag; /* Command Status Wrapper */ typedef struct { @@ -126,34 +124,35 @@ typedef struct { #define UMASS_BBB_CSW_SIZE 13 #define USB_MAX_STOR_DEV 5 -static int usb_max_devs = 0; /* number of highest available usb device */ +static int usb_max_devs; /* number of highest available usb device */ static block_dev_desc_t usb_dev_desc[USB_MAX_STOR_DEV]; struct us_data; -typedef int (*trans_cmnd)(ccb*, struct us_data*); -typedef int (*trans_reset)(struct us_data*); +typedef int (*trans_cmnd)(ccb *cb, struct us_data *data); +typedef int (*trans_reset)(struct us_data *data); struct us_data { - struct usb_device *pusb_dev; /* this usb_device */ - unsigned int flags; /* from filter initially */ - unsigned char ifnum; /* interface number */ - unsigned char ep_in; /* in endpoint */ - unsigned char ep_out; /* out ....... */ - unsigned char ep_int; /* interrupt . */ - unsigned char subclass; /* as in overview */ - unsigned char protocol; /* .............. */ - unsigned char attention_done; /* force attn on first cmd */ - unsigned short ip_data; /* interrupt data */ - int action; /* what to do */ - int ip_wanted; /* needed */ - int *irq_handle; /* for USB int requests */ - unsigned int irqpipe; /* pipe for release_irq */ - unsigned char irqmaxp; /* max packed for irq Pipe */ - unsigned char irqinterval; /* Intervall for IRQ Pipe */ - ccb *srb; /* current srb */ - trans_reset transport_reset; /* reset routine */ - trans_cmnd transport; /* transport routine */ + struct usb_device *pusb_dev; /* this usb_device */ + + unsigned int flags; /* from filter initially */ + unsigned char ifnum; /* interface number */ + unsigned char ep_in; /* in endpoint */ + unsigned char ep_out; /* out ....... */ + unsigned char ep_int; /* interrupt . */ + unsigned char subclass; /* as in overview */ + unsigned char protocol; /* .............. */ + unsigned char attention_done; /* force attn on first cmd */ + unsigned short ip_data; /* interrupt data */ + int action; /* what to do */ + int ip_wanted; /* needed */ + int *irq_handle; /* for USB int requests */ + unsigned int irqpipe; /* pipe for release_irq */ + unsigned char irqmaxp; /* max packed for irq Pipe */ + unsigned char irqinterval; /* Intervall for IRQ Pipe */ + ccb *srb; /* current srb */ + trans_reset transport_reset; /* reset routine */ + trans_cmnd transport; /* transport routine */ }; static struct us_data usb_stor[USB_MAX_STOR_DEV]; @@ -163,10 +162,12 @@ static struct us_data usb_stor[USB_MAX_STOR_DEV]; #define USB_STOR_TRANSPORT_FAILED -1 #define USB_STOR_TRANSPORT_ERROR -2 - -int usb_stor_get_info(struct usb_device *dev, struct us_data *us, block_dev_desc_t *dev_desc); -int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data *ss); -unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcnt, void *buffer); +int usb_stor_get_info(struct usb_device *dev, struct us_data *us, + block_dev_desc_t *dev_desc); +int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, + struct us_data *ss); +unsigned long usb_stor_read(int device, unsigned long blknr, + unsigned long blkcnt, void *buffer); struct usb_device * usb_get_dev_index(int index); void uhci_show_temp_int_td(void); @@ -181,7 +182,7 @@ void usb_show_progress(void) printf("."); } -/********************************************************************************* +/******************************************************************************* * show info on storage devices; 'usb start/init' must be invoked earlier * as we only retrieve structures populated during devices initialization */ @@ -191,7 +192,7 @@ int usb_stor_info(void) if (usb_max_devs > 0) { for (i = 0; i < usb_max_devs; i++) { - printf (" Device %d: ", i); + printf(" Device %d: ", i); dev_print(&usb_dev_desc[i]); } return 0; @@ -201,7 +202,7 @@ int usb_stor_info(void) return 1; } -/********************************************************************************* +/******************************************************************************* * scan the usb and reports device info * to the user if mode = 1 * returns current device or -1 if no @@ -214,67 +215,69 @@ int usb_stor_scan(int mode) /* GJ */ memset(usb_stor_buf, 0, sizeof(usb_stor_buf)); - if(mode==1) { + if (mode == 1) printf(" scanning bus for storage devices... "); - } + usb_disable_asynch(1); /* asynch transfer not allowed */ - for(i=0;i<USB_MAX_STOR_DEV;i++) { - memset(&usb_dev_desc[i],0,sizeof(block_dev_desc_t)); - usb_dev_desc[i].target=0xff; - usb_dev_desc[i].if_type=IF_TYPE_USB; - usb_dev_desc[i].dev=i; - usb_dev_desc[i].part_type=PART_TYPE_UNKNOWN; - usb_dev_desc[i].block_read=usb_stor_read; + for (i = 0; i < USB_MAX_STOR_DEV; i++) { + memset(&usb_dev_desc[i], 0, sizeof(block_dev_desc_t)); + usb_dev_desc[i].target = 0xff; + usb_dev_desc[i].if_type = IF_TYPE_USB; + usb_dev_desc[i].dev = i; + usb_dev_desc[i].part_type = PART_TYPE_UNKNOWN; + usb_dev_desc[i].block_read = usb_stor_read; } - usb_max_devs=0; - for(i=0;i<USB_MAX_DEVICE;i++) { - dev=usb_get_dev_index(i); /* get device */ - USB_STOR_PRINTF("i=%d\n",i); - if(dev==NULL) { + usb_max_devs = 0; + for (i = 0; i < USB_MAX_DEVICE; i++) { + dev = usb_get_dev_index(i); /* get device */ + USB_STOR_PRINTF("i=%d\n", i); + if (dev == NULL) break; /* no more devices avaiable */ - } - if(usb_storage_probe(dev,0,&usb_stor[usb_max_devs])) { /* ok, it is a storage devices */ - /* get info and fill it in */ - if(usb_stor_get_info(dev, &usb_stor[usb_max_devs], &usb_dev_desc[usb_max_devs])) + + if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) { + /* ok, it is a storage devices + * get info and fill it in + */ + if (usb_stor_get_info(dev, &usb_stor[usb_max_devs], + &usb_dev_desc[usb_max_devs])) usb_max_devs++; - } /* if storage device */ - if(usb_max_devs==USB_MAX_STOR_DEV) { - printf("max USB Storage Device reached: %d stopping\n",usb_max_devs); + } + /* if storage device */ + if (usb_max_devs == USB_MAX_STOR_DEV) { + printf("max USB Storage Device reached: %d stopping\n", + usb_max_devs); break; } } /* for */ usb_disable_asynch(0); /* asynch transfer allowed */ printf("%d Storage Device(s) found\n", usb_max_devs); - if(usb_max_devs>0) + if (usb_max_devs > 0) return 0; - else - return-1; + return -1; } static int usb_stor_irq(struct usb_device *dev) { struct us_data *us; - us=(struct us_data *)dev->privptr; + us = (struct us_data *)dev->privptr; - if(us->ip_wanted) { - us->ip_wanted=0; - } + if (us->ip_wanted) + us->ip_wanted = 0; return 0; } #ifdef USB_STOR_DEBUG -static void usb_show_srb(ccb * pccb) +static void usb_show_srb(ccb *pccb) { int i; - printf("SRB: len %d datalen 0x%lX\n ",pccb->cmdlen,pccb->datalen); - for(i=0;i<12;i++) { - printf("%02X ",pccb->cmd[i]); - } + printf("SRB: len %d datalen 0x%lX\n ", pccb->cmdlen, pccb->datalen); + for (i = 0; i < 12; i++) + printf("%02X ", pccb->cmd[i]); printf("\n"); } @@ -322,11 +325,14 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) USB_STOR_PRINTF("Bulk xfer 0x%x(%d) try #%d\n", (unsigned int)buf, this_xfer, 11 - maxtry); result = usb_bulk_msg(us->pusb_dev, pipe, buf, - this_xfer, &partial, USB_CNTL_TIMEOUT*5); + this_xfer, &partial, + USB_CNTL_TIMEOUT * 5); USB_STOR_PRINTF("bulk_msg returned %d xferred %d/%d\n", result, partial, this_xfer); - if(us->pusb_dev->status!=0) { - /* if we stall, we need to clear it before we go on */ + if (us->pusb_dev->status != 0) { + /* if we stall, we need to clear it before + * we go on + */ #ifdef USB_STOR_DEBUG display_int_status(us->pusb_dev->status); #endif @@ -334,9 +340,9 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) USB_STOR_PRINTF("stalled ->clearing endpoint halt for pipe 0x%x\n", pipe); stat = us->pusb_dev->status; usb_clear_halt(us->pusb_dev, pipe); - us->pusb_dev->status=stat; - if(this_xfer == partial) { - USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n",us->pusb_dev->status); + us->pusb_dev->status = stat; + if (this_xfer == partial) { + USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n", us->pusb_dev->status); return 0; } else @@ -346,12 +352,15 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) USB_STOR_PRINTF("Device NAKed bulk_msg\n"); return result; } - if(this_xfer == partial) { - USB_STOR_PRINTF("bulk transferred with error %d, but data ok\n",us->pusb_dev->status); + USB_STOR_PRINTF("bulk transferred with error"); + if (this_xfer == partial) { + USB_STOR_PRINTF(" %d, but data ok\n", + us->pusb_dev->status); return 0; } /* if our try counter reaches 0, bail out */ - USB_STOR_PRINTF("bulk transferred with error %d, data %d\n",us->pusb_dev->status,partial); + USB_STOR_PRINTF(" %d, data %d\n", + us->pusb_dev->status, partial); if (!maxtry--) return result; } @@ -359,7 +368,7 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) this_xfer -= partial; buf += partial; /* continue until this transfer is done */ - } while ( this_xfer ); + } while (this_xfer); } /* if we get here, we're done and successful */ @@ -386,29 +395,33 @@ static int usb_stor_BBB_reset(struct us_data *us) * This comment stolen from FreeBSD's /sys/dev/usb/umass.c. */ USB_STOR_PRINTF("BBB_reset\n"); - result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0), - US_BBB_RESET, USB_TYPE_CLASS | USB_RECIP_INTERFACE, - 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT*5); + result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), + US_BBB_RESET, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT * 5); - if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) - { + if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) { USB_STOR_PRINTF("RESET:stall\n"); return -1; } /* long wait for reset */ wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n",result,us->pusb_dev->status); + USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n", result, + us->pusb_dev->status); pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); result = usb_clear_halt(us->pusb_dev, pipe); /* long wait for reset */ wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n",result,us->pusb_dev->status); + USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n", + result, us->pusb_dev->status); /* long wait for reset */ pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); result = usb_clear_halt(us->pusb_dev, pipe); wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X clearing OUT endpoint\n",result,us->pusb_dev->status); + USB_STOR_PRINTF("BBB_reset result %d: status %X" + " clearing OUT endpoint\n", result, + us->pusb_dev->status); USB_STOR_PRINTF("BBB_reset done\n"); return 0; } @@ -423,16 +436,20 @@ static int usb_stor_CB_reset(struct us_data *us) int result; USB_STOR_PRINTF("CB_reset\n"); - memset(cmd, 0xFF, sizeof(cmd)); + memset(cmd, 0xff, sizeof(cmd)); cmd[0] = SCSI_SEND_DIAG; cmd[1] = 4; - result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0), - US_CBI_ADSC, USB_TYPE_CLASS | USB_RECIP_INTERFACE, - 0, us->ifnum, cmd, sizeof(cmd), USB_CNTL_TIMEOUT*5); + result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), + US_CBI_ADSC, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0, us->ifnum, cmd, sizeof(cmd), + USB_CNTL_TIMEOUT * 5); /* long wait for reset */ wait_ms(1500); - USB_STOR_PRINTF("CB_reset result %d: status %X clearing endpoint halt\n",result,us->pusb_dev->status); + USB_STOR_PRINTF("CB_reset result %d: status %X" + " clearing endpoint halt\n", result, + us->pusb_dev->status); usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_in)); usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_out)); @@ -455,9 +472,11 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) dir_in = US_DIRECTION(srb->cmd[0]); #ifdef BBB_COMDAT_TRACE - printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n", dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen, srb->pdata); + printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n", + dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen, + srb->pdata); if (srb->cmdlen) { - for(result = 0;result < srb->cmdlen;result++) + for (result = 0; result < srb->cmdlen; result++) printf("cmd[%d] %#x ", result, srb->cmd[result]); printf("\n"); } @@ -474,13 +493,14 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) cbw.dCBWSignature = cpu_to_le32(CBWSIGNATURE); cbw.dCBWTag = cpu_to_le32(CBWTag++); cbw.dCBWDataTransferLength = cpu_to_le32(srb->datalen); - cbw.bCBWFlags = (dir_in? CBWFLAGS_IN : CBWFLAGS_OUT); + cbw.bCBWFlags = (dir_in ? CBWFLAGS_IN : CBWFLAGS_OUT); cbw.bCBWLUN = srb->lun; cbw.bCDBLength = srb->cmdlen; /* copy the command data into the CBW command data buffer */ /* DST SRC LEN!!! */ memcpy(cbw.CBWCDB, srb->cmd, srb->cmdlen); - result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE, &actlen, USB_CNTL_TIMEOUT*5); + result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE, + &actlen, USB_CNTL_TIMEOUT * 5); if (result < 0) USB_STOR_PRINTF("usb_stor_BBB_comdat:usb_bulk_msg error\n"); return result; @@ -492,46 +512,61 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) int usb_stor_CB_comdat(ccb *srb, struct us_data *us) { int result = 0; - int dir_in,retry; + int dir_in, retry; unsigned int pipe; unsigned long status; - retry=5; - dir_in=US_DIRECTION(srb->cmd[0]); + retry = 5; + dir_in = US_DIRECTION(srb->cmd[0]); - if(dir_in) - pipe=usb_rcvbulkpipe(us->pusb_dev, us->ep_in); - else - pipe=usb_sndbulkpipe(us->pusb_dev, us->ep_out); - while(retry--) { - USB_STOR_PRINTF("CBI gets a command: Try %d\n",5-retry); + if (dir_in) + pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); + else + pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); + + while (retry--) { + USB_STOR_PRINTF("CBI gets a command: Try %d\n", 5 - retry); #ifdef USB_STOR_DEBUG usb_show_srb(srb); #endif /* let's send the command via the control pipe */ - result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0), - US_CBI_ADSC, USB_TYPE_CLASS | USB_RECIP_INTERFACE, + result = usb_control_msg(us->pusb_dev, + usb_sndctrlpipe(us->pusb_dev , 0), + US_CBI_ADSC, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, us->ifnum, - srb->cmd, srb->cmdlen, USB_CNTL_TIMEOUT*5); - USB_STOR_PRINTF("CB_transport: control msg returned %d, status %X\n",result,us->pusb_dev->status); + srb->cmd, srb->cmdlen, + USB_CNTL_TIMEOUT * 5); + USB_STOR_PRINTF("CB_transport: control msg returned %d," + " status %X\n", result, us->pusb_dev->status); /* check the return code for the command */ if (result < 0) { - if(us->pusb_dev->status & USB_ST_STALLED) { - status=us->pusb_dev->status; - USB_STOR_PRINTF(" stall during command found, clear pipe\n"); - usb_clear_halt(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0)); - us->pusb_dev->status=status; + if (us->pusb_dev->status & USB_ST_STALLED) { + status = us->pusb_dev->status; + USB_STOR_PRINTF(" stall during command found," + " clear pipe\n"); + usb_clear_halt(us->pusb_dev, + usb_sndctrlpipe(us->pusb_dev, 0)); + us->pusb_dev->status = status; } - USB_STOR_PRINTF(" error during command %02X Stat = %X\n",srb->cmd[0],us->pusb_dev->status); + USB_STOR_PRINTF(" error during command %02X" + " Stat = %X\n", srb->cmd[0], + us->pusb_dev->status); return result; } /* transfer the data payload for this command, if one exists*/ - USB_STOR_PRINTF("CB_transport: control msg returned %d, direction is %s to go 0x%lx\n",result,dir_in ? "IN" : "OUT",srb->datalen); + USB_STOR_PRINTF("CB_transport: control msg returned %d," + " direction is %s to go 0x%lx\n", result, + dir_in ? "IN" : "OUT", srb->datalen); if (srb->datalen) { - result = us_one_transfer(us, pipe, (char *)srb->pdata,srb->datalen); - USB_STOR_PRINTF("CBI attempted to transfer data, result is %d status %lX, len %d\n", result,us->pusb_dev->status,us->pusb_dev->act_len); - if(!(us->pusb_dev->status & USB_ST_NAK_REC)) + result = us_one_transfer(us, pipe, (char *)srb->pdata, + srb->datalen); + USB_STOR_PRINTF("CBI attempted to transfer data," + " result is %d status %lX, len %d\n", + result, us->pusb_dev->status, + us->pusb_dev->act_len); + if (!(us->pusb_dev->status & USB_ST_NAK_REC)) break; } /* if (srb->datalen) */ else @@ -543,21 +578,21 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us) } -int usb_stor_CBI_get_status (ccb * srb, struct us_data *us) +int usb_stor_CBI_get_status(ccb *srb, struct us_data *us) { int timeout; us->ip_wanted = 1; - submit_int_msg (us->pusb_dev, us->irqpipe, + submit_int_msg(us->pusb_dev, us->irqpipe, (void *) &us->ip_data, us->irqmaxp, us->irqinterval); timeout = 1000; while (timeout--) { if ((volatile int *) us->ip_wanted == 0) break; - wait_ms (10); + wait_ms(10); } if (us->ip_wanted) { - printf (" Did not get interrupt on CBI\n"); + printf(" Did not get interrupt on CBI\n"); us->ip_wanted = 0; return USB_STOR_TRANSPORT_ERROR; } @@ -596,9 +631,9 @@ int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt) int result; /* ENDPOINT_HALT = 0, so set value to 0 */ - result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0), + result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - 0, endpt, 0, 0, USB_CNTL_TIMEOUT*5); + 0, endpt, 0, 0, USB_CNTL_TIMEOUT * 5); return result; } @@ -638,12 +673,14 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us) pipe = pipein; else pipe = pipeout; - result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen, &data_actlen, USB_CNTL_TIMEOUT*5); + result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen, + &data_actlen, USB_CNTL_TIMEOUT * 5); /* special handling of STALL in DATA phase */ - if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) { + if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) { USB_STOR_PRINTF("DATA:stall\n"); /* clear the STALL on the endpoint */ - result = usb_stor_BBB_clear_endpt_stall(us, dir_in? us->ep_in : us->ep_out); + result = usb_stor_BBB_clear_endpt_stall(us, + dir_in ? us->ep_in : us->ep_out); if (result >= 0) /* continue on to STATUS phase */ goto st; @@ -660,15 +697,16 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us) printf("\n"); #endif /* STATUS phase + error handling */ - st: +st: retry = 0; - again: +again: USB_STOR_PRINTF("STATUS phase\n"); result = usb_bulk_msg(us->pusb_dev, pipein, &csw, UMASS_BBB_CSW_SIZE, &actlen, USB_CNTL_TIMEOUT*5); /* special handling of STALL in STATUS phase */ - if((result < 0) && (retry < 1) && (us->pusb_dev->status & USB_ST_STALLED)) { + if ((result < 0) && (retry < 1) && + (us->pusb_dev->status & USB_ST_STALLED)) { USB_STOR_PRINTF("STATUS:stall\n"); /* clear the STALL on the endpoint */ result = usb_stor_BBB_clear_endpt_stall(us, us->ep_in); @@ -722,32 +760,33 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us) int usb_stor_CB_transport(ccb *srb, struct us_data *us) { - int result,status; + int result, status; ccb *psrb; ccb reqsrb; - int retry,notready; + int retry, notready; psrb = &reqsrb; - status=USB_STOR_TRANSPORT_GOOD; - retry=0; - notready=0; + status = USB_STOR_TRANSPORT_GOOD; + retry = 0; + notready = 0; /* issue the command */ do_retry: - result=usb_stor_CB_comdat(srb,us); - USB_STOR_PRINTF("command / Data returned %d, status %X\n",result,us->pusb_dev->status); + result = usb_stor_CB_comdat(srb, us); + USB_STOR_PRINTF("command / Data returned %d, status %X\n", + result, us->pusb_dev->status); /* if this is an CBI Protocol, get IRQ */ - if(us->protocol==US_PR_CBI) { - status=usb_stor_CBI_get_status(srb,us); + if (us->protocol == US_PR_CBI) { + status = usb_stor_CBI_get_status(srb, us); /* if the status is error, report it */ - if(status==USB_STOR_TRANSPORT_ERROR) { + if (status == USB_STOR_TRANSPORT_ERROR) { USB_STOR_PRINTF(" USB CBI Command Error\n"); return status; } - srb->sense_buf[12]=(unsigned char)(us->ip_data>>8); - srb->sense_buf[13]=(unsigned char)(us->ip_data&0xff); - if(!us->ip_data) { - /* if the status is good, report it */ - if(status==USB_STOR_TRANSPORT_GOOD) { + srb->sense_buf[12] = (unsigned char)(us->ip_data >> 8); + srb->sense_buf[13] = (unsigned char)(us->ip_data & 0xff); + if (!us->ip_data) { + /* if the status is good, report it */ + if (status == USB_STOR_TRANSPORT_GOOD) { USB_STOR_PRINTF(" USB CBI Command Good\n"); return status; } @@ -755,51 +794,62 @@ do_retry: } /* do we have to issue an auto request? */ /* HERE we have to check the result */ - if((result<0) && !(us->pusb_dev->status & USB_ST_STALLED)) { - USB_STOR_PRINTF("ERROR %X\n",us->pusb_dev->status); + if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) { + USB_STOR_PRINTF("ERROR %X\n", us->pusb_dev->status); us->transport_reset(us); return USB_STOR_TRANSPORT_ERROR; } - if((us->protocol==US_PR_CBI) && - ((srb->cmd[0]==SCSI_REQ_SENSE) || - (srb->cmd[0]==SCSI_INQUIRY))) { /* do not issue an autorequest after request sense */ + if ((us->protocol == US_PR_CBI) && + ((srb->cmd[0] == SCSI_REQ_SENSE) || + (srb->cmd[0] == SCSI_INQUIRY))) { + /* do not issue an autorequest after request sense */ USB_STOR_PRINTF("No auto request and good\n"); return USB_STOR_TRANSPORT_GOOD; } /* issue an request_sense */ - memset(&psrb->cmd[0],0,12); - psrb->cmd[0]=SCSI_REQ_SENSE; - psrb->cmd[1]=srb->lun<<5; - psrb->cmd[4]=18; - psrb->datalen=18; + memset(&psrb->cmd[0], 0, 12); + psrb->cmd[0] = SCSI_REQ_SENSE; + psrb->cmd[1] = srb->lun << 5; + psrb->cmd[4] = 18; + psrb->datalen = 18; psrb->pdata = &srb->sense_buf[0]; - psrb->cmdlen=12; + psrb->cmdlen = 12; /* issue the command */ - result=usb_stor_CB_comdat(psrb,us); - USB_STOR_PRINTF("auto request returned %d\n",result); + result = usb_stor_CB_comdat(psrb, us); + USB_STOR_PRINTF("auto request returned %d\n", result); /* if this is an CBI Protocol, get IRQ */ - if(us->protocol==US_PR_CBI) { - status=usb_stor_CBI_get_status(psrb,us); - } - if((result<0)&&!(us->pusb_dev->status & USB_ST_STALLED)) { - USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n",us->pusb_dev->status); + if (us->protocol == US_PR_CBI) + status = usb_stor_CBI_get_status(psrb, us); + + if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) { + USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n", + us->pusb_dev->status); return USB_STOR_TRANSPORT_ERROR; } - USB_STOR_PRINTF("autorequest returned 0x%02X 0x%02X 0x%02X 0x%02X\n",srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]); + USB_STOR_PRINTF("autorequest returned 0x%02X 0x%02X 0x%02X 0x%02X\n", + srb->sense_buf[0], srb->sense_buf[2], + srb->sense_buf[12], srb->sense_buf[13]); /* Check the auto request result */ - if((srb->sense_buf[2]==0) && - (srb->sense_buf[12]==0) && - (srb->sense_buf[13]==0)) /* ok, no sense */ + if ((srb->sense_buf[2] == 0) && + (srb->sense_buf[12] == 0) && + (srb->sense_buf[13] == 0)) { + /* ok, no sense */ return USB_STOR_TRANSPORT_GOOD; + } + /* Check the auto request result */ - switch(srb->sense_buf[2]) { - case 0x01: /* Recovered Error */ + switch (srb->sense_buf[2]) { + case 0x01: + /* Recovered Error */ return USB_STOR_TRANSPORT_GOOD; break; - case 0x02: /* Not Ready */ - if(notready++ > USB_TRANSPORT_NOT_READY_RETRY) { - printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X (NOT READY)\n", - srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]); + case 0x02: + /* Not Ready */ + if (notready++ > USB_TRANSPORT_NOT_READY_RETRY) { + printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X" + " 0x%02X (NOT READY)\n", srb->cmd[0], + srb->sense_buf[0], srb->sense_buf[2], + srb->sense_buf[12], srb->sense_buf[13]); return USB_STOR_TRANSPORT_FAILED; } else { wait_ms(100); @@ -807,113 +857,116 @@ do_retry: } break; default: - if(retry++ > USB_TRANSPORT_UNKNOWN_RETRY) { - printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X\n", - srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]); + if (retry++ > USB_TRANSPORT_UNKNOWN_RETRY) { + printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X" + " 0x%02X\n", srb->cmd[0], srb->sense_buf[0], + srb->sense_buf[2], srb->sense_buf[12], + srb->sense_buf[13]); return USB_STOR_TRANSPORT_FAILED; - } else { + } else goto do_retry; - } break; } return USB_STOR_TRANSPORT_FAILED; } -static int usb_inquiry(ccb *srb,struct us_data *ss) +static int usb_inquiry(ccb *srb, struct us_data *ss) { - int retry,i; - retry=5; + int retry, i; + retry = 5; do { - memset(&srb->cmd[0],0,12); - srb->cmd[0]=SCSI_INQUIRY; - srb->cmd[1]=srb->lun<<5; - srb->cmd[4]=36; - srb->datalen=36; - srb->cmdlen=12; - i=ss->transport(srb,ss); - USB_STOR_PRINTF("inquiry returns %d\n",i); - if(i==0) + memset(&srb->cmd[0], 0, 12); + srb->cmd[0] = SCSI_INQUIRY; + srb->cmd[1] = srb->lun<<5; + srb->cmd[4] = 36; + srb->datalen = 36; + srb->cmdlen = 12; + i = ss->transport(srb, ss); + USB_STOR_PRINTF("inquiry returns %d\n", i); + if (i == 0) break; - } while(retry--); + } while (retry--); - if(!retry) { + if (!retry) { printf("error in inquiry\n"); return -1; } return 0; } -static int usb_request_sense(ccb *srb,struct us_data *ss) +static int usb_request_sense(ccb *srb, struct us_data *ss) { char *ptr; - ptr=(char *)srb->pdata; - memset(&srb->cmd[0],0,12); - srb->cmd[0]=SCSI_REQ_SENSE; - srb->cmd[1]=srb->lun<<5; - srb->cmd[4]=18; - srb->datalen=18; + ptr = (char *)srb->pdata; + memset(&srb->cmd[0], 0, 12); + srb->cmd[0] = SCSI_REQ_SENSE; + srb->cmd[1] = srb->lun << 5; + srb->cmd[4] = 18; + srb->datalen = 18; srb->pdata = &srb->sense_buf[0]; - srb->cmdlen=12; - ss->transport(srb,ss); - USB_STOR_PRINTF("Request Sense returned %02X %02X %02X\n",srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]); - srb->pdata=(uchar *)ptr; + srb->cmdlen = 12; + ss->transport(srb, ss); + USB_STOR_PRINTF("Request Sense returned %02X %02X %02X\n", + srb->sense_buf[2], srb->sense_buf[12], + srb->sense_buf[13]); + srb->pdata = (uchar *)ptr; return 0; } -static int usb_test_unit_ready(ccb *srb,struct us_data *ss) +static int usb_test_unit_ready(ccb *srb, struct us_data *ss) { int retries = 10; do { - memset(&srb->cmd[0],0,12); - srb->cmd[0]=SCSI_TST_U_RDY; - srb->cmd[1]=srb->lun<<5; - srb->datalen=0; - srb->cmdlen=12; - if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) { + memset(&srb->cmd[0], 0, 12); + srb->cmd[0] = SCSI_TST_U_RDY; + srb->cmd[1] = srb->lun << 5; + srb->datalen = 0; + srb->cmdlen = 12; + if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD) return 0; - } - usb_request_sense (srb, ss); - wait_ms (100); - } while(retries--); + usb_request_sense(srb, ss); + wait_ms(100); + } while (retries--); return -1; } -static int usb_read_capacity(ccb *srb,struct us_data *ss) +static int usb_read_capacity(ccb *srb, struct us_data *ss) { int retry; - retry = 3; /* retries */ + /* XXX retries */ + retry = 3; do { - memset(&srb->cmd[0],0,12); - srb->cmd[0]=SCSI_RD_CAPAC; - srb->cmd[1]=srb->lun<<5; - srb->datalen=8; - srb->cmdlen=12; - if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) { + memset(&srb->cmd[0], 0, 12); + srb->cmd[0] = SCSI_RD_CAPAC; + srb->cmd[1] = srb->lun << 5; + srb->datalen = 8; + srb->cmdlen = 12; + if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD) return 0; - } - } while(retry--); + } while (retry--); return -1; } -static int usb_read_10(ccb *srb,struct us_data *ss, unsigned long start, unsigned short blocks) +static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start, + unsigned short blocks) { - memset(&srb->cmd[0],0,12); - srb->cmd[0]=SCSI_READ10; - srb->cmd[1]=srb->lun<<5; - srb->cmd[2]=((unsigned char) (start>>24))&0xff; - srb->cmd[3]=((unsigned char) (start>>16))&0xff; - srb->cmd[4]=((unsigned char) (start>>8))&0xff; - srb->cmd[5]=((unsigned char) (start))&0xff; - srb->cmd[7]=((unsigned char) (blocks>>8))&0xff; - srb->cmd[8]=(unsigned char) blocks & 0xff; - srb->cmdlen=12; - USB_STOR_PRINTF("read10: start %lx blocks %x\n",start,blocks); - return ss->transport(srb,ss); + memset(&srb->cmd[0], 0, 12); + srb->cmd[0] = SCSI_READ10; + srb->cmd[1] = srb->lun << 5; + srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff; + srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff; + srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff; + srb->cmd[5] = ((unsigned char) (start)) & 0xff; + srb->cmd[7] = ((unsigned char) (blocks >> 8)) & 0xff; + srb->cmd[8] = (unsigned char) blocks & 0xff; + srb->cmdlen = 12; + USB_STOR_PRINTF("read10: start %lx blocks %x\n", start, blocks); + return ss->transport(srb, ss); } @@ -933,85 +986,94 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor, const unsigned char max_vendor_len = 40; const unsigned char max_product_len = 20; if (descriptor.idVendor == 0x0424 && descriptor.idProduct == 0x223a) { - strncpy ((char *)vendor, "SMSC", max_vendor_len); - strncpy ((char *)product, "Flash Media Cntrller", max_product_len); + strncpy((char *)vendor, "SMSC", max_vendor_len); + strncpy((char *)product, "Flash Media Cntrller", + max_product_len); } } #endif /* CONFIG_USB_BIN_FIXUP */ #define USB_MAX_READ_BLK 20 -unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcnt, void *buffer) +unsigned long usb_stor_read(int device, unsigned long blknr, + unsigned long blkcnt, void *buffer) { - unsigned long start,blks, buf_addr; + unsigned long start, blks, buf_addr; unsigned short smallblks; struct usb_device *dev; - int retry,i; + int retry, i; ccb *srb = &usb_ccb; if (blkcnt == 0) return 0; device &= 0xff; - /* Setup device - */ - USB_STOR_PRINTF("\nusb_read: dev %d \n",device); - dev=NULL; - for(i=0;i<USB_MAX_DEVICE;i++) { - dev=usb_get_dev_index(i); - if(dev==NULL) { + /* Setup device */ + USB_STOR_PRINTF("\nusb_read: dev %d \n", device); + dev = NULL; + for (i = 0; i < USB_MAX_DEVICE; i++) { + dev = usb_get_dev_index(i); + if (dev == NULL) return 0; - } - if(dev->devnum==usb_dev_desc[device].target) + if (dev->devnum == usb_dev_desc[device].target) break; } usb_disable_asynch(1); /* asynch transfer not allowed */ - srb->lun=usb_dev_desc[device].lun; - buf_addr=(unsigned long)buffer; - start=blknr; - blks=blkcnt; - if(usb_test_unit_ready(srb,(struct us_data *)dev->privptr)) { - printf("Device NOT ready\n Request Sense returned %02X %02X %02X\n", - srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]); + srb->lun = usb_dev_desc[device].lun; + buf_addr = (unsigned long)buffer; + start = blknr; + blks = blkcnt; + if (usb_test_unit_ready(srb, (struct us_data *)dev->privptr)) { + printf("Device NOT ready\n Request Sense returned %02X %02X" + " %02X\n", srb->sense_buf[2], srb->sense_buf[12], + srb->sense_buf[13]); return 0; } - USB_STOR_PRINTF("\nusb_read: dev %d startblk %lx, blccnt %lx buffer %lx\n",device,start,blks, buf_addr); + + USB_STOR_PRINTF("\nusb_read: dev %d startblk %lx, blccnt %lx" + " buffer %lx\n", device, start, blks, buf_addr); + do { - retry=2; - srb->pdata=(unsigned char *)buf_addr; - if(blks>USB_MAX_READ_BLK) { - smallblks=USB_MAX_READ_BLK; - } else { - smallblks=(unsigned short) blks; - } + /* XXX need some comment here */ + retry = 2; + srb->pdata = (unsigned char *)buf_addr; + if (blks > USB_MAX_READ_BLK) + smallblks = USB_MAX_READ_BLK; + else + smallblks = (unsigned short) blks; retry_it: - if(smallblks==USB_MAX_READ_BLK) + if (smallblks == USB_MAX_READ_BLK) usb_show_progress(); - srb->datalen=usb_dev_desc[device].blksz * smallblks; - srb->pdata=(unsigned char *)buf_addr; - if(usb_read_10(srb,(struct us_data *)dev->privptr, start, smallblks)) { + srb->datalen = usb_dev_desc[device].blksz * smallblks; + srb->pdata = (unsigned char *)buf_addr; + if (usb_read_10(srb, (struct us_data *)dev->privptr, start, + smallblks)) { USB_STOR_PRINTF("Read ERROR\n"); - usb_request_sense(srb,(struct us_data *)dev->privptr); - if(retry--) + usb_request_sense(srb, (struct us_data *)dev->privptr); + if (retry--) goto retry_it; - blkcnt-=blks; + blkcnt -= blks; break; } - start+=smallblks; - blks-=smallblks; - buf_addr+=srb->datalen; - } while(blks!=0); - USB_STOR_PRINTF("usb_read: end startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr); + start += smallblks; + blks -= smallblks; + buf_addr += srb->datalen; + } while (blks != 0); + + USB_STOR_PRINTF("usb_read: end startblk %lx, blccnt %x buffer %lx\n", + start, smallblks, buf_addr); + usb_disable_asynch(0); /* asynch transfer allowed */ - if(blkcnt>=USB_MAX_READ_BLK) + if (blkcnt >= USB_MAX_READ_BLK) printf("\n"); - return(blkcnt); + return blkcnt; } /* Probe to see if a new device is actually a Storage device */ -int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data *ss) +int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, + struct us_data *ss) { struct usb_interface_descriptor *iface; int i; @@ -1025,8 +1087,11 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data #if 0 /* this is the place to patch some storage devices */ - USB_STOR_PRINTF("iVendor %X iProduct %X\n",dev->descriptor.idVendor,dev->descriptor.idProduct); - if ((dev->descriptor.idVendor) == 0x066b && (dev->descriptor.idProduct) == 0x0103) { + USB_STOR_PRINTF("iVendor %X iProduct %X\n", dev->descriptor.idVendor, + dev->descriptor.idProduct); + + if ((dev->descriptor.idVendor) == 0x066b && + (dev->descriptor.idProduct) == 0x0103) { USB_STOR_PRINTF("patched for E-USB\n"); protocol = US_PR_CB; subclass = US_SC_UFI; /* an assumption */ @@ -1095,19 +1160,20 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data */ for (i = 0; i < iface->bNumEndpoints; i++) { /* is it an BULK endpoint? */ - if ((iface->ep_desc[i].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) - == USB_ENDPOINT_XFER_BULK) { + if ((iface->ep_desc[i].bmAttributes & + USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { if (iface->ep_desc[i].bEndpointAddress & USB_DIR_IN) ss->ep_in = iface->ep_desc[i].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; else - ss->ep_out = iface->ep_desc[i].bEndpointAddress & + ss->ep_out = + iface->ep_desc[i].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } /* is it an interrupt endpoint? */ - if ((iface->ep_desc[i].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) - == USB_ENDPOINT_XFER_INT) { + if ((iface->ep_desc[i].bmAttributes & + USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { ss->ep_int = iface->ep_desc[i].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ss->irqinterval = iface->ep_desc[i].bInterval; @@ -1130,26 +1196,28 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data */ if (ss->subclass != US_SC_UFI && ss->subclass != US_SC_SCSI && ss->subclass != US_SC_8070) { - printf("Sorry, protocol %d not yet supported.\n",ss->subclass); + printf("Sorry, protocol %d not yet supported.\n", ss->subclass); return 0; } - if(ss->ep_int) { /* we had found an interrupt endpoint, prepare irq pipe */ - /* set up the IRQ pipe and handler */ - + if (ss->ep_int) { + /* we had found an interrupt endpoint, prepare irq pipe + * set up the IRQ pipe and handler + */ ss->irqinterval = (ss->irqinterval > 0) ? ss->irqinterval : 255; ss->irqpipe = usb_rcvintpipe(ss->pusb_dev, ss->ep_int); ss->irqmaxp = usb_maxpacket(dev, ss->irqpipe); - dev->irq_handle=usb_stor_irq; + dev->irq_handle = usb_stor_irq; } - dev->privptr=(void *)ss; + dev->privptr = (void *)ss; return 1; } -int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t *dev_desc) +int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, + block_dev_desc_t *dev_desc) { - unsigned char perq,modi; + unsigned char perq, modi; unsigned long cap[2]; - unsigned long *capacity,*blksz; + unsigned long *capacity, *blksz; ccb *pccb = &usb_ccb; /* for some reasons a couple of devices would not survive this reset */ @@ -1157,7 +1225,6 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t /* Sony USM256E */ (dev->descriptor.idVendor == 0x054c && dev->descriptor.idProduct == 0x019e) - || /* USB007 Mini-USB2 Flash Drive */ (dev->descriptor.idVendor == 0x066f && @@ -1166,6 +1233,13 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t /* SanDisk Corporation Cruzer Micro 20044318410546613953 */ (dev->descriptor.idVendor == 0x0781 && dev->descriptor.idProduct == 0x5151) + || + /* + * SanDisk Corporation U3 Cruzer Micro 1/4GB + * Flash Drive 000016244373FFB4 + */ + (dev->descriptor.idVendor == 0x0781 && + dev->descriptor.idProduct == 0x5406) ) USB_STOR_PRINTF("usb_stor_get_info: skipping RESET..\n"); else @@ -1175,17 +1249,20 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t dev_desc->target = dev->devnum; pccb->lun = dev_desc->lun; - USB_STOR_PRINTF(" address %d\n",dev_desc->target); + USB_STOR_PRINTF(" address %d\n", dev_desc->target); - if(usb_inquiry(pccb,ss)) + if (usb_inquiry(pccb, ss)) return -1; perq = usb_stor_buf[0]; modi = usb_stor_buf[1]; - if((perq & 0x1f) == 0x1f) { - return 0; /* skip unknown devices */ + + if ((perq & 0x1f) == 0x1f) { + /* skip unknown devices */ + return 0; } - if((modi&0x80) == 0x80) {/* drive is removable */ + if ((modi&0x80) == 0x80) { + /* drive is removable */ dev_desc->removable = 1; } memcpy(&dev_desc->vendor[0], &usb_stor_buf[8], 8); @@ -1195,29 +1272,34 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t dev_desc->product[16] = 0; dev_desc->revision[4] = 0; #ifdef CONFIG_USB_BIN_FIXUP - usb_bin_fixup(dev->descriptor, (uchar *)dev_desc->vendor, (uchar *)dev_desc->product); + usb_bin_fixup(dev->descriptor, (uchar *)dev_desc->vendor, + (uchar *)dev_desc->product); #endif /* CONFIG_USB_BIN_FIXUP */ - USB_STOR_PRINTF("ISO Vers %X, Response Data %X\n",usb_stor_buf[2],usb_stor_buf[3]); - if(usb_test_unit_ready(pccb,ss)) { - printf("Device NOT ready\n Request Sense returned %02X %02X %02X\n",pccb->sense_buf[2],pccb->sense_buf[12],pccb->sense_buf[13]); - if(dev_desc->removable == 1) { + USB_STOR_PRINTF("ISO Vers %X, Response Data %X\n", usb_stor_buf[2], + usb_stor_buf[3]); + if (usb_test_unit_ready(pccb, ss)) { + printf("Device NOT ready\n" + " Request Sense returned %02X %02X %02X\n", + pccb->sense_buf[2], pccb->sense_buf[12], + pccb->sense_buf[13]); + if (dev_desc->removable == 1) { dev_desc->type = perq; return 1; } - else - return 0; + return 0; } pccb->pdata = (unsigned char *)&cap[0]; - memset(pccb->pdata,0,8); - if(usb_read_capacity(pccb,ss) != 0) { + memset(pccb->pdata, 0, 8); + if (usb_read_capacity(pccb, ss) != 0) { printf("READ_CAP ERROR\n"); cap[0] = 2880; cap[1] = 0x200; } - USB_STOR_PRINTF("Read Capacity returns: 0x%lx, 0x%lx\n",cap[0],cap[1]); + USB_STOR_PRINTF("Read Capacity returns: 0x%lx, 0x%lx\n", cap[0], + cap[1]); #if 0 - if(cap[0]>(0x200000 * 10)) /* greater than 10 GByte */ - cap[0]>>=16; + if (cap[0] > (0x200000 * 10)) /* greater than 10 GByte */ + cap[0] >>= 16; #endif cap[0] = cpu_to_be32(cap[0]); cap[1] = cpu_to_be32(cap[1]); @@ -1226,15 +1308,16 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t cap[0] += 1; capacity = &cap[0]; blksz = &cap[1]; - USB_STOR_PRINTF("Capacity = 0x%lx, blocksz = 0x%lx\n",*capacity,*blksz); + USB_STOR_PRINTF("Capacity = 0x%lx, blocksz = 0x%lx\n", + *capacity, *blksz); dev_desc->lba = *capacity; dev_desc->blksz = *blksz; dev_desc->type = perq; - USB_STOR_PRINTF(" address %d\n",dev_desc->target); - USB_STOR_PRINTF("partype: %d\n",dev_desc->part_type); + USB_STOR_PRINTF(" address %d\n", dev_desc->target); + USB_STOR_PRINTF("partype: %d\n", dev_desc->part_type); init_part(dev_desc); - USB_STOR_PRINTF("partype: %d\n",dev_desc->part_type); + USB_STOR_PRINTF("partype: %d\n", dev_desc->part_type); return 1; } |