From 3048bcbf0bad262378c5af68f2bf6778fb7d829a Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 3 Oct 2007 15:01:02 +0200 Subject: ppc4xx: Rename 405gp_pci to 4xx_pci since its used on all 4xx platforms These files were introduced with the IBM 405GP but are currently used on all 4xx PPC platforms. So the name doesn't match the content anymore. This patch renames the files to 4xx_pci.c/h. Signed-off-by: Stefan Roese --- common/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index 933afa9e7bc..4df01eabe51 100644 --- a/common/usb.c +++ b/common/usb.c @@ -53,7 +53,7 @@ #include #ifdef CONFIG_4xx -#include <405gp_pci.h> +#include #endif #undef USB_DEBUG -- cgit v1.2.3 From dbbd125721aea6645fdb962f36bd41f59e272f9d Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Fri, 5 Oct 2007 17:10:59 +0200 Subject: ppc4xx: Add PPC405EX support Signed-off-by: Stefan Roese --- common/serial.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/serial.c b/common/serial.c index dee1cc0ab9c..b9916e2b5ec 100644 --- a/common/serial.c +++ b/common/serial.c @@ -41,7 +41,8 @@ struct serial_device *default_serial_console (void) || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4) return &serial_scc_device; #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \ - || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx) + || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \ + || defined(CONFIG_MPC5xxx) #if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL) #if (CONFIG_CONS_INDEX==1) return &eserial1_device; @@ -91,7 +92,8 @@ void serial_initialize (void) #endif #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \ - || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx) + || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \ + || defined(CONFIG_MPC5xxx) serial_register(&serial0_device); serial_register(&serial1_device); #endif -- cgit v1.2.3 From 2ae64f5135e51bb18753884d1265b99e89b5aedd Mon Sep 17 00:00:00 2001 From: Peter Pearse Date: Thu, 15 Nov 2007 08:58:00 +0000 Subject: Remove warnings re CONFIG_EXTRA_ENV_SETTINGS Remove warnings re onenand_read() & write() --- common/env_onenand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/env_onenand.c b/common/env_onenand.c index 66107f91f17..5888f75d895 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -64,7 +64,7 @@ void env_relocate_spec(void) DECLARE_GLOBAL_DATA_PTR; unsigned long env_addr; int use_default = 0; - int retlen; + size_t retlen; env_addr = CFG_ENV_ADDR; env_addr -= (unsigned long)onenand_chip.base; @@ -96,7 +96,7 @@ int saveenv(void) { unsigned long env_addr = CFG_ENV_ADDR; struct erase_info instr; - int retlen; + size_t retlen; instr.len = CFG_ENV_SIZE; instr.addr = env_addr; -- cgit v1.2.3 From ea6d8be153ceaf16958f8009cea6d75f3ff58d92 Mon Sep 17 00:00:00 2001 From: Gerald Van Baren Date: Sat, 5 Jan 2008 14:52:04 -0500 Subject: Support setting FDT properties with optional values. Fix a bug found and documented by Bartlomiej Sieka where the optional value on "fdt set []" wasn't optional. => fdt mknode / testnode => fdt print /testnode testnode { }; => fdt set /testnode testprop => fdt print /testnode testnode { testprop; }; Signed-off-by: Gerald Van Baren --- common/cmd_fdt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 4639126536b..74e28b517d0 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -184,23 +184,28 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (argv[1][0] == 's') { char *pathp; /* path */ char *prop; /* property */ - char *newval; /* value from the user (as a string) */ int nodeoffset; /* node offset from libfdt */ static char data[SCRATCHPAD]; /* storage for the property */ int len; /* new length of the property */ int ret; /* return value */ /* - * Parameters: Node path, property, value. + * Parameters: Node path, property, optional value. */ - if (argc < 5) { + if (argc < 4) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } pathp = argv[2]; prop = argv[3]; - newval = argv[4]; + if (argc == 4) { + len = 0; + } else { + ret = fdt_parse_prop(pathp, prop, argv[4], data, &len); + if (ret != 0) + return ret; + } nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { @@ -211,9 +216,6 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) fdt_strerror(nodeoffset)); return 1; } - ret = fdt_parse_prop(pathp, prop, newval, data, &len); - if (ret != 0) - return ret; ret = fdt_setprop(fdt, nodeoffset, prop, data, len); if (ret < 0) { -- cgit v1.2.3 From 238cb7a423c6eaa36496efb788cfb9798cea7f95 Mon Sep 17 00:00:00 2001 From: Gerald Van Baren Date: Sat, 5 Jan 2008 15:33:29 -0500 Subject: Improve the FDT help message. Add a note that "fdt copy" makes the new address active. Remove most of the extra hints at the end of the fdt help. Signed-off-by: Gerald Van Baren --- common/cmd_fdt.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 74e28b517d0..9cd22ee94ae 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -683,7 +683,7 @@ U_BOOT_CMD( #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" #endif - "fdt move - Copy the fdt to \n" + "fdt move - Copy the fdt to and make it active\n" "fdt print [] - Recursive print starting at \n" "fdt list [] - Print one level starting at \n" "fdt set [] - Set [to ]\n" @@ -696,10 +696,6 @@ U_BOOT_CMD( #ifdef CONFIG_OF_HAS_BD_T "fdt bd_t - Add/replace the /bd_t branch in the tree\n" #endif - "Hints:\n" - " If the property you are setting/printing has a '#' character or spaces,\n" - " you MUST escape it with a \\ character or quote it with \".\n" - "Examples: fdt print / # print the whole tree\n" - " fdt print /cpus \"#address-cells\"\n" - " fdt set /cpus \"#address-cells\" \"[00 00 00 01]\"\n" + "NOTE: If the path or property you are setting/printing has a '#' character\n" + " or spaces, you MUST escape it with a \\ character or quote it with \".\n" ); -- cgit v1.2.3 From b60af3d4c1680487ee37e11aa1b3db6dec04d8f0 Mon Sep 17 00:00:00 2001 From: Gerald Van Baren Date: Sat, 29 Dec 2007 22:45:27 -0500 Subject: Fine grained per property /chosen updating. Implement a suggestion by Scott Wood to make the /chosen handling fine grained. Don't overwrite pre-existing properties on a per-property basis, so if /chosen exists but a necessary /chosen/property doesn't, it gets created. If a /chosen property exists, it is NOT overwritten unless the "force" flag is true. Signed-off-by: Gerald Van Baren --- common/fdt_support.c | 73 ++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'common') diff --git a/common/fdt_support.c b/common/fdt_support.c index b5ee6e9601b..92f1c7f54fd 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -111,6 +111,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) int err; u32 tmp; /* used to set 32 bit integer properties */ char *str; /* used to set string properties */ + const char *path; err = fdt_check_header(fdt); if (err < 0) { @@ -148,14 +149,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) nodeoffset = fdt_path_offset (fdt, "/chosen"); /* - * If we have a "chosen" node already the "force the writing" - * is not set, our job is done. - */ - if ((nodeoffset >= 0) && !force) - return 0; - - /* - * No "chosen" node in the blob: create it. + * If there is no "chosen" node in the blob, create it. */ if (nodeoffset < 0) { /* @@ -170,42 +164,55 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) } /* - * Update pre-existing properties, create them if non-existant. + * Create /chosen properites that don't exist in the fdt. + * If the property exists, update it only if the "force" parameter + * is true. */ str = getenv("bootargs"); if (str != NULL) { - err = fdt_setprop(fdt, nodeoffset, - "bootargs", str, strlen(str)+1); - if (err < 0) - printf("WARNING: could not set bootargs %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "bootargs", NULL); + if ((path == NULL) || force) { + err = fdt_setprop(fdt, nodeoffset, + "bootargs", str, strlen(str)+1); + if (err < 0) + printf("WARNING: could not set bootargs %s.\n", + fdt_strerror(err)); + } } if (initrd_start && initrd_end) { - tmp = __cpu_to_be32(initrd_start); - err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-start", &tmp, sizeof(tmp)); - if (err < 0) - printf("WARNING: " - "could not set linux,initrd-start %s.\n", - fdt_strerror(err)); - tmp = __cpu_to_be32(initrd_end); - err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-end", &tmp, sizeof(tmp)); - if (err < 0) - printf("WARNING: could not set linux,initrd-end %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL); + if ((path == NULL) || force) { + tmp = __cpu_to_be32(initrd_start); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-start", &tmp, sizeof(tmp)); + if (err < 0) + printf("WARNING: " + "could not set linux,initrd-start %s.\n", + fdt_strerror(err)); + tmp = __cpu_to_be32(initrd_end); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-end", &tmp, sizeof(tmp)); + if (err < 0) + printf("WARNING: could not set linux,initrd-end %s.\n", + fdt_strerror(err)); + } } #ifdef CONFIG_OF_STDOUT_VIA_ALIAS - err = fdt_fixup_stdout(fdt, nodeoffset); + path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL); + if ((path == NULL) || force) + err = fdt_fixup_stdout(fdt, nodeoffset); #endif #ifdef OF_STDOUT_PATH - err = fdt_setprop(fdt, nodeoffset, - "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1); - if (err < 0) - printf("WARNING: could not set linux,stdout-path %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL); + if ((path == NULL) || force) { + err = fdt_setprop(fdt, nodeoffset, + "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1); + if (err < 0) + printf("WARNING: could not set linux,stdout-path %s.\n", + fdt_strerror(err)); + } #endif return err; -- cgit v1.2.3 From 23d0baf967fecdaf1804f045f6339337c5607eec Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 22 Dec 2007 15:52:58 +0100 Subject: Allow CONFIG_AUTO_COMPLETE and command history CONFIG_CMDLINE_EDITING at the sametime Signed-off-by: Mike Frysinger Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/main.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/main.c b/common/main.c index 379695cc426..4253eac2d4f 100644 --- a/common/main.c +++ b/common/main.c @@ -696,7 +696,7 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num } } -static int cread_line(char *buf, unsigned int *len) +static int cread_line(const char *const prompt, char *buf, unsigned int *len) { unsigned long num = 0; unsigned long eol_num = 0; @@ -818,6 +818,7 @@ static int cread_line(char *buf, unsigned int *len) insert = !insert; break; case CTL_CH('x'): + case CTL_CH('u'): BEGINNING_OF_LINE(); ERASE_TO_EOL(); break; @@ -867,6 +868,27 @@ static int cread_line(char *buf, unsigned int *len) REFRESH_TO_EOL(); continue; } +#ifdef CONFIG_AUTO_COMPLETE + case '\t': { + int num2, col; + + /* do not autocomplete when in the middle */ + if (num < eol_num) { + getcmd_cbeep(); + break; + } + + buf[num] = '\0'; + col = strlen(prompt) + eol_num; + num2 = num; + if (cmd_auto_complete(prompt, buf, &num2, &col)) { + col = num2 - num; + num += col; + eol_num += col; + } + break; + } +#endif default: cread_add_char(ichar, insert, &num, &eol_num, buf, *len); break; @@ -909,7 +931,7 @@ int readline (const char *const prompt) puts (prompt); - rc = cread_line(p, &len); + rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; #else char *p = console_buffer; -- cgit v1.2.3 From f540c42d9564854b19ce9bbb70affe172529fe70 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 19 Dec 2007 14:09:58 +0100 Subject: Fix building with CRAMFS but not JFFS2 support Signed-off-by: Harald Welte --- common/cmd_jffs2.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index efe9eb7be4c..1b67e73f111 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -167,10 +167,19 @@ struct list_head devices; static struct mtd_device *current_dev = NULL; static u8 current_partnum = 0; +#if defined(CONFIG_CMD_CRAMFS) extern int cramfs_check (struct part_info *info); extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename); extern int cramfs_ls (struct part_info *info, char *filename); extern int cramfs_info (struct part_info *info); +#else +/* defining empty macros for function names is ugly but avoids ifdef clutter + * all over the code */ +#define cramfs_check(x) (0) +#define cramfs_load(x,y,z) (-1) +#define cramfs_ls(x,y) (0) +#define cramfs_info(x) (0) +#endif static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num); -- cgit v1.2.3 From 62d4f4365341576f5a5307b2b205a5aa2e3c6be6 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 19 Dec 2007 14:12:53 +0100 Subject: Re-introduce the 'nand read.oob' and 'nand write.oob' commands that used to exist with the legacy NAND code Signed-off-by: Harald Welte --- common/cmd_nand.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 1fdd7a67f60..b248a2cdb2c 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -347,6 +347,14 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) opts.quiet = quiet; ret = nand_write_opts(nand, &opts); } + } else if (s != NULL && !strcmp(s, ".oob")) { + /* read out-of-band data */ + if (read) + ret = nand->read_oob(nand, off, size, &size, + (u_char *) addr); + else + ret = nand->write_oob(nand, off, size, &size, + (u_char *) addr); } else { if (read) ret = nand_read(nand, off, &size, (u_char *)addr); -- cgit v1.2.3 From d16471ee05ce7ac5392bc0e9fe3ff4b58a768f33 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 19 Dec 2007 14:14:47 +0100 Subject: add 'terminal program' functionality This patch adds a 'cu' like serial terminal command to u-boot using which you can access other serial ports from the system console. OpenMoko uses this in their Neo1973 phones to get access to the GSM Modem and GPS chip from the bootloader. Signed-off-by: Harald Welte --- common/Makefile | 1 + common/cmd_terminal.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 common/cmd_terminal.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 7be89a41c6e..fbfa536a30c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -86,6 +86,7 @@ COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o COBJS-y += cmd_sata.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o +COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o COBJS-$(CONFIG_CMD_USB) += cmd_usb.o COBJS-y += cmd_vfd.o diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c new file mode 100644 index 00000000000..88716072b30 --- /dev/null +++ b/common/cmd_terminal.c @@ -0,0 +1,102 @@ +/* + * (C) Copyright 2007 OpenMoko, Inc. + * Written by Harald Welte + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * Boot support + */ +#include +#include +#include + +#if defined(CONFIG_CMD_TERMINAL) + +int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[]) +{ + int i, l; + int last_tilde = 0; + device_t *dev = NULL; + + if (argc < 1) + return -1; + + /* Scan for selected output/input device */ + for (i = 1; i <= ListNumItems (devlist); i++) { + device_t *tmp = ListGetPtrToItem (devlist, i); + if (!strcmp(tmp->name, argv[1])) { + dev = tmp; + break; + } + } + if (!dev) + return -1; + + serial_reinit_all(); + printf("Entering terminal mode for port %s\n", dev->name); + puts("Use '~.' to leave the terminal and get back to u-boot\n"); + + while (1) { + int c; + + /* read from console and display on serial port */ + if (stdio_devices[0]->tstc()) { + c = stdio_devices[0]->getc(); + if (last_tilde == 1) { + if (c == '.') { + putc(c); + putc('\n'); + break; + } else { + last_tilde = 0; + /* write the delayed tilde */ + dev->putc('~'); + /* fall-through to print current + * character */ + } + } + if (c == '~') { + last_tilde = 1; + puts("[u-boot]"); + putc(c); + } + dev->putc(c); + } + + /* read from serial port and display on console */ + if (dev->tstc()) { + c = dev->getc(); + putc(c); + } + } + return 0; +} + + +/***************************************************/ + +U_BOOT_CMD( + terminal, 3, 1, do_terminal, + "terminal - start terminal emulator\n", + "" +); + +#endif /* CONFIG_CMD_TERMINAL */ -- cgit v1.2.3 From 1208a2dfde02bedd3c5bda29a606632b8e0be058 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 27 Dec 2007 16:57:23 +0100 Subject: serial: Make default_serial_console() a weak function With this patch it is possible to reimplement default_serial_console() in board specific code. This will be done in the upcomming PMC440 U-Boot port. This also allows the lwmon board maintainer to remove the '#if !defined(CONFIG_LWMON) ...' from common/serial.c. Signed-off-by: Matthias Fuchs --- common/serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/serial.c b/common/serial.c index b9916e2b5ec..56010807be5 100644 --- a/common/serial.c +++ b/common/serial.c @@ -33,7 +33,7 @@ static struct serial_device *serial_devices = NULL; static struct serial_device *serial_current = NULL; #if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA27X) -struct serial_device *default_serial_console (void) +struct serial_device *__default_serial_console (void) { #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) return &serial_smc_device; @@ -64,6 +64,8 @@ struct serial_device *default_serial_console (void) #error No default console #endif } + +struct serial_device *default_serial_console(void) __attribute__((weak, alias("__default_serial_console"))); #endif int serial_register (struct serial_device *dev) -- cgit v1.2.3 From 0133502e39ff89b67c26cb4015e0e7e8d9571184 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 27 Dec 2007 17:12:34 +0100 Subject: Improve configuration of FPGA subsystem This patch removes the FPGA subsystem configuration through the CONFIG_FPGA bitmask configuration option. See README for the new options: CONFIG_FPGA, CONFIG_FPGA_, CONFIG_FPGA_ Signed-off-by: Matthias Fuchs --- common/ACEX1K.c | 4 ++-- common/altera.c | 18 +++++++++--------- common/cmd_fpga.c | 2 +- common/cyclon2.c | 4 ++-- common/fpga.c | 30 +++++++++++------------------- common/spartan2.c | 2 +- common/spartan3.c | 2 +- common/virtex2.c | 2 +- common/xilinx.c | 28 ++++++++++++++-------------- 9 files changed, 42 insertions(+), 50 deletions(-) (limited to 'common') diff --git a/common/ACEX1K.c b/common/ACEX1K.c index 2a421e2da9c..76dc1664385 100644 --- a/common/ACEX1K.c +++ b/common/ACEX1K.c @@ -28,7 +28,7 @@ #include /* core U-Boot definitions */ #include /* ACEX device family */ -#if (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_ACEX1K) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -363,4 +363,4 @@ static int ACEX1K_ps_reloc (Altera_desc * desc, ulong reloc_offset) } -#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K)) */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_ACEX1K */ diff --git a/common/altera.c b/common/altera.c index 06e8a950158..0df7bae013e 100644 --- a/common/altera.c +++ b/common/altera.c @@ -40,7 +40,7 @@ #define PRINTF(fmt,args...) #endif -#if (CONFIG_FPGA & CFG_FPGA_ALTERA) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) /* Local Static Functions */ static int altera_validate (Altera_desc * desc, char *fn); @@ -56,11 +56,11 @@ int altera_load( Altera_desc *desc, void *buf, size_t bsize ) switch (desc->family) { case Altera_ACEX1K: case Altera_CYC2: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) PRINTF ("%s: Launching the ACEX1K Loader...\n", __FUNCTION__); ret_val = ACEX1K_load (desc, buf, bsize); -#elif (CONFIG_FPGA & CFG_CYCLON2) +#elif defined CONFIG_FPGA_CYCLON2 PRINTF ("%s: Launching the CYCLON II Loader...\n", __FUNCTION__); ret_val = CYC2_load (desc, buf, bsize); @@ -88,7 +88,7 @@ int altera_dump( Altera_desc *desc, void *buf, size_t bsize ) } else { switch (desc->family) { case Altera_ACEX1K: -#if (CONFIG_FPGA & CFG_ACEX) +#if defined(CONFIG_FPGA_ACEX) PRINTF ("%s: Launching the ACEX1K Reader...\n", __FUNCTION__); ret_val = ACEX1K_dump (desc, buf, bsize); @@ -156,9 +156,9 @@ int altera_info( Altera_desc *desc ) switch (desc->family) { case Altera_ACEX1K: case Altera_CYC2: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) ACEX1K_info (desc); -#elif (CONFIG_FPGA & CFG_CYCLON2) +#elif defined(CONFIG_FPGA_CYCLON2) CYC2_info (desc); #else /* just in case */ @@ -192,7 +192,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset) } else { switch (desc->family) { case Altera_ACEX1K: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) ret_val = ACEX1K_reloc (desc, reloc_offset); #else printf ("%s: No support for ACEX devices.\n", @@ -200,7 +200,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset) #endif break; case Altera_CYC2: -#if (CONFIG_FPGA & CFG_CYCLON2) +#if defined(CONFIG_FPGA_CYCLON2) ret_val = CYC2_reloc (desc, reloc_offset); #else printf ("%s: No support for CYCLON II devices.\n", @@ -249,4 +249,4 @@ static int altera_validate (Altera_desc * desc, char *fn) /* ------------------------------------------------------------------------- */ -#endif /* CONFIG_FPGA & CFG_FPGA_ALTERA */ +#endif /* CONFIG_FPGA & CONFIG_FPGA_ALTERA */ diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index 377a692f7dc..fb24395b58a 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -58,7 +58,7 @@ static int fpga_get_op (char *opstr); /* Convert bitstream data and load into the fpga */ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) { -#if (CONFIG_FPGA & CFG_FPGA_XILINX) +#if defined(CONFIG_FPGA_XILINX) unsigned int length; unsigned char* swapdata; unsigned int swapsize; diff --git a/common/cyclon2.c b/common/cyclon2.c index dce13b50d00..06f5e8aeaec 100644 --- a/common/cyclon2.c +++ b/common/cyclon2.c @@ -27,7 +27,7 @@ #include #include /* ACEX device family */ -#if (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_CYCLON2) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -302,4 +302,4 @@ static int CYC2_ps_reloc (Altera_desc * desc, ulong reloc_offset) return ret_val; } -#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2)) */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_CYCLON2 */ diff --git a/common/fpga.c b/common/fpga.c index 2eff239c478..d8b6ae354ab 100644 --- a/common/fpga.c +++ b/common/fpga.c @@ -67,14 +67,11 @@ static int fpga_dev_info( int devnum ); static void fpga_no_sup( char *fn, char *msg ) { if ( fn && msg ) { - printf( "%s: No support for %s. CONFIG_FPGA defined as 0x%x.\n", - fn, msg, CONFIG_FPGA ); + printf( "%s: No support for %s.\n", fn, msg); } else if ( msg ) { - printf( "No support for %s. CONFIG_FPGA defined as 0x%x.\n", - msg, CONFIG_FPGA ); + printf( "No support for %s.\n", msg); } else { - printf( "No FPGA suport! CONFIG_FPGA defined as 0x%x.\n", - CONFIG_FPGA ); + printf( "No FPGA suport!\n"); } } @@ -112,11 +109,6 @@ static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_va printf( "%s: Null buffer.\n", fn ); return (fpga_desc * const)NULL; } - if ( !bsize ) { - printf( "%s: Null buffer size.\n", fn ); - return (fpga_desc * const)NULL; - } - return desc; } @@ -135,7 +127,7 @@ static int fpga_dev_info( int devnum ) switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) printf( "Xilinx Device\nDescriptor @ 0x%p\n", desc ); ret_val = xilinx_info( desc->devdesc ); #else @@ -143,7 +135,7 @@ static int fpga_dev_info( int devnum ) #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) printf( "Altera Device\nDescriptor @ 0x%p\n", desc ); ret_val = altera_info( desc->devdesc ); #else @@ -175,14 +167,14 @@ int fpga_reloc( fpga_type devtype, void *desc, ulong reloc_off ) switch ( devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_reloc( desc, reloc_off ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_reloc( desc, reloc_off ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); @@ -268,14 +260,14 @@ int fpga_load( int devnum, void *buf, size_t bsize ) if ( desc ) { switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_load( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_load( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); @@ -301,14 +293,14 @@ int fpga_dump( int devnum, void *buf, size_t bsize ) if ( desc ) { switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_dump( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_dump( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); diff --git a/common/spartan2.c b/common/spartan2.c index 06550b9858c..457009f8584 100644 --- a/common/spartan2.c +++ b/common/spartan2.c @@ -25,7 +25,7 @@ #include /* core U-Boot definitions */ #include /* Spartan-II device family */ -#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN2) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG diff --git a/common/spartan3.c b/common/spartan3.c index f7c4f8cf2b2..17379eb8b1e 100644 --- a/common/spartan3.c +++ b/common/spartan3.c @@ -30,7 +30,7 @@ #include /* core U-Boot definitions */ #include /* Spartan-II device family */ -#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN3)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN3) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG diff --git a/common/virtex2.c b/common/virtex2.c index b5dc366aad3..1283ff610d8 100644 --- a/common/virtex2.c +++ b/common/virtex2.c @@ -31,7 +31,7 @@ #include #include -#if (CONFIG_FPGA & (CFG_XILINX | CFG_VIRTEX2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_VIRTEX2) #if 0 #define FPGA_DEBUG diff --git a/common/xilinx.c b/common/xilinx.c index e03e78cb285..c8982386824 100644 --- a/common/xilinx.c +++ b/common/xilinx.c @@ -32,7 +32,7 @@ #include #include -#if (CONFIG_FPGA & CFG_FPGA_XILINX) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX) #if 0 #define FPGA_DEBUG @@ -59,7 +59,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) PRINTF ("%s: Launching the Spartan-II Loader...\n", __FUNCTION__); ret_val = Spartan2_load (desc, buf, bsize); @@ -69,7 +69,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) PRINTF ("%s: Launching the Spartan-III Loader...\n", __FUNCTION__); ret_val = Spartan3_load (desc, buf, bsize); @@ -79,7 +79,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) PRINTF ("%s: Launching the Virtex-II Loader...\n", __FUNCTION__); ret_val = Virtex2_load (desc, buf, bsize); @@ -106,7 +106,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) PRINTF ("%s: Launching the Spartan-II Reader...\n", __FUNCTION__); ret_val = Spartan2_dump (desc, buf, bsize); @@ -116,7 +116,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) PRINTF ("%s: Launching the Spartan-III Reader...\n", __FUNCTION__); ret_val = Spartan3_dump (desc, buf, bsize); @@ -126,7 +126,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined( CONFIG_FPGA_VIRTEX2) PRINTF ("%s: Launching the Virtex-II Reader...\n", __FUNCTION__); ret_val = Virtex2_dump (desc, buf, bsize); @@ -198,7 +198,7 @@ int xilinx_info (Xilinx_desc * desc) printf ("Device Function Table @ 0x%p\n", desc->iface_fns); switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) Spartan2_info (desc); #else /* just in case */ @@ -207,7 +207,7 @@ int xilinx_info (Xilinx_desc * desc) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) Spartan3_info (desc); #else /* just in case */ @@ -216,7 +216,7 @@ int xilinx_info (Xilinx_desc * desc) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) Virtex2_info (desc); #else /* just in case */ @@ -249,7 +249,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) ret_val = Spartan2_reloc (desc, reloc_offset); #else printf ("%s: No support for Spartan-II devices.\n", @@ -257,7 +257,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) ret_val = Spartan3_reloc (desc, reloc_offset); #else printf ("%s: No support for Spartan-III devices.\n", @@ -265,7 +265,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) ret_val = Virtex2_reloc (desc, reloc_offset); #else printf ("%s: No support for Virtex-II devices.\n", @@ -308,4 +308,4 @@ static int xilinx_validate (Xilinx_desc * desc, char *fn) return ret_val; } -#endif /* CONFIG_FPGA & CFG_FPGA_XILINX */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_XILINX */ -- cgit v1.2.3 From 21d39d598c4e74d4e7761608c79dba2715d40a4c Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 27 Dec 2007 17:12:43 +0100 Subject: Add pre and post configuration callbacks for Spartan FPGAs This patch adds a post configuration callback for Spartan2/3 FPGAs. pre and post configuration callback are now optional and not called when the function pointer is set to NULL. Signed-off-by: Matthias Fuchs --- common/spartan2.c | 18 ++++++++++++++++-- common/spartan3.c | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/spartan2.c b/common/spartan2.c index 457009f8584..ef107bcbc86 100644 --- a/common/spartan2.c +++ b/common/spartan2.c @@ -561,6 +561,13 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) } putc ('\n'); /* terminate the dotted line */ + /* + * Run the post configuration function if there is one. + */ + if (*fn->post) { + (*fn->post) (cookie); + } + #ifdef CFG_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); @@ -615,8 +622,10 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, desc); - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Xilinx_pre_fn) addr; + if (fn->pre) { + addr = (ulong) (fn->pre) + reloc_offset; + fn_r->pre = (Xilinx_pre_fn) addr; + } addr = (ulong) (fn->pgm) + reloc_offset; fn_r->pgm = (Xilinx_pgm_fn) addr; @@ -633,6 +642,11 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) addr = (ulong) (fn->wr) + reloc_offset; fn_r->wr = (Xilinx_wr_fn) addr; + if (fn->post) { + addr = (ulong) (fn->post) + reloc_offset; + fn_r->post = (Xilinx_post_fn) addr; + } + fn_r->relocated = TRUE; } else { diff --git a/common/spartan3.c b/common/spartan3.c index 17379eb8b1e..56a172e0be8 100644 --- a/common/spartan3.c +++ b/common/spartan3.c @@ -566,6 +566,13 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) } putc ('\n'); /* terminate the dotted line */ + /* + * Run the post configuration function if there is one. + */ + if (*fn->post) { + (*fn->post) (cookie); + } + #ifdef CFG_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); @@ -620,8 +627,10 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, desc); - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Xilinx_pre_fn) addr; + if (fn->pre) { + addr = (ulong) (fn->pre) + reloc_offset; + fn_r->pre = (Xilinx_pre_fn) addr; + } addr = (ulong) (fn->pgm) + reloc_offset; fn_r->pgm = (Xilinx_pgm_fn) addr; @@ -638,6 +647,11 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) addr = (ulong) (fn->wr) + reloc_offset; fn_r->wr = (Xilinx_wr_fn) addr; + if (fn->post) { + addr = (ulong) (fn->post) + reloc_offset; + fn_r->post = (Xilinx_post_fn) addr; + } + fn_r->relocated = TRUE; } else { -- cgit v1.2.3 From 437fc7327f0611f82937858f2d80e4cd61b40984 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 27 Dec 2007 17:13:05 +0100 Subject: Fix MSB check in Xilinx Spartan slave serial mode Signed-off-by: Matthias Fuchs --- common/spartan2.c | 2 +- common/spartan3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/spartan2.c b/common/spartan2.c index ef107bcbc86..2f1ea2c099e 100644 --- a/common/spartan2.c +++ b/common/spartan2.c @@ -441,7 +441,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ Xilinx_Spartan2_Slave_Serial_fns *fn = desc->iface_fns; int i; - char val; + unsigned char val; PRINTF ("%s: start with interface functions @ 0x%p\n", __FUNCTION__, fn); diff --git a/common/spartan3.c b/common/spartan3.c index 56a172e0be8..d329e70cf73 100644 --- a/common/spartan3.c +++ b/common/spartan3.c @@ -446,7 +446,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ Xilinx_Spartan3_Slave_Serial_fns *fn = desc->iface_fns; int i; - char val; + unsigned char val; PRINTF ("%s: start with interface functions @ 0x%p\n", __FUNCTION__, fn); -- cgit v1.2.3 From c26acc1a43b31ddca5add42fd0360ff0eee90c80 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 27 Dec 2007 17:13:11 +0100 Subject: Remove bit swapping in Xilinx Spartan bitfile loading This patch removes the unnecessary bit swapping when booting .bit files with the 'fpga loadb' command. Signed-off-by: Matthias Fuchs --- common/cmd_fpga.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'common') diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index fb24395b58a..f55447ab1fe 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -60,12 +60,9 @@ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) { #if defined(CONFIG_FPGA_XILINX) unsigned int length; - unsigned char* swapdata; unsigned int swapsize; char buffer[80]; - unsigned char *ptr; unsigned char *dataptr; - unsigned char data; unsigned int i; int rc; @@ -143,39 +140,7 @@ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) dataptr+=4; printf(" bytes in bitstream = %d\n", swapsize); - /* check consistency of length obtained */ - if (swapsize >= size) { - printf("%s: Could not find right length of data in bitstream\n", - __FUNCTION__); - return FPGA_FAIL; - } - - /* allocate memory */ - swapdata = (unsigned char *)malloc(swapsize); - if (swapdata == NULL) { - printf("%s: Could not allocate %d bytes memory !\n", - __FUNCTION__, swapsize); - return FPGA_FAIL; - } - - /* read data into memory and swap bits */ - ptr = swapdata; - for (i = 0; i < swapsize; i++) { - data = 0x00; - data |= (*dataptr & 0x01) << 7; - data |= (*dataptr & 0x02) << 5; - data |= (*dataptr & 0x04) << 3; - data |= (*dataptr & 0x08) << 1; - data |= (*dataptr & 0x10) >> 1; - data |= (*dataptr & 0x20) >> 3; - data |= (*dataptr & 0x40) >> 5; - data |= (*dataptr & 0x80) >> 7; - *ptr++ = data; - dataptr++; - } - - rc = fpga_load(dev, swapdata, swapsize); - free(swapdata); + rc = fpga_load(dev, dataptr, swapsize); return rc; #else printf("Bitstream support only for Xilinx devices\n"); -- cgit v1.2.3 From 43ef1c381f9195504a2488f5cb909227eb97d475 Mon Sep 17 00:00:00 2001 From: Hans-Christian Egtvedt Date: Fri, 30 Nov 2007 17:29:59 +0100 Subject: cmd_bmp: Add support for displaying gzip compressed bmps The existing code can show information about a gzip compressed BMP image, but can't actually display it. Therefore, move the decompression code out of bmp_info() and use it in bmp_display() as well in order to display a compressed BMP image. Also, clean things up a bit and fix a memory leak while we're at it. [hskinnemoen@atmel.com: a bit of refactoring] Signed-off-by: Haavard Skinnemoen --- common/cmd_bmp.c | 134 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 49 deletions(-) (limited to 'common') diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 907f9a2db7e..2437e227801 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -36,6 +36,62 @@ static int bmp_display (ulong addr, int x, int y); int gunzip(void *, int, unsigned char *, unsigned long *); +/* + * Allocate and decompress a BMP image using gunzip(). + * + * Returns a pointer to the decompressed image data. Must be freed by + * the caller after use. + * + * Returns NULL if decompression failed, or if the decompressed data + * didn't contain a valid BMP signature. + */ +#ifdef CONFIG_VIDEO_BMP_GZIP +static bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) +{ + void *dst; + unsigned long len; + bmp_image_t *bmp; + + /* + * Decompress bmp image + */ + len = CFG_VIDEO_LOGO_MAX_SIZE; + dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); + if (dst == NULL) { + puts("Error: malloc in gunzip failed!\n"); + return NULL; + } + if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { + free(dst); + return NULL; + } + if (len == CFG_VIDEO_LOGO_MAX_SIZE) + puts("Image could be truncated" + " (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); + + bmp = dst; + + /* + * Check for bmp mark 'BM' + */ + if (!((bmp->header.signature[0] == 'B') && + (bmp->header.signature[1] == 'M'))) { + free(dst); + return NULL; + } + + puts("Gzipped BMP image detected!\n"); + + return bmp; +} +#else +static bmp_image_t *gunzip_bmp(unsigned long addr) +{ + return NULL; +} +#endif + + /* * Subroutine: do_bmp * @@ -101,63 +157,24 @@ U_BOOT_CMD( static int bmp_info(ulong addr) { bmp_image_t *bmp=(bmp_image_t *)addr; -#ifdef CONFIG_VIDEO_BMP_GZIP - unsigned char *dst = NULL; - ulong len; -#endif /* CONFIG_VIDEO_BMP_GZIP */ + unsigned long len; if (!((bmp->header.signature[0]=='B') && - (bmp->header.signature[1]=='M'))) { + (bmp->header.signature[1]=='M'))) + bmp = gunzip_bmp(addr, &len); -#ifdef CONFIG_VIDEO_BMP_GZIP - /* - * Decompress bmp image - */ - len = CFG_VIDEO_LOGO_MAX_SIZE; - dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); - if (dst == NULL) { - printf("Error: malloc in gunzip failed!\n"); - return(1); - } - if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { - printf("There is no valid bmp file at the given address\n"); - return(1); - } - if (len == CFG_VIDEO_LOGO_MAX_SIZE) { - printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); - } - - /* - * Set addr to decompressed image - */ - bmp = (bmp_image_t *)dst; - - /* - * Check for bmp mark 'BM' - */ - if (!((bmp->header.signature[0] == 'B') && - (bmp->header.signature[1] == 'M'))) { - printf("There is no valid bmp file at the given address\n"); - free(dst); - return(1); - } - - printf("Gzipped BMP image detected!\n"); -#else /* CONFIG_VIDEO_BMP_GZIP */ + if (bmp == NULL) { printf("There is no valid bmp file at the given address\n"); - return(1); -#endif /* CONFIG_VIDEO_BMP_GZIP */ + return 1; } + printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), le32_to_cpu(bmp->header.height)); printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); -#ifdef CONFIG_VIDEO_BMP_GZIP - if (dst) { - free(dst); - } -#endif /* CONFIG_VIDEO_BMP_GZIP */ + if ((unsigned long)bmp != addr) + free(bmp); return(0); } @@ -174,14 +191,33 @@ static int bmp_info(ulong addr) */ static int bmp_display(ulong addr, int x, int y) { + int ret; + bmp_image_t *bmp = (bmp_image_t *)addr; + unsigned long len; + + if (!((bmp->header.signature[0]=='B') && + (bmp->header.signature[1]=='M'))) + bmp = gunzip_bmp(addr, &len); + + if (!bmp) { + printf("There is no valid bmp file at the given address\n"); + return 1; + } + #if defined(CONFIG_LCD) extern int lcd_display_bitmap (ulong, int, int); - return (lcd_display_bitmap (addr, x, y)); + ret = lcd_display_bitmap ((unsigned long)bmp, x, y); #elif defined(CONFIG_VIDEO) extern int video_display_bitmap (ulong, int, int); - return (video_display_bitmap (addr, x, y)); + + ret = video_display_bitmap ((unsigned long)bmp, x, y); #else # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO #endif + + if ((unsigned long)bmp != addr) + free(bmp); + + return ret; } -- cgit v1.2.3 From 26a41790f8eba19ad450e18ae91351daf485b3e2 Mon Sep 17 00:00:00 2001 From: Rafal Jaworowski Date: Wed, 9 Jan 2008 18:05:27 +0100 Subject: Globalize envmatch() The newly introduced API (routines related to env vars) will need to call it. Signed-off-by: Rafal Zabdyr --- common/cmd_nvedit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 67704088104..dd263b66663 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -81,8 +81,6 @@ extern void env_crc_update (void); /************************************************************************ ************************************************************************/ -static int envmatch (uchar *, int); - /* * Table with supported baudrates (defined in config_xyz.h) */ @@ -576,8 +574,7 @@ int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) * If the names match, return the index for the value2, else NULL. */ -static int -envmatch (uchar *s1, int i2) +int envmatch (uchar *s1, int i2) { while (*s1 == env_get_char(i2++)) -- cgit v1.2.3 From b9173af73e524d37c812f210173cf83385c5171a Mon Sep 17 00:00:00 2001 From: Shinya Kuribayashi Date: Thu, 27 Dec 2007 15:39:54 +0900 Subject: common/cmd_mii.c: Add sanity argc check If type mii command without arguments, we suffer from uninitialized argv[] entries; for example we MIPS get stuck by TLB error. Signed-off-by: Shinya Kuribayashi --- common/cmd_mii.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common') diff --git a/common/cmd_mii.c b/common/cmd_mii.c index f530a38421e..079612a4e65 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -438,6 +438,11 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int rcode = 0; char *devname; + if (argc < 2) { + printf("Usage:\n%s\n", cmdtp->usage); + return 1; + } + #if defined(CONFIG_8xx) || defined(CONFIG_MCF532x) mii_init (); #endif -- cgit v1.2.3 From a9b410dc7d2a4721c408b13abfc037988150f145 Mon Sep 17 00:00:00 2001 From: Shinya Kuribayashi Date: Fri, 28 Dec 2007 12:50:59 +0900 Subject: Remove the obsolete terse version of do_mii() We now have more useful version of do_mii() and everybody use it. Gerald Van Baren says: > When I originally wrote the mii command 6(!) years ago, I wrote a > verbose version that printed human readable decomposition of the flags, > etc., and a terse one that didn't print as much stuff and thus had a > smaller memory footprint. > > It sounds like the terse version has withered and died, apparently > people are only using the verbose version (which is very understandable, > I do myself). Signed-off-by: Shinya Kuribayashi Signed-off-by: Gerald Van Baren --- common/cmd_mii.c | 139 ------------------------------------------------------- 1 file changed, 139 deletions(-) (limited to 'common') diff --git a/common/cmd_mii.c b/common/cmd_mii.c index 079612a4e65..31ac43db588 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -29,143 +29,6 @@ #include #include -#ifdef CONFIG_TERSE_MII -/* - * Display values from last command. - */ -uint last_op; -uint last_addr; -uint last_data; -uint last_reg; - -/* - * MII device/info/read/write - * - * Syntax: - * mii device {devname} - * mii info {addr} - * mii read {addr} {reg} - * mii write {addr} {reg} {data} - */ -int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) -{ - char op; - unsigned char addr, reg; - unsigned short data; - int rcode = 0; - char *devname; - - if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - -#if defined(CONFIG_8xx) || defined(CONFIG_MCF52x2) - mii_init (); -#endif - - /* - * We use the last specified parameters, unless new ones are - * entered. - */ - op = last_op; - addr = last_addr; - data = last_data; - reg = last_reg; - - if ((flag & CMD_FLAG_REPEAT) == 0) { - op = argv[1][0]; - if (argc >= 3) - addr = simple_strtoul (argv[2], NULL, 16); - if (argc >= 4) - reg = simple_strtoul (argv[3], NULL, 16); - if (argc >= 5) - data = simple_strtoul (argv[4], NULL, 16); - } - - /* use current device */ - devname = miiphy_get_current_dev(); - - /* - * check device/read/write/list. - */ - if (op == 'i') { - unsigned char j, start, end; - unsigned int oui; - unsigned char model; - unsigned char rev; - - /* - * Look for any and all PHYs. Valid addresses are 0..31. - */ - if (argc >= 3) { - start = addr; end = addr + 1; - } else { - start = 0; end = 31; - } - - for (j = start; j < end; j++) { - if (miiphy_info (devname, j, &oui, &model, &rev) == 0) { - printf ("PHY 0x%02X: " - "OUI = 0x%04X, " - "Model = 0x%02X, " - "Rev = 0x%02X, " - "%3dbase%s, %s\n", - j, oui, model, rev, - miiphy_speed (devname, j), - miiphy_is_1000base_x (devname, j) - ? "X" : "T", - (miiphy_duplex (devname, j) == FULL) - ? "FDX" : "HDX"); - } - } - } else if (op == 'r') { - if (miiphy_read (devname, addr, reg, &data) != 0) { - puts ("Error reading from the PHY\n"); - rcode = 1; - } else { - printf ("%04X\n", data & 0x0000FFFF); - } - } else if (op == 'w') { - if (miiphy_write (devname, addr, reg, data) != 0) { - puts ("Error writing to the PHY\n"); - rcode = 1; - } - } else if (op == 'd') { - if (argc == 2) - miiphy_listdev (); - else - miiphy_set_current_dev (argv[2]); - } else { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - /* - * Save the parameters for repeats. - */ - last_op = op; - last_addr = addr; - last_data = data; - last_reg = reg; - - return rcode; -} - -/***************************************************/ - -U_BOOT_CMD( - mii, 5, 1, do_mii, - "mii - MII utility commands\n", - "device - list available devices\n" - "mii device - set current device\n" - "mii info - display MII PHY info\n" - "mii read - read MII PHY register \n" - "mii write - write MII PHY register \n" -); - -#else /* ! CONFIG_TERSE_MII ================================================= */ - typedef struct _MII_reg_desc_t { ushort regno; char * name; @@ -599,5 +462,3 @@ U_BOOT_CMD( "mii dump - pretty-print (0-5 only)\n" "Addr and/or reg may be ranges, e.g. 2-7.\n" ); - -#endif /* CONFIG_TERSE_MII */ -- cgit v1.2.3 From 7817cb2083d982923752fe0f12b67c0e7c09a027 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Sun, 30 Dec 2007 03:30:46 +0100 Subject: fix comments with new drivers organization Signed-off-by: Marcel Ziswiler --- common/env_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/env_nand.c b/common/env_nand.c index 38a07f8993f..ce0a2514db4 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -57,7 +57,7 @@ int nand_legacy_rw (struct nand_chip* nand, int cmd, size_t start, size_t len, size_t * retlen, u_char * buf); -/* info for NAND chips, defined in drivers/nand/nand.c */ +/* info for NAND chips, defined in drivers/mtd/nand/nand.c */ extern nand_info_t nand_info[]; /* references to names in env_common.c */ -- cgit v1.2.3 From 4785a694c0045996ccf0ac5b8edf531efc1b730e Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Thu, 3 Jan 2008 10:51:15 +0800 Subject: Add Ctrl combo key support to usb keyboard driver. Ctrl combo key support is added, which is very useful to input Ctrl-C for interrupt current job. Also add usb_event_poll() calling to usb_kbd_testc(), which can get key input when tstc() is called. Signed-off-by: Zhang Wei --- common/usb_kbd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common') diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 7bdfcc0b903..1703b2339b8 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -84,6 +84,7 @@ int repeat_delay; static unsigned char num_lock = 0; static unsigned char caps_lock = 0; static unsigned char scroll_lock = 0; +static unsigned char ctrl = 0; static unsigned char leds __attribute__ ((aligned (0x4))); @@ -120,6 +121,9 @@ static void usb_kbd_put_queue(char data) /* test if a character is in the queue */ static int usb_kbd_testc(void) { +#ifdef CFG_USB_EVENT_POLL + usb_event_poll(); +#endif if(usb_in_pointer==usb_out_pointer) return(0); /* no data */ else @@ -274,6 +278,10 @@ static int usb_kbd_translate(unsigned char scancode,unsigned char modifier,int p else /* non shifted */ keycode=usb_kbd_numkey[scancode-0x1e]; } + + if (ctrl) + keycode = scancode - 0x3; + if(pressed==1) { if(scancode==NUM_LOCK) { num_lock=~num_lock; @@ -306,6 +314,17 @@ static int usb_kbd_irq(struct usb_device *dev) return 1; } res=0; + + switch (new[0]) { + case 0x0: /* No combo key pressed */ + ctrl = 0; + break; + case 0x01: /* Left Ctrl pressed */ + case 0x10: /* Right Ctrl pressed */ + ctrl = 1; + break; + } + for (i = 2; i < 8; i++) { if (old[i] > 3 && memscan(&new[2], old[i], 6) == &new[8]) { res|=usb_kbd_translate(old[i],new[0],0); -- cgit v1.2.3 From 6636b62a6efc7f14e6e788788631ae7a7fca4537 Mon Sep 17 00:00:00 2001 From: James Yang Date: Wed, 9 Jan 2008 11:17:49 -0600 Subject: Expose parse_line() globally. Add new function readline_into_buffer() that allows the output of readline to be put into a pointer to char buffer. This refactoring allows other functions besides the main command loop to also use the same input mechanism. Signed-off-by: James Yang Acked-by: Jon Loeliger --- common/main.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'common') diff --git a/common/main.c b/common/main.c index 4253eac2d4f..ad2a386c865 100644 --- a/common/main.c +++ b/common/main.c @@ -59,7 +59,6 @@ extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); #define MAX_DELAY_STOP_STR 32 -static int parse_line (char *, char *[]); #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) static int abortboot(int); #endif @@ -918,8 +917,15 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len) */ int readline (const char *const prompt) { + return readline_into_buffer(prompt, console_buffer); +} + + +int readline_into_buffer (const char *const prompt, char * buffer) +{ + char *p = buffer; + char * p_buf = p; #ifdef CONFIG_CMDLINE_EDITING - char *p = console_buffer; unsigned int len=MAX_CMDBUF_SIZE; int rc; static int initted = 0; @@ -934,7 +940,6 @@ int readline (const char *const prompt) rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; #else - char *p = console_buffer; int n = 0; /* buffer index */ int plen = 0; /* prompt length */ int col; /* output column cnt */ @@ -972,13 +977,13 @@ int readline (const char *const prompt) case '\n': *p = '\0'; puts ("\r\n"); - return (p - console_buffer); + return (p - p_buf); case '\0': /* nul */ continue; case 0x03: /* ^C - break */ - console_buffer[0] = '\0'; /* discard input */ + p_buf[0] = '\0'; /* discard input */ return (-1); case 0x15: /* ^U - erase line */ @@ -986,20 +991,20 @@ int readline (const char *const prompt) puts (erase_seq); --col; } - p = console_buffer; + p = p_buf; n = 0; continue; case 0x17: /* ^W - erase word */ - p=delete_char(console_buffer, p, &col, &n, plen); + p=delete_char(p_buf, p, &col, &n, plen); while ((n > 0) && (*p != ' ')) { - p=delete_char(console_buffer, p, &col, &n, plen); + p=delete_char(p_buf, p, &col, &n, plen); } continue; case 0x08: /* ^H - backspace */ case 0x7F: /* DEL - backspace */ - p=delete_char(console_buffer, p, &col, &n, plen); + p=delete_char(p_buf, p, &col, &n, plen); continue; default: @@ -1012,7 +1017,7 @@ int readline (const char *const prompt) /* if auto completion triggered just continue */ *p = '\0'; if (cmd_auto_complete(prompt, console_buffer, &n, &col)) { - p = console_buffer + n; /* reset */ + p = p_buf + n; /* reset */ continue; } #endif -- cgit v1.2.3 From b8ec2385038c094b07ec5b49336289a46b6e9cc6 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 7 Jan 2008 13:31:19 -0600 Subject: 85xx: add ability to upload QE firmware Define the layout of a binary blob that contains a QE firmware and instructions on how to upload it. Add function qe_upload_firmware() to parse the blob and perform the actual upload. Add command-line command "qe fw" to take a firmware blob in memory and upload it. Update ft_cpu_setup() on 85xx to create the 'firmware' device tree node if U-Boot has uploaded a firmware. Fully define 'struct rsp' in immap_qe.h to include the actual RISC Special Registers. Signed-off-by: Timur Tabi --- common/fdt_support.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'common') diff --git a/common/fdt_support.c b/common/fdt_support.c index 92f1c7f54fd..a13c140cff4 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -30,6 +30,9 @@ #include #include +#ifdef CONFIG_QE +#include "../drivers/qe/qe.h" +#endif /* * Global data (for the gd->bd) */ @@ -614,4 +617,49 @@ void fdt_fixup_ethernet(void *fdt, bd_t *bd) #endif } } + +#ifdef CONFIG_QE +/* + * If a QE firmware has been uploaded, then add the 'firmware' node under + * the 'qe' node. + */ +void fdt_fixup_qe_firmware(void *fdt) +{ + struct qe_firmware_info *qe_fw_info; + int node, ret; + + qe_fw_info = qe_get_firmware_info(); + if (!qe_fw_info) + return; + + node = fdt_path_offset(fdt, "/qe"); + if (node < 0) + return; + + /* We assume the node doesn't exist yet */ + node = fdt_add_subnode(fdt, node, "firmware"); + if (node < 0) + return; + + ret = fdt_setprop(fdt, node, "extended-modes", + &qe_fw_info->extended_modes, sizeof(u64)); + if (ret < 0) + goto error; + + ret = fdt_setprop_string(fdt, node, "id", qe_fw_info->id); + if (ret < 0) + goto error; + + ret = fdt_setprop(fdt, node, "virtual-traps", qe_fw_info->vtraps, + sizeof(qe_fw_info->vtraps)); + if (ret < 0) + goto error; + + return; + +error: + fdt_del_node(fdt, node); +} +#endif + #endif -- cgit v1.2.3 From 252f60b068d1f94190b5bcfda169db582387e15e Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Thu, 10 Jan 2008 03:52:44 -0500 Subject: Nios2: remove common/cmd_bdinfo.c unused variable. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Scott McNutt --- common/cmd_bdinfo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index d05998366b1..c28a1554530 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -152,7 +152,9 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { +#if defined(CONFIG_CMD_NET) int i; +#endif bd_t *bd = gd->bd; print_num ("mem start", (ulong)bd->bi_memstart); -- cgit v1.2.3 From 0ec595243dc99edcd248bbcfbfd5a1dc860bde89 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 10 Jan 2008 02:22:05 -0600 Subject: Fix compiler warning main.c: In function 'readline_into_buffer': main.c:927: warning: unused variable 'p_buf' Signed-off-by: Kumar Gala --- common/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/main.c b/common/main.c index ad2a386c865..1c7d73e5dba 100644 --- a/common/main.c +++ b/common/main.c @@ -924,7 +924,6 @@ int readline (const char *const prompt) int readline_into_buffer (const char *const prompt, char * buffer) { char *p = buffer; - char * p_buf = p; #ifdef CONFIG_CMDLINE_EDITING unsigned int len=MAX_CMDBUF_SIZE; int rc; @@ -940,6 +939,7 @@ int readline_into_buffer (const char *const prompt, char * buffer) rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; #else + char * p_buf = p; int n = 0; /* buffer index */ int plen = 0; /* prompt length */ int col; /* output column cnt */ -- cgit v1.2.3 From 5ba7390c3cb579172be66888a371707b47b5be4e Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Fri, 11 Jan 2008 02:15:02 +0100 Subject: Fix compilation problem in common/cmd_bmp.c common/cmd_bmp.c fails to compile if CONFIG_VIDEO_BMP_GZIP isn't defined. This patch fix this. Signed-off-by: Anatolij Gustschin --- common/cmd_bmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 2437e227801..197e5e871d2 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -85,7 +85,7 @@ static bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) return bmp; } #else -static bmp_image_t *gunzip_bmp(unsigned long addr) +static bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) { return NULL; } -- cgit v1.2.3 From 0df6b8446c4721b91ce311548114891130371083 Mon Sep 17 00:00:00 2001 From: Larry Johnson Date: Thu, 10 Jan 2008 22:23:39 -0500 Subject: Fix "i2c sdram" command for DDR2 DIMMs Many of the SPD bytes for DDR2 SDRAM are not interpreted correctly by the "i2c sdram" command. This patch provides correct alternative interpretations when DDR2 memory is detected. Signed-off-by: Larry Johnson --- common/cmd_i2c.c | 615 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 496 insertions(+), 119 deletions(-) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 10cab4609a5..988f91d5340 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -662,6 +662,7 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) */ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { + enum {unknown, EDO, SDRAM, DDR2} type; u_char chip; u_char data[128]; u_char cksum; @@ -696,10 +697,22 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf("Serial memory size 0x%02X\n", 1 << data[1]); puts ("Memory type "); switch(data[2]) { - case 2: puts ("EDO\n"); break; - case 4: puts ("SDRAM\n"); break; - case 8: puts ("DDR2\n"); break; - default: puts ("unknown\n"); break; + case 2: + type = EDO; + puts ("EDO\n"); + break; + case 4: + type = SDRAM; + puts ("SDRAM\n"); + break; + case 8: + type = DDR2; + puts ("DDR2\n"); + break; + default: + type = unknown; + puts ("unknown\n"); + break; } puts ("Row address bits "); if ((data[3] & 0x00F0) == 0) @@ -711,22 +724,89 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf("%d\n", data[4] & 0x0F); else printf("%d/%d\n", data[4] & 0x0F, (data[4] >> 4) & 0x0F); - printf("Module rows %d\n", data[5]); - printf("Module data width %d bits\n", (data[7] << 8) | data[6]); + + switch (type) { + case DDR2: + printf("Number of ranks %d\n", + (data[5] & 0x07) + 1); + break; + default: + printf("Module rows %d\n", data[5]); + break; + } + + switch (type) { + case DDR2: + printf("Module data width %d bits\n", data[6]); + break; + default: + printf("Module data width %d bits\n", + (data[7] << 8) | data[6]); + break; + } + puts ("Interface signal levels "); switch(data[8]) { - case 0: puts ("5.0v/TTL\n"); break; + case 0: puts ("TTL 5.0 V\n"); break; case 1: puts ("LVTTL\n"); break; - case 2: puts ("HSTL 1.5\n"); break; - case 3: puts ("SSTL 3.3\n"); break; - case 4: puts ("SSTL 2.5\n"); break; - case 5: puts ("SSTL 1.8\n"); break; + case 2: puts ("HSTL 1.5 V\n"); break; + case 3: puts ("SSTL 3.3 V\n"); break; + case 4: puts ("SSTL 2.5 V\n"); break; + case 5: puts ("SSTL 1.8 V\n"); break; default: puts ("unknown\n"); break; } - printf("SDRAM cycle time %d.%d nS\n", - (data[9] >> 4) & 0x0F, data[9] & 0x0F); - printf("SDRAM access time %d.%d nS\n", - (data[10] >> 4) & 0x0F, data[10] & 0x0F); + + switch (type) { + case DDR2: + printf("SDRAM cycle time %d.", + (data[9] >> 4) & 0x0F); + switch (data[9] & 0x0F) { + case 0x0: + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x8: + case 0x9: + printf("%d ns\n", data[9] & 0x0F); + break; + case 0xA: + puts("25 ns\n"); + break; + case 0xB: + puts("33 ns\n"); + break; + case 0xC: + puts("66 ns\n"); + break; + case 0xD: + puts("75 ns\n"); + break; + default: + puts("?? ns\n"); + break; + } + break; + default: + printf("SDRAM cycle time %d.%d nS\n", + (data[9] >> 4) & 0x0F, data[9] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("SDRAM access time 0.%d%d ns\n", + (data[10] >> 4) & 0x0F, data[10] & 0x0F); + break; + default: + printf("SDRAM access time %d.%d nS\n", + (data[10] >> 4) & 0x0F, data[10] & 0x0F); + break; + } + puts ("EDC configuration "); switch(data[11]) { case 0: puts ("None\n"); break; @@ -739,28 +819,51 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) else puts ("Self refresh, rate "); switch(data[12] & 0x7F) { - case 0: puts ("15.625uS\n"); break; - case 1: puts ("3.9uS\n"); break; - case 2: puts ("7.8uS\n"); break; - case 3: puts ("31.3uS\n"); break; - case 4: puts ("62.5uS\n"); break; - case 5: puts ("125uS\n"); break; + case 0: puts ("15.625 uS\n"); break; + case 1: puts ("3.9 uS\n"); break; + case 2: puts ("7.8 uS \n"); break; + case 3: puts ("31.3 uS\n"); break; + case 4: puts ("62.5 uS\n"); break; + case 5: puts ("125 uS\n"); break; default: puts ("unknown\n"); break; } - printf("SDRAM width (primary) %d\n", data[13] & 0x7F); - if ((data[13] & 0x80) != 0) { - printf(" (second bank) %d\n", - 2 * (data[13] & 0x7F)); - } - if (data[14] != 0) { - printf("EDC width %d\n", - data[14] & 0x7F); - if ((data[14] & 0x80) != 0) + + switch (type) { + case DDR2: + printf("SDRAM width (primary) %d\n", data[13]); + break; + default: + printf("SDRAM width (primary) %d\n", data[13] & 0x7F); + if ((data[13] & 0x80) != 0) { printf(" (second bank) %d\n", - 2 * (data[14] & 0x7F)); + 2 * (data[13] & 0x7F)); + } + break; + } + + switch (type) { + case DDR2: + if (data[14] != 0) + printf("EDC width %d\n", data[14]); + break; + default: + if (data[14] != 0) { + printf("EDC width %d\n", + data[14] & 0x7F); + + if ((data[14] & 0x80) != 0) { + printf(" (second bank) %d\n", + 2 * (data[14] & 0x7F)); + } + } + break; } - printf("Min clock delay, back-to-back random column addresses %d\n", - data[15]); + + if (DDR2 != type ) { + printf("Min clock delay, back-to-back random column addresses " + "%d\n", data[15]); + } + puts ("Burst length(s) "); if (data[16] & 0x80) puts (" Page"); if (data[16] & 0x08) puts (" 8"); @@ -769,91 +872,363 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (data[16] & 0x01) puts (" 1"); putc ('\n'); printf("Number of banks %d\n", data[17]); - puts ("CAS latency(s) "); - if (data[18] & 0x80) puts (" TBD"); - if (data[18] & 0x40) puts (" 7"); - if (data[18] & 0x20) puts (" 6"); - if (data[18] & 0x10) puts (" 5"); - if (data[18] & 0x08) puts (" 4"); - if (data[18] & 0x04) puts (" 3"); - if (data[18] & 0x02) puts (" 2"); - if (data[18] & 0x01) puts (" 1"); - putc ('\n'); - puts ("CS latency(s) "); - if (data[19] & 0x80) puts (" TBD"); - if (data[19] & 0x40) puts (" 6"); - if (data[19] & 0x20) puts (" 5"); - if (data[19] & 0x10) puts (" 4"); - if (data[19] & 0x08) puts (" 3"); - if (data[19] & 0x04) puts (" 2"); - if (data[19] & 0x02) puts (" 1"); - if (data[19] & 0x01) puts (" 0"); - putc ('\n'); - puts ("WE latency(s) "); - if (data[20] & 0x80) puts (" TBD"); - if (data[20] & 0x40) puts (" 6"); - if (data[20] & 0x20) puts (" 5"); - if (data[20] & 0x10) puts (" 4"); - if (data[20] & 0x08) puts (" 3"); - if (data[20] & 0x04) puts (" 2"); - if (data[20] & 0x02) puts (" 1"); - if (data[20] & 0x01) puts (" 0"); - putc ('\n'); - puts ("Module attributes:\n"); - if (!data[21]) puts (" (none)\n"); - if (data[21] & 0x80) puts (" TBD (bit 7)\n"); - if (data[21] & 0x40) puts (" Redundant row address\n"); - if (data[21] & 0x20) puts (" Differential clock input\n"); - if (data[21] & 0x10) puts (" Registerd DQMB inputs\n"); - if (data[21] & 0x08) puts (" Buffered DQMB inputs\n"); - if (data[21] & 0x04) puts (" On-card PLL\n"); - if (data[21] & 0x02) puts (" Registered address/control lines\n"); - if (data[21] & 0x01) puts (" Buffered address/control lines\n"); - puts ("Device attributes:\n"); - if (data[22] & 0x80) puts (" TBD (bit 7)\n"); - if (data[22] & 0x40) puts (" TBD (bit 6)\n"); - if (data[22] & 0x20) puts (" Upper Vcc tolerance 5%\n"); - else puts (" Upper Vcc tolerance 10%\n"); - if (data[22] & 0x10) puts (" Lower Vcc tolerance 5%\n"); - else puts (" Lower Vcc tolerance 10%\n"); - if (data[22] & 0x08) puts (" Supports write1/read burst\n"); - if (data[22] & 0x04) puts (" Supports precharge all\n"); - if (data[22] & 0x02) puts (" Supports auto precharge\n"); - if (data[22] & 0x01) puts (" Supports early RAS# precharge\n"); - printf("SDRAM cycle time (2nd highest CAS latency) %d.%d nS\n", - (data[23] >> 4) & 0x0F, data[23] & 0x0F); - printf("SDRAM access from clock (2nd highest CAS latency) %d.%d nS\n", - (data[24] >> 4) & 0x0F, data[24] & 0x0F); - printf("SDRAM cycle time (3rd highest CAS latency) %d.%d nS\n", - (data[25] >> 4) & 0x0F, data[25] & 0x0F); - printf("SDRAM access from clock (3rd highest CAS latency) %d.%d nS\n", - (data[26] >> 4) & 0x0F, data[26] & 0x0F); - printf("Minimum row precharge %d nS\n", data[27]); - printf("Row active to row active min %d nS\n", data[28]); - printf("RAS to CAS delay min %d nS\n", data[29]); + + switch (type) { + case DDR2: + puts ("CAS latency(s) "); + if (data[18] & 0x83) puts (" TBD"); + if (data[18] & 0x40) puts (" 6"); + if (data[18] & 0x20) puts (" 5"); + if (data[18] & 0x10) puts (" 4"); + if (data[18] & 0x08) puts (" 3"); + if (data[18] & 0x04) puts (" 2"); + putc ('\n'); + break; + default: + puts ("CAS latency(s) "); + if (data[18] & 0x80) puts (" TBD"); + if (data[18] & 0x40) puts (" 7"); + if (data[18] & 0x20) puts (" 6"); + if (data[18] & 0x10) puts (" 5"); + if (data[18] & 0x08) puts (" 4"); + if (data[18] & 0x04) puts (" 3"); + if (data[18] & 0x02) puts (" 2"); + if (data[18] & 0x01) puts (" 1"); + putc ('\n'); + break; + } + + if (DDR2 != type) { + puts ("CS latency(s) "); + if (data[19] & 0x80) puts (" TBD"); + if (data[19] & 0x40) puts (" 6"); + if (data[19] & 0x20) puts (" 5"); + if (data[19] & 0x10) puts (" 4"); + if (data[19] & 0x08) puts (" 3"); + if (data[19] & 0x04) puts (" 2"); + if (data[19] & 0x02) puts (" 1"); + if (data[19] & 0x01) puts (" 0"); + putc ('\n'); + } + + if (DDR2 != type) { + puts ("WE latency(s) "); + if (data[20] & 0x80) puts (" TBD"); + if (data[20] & 0x40) puts (" 6"); + if (data[20] & 0x20) puts (" 5"); + if (data[20] & 0x10) puts (" 4"); + if (data[20] & 0x08) puts (" 3"); + if (data[20] & 0x04) puts (" 2"); + if (data[20] & 0x02) puts (" 1"); + if (data[20] & 0x01) puts (" 0"); + putc ('\n'); + } + + switch (type) { + case DDR2: + puts ("Module attributes:\n"); + if (data[21] & 0x80) + puts (" TBD (bit 7)\n"); + if (data[21] & 0x40) + puts (" Analysis probe installed\n"); + if (data[21] & 0x20) + puts (" TBD (bit 5)\n"); + if (data[21] & 0x10) + puts (" FET switch external enable\n"); + printf(" %d PLLs on DIMM\n", (data[21] >> 2) & 0x03); + if (data[20] & 0x11) { + printf(" %d active registers on DIMM\n", + (data[21] & 0x03) + 1); + } + break; + default: + puts ("Module attributes:\n"); + if (!data[21]) + puts (" (none)\n"); + if (data[21] & 0x80) + puts (" TBD (bit 7)\n"); + if (data[21] & 0x40) + puts (" Redundant row address\n"); + if (data[21] & 0x20) + puts (" Differential clock input\n"); + if (data[21] & 0x10) + puts (" Registerd DQMB inputs\n"); + if (data[21] & 0x08) + puts (" Buffered DQMB inputs\n"); + if (data[21] & 0x04) + puts (" On-card PLL\n"); + if (data[21] & 0x02) + puts (" Registered address/control lines\n"); + if (data[21] & 0x01) + puts (" Buffered address/control lines\n"); + break; + } + + switch (type) { + case DDR2: + if (data[22] & 0x80) puts (" TBD (bit 7)\n"); + if (data[22] & 0x40) puts (" TBD (bit 6)\n"); + if (data[22] & 0x20) puts (" TBD (bit 5)\n"); + if (data[22] & 0x10) puts (" TBD (bit 4)\n"); + if (data[22] & 0x08) puts (" TBD (bit 3)\n"); + if (data[22] & 0x04) + puts (" Supports parital array self refresh\n"); + if (data[22] & 0x02) + puts (" Supports 50 ohm ODT\n"); + if (data[22] & 0x01) + puts (" Supports weak driver\n"); + break; + default: + puts ("Device attributes:\n"); + if (data[22] & 0x80) puts (" TBD (bit 7)\n"); + if (data[22] & 0x40) puts (" TBD (bit 6)\n"); + if (data[22] & 0x20) puts (" Upper Vcc tolerance 5%\n"); + else puts (" Upper Vcc tolerance 10%\n"); + if (data[22] & 0x10) puts (" Lower Vcc tolerance 5%\n"); + else puts (" Lower Vcc tolerance 10%\n"); + if (data[22] & 0x08) puts (" Supports write1/read burst\n"); + if (data[22] & 0x04) puts (" Supports precharge all\n"); + if (data[22] & 0x02) puts (" Supports auto precharge\n"); + if (data[22] & 0x01) puts (" Supports early RAS# precharge\n"); + break; + } + + switch (type) { + case DDR2: + printf("SDRAM cycle time (2nd highest CAS latency) %d.", + (data[23] >> 4) & 0x0F); + + switch (data[23] & 0x0F) { + case 0x0: + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x8: + case 0x9: + printf("%d ns\n", data[23] & 0x0F); + break; + case 0xA: + puts("25 ns\n"); + break; + case 0xB: + puts("33 ns\n"); + break; + case 0xC: + puts("66 ns\n"); + break; + case 0xD: + puts("75 ns\n"); + break; + default: + puts("?? ns\n"); + break; + } + break; + default: + printf("SDRAM cycle time (2nd highest CAS latency) %d." + "%d nS\n", (data[23] >> 4) & 0x0F, data[23] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("SDRAM access from clock (2nd highest CAS latency) 0." + "%d%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); + break; + default: + printf("SDRAM access from clock (2nd highest CAS latency) %d." + "%d nS\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("SDRAM cycle time (3rd highest CAS latency) %d.", + (data[25] >> 4) & 0x0F); + + switch (data[25] & 0x0F) { + case 0x0: + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x8: + case 0x9: + printf("%d ns\n", data[25] & 0x0F); + break; + case 0xA: + puts("25 ns\n"); + break; + case 0xB: + puts("33 ns\n"); + break; + case 0xC: + puts("66 ns\n"); + break; + case 0xD: + puts("75 ns\n"); + break; + default: + puts("?? ns\n"); + break; + } + break; + default: + printf("SDRAM cycle time (3rd highest CAS latency) %d." + "%d nS\n", (data[25] >> 4) & 0x0F, data[25] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("SDRAM access from clock (3rd highest CAS latency) 0." + "%d%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); + break; + default: + printf("SDRAM access from clock (3rd highest CAS latency) %d." + "%d nS\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("Minimum row precharge %d", data[27] >> 2); + switch (data[27] & 0x03) { + case 0x0: puts(".00 ns\n"); break; + case 0x1: puts(".25 ns\n"); break; + case 0x2: puts(".50 ns\n"); break; + case 0x3: puts(".75 ns\n"); break; + } + break; + default: + printf("Minimum row precharge %d nS\n", data[27]); + break; + } + + switch (type) { + case DDR2: + printf("Row active to row active min %d", data[28] >> 2); + switch (data[28] & 0x03) { + case 0x0: puts(".00 ns\n"); break; + case 0x1: puts(".25 ns\n"); break; + case 0x2: puts(".50 ns\n"); break; + case 0x3: puts(".75 ns\n"); break; + } + break; + default: + printf("Row active to row active min %d nS\n", data[28]); + break; + } + + switch (type) { + case DDR2: + printf("RAS to CAS delay min %d", data[29] >> 2); + switch (data[29] & 0x03) { + case 0x0: puts(".00 ns\n"); break; + case 0x1: puts(".25 ns\n"); break; + case 0x2: puts(".50 ns\n"); break; + case 0x3: puts(".75 ns\n"); break; + } + break; + default: + printf("RAS to CAS delay min %d nS\n", data[29]); + break; + } + printf("Minimum RAS pulse width %d nS\n", data[30]); - puts ("Density of each row "); - if (data[31] & 0x80) puts (" 512"); - if (data[31] & 0x40) puts (" 256"); - if (data[31] & 0x20) puts (" 128"); - if (data[31] & 0x10) puts (" 64"); - if (data[31] & 0x08) puts (" 32"); - if (data[31] & 0x04) puts (" 16"); - if (data[31] & 0x02) puts (" 8"); - if (data[31] & 0x01) puts (" 4"); - puts ("MByte\n"); - printf("Command and Address setup %c%d.%d nS\n", - (data[32] & 0x80) ? '-' : '+', - (data[32] >> 4) & 0x07, data[32] & 0x0F); - printf("Command and Address hold %c%d.%d nS\n", - (data[33] & 0x80) ? '-' : '+', - (data[33] >> 4) & 0x07, data[33] & 0x0F); - printf("Data signal input setup %c%d.%d nS\n", - (data[34] & 0x80) ? '-' : '+', - (data[34] >> 4) & 0x07, data[34] & 0x0F); - printf("Data signal input hold %c%d.%d nS\n", - (data[35] & 0x80) ? '-' : '+', - (data[35] >> 4) & 0x07, data[35] & 0x0F); + + switch (type) { + case DDR2: + puts ("Density of each row "); + if (data[31] & 0x80) puts (" 512 MiB\n"); + if (data[31] & 0x40) puts (" 256 MiB\n"); + if (data[31] & 0x20) puts (" 128 MiB\n"); + if (data[31] & 0x10) puts (" 16 GiB\n"); + if (data[31] & 0x08) puts (" 8 GiB\n"); + if (data[31] & 0x04) puts (" 4 GiB\n"); + if (data[31] & 0x02) puts (" 2 GiB\n"); + if (data[31] & 0x01) puts (" 1 GiB\n"); + break; + default: + puts ("Density of each row "); + if (data[31] & 0x80) puts (" 512 MiB\n"); + if (data[31] & 0x40) puts (" 256 MiB\n"); + if (data[31] & 0x20) puts (" 128 MiB\n"); + if (data[31] & 0x10) puts (" 64 MiB\n"); + if (data[31] & 0x08) puts (" 32 MiB\n"); + if (data[31] & 0x04) puts (" 16 MiB\n"); + if (data[31] & 0x02) puts (" 8 MiB\n"); + if (data[31] & 0x01) puts (" 4 MiB\n"); + break; + } + + switch (type) { + case DDR2: + puts("Command and Address setup "); + if (data[32] >= 0xA0) { + printf("1.%d%d ns\n", + ((data[32] >> 4) & 0x0F) - 10, data[32] & 0x0F); + } else { + printf("0.%d%d ns\n", + ((data[32] >> 4) & 0x0F), data[32] & 0x0F); + } + break; + default: + printf("Command and Address setup %c%d.%d nS\n", + (data[32] & 0x80) ? '-' : '+', + (data[32] >> 4) & 0x07, data[32] & 0x0F); + break; + } + + switch (type) { + case DDR2: + puts("Command and Address hold "); + if (data[33] >= 0xA0) { + printf("1.%d%d ns\n", + ((data[33] >> 4) & 0x0F) - 10, data[33] & 0x0F); + } else { + printf("0.%d%d ns\n", + ((data[33] >> 4) & 0x0F), data[33] & 0x0F); + } + break; + default: + printf("Command and Address hold %c%d.%d nS\n", + (data[33] & 0x80) ? '-' : '+', + (data[33] >> 4) & 0x07, data[33] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("Data signal input setup 0.%d%d ns\n", + (data[34] >> 4) & 0x0F, data[34] & 0x0F); + break; + default: + printf("Data signal input setup %c%d.%d nS\n", + (data[34] & 0x80) ? '-' : '+', + (data[34] >> 4) & 0x07, data[34] & 0x0F); + break; + } + + switch (type) { + case DDR2: + printf("Data signal input hold 0.%d%d ns\n", + (data[35] >> 4) & 0x0F, data[35] & 0x0F); + break; + default: + printf("Data signal input hold %c%d.%d nS\n", + (data[35] & 0x80) ? '-' : '+', + (data[35] >> 4) & 0x07, data[35] & 0x0F); + break; + } + puts ("Manufacturer's JEDEC ID "); for (j = 64; j <= 71; j++) printf("%02X ", data[j]); @@ -869,9 +1244,11 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) for (j = 95; j <= 98; j++) printf("%02X ", data[j]); putc ('\n'); - printf("Speed rating PC%d\n", - data[126] == 0x66 ? 66 : data[126]); + if (DDR2 != type) { + printf("Speed rating PC%d\n", + data[126] == 0x66 ? 66 : data[126]); + } return 0; } #endif -- cgit v1.2.3 From 632de0672d3c3ab53ad798c47f5f1eb26008a0e4 Mon Sep 17 00:00:00 2001 From: Larry Johnson Date: Fri, 11 Jan 2008 23:26:18 -0500 Subject: Refactor code for "i2c sdram" command Signed-off-by: Larry Johnson --- common/cmd_i2c.c | 511 ++++++++++++++++++++++++------------------------------- 1 file changed, 220 insertions(+), 291 deletions(-) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 988f91d5340..c60ec99dad9 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -655,29 +655,120 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) * (most?) embedded boards don't use SDRAM DIMMs. */ #if defined(CONFIG_CMD_SDRAM) +static void print_ddr2_tcyc (u_char const b) +{ + printf ("%d.", (b >> 4) & 0x0F); + switch (b & 0x0F) { + case 0x0: + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x8: + case 0x9: + printf ("%d ns\n", b & 0x0F); + break; + case 0xA: + puts ("25 ns\n"); + break; + case 0xB: + puts ("33 ns\n"); + break; + case 0xC: + puts ("66 ns\n"); + break; + case 0xD: + puts ("75 ns\n"); + break; + default: + puts ("?? ns\n"); + break; + } +} + +static void decode_bits (u_char const b, char const *str[], int const do_once) +{ + u_char mask; + + for (mask = 0x80; mask != 0x00; mask >>= 1, ++str) { + if (b & mask) { + puts (*str); + if (do_once) + return; + } + } +} /* * Syntax: * sdram {i2c_chip} */ -int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { - enum {unknown, EDO, SDRAM, DDR2} type; + enum { unknown, EDO, SDRAM, DDR2 } type; + u_char chip; u_char data[128]; u_char cksum; int j; + static const char *decode_CAS_DDR2[] = { + " TBD", " 6", " 5", " 4", " 3", " 2", " TBD", " TBD" + }; + + static const char *decode_CAS_default[] = { + " TBD", " 7", " 6", " 5", " 4", " 3", " 2", " 1" + }; + + static const char *decode_CS_WE_default[] = { + " TBD", " 6", " 5", " 4", " 3", " 2", " 1", " 0" + }; + + static const char *decode_byte21_default[] = { + " TBD (bit 7)\n", + " Redundant row address\n", + " Differential clock input\n", + " Registerd DQMB inputs\n", + " Buffered DQMB inputs\n", + " On-card PLL\n", + " Registered address/control lines\n", + " Buffered address/control lines\n" + }; + + static const char *decode_byte22_DDR2[] = { + " TBD (bit 7)\n", + " TBD (bit 6)\n", + " TBD (bit 5)\n", + " TBD (bit 4)\n", + " TBD (bit 3)\n", + " Supports partial array self refresh\n", + " Supports 50 ohm ODT\n", + " Supports weak driver\n" + }; + + static const char *decode_row_density_DDR2[] = { + "512 MiB", "256 MiB", "128 MiB", "16 GiB", + "8 GiB", "4 GiB", "2 GiB", "1 GiB" + }; + + static const char *decode_row_density_default[] = { + "512 MiB", "256 MiB", "128 MiB", "64 MiB", + "32 MiB", "16 MiB", "8 MiB", "4 MiB" + }; + if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } /* * Chip is always specified. - */ - chip = simple_strtoul(argv[1], NULL, 16); + */ + chip = simple_strtoul (argv[1], NULL, 16); - if (i2c_read(chip, 0, 1, data, sizeof(data)) != 0) { + if (i2c_read (chip, 0, 1, data, sizeof (data)) != 0) { puts ("No SDRAM Serial Presence Detect found.\n"); return 1; } @@ -688,15 +779,15 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (cksum != data[63]) { printf ("WARNING: Configuration data checksum failure:\n" - " is 0x%02x, calculated 0x%02x\n", - data[63], cksum); + " is 0x%02x, calculated 0x%02x\n", data[63], cksum); } - printf("SPD data revision %d.%d\n", + printf ("SPD data revision %d.%d\n", (data[62] >> 4) & 0x0F, data[62] & 0x0F); - printf("Bytes used 0x%02X\n", data[0]); - printf("Serial memory size 0x%02X\n", 1 << data[1]); + printf ("Bytes used 0x%02X\n", data[0]); + printf ("Serial memory size 0x%02X\n", 1 << data[1]); + puts ("Memory type "); - switch(data[2]) { + switch (data[2]) { case 2: type = EDO; puts ("EDO\n"); @@ -714,34 +805,36 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) puts ("unknown\n"); break; } + puts ("Row address bits "); if ((data[3] & 0x00F0) == 0) - printf("%d\n", data[3] & 0x0F); + printf ("%d\n", data[3] & 0x0F); else - printf("%d/%d\n", data[3] & 0x0F, (data[3] >> 4) & 0x0F); + printf ("%d/%d\n", data[3] & 0x0F, (data[3] >> 4) & 0x0F); + puts ("Column address bits "); if ((data[4] & 0x00F0) == 0) - printf("%d\n", data[4] & 0x0F); + printf ("%d\n", data[4] & 0x0F); else - printf("%d/%d\n", data[4] & 0x0F, (data[4] >> 4) & 0x0F); + printf ("%d/%d\n", data[4] & 0x0F, (data[4] >> 4) & 0x0F); switch (type) { case DDR2: - printf("Number of ranks %d\n", - (data[5] & 0x07) + 1); + printf ("Number of ranks %d\n", + (data[5] & 0x07) + 1); break; default: - printf("Module rows %d\n", data[5]); + printf ("Module rows %d\n", data[5]); break; } switch (type) { case DDR2: - printf("Module data width %d bits\n", data[6]); + printf ("Module data width %d bits\n", data[6]); break; default: - printf("Module data width %d bits\n", - (data[7] << 8) | data[6]); + printf ("Module data width %d bits\n", + (data[7] << 8) | data[6]); break; } @@ -758,85 +851,58 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (type) { case DDR2: - printf("SDRAM cycle time %d.", - (data[9] >> 4) & 0x0F); - switch (data[9] & 0x0F) { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x8: - case 0x9: - printf("%d ns\n", data[9] & 0x0F); - break; - case 0xA: - puts("25 ns\n"); - break; - case 0xB: - puts("33 ns\n"); - break; - case 0xC: - puts("66 ns\n"); - break; - case 0xD: - puts("75 ns\n"); - break; - default: - puts("?? ns\n"); - break; - } + printf ("SDRAM cycle time "); + print_ddr2_tcyc (data[9]); break; default: - printf("SDRAM cycle time %d.%d nS\n", - (data[9] >> 4) & 0x0F, data[9] & 0x0F); + printf ("SDRAM cycle time %d.%d ns\n", + (data[9] >> 4) & 0x0F, data[9] & 0x0F); break; } switch (type) { case DDR2: - printf("SDRAM access time 0.%d%d ns\n", - (data[10] >> 4) & 0x0F, data[10] & 0x0F); + printf ("SDRAM access time 0.%d%d ns\n", + (data[10] >> 4) & 0x0F, data[10] & 0x0F); break; default: - printf("SDRAM access time %d.%d nS\n", - (data[10] >> 4) & 0x0F, data[10] & 0x0F); + printf ("SDRAM access time %d.%d ns\n", + (data[10] >> 4) & 0x0F, data[10] & 0x0F); break; } puts ("EDC configuration "); - switch(data[11]) { + switch (data[11]) { case 0: puts ("None\n"); break; case 1: puts ("Parity\n"); break; case 2: puts ("ECC\n"); break; default: puts ("unknown\n"); break; } + if ((data[12] & 0x80) == 0) puts ("No self refresh, rate "); else puts ("Self refresh, rate "); + switch(data[12] & 0x7F) { - case 0: puts ("15.625 uS\n"); break; - case 1: puts ("3.9 uS\n"); break; - case 2: puts ("7.8 uS \n"); break; - case 3: puts ("31.3 uS\n"); break; - case 4: puts ("62.5 uS\n"); break; - case 5: puts ("125 uS\n"); break; + case 0: puts ("15.625 us\n"); break; + case 1: puts ("3.9 us\n"); break; + case 2: puts ("7.8 us\n"); break; + case 3: puts ("31.3 us\n"); break; + case 4: puts ("62.5 us\n"); break; + case 5: puts ("125 us\n"); break; default: puts ("unknown\n"); break; } switch (type) { case DDR2: - printf("SDRAM width (primary) %d\n", data[13]); + printf ("SDRAM width (primary) %d\n", data[13]); break; default: - printf("SDRAM width (primary) %d\n", data[13] & 0x7F); + printf ("SDRAM width (primary) %d\n", data[13] & 0x7F); if ((data[13] & 0x80) != 0) { - printf(" (second bank) %d\n", - 2 * (data[13] & 0x7F)); + printf (" (second bank) %d\n", + 2 * (data[13] & 0x7F)); } break; } @@ -844,24 +910,24 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (type) { case DDR2: if (data[14] != 0) - printf("EDC width %d\n", data[14]); + printf ("EDC width %d\n", data[14]); break; default: if (data[14] != 0) { - printf("EDC width %d\n", - data[14] & 0x7F); + printf ("EDC width %d\n", + data[14] & 0x7F); if ((data[14] & 0x80) != 0) { - printf(" (second bank) %d\n", - 2 * (data[14] & 0x7F)); + printf (" (second bank) %d\n", + 2 * (data[14] & 0x7F)); } } break; } - if (DDR2 != type ) { - printf("Min clock delay, back-to-back random column addresses " - "%d\n", data[15]); + if (DDR2 != type) { + printf ("Min clock delay, back-to-back random column addresses " + "%d\n", data[15]); } puts ("Burst length(s) "); @@ -871,56 +937,30 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (data[16] & 0x02) puts (" 2"); if (data[16] & 0x01) puts (" 1"); putc ('\n'); - printf("Number of banks %d\n", data[17]); + printf ("Number of banks %d\n", data[17]); switch (type) { case DDR2: puts ("CAS latency(s) "); - if (data[18] & 0x83) puts (" TBD"); - if (data[18] & 0x40) puts (" 6"); - if (data[18] & 0x20) puts (" 5"); - if (data[18] & 0x10) puts (" 4"); - if (data[18] & 0x08) puts (" 3"); - if (data[18] & 0x04) puts (" 2"); + decode_bits (data[18], decode_CAS_DDR2, 0); putc ('\n'); break; default: puts ("CAS latency(s) "); - if (data[18] & 0x80) puts (" TBD"); - if (data[18] & 0x40) puts (" 7"); - if (data[18] & 0x20) puts (" 6"); - if (data[18] & 0x10) puts (" 5"); - if (data[18] & 0x08) puts (" 4"); - if (data[18] & 0x04) puts (" 3"); - if (data[18] & 0x02) puts (" 2"); - if (data[18] & 0x01) puts (" 1"); + decode_bits (data[18], decode_CAS_default, 0); putc ('\n'); break; } if (DDR2 != type) { puts ("CS latency(s) "); - if (data[19] & 0x80) puts (" TBD"); - if (data[19] & 0x40) puts (" 6"); - if (data[19] & 0x20) puts (" 5"); - if (data[19] & 0x10) puts (" 4"); - if (data[19] & 0x08) puts (" 3"); - if (data[19] & 0x04) puts (" 2"); - if (data[19] & 0x02) puts (" 1"); - if (data[19] & 0x01) puts (" 0"); + decode_bits (data[19], decode_CS_WE_default, 0); putc ('\n'); } if (DDR2 != type) { puts ("WE latency(s) "); - if (data[20] & 0x80) puts (" TBD"); - if (data[20] & 0x40) puts (" 6"); - if (data[20] & 0x20) puts (" 5"); - if (data[20] & 0x10) puts (" 4"); - if (data[20] & 0x08) puts (" 3"); - if (data[20] & 0x04) puts (" 2"); - if (data[20] & 0x02) puts (" 1"); - if (data[20] & 0x01) puts (" 0"); + decode_bits (data[20], decode_CS_WE_default, 0); putc ('\n'); } @@ -935,48 +975,24 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) puts (" TBD (bit 5)\n"); if (data[21] & 0x10) puts (" FET switch external enable\n"); - printf(" %d PLLs on DIMM\n", (data[21] >> 2) & 0x03); + printf (" %d PLLs on DIMM\n", (data[21] >> 2) & 0x03); if (data[20] & 0x11) { - printf(" %d active registers on DIMM\n", - (data[21] & 0x03) + 1); + printf (" %d active registers on DIMM\n", + (data[21] & 0x03) + 1); } break; default: puts ("Module attributes:\n"); if (!data[21]) puts (" (none)\n"); - if (data[21] & 0x80) - puts (" TBD (bit 7)\n"); - if (data[21] & 0x40) - puts (" Redundant row address\n"); - if (data[21] & 0x20) - puts (" Differential clock input\n"); - if (data[21] & 0x10) - puts (" Registerd DQMB inputs\n"); - if (data[21] & 0x08) - puts (" Buffered DQMB inputs\n"); - if (data[21] & 0x04) - puts (" On-card PLL\n"); - if (data[21] & 0x02) - puts (" Registered address/control lines\n"); - if (data[21] & 0x01) - puts (" Buffered address/control lines\n"); + else + decode_bits (data[21], decode_byte21_default, 0); break; } switch (type) { case DDR2: - if (data[22] & 0x80) puts (" TBD (bit 7)\n"); - if (data[22] & 0x40) puts (" TBD (bit 6)\n"); - if (data[22] & 0x20) puts (" TBD (bit 5)\n"); - if (data[22] & 0x10) puts (" TBD (bit 4)\n"); - if (data[22] & 0x08) puts (" TBD (bit 3)\n"); - if (data[22] & 0x04) - puts (" Supports parital array self refresh\n"); - if (data[22] & 0x02) - puts (" Supports 50 ohm ODT\n"); - if (data[22] & 0x01) - puts (" Supports weak driver\n"); + decode_bits (data[22], decode_byte22_DDR2, 0); break; default: puts ("Device attributes:\n"); @@ -995,259 +1011,172 @@ int do_sdram ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (type) { case DDR2: - printf("SDRAM cycle time (2nd highest CAS latency) %d.", - (data[23] >> 4) & 0x0F); - - switch (data[23] & 0x0F) { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x8: - case 0x9: - printf("%d ns\n", data[23] & 0x0F); - break; - case 0xA: - puts("25 ns\n"); - break; - case 0xB: - puts("33 ns\n"); - break; - case 0xC: - puts("66 ns\n"); - break; - case 0xD: - puts("75 ns\n"); - break; - default: - puts("?? ns\n"); - break; - } + printf ("SDRAM cycle time (2nd highest CAS latency) "); + print_ddr2_tcyc (data[23]); break; default: - printf("SDRAM cycle time (2nd highest CAS latency) %d." - "%d nS\n", (data[23] >> 4) & 0x0F, data[23] & 0x0F); + printf ("SDRAM cycle time (2nd highest CAS latency) %d." + "%d ns\n", (data[23] >> 4) & 0x0F, data[23] & 0x0F); break; } switch (type) { case DDR2: - printf("SDRAM access from clock (2nd highest CAS latency) 0." - "%d%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); + printf ("SDRAM access from clock (2nd highest CAS latency) 0." + "%d%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); break; default: - printf("SDRAM access from clock (2nd highest CAS latency) %d." - "%d nS\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); + printf ("SDRAM access from clock (2nd highest CAS latency) %d." + "%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F); break; } switch (type) { case DDR2: - printf("SDRAM cycle time (3rd highest CAS latency) %d.", - (data[25] >> 4) & 0x0F); - - switch (data[25] & 0x0F) { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x8: - case 0x9: - printf("%d ns\n", data[25] & 0x0F); - break; - case 0xA: - puts("25 ns\n"); - break; - case 0xB: - puts("33 ns\n"); - break; - case 0xC: - puts("66 ns\n"); - break; - case 0xD: - puts("75 ns\n"); - break; - default: - puts("?? ns\n"); - break; - } + printf ("SDRAM cycle time (3rd highest CAS latency) "); + print_ddr2_tcyc (data[25]); break; default: - printf("SDRAM cycle time (3rd highest CAS latency) %d." - "%d nS\n", (data[25] >> 4) & 0x0F, data[25] & 0x0F); + printf ("SDRAM cycle time (3rd highest CAS latency) %d." + "%d ns\n", (data[25] >> 4) & 0x0F, data[25] & 0x0F); break; } switch (type) { case DDR2: - printf("SDRAM access from clock (3rd highest CAS latency) 0." - "%d%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); + printf ("SDRAM access from clock (3rd highest CAS latency) 0." + "%d%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); break; default: - printf("SDRAM access from clock (3rd highest CAS latency) %d." - "%d nS\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); + printf ("SDRAM access from clock (3rd highest CAS latency) %d." + "%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F); break; } switch (type) { case DDR2: - printf("Minimum row precharge %d", data[27] >> 2); - switch (data[27] & 0x03) { - case 0x0: puts(".00 ns\n"); break; - case 0x1: puts(".25 ns\n"); break; - case 0x2: puts(".50 ns\n"); break; - case 0x3: puts(".75 ns\n"); break; - } + printf ("Minimum row precharge %d.%02d ns\n", + (data[27] >> 2) & 0x3F, 25 * (data[27] & 0x03)); break; default: - printf("Minimum row precharge %d nS\n", data[27]); + printf ("Minimum row precharge %d ns\n", data[27]); break; } switch (type) { case DDR2: - printf("Row active to row active min %d", data[28] >> 2); - switch (data[28] & 0x03) { - case 0x0: puts(".00 ns\n"); break; - case 0x1: puts(".25 ns\n"); break; - case 0x2: puts(".50 ns\n"); break; - case 0x3: puts(".75 ns\n"); break; - } + printf ("Row active to row active min %d.%02d ns\n", + (data[28] >> 2) & 0x3F, 25 * (data[28] & 0x03)); break; default: - printf("Row active to row active min %d nS\n", data[28]); + printf ("Row active to row active min %d ns\n", data[28]); break; } switch (type) { case DDR2: - printf("RAS to CAS delay min %d", data[29] >> 2); - switch (data[29] & 0x03) { - case 0x0: puts(".00 ns\n"); break; - case 0x1: puts(".25 ns\n"); break; - case 0x2: puts(".50 ns\n"); break; - case 0x3: puts(".75 ns\n"); break; - } + printf ("RAS to CAS delay min %d.%02d ns\n", + (data[29] >> 2) & 0x3F, 25 * (data[29] & 0x03)); break; default: - printf("RAS to CAS delay min %d nS\n", data[29]); + printf ("RAS to CAS delay min %d ns\n", data[29]); break; } - printf("Minimum RAS pulse width %d nS\n", data[30]); + printf ("Minimum RAS pulse width %d ns\n", data[30]); switch (type) { case DDR2: - puts ("Density of each row "); - if (data[31] & 0x80) puts (" 512 MiB\n"); - if (data[31] & 0x40) puts (" 256 MiB\n"); - if (data[31] & 0x20) puts (" 128 MiB\n"); - if (data[31] & 0x10) puts (" 16 GiB\n"); - if (data[31] & 0x08) puts (" 8 GiB\n"); - if (data[31] & 0x04) puts (" 4 GiB\n"); - if (data[31] & 0x02) puts (" 2 GiB\n"); - if (data[31] & 0x01) puts (" 1 GiB\n"); + puts ("Density of each row "); + decode_bits (data[31], decode_row_density_DDR2, 1); + putc ('\n'); break; default: - puts ("Density of each row "); - if (data[31] & 0x80) puts (" 512 MiB\n"); - if (data[31] & 0x40) puts (" 256 MiB\n"); - if (data[31] & 0x20) puts (" 128 MiB\n"); - if (data[31] & 0x10) puts (" 64 MiB\n"); - if (data[31] & 0x08) puts (" 32 MiB\n"); - if (data[31] & 0x04) puts (" 16 MiB\n"); - if (data[31] & 0x02) puts (" 8 MiB\n"); - if (data[31] & 0x01) puts (" 4 MiB\n"); + puts ("Density of each row "); + decode_bits (data[31], decode_row_density_default, 1); + putc ('\n'); break; } switch (type) { case DDR2: - puts("Command and Address setup "); + puts ("Command and Address setup "); if (data[32] >= 0xA0) { - printf("1.%d%d ns\n", - ((data[32] >> 4) & 0x0F) - 10, data[32] & 0x0F); + printf ("1.%d%d ns\n", + ((data[32] >> 4) & 0x0F) - 10, data[32] & 0x0F); } else { - printf("0.%d%d ns\n", - ((data[32] >> 4) & 0x0F), data[32] & 0x0F); + printf ("0.%d%d ns\n", + ((data[32] >> 4) & 0x0F), data[32] & 0x0F); } break; default: - printf("Command and Address setup %c%d.%d nS\n", - (data[32] & 0x80) ? '-' : '+', - (data[32] >> 4) & 0x07, data[32] & 0x0F); + printf ("Command and Address setup %c%d.%d ns\n", + (data[32] & 0x80) ? '-' : '+', + (data[32] >> 4) & 0x07, data[32] & 0x0F); break; } switch (type) { case DDR2: - puts("Command and Address hold "); + puts ("Command and Address hold "); if (data[33] >= 0xA0) { - printf("1.%d%d ns\n", - ((data[33] >> 4) & 0x0F) - 10, data[33] & 0x0F); + printf ("1.%d%d ns\n", + ((data[33] >> 4) & 0x0F) - 10, data[33] & 0x0F); } else { - printf("0.%d%d ns\n", - ((data[33] >> 4) & 0x0F), data[33] & 0x0F); + printf ("0.%d%d ns\n", + ((data[33] >> 4) & 0x0F), data[33] & 0x0F); } break; default: - printf("Command and Address hold %c%d.%d nS\n", - (data[33] & 0x80) ? '-' : '+', - (data[33] >> 4) & 0x07, data[33] & 0x0F); + printf ("Command and Address hold %c%d.%d ns\n", + (data[33] & 0x80) ? '-' : '+', + (data[33] >> 4) & 0x07, data[33] & 0x0F); break; } switch (type) { case DDR2: - printf("Data signal input setup 0.%d%d ns\n", - (data[34] >> 4) & 0x0F, data[34] & 0x0F); + printf ("Data signal input setup 0.%d%d ns\n", + (data[34] >> 4) & 0x0F, data[34] & 0x0F); break; default: - printf("Data signal input setup %c%d.%d nS\n", - (data[34] & 0x80) ? '-' : '+', - (data[34] >> 4) & 0x07, data[34] & 0x0F); + printf ("Data signal input setup %c%d.%d ns\n", + (data[34] & 0x80) ? '-' : '+', + (data[34] >> 4) & 0x07, data[34] & 0x0F); break; } switch (type) { case DDR2: - printf("Data signal input hold 0.%d%d ns\n", - (data[35] >> 4) & 0x0F, data[35] & 0x0F); + printf ("Data signal input hold 0.%d%d ns\n", + (data[35] >> 4) & 0x0F, data[35] & 0x0F); break; default: - printf("Data signal input hold %c%d.%d nS\n", - (data[35] & 0x80) ? '-' : '+', - (data[35] >> 4) & 0x07, data[35] & 0x0F); + printf ("Data signal input hold %c%d.%d ns\n", + (data[35] & 0x80) ? '-' : '+', + (data[35] >> 4) & 0x07, data[35] & 0x0F); break; } puts ("Manufacturer's JEDEC ID "); for (j = 64; j <= 71; j++) - printf("%02X ", data[j]); + printf ("%02X ", data[j]); putc ('\n'); - printf("Manufacturing Location %02X\n", data[72]); + printf ("Manufacturing Location %02X\n", data[72]); puts ("Manufacturer's Part Number "); for (j = 73; j <= 90; j++) - printf("%02X ", data[j]); + printf ("%02X ", data[j]); putc ('\n'); - printf("Revision Code %02X %02X\n", data[91], data[92]); - printf("Manufacturing Date %02X %02X\n", data[93], data[94]); + printf ("Revision Code %02X %02X\n", data[91], data[92]); + printf ("Manufacturing Date %02X %02X\n", data[93], data[94]); puts ("Assembly Serial Number "); for (j = 95; j <= 98; j++) - printf("%02X ", data[j]); + printf ("%02X ", data[j]); putc ('\n'); if (DDR2 != type) { - printf("Speed rating PC%d\n", - data[126] == 0x66 ? 66 : data[126]); + printf ("Speed rating PC%d\n", + data[126] == 0x66 ? 66 : data[126]); } return 0; } -- cgit v1.2.3 From 00ac50e348d1bace27a174b7f528d113bc7cdf7f Mon Sep 17 00:00:00 2001 From: Andreas Engel Date: Wed, 9 Jan 2008 17:10:56 +0100 Subject: Make bootretry work when command line editing is enabled Currently, when CONFIG_CMDLINE_EDITING is set, bootretry doesn't work. This patch fixes the problem. Signed-off-by: Andreas Engel --- common/main.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/main.c b/common/main.c index 1c7d73e5dba..163ba02e62b 100644 --- a/common/main.c +++ b/common/main.c @@ -709,6 +709,13 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len) while (1) { rlen = 1; +#ifdef CONFIG_BOOT_RETRY_TIME + while (!tstc()) { /* while no incoming data */ + if (retry_time >= 0 && get_ticks() > endtime) + return (-2); /* timed out */ + } +#endif + ichar = getcmd_getch(); if ((ichar == '\n') || (ichar == '\r')) { -- cgit v1.2.3