From 628ffd73bcff0c9f3bc5a8eeb2c7455fe9d28a51 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 1 Sep 2008 17:11:26 +0200 Subject: device: make device_register() clone the device This is expected by the callers, but this fact was hidden well within the old list implementation. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/devices.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/devices.c b/common/devices.c index 2977436..8beebe2 100644 --- a/common/devices.c +++ b/common/devices.c @@ -130,10 +130,32 @@ device_t* device_get_by_name(char* name) return NULL; } +device_t* device_clone(device_t *dev) +{ + device_t *_dev; + + if(!dev) + return NULL; + + _dev = calloc(1, sizeof(device_t)); + + if(!_dev) + return NULL; + + memcpy(_dev, dev, sizeof(device_t)); + strncpy(_dev->name, dev->name, 16); + + return _dev; +} int device_register (device_t * dev) { - list_add(&(dev->list), &(devs.list)); + device_t *_dev; + + _dev = device_clone(dev); + if(!_dev) + return -1; + list_add(&(_dev->list), &(devs.list)); return 0; } -- cgit v1.1 From 3e3c026ed746a284c6f0ef139b26d859939de7e9 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Fri, 5 Sep 2008 10:47:46 +0200 Subject: devices: Use list_add_tail() instead of list_add() to register a device This patch fixes a problem spotted on Glacier/Canyonlands (and most likely lots of other board ports), that no serial output was seen after console initialization in console_init_r(). This is because the last added console device was used instead of the first added. This patch fixes this problem by using list_add_tail() instead of list_add() to register a device. This way the first added console is used again. Signed-off-by: Stefan Roese --- common/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/devices.c b/common/devices.c index 8beebe2..7d0ac2e 100644 --- a/common/devices.c +++ b/common/devices.c @@ -155,7 +155,7 @@ int device_register (device_t * dev) _dev = device_clone(dev); if(!_dev) return -1; - list_add(&(_dev->list), &(devs.list)); + list_add_tail(&(_dev->list), &(devs.list)); return 0; } -- cgit v1.1 From 2b22d608f370565c87f55928b524207031419c11 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Delgado Date: Wed, 30 Jul 2008 12:39:29 +0200 Subject: loads: allow negative offsets Signed-off-by: Ricardo Ribalda Delgado --- common/cmd_load.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/cmd_load.c b/common/cmd_load.c index f2b73bd..1351fe2 100644 --- a/common/cmd_load.c +++ b/common/cmd_load.c @@ -38,7 +38,7 @@ static ulong load_serial_ymodem (ulong offset); #endif #if defined(CONFIG_CMD_LOADS) -static ulong load_serial (ulong offset); +static ulong load_serial (long offset); static int read_record (char *buf, ulong len); # if defined(CONFIG_CMD_SAVES) static int save_serial (ulong offset, ulong size); @@ -53,7 +53,7 @@ static int do_echo = 1; #if defined(CONFIG_CMD_LOADS) int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - ulong offset = 0; + long offset = 0; ulong addr; int i; char *env_echo; @@ -72,7 +72,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #ifdef CFG_LOADS_BAUD_CHANGE if (argc >= 2) { - offset = simple_strtoul(argv[1], NULL, 16); + offset = simple_strtol(argv[1], NULL, 16); } if (argc == 3) { load_baudrate = (int)simple_strtoul(argv[2], NULL, 10); @@ -95,7 +95,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #else /* ! CFG_LOADS_BAUD_CHANGE */ if (argc == 2) { - offset = simple_strtoul(argv[1], NULL, 16); + offset = simple_strtol(argv[1], NULL, 16); } #endif /* CFG_LOADS_BAUD_CHANGE */ @@ -141,7 +141,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } static ulong -load_serial (ulong offset) +load_serial (long offset) { char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */ char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */ -- cgit v1.1 From f5c3ba79788b0e39baab7026d374fe375dd1a43f Mon Sep 17 00:00:00 2001 From: Mark Jackson Date: Mon, 25 Aug 2008 19:21:30 +0100 Subject: Allow console input to be disabled Added new CONFIG_DISABLE_CONSOLE define and GD_FLG_DISABLE_CONSOLE. When CONFIG_DISABLE_CONSOLE is defined, setting GD_FLG_DISABLE_CONSOLE disables all console input and output. Signed-off-by: Mark Jackson --- common/console.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common') diff --git a/common/console.c b/common/console.c index cfcaeb8..56d9118 100644 --- a/common/console.c +++ b/common/console.c @@ -162,6 +162,11 @@ void fprintf (int file, const char *fmt, ...) int getc (void) { +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return 0; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Get from the standard input */ return fgetc (stdin); @@ -173,6 +178,11 @@ int getc (void) int tstc (void) { +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return 0; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Test the standard input */ return ftstc (stdin); @@ -189,6 +199,11 @@ void putc (const char c) return; #endif +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fputc (stdout, c); @@ -205,6 +220,11 @@ void puts (const char *s) return; #endif +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fputs (stdout, s); -- cgit v1.1 From 1a7f8ccec981648ccd38fca2535490582eee08e6 Mon Sep 17 00:00:00 2001 From: Kyungmin Park Date: Wed, 27 Aug 2008 14:45:20 +0900 Subject: Add JFFS2 command support on OneNAND Signed-off-by: Kyungmin Park --- common/cmd_jffs2.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index c031d80..c6920c9 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -51,7 +51,7 @@ * mtdids=[,,...] * * := = - * := 'nand'|'nor' + * := 'nand'|'nor'|'onenand' * := mtd device number, 0... * := unique device tag used by linux kernel to find mtd device (mtd->name) * @@ -103,6 +103,13 @@ #include #endif /* !CONFIG_NAND_LEGACY */ #endif + +#if defined(CONFIG_CMD_ONENAND) +#include +#include +#include +#endif + /* enable/disable debugging messages */ #define DEBUG_JFFS #undef DEBUG_JFFS @@ -401,6 +408,43 @@ static int part_validate_nand(struct mtdids *id, struct part_info *part) } /** + * Performs sanity check for supplied OneNAND flash partition. + * Table of existing OneNAND flash devices is searched and partition device + * is located. Alignment with the granularity of nand erasesize is verified. + * + * @param id of the parent device + * @param part partition to validate + * @return 0 if partition is valid, 1 otherwise + */ +static int part_validate_onenand(struct mtdids *id, struct part_info *part) +{ +#if defined(CONFIG_CMD_ONENAND) + /* info for OneNAND chips */ + struct mtd_info *mtd; + + mtd = &onenand_mtd; + + if ((unsigned long)(part->offset) % mtd->erasesize) { + printf("%s%d: partition (%s) start offset" + "alignment incorrect\n", + MTD_DEV_TYPE(id->type), id->num, part->name); + return 1; + } + + if (part->size % mtd->erasesize) { + printf("%s%d: partition (%s) size alignment incorrect\n", + MTD_DEV_TYPE(id->type), id->num, part->name); + return 1; + } + + return 0; +#else + return 1; +#endif +} + + +/** * Performs sanity check for supplied partition. Offset and size are verified * to be within valid range. Partition type is checked and either * parts_validate_nor() or parts_validate_nand() is called with the argument @@ -436,6 +480,8 @@ static int part_validate(struct mtdids *id, struct part_info *part) return part_validate_nand(id, part); else if (id->type == MTD_DEV_TYPE_NOR) return part_validate_nor(id, part); + else if (id->type == MTD_DEV_TYPE_ONENAND) + return part_validate_onenand(id, part); else DEBUGF("part_validate: invalid dev type\n"); @@ -755,7 +801,15 @@ static int device_validate(u8 type, u8 num, u32 *size) #else printf("support for NAND devices not present\n"); #endif - } + } else if (type == MTD_DEV_TYPE_ONENAND) { +#if defined(CONFIG_CMD_ONENAND) + *size = onenand_mtd.size; + return 0; +#else + printf("support for OneNAND devices not present\n"); +#endif + } else + printf("Unknown defice type %d\n", type); return 1; } @@ -1065,8 +1119,8 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_ #endif /* #ifdef CONFIG_JFFS2_CMDLINE */ /** - * Parse device id string := 'nand'|'nor', return device - * type and number. + * Parse device id string := 'nand'|'nor'|'onenand', + * return device type and number. * * @param id string describing device id * @param ret_id output pointer to next char after parse completes (output) @@ -1085,6 +1139,9 @@ int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num) } else if (strncmp(p, "nor", 3) == 0) { *dev_type = MTD_DEV_TYPE_NOR; p += 3; + } else if (strncmp(p, "onenand", 7) == 0) { + *dev_type = MTD_DEV_TYPE_ONENAND; + p += 7; } else { printf("incorrect device type in %s\n", id); return 1; @@ -1489,7 +1546,7 @@ static int parse_mtdids(const char *const ids) while(p && (*p != '\0')) { ret = 1; - /* parse 'nor'|'nand' */ + /* parse 'nor'|'nand'|'onenand' */ if (id_parse(p, &p, &type, &num) != 0) break; @@ -2181,7 +2238,7 @@ U_BOOT_CMD( "'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n" "mtdids=[,,...]\n\n" " := =\n" - " := 'nand'|'nor'\n" + " := 'nand'|'nor'|'onenand'\n" " := mtd device number, 0...\n" " := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n" "'mtdparts' - partition list\n\n" -- cgit v1.1 From 8e02494e8f86c8f2d7324b5eb9e75271104a01ef Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Fri, 29 Aug 2008 21:04:45 +0200 Subject: Prevent crash if random DTB address is passed to bootm This patch adds bootm_start() return value check. If error status is returned, we do not proceed further to prevent board reset or crash as we still can recover at this point. Signed-off-by: Anatolij Gustschin --- common/cmd_bootm.c | 3 ++- common/image.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 0db7b75..374085c 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -361,7 +361,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong load_end = 0; int ret; - bootm_start(cmdtp, flag, argc, argv); + if (bootm_start(cmdtp, flag, argc, argv)) + return 1; /* * We have reached the point of no return: we are going to diff --git a/common/image.c b/common/image.c index 55c4cce..0acdcf1 100644 --- a/common/image.c +++ b/common/image.c @@ -1516,7 +1516,7 @@ int boot_get_fdt (int flag, int argc, char *argv[], bootm_headers_t *images, } break; default: - fdt_error ("Did not find a cmdline Flattened Device Tree"); + puts ("ERROR: Did not find a cmdline Flattened Device Tree\n"); goto error; } -- cgit v1.1 From ea86b9e64b811753d9eabe0f560ee189fbe5d0c1 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 29 Aug 2008 19:08:29 -0500 Subject: Prevent crash if random/invalid ramdisks are passed to bootm Adds returning an error from the ramdisk detection code if its not a real ramdisk (invalid). There is no reason we can't just return back to the console if we detect an invalid ramdisk or CRC error. Signed-off-by: Kumar Gala --- common/cmd_bootm.c | 2 +- common/image.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 374085c..751f5b9 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -246,7 +246,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ret = boot_get_ramdisk (argc, argv, &images, IH_INITRD_ARCH, &images.rd_start, &images.rd_end); if (ret) { - puts ("Ramdisk image is corrupt\n"); + puts ("Ramdisk image is corrupt or invalid\n"); return 1; } diff --git a/common/image.c b/common/image.c index 0acdcf1..94f01ad 100644 --- a/common/image.c +++ b/common/image.c @@ -749,7 +749,7 @@ int genimg_has_config (bootm_headers_t *images) * rd_start and rd_end are set to ramdisk start/end addresses if * ramdisk image is found and valid * - * 1, if ramdisk image is found but corrupted + * 1, if ramdisk image is found but corrupted, or invalid * rd_start and rd_end are set to 0 if no ramdisk exists */ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images, @@ -936,6 +936,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images, default: puts ("Wrong Ramdisk Image Format\n"); rd_data = rd_len = rd_load = 0; + return 1; } #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) -- cgit v1.1 From d1e2319414ea5218ba801163e4530ecf2dfcbf36 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 1 Sep 2008 23:06:23 +0200 Subject: rtc: allow rtc_set to return an error and use it in cmd_date Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_date.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/cmd_date.c b/common/cmd_date.c index 7511598..d6cd565 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -56,18 +56,30 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) rtc_reset (); } else { /* initialize tm with current time */ - rtc_get (&tm); - /* insert new date & time */ - if (mk_date (argv[1], &tm) != 0) { - puts ("## Bad date format\n"); - break; + rcode = rtc_get (&tm); + + if(!rcode) { + /* insert new date & time */ + if (mk_date (argv[1], &tm) != 0) { + puts ("## Bad date format\n"); + break; + } + /* and write to RTC */ + rcode = rtc_set (&tm); + if(rcode) + puts("## Set date failled\n"); + } else { + puts("## Get date failled\n"); } - /* and write to RTC */ - rtc_set (&tm); } /* FALL TROUGH */ case 1: /* get date & time */ - rtc_get (&tm); + rcode = rtc_get (&tm); + + if (rcode) { + puts("## Get date failled\n"); + break; + } printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, -- cgit v1.1 From 9863a15a98f23b79f34a0e4f9e465bc6df5d504d Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Mon, 8 Sep 2008 22:10:28 +0200 Subject: common/cmd_bootm.c: fix printf() format warnings Signed-off-by: Wolfgang Denk --- common/cmd_bootm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 751f5b9..8dbab02 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -337,13 +337,13 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) return BOOTM_ERR_UNIMPLEMENTED; } puts ("OK\n"); - debug (" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, load_end); + debug (" kernel loaded at 0x%08lx, end = 0x%8p\n", load, load_end); if (boot_progress) show_boot_progress (7); if ((load < blob_end) && (*load_end > blob_start)) { debug ("images.os.start = 0x%lX, images.os.end = 0x%lx\n", blob_start, blob_end); - debug ("images.os.load = 0x%lx, load_end = 0x%lx\n", load, load_end); + debug ("images.os.load = 0x%lx, load_end = 0x%p\n", load, load_end); return BOOTM_ERR_OVERLAP; } -- cgit v1.1 From 47ffd6c2fc72b46daa9d5d59eedb894fab2b7ee1 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 9 Sep 2008 15:45:18 +0200 Subject: Makefile: compile and link each module just once Several source files need to be compiled and linked when one or more config options are selected. To allow for easy selection in the Makefiles yet to avoild multiple compilation (which costs build time) and especially multiple linking (which causes errors), we use "COBJS = $(sort COBJS-y)" which eliminates duplicates. By courtesy of Detlev Zundel who suggested this approach. Signed-off-by: Wolfgang Denk --- common/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 0fe9c8b..d3888d6 100644 --- a/common/Makefile +++ b/common/Makefile @@ -56,7 +56,8 @@ COBJS-y += env_nowhere.o # command COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o -COBJS-$(CONFIG_AUTOSCRIPT)$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o +COBJS-$(CONFIG_AUTOSCRIPT) += cmd_autoscript.o +COBJS-$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o @@ -110,7 +111,8 @@ COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o COBJS-y += cmd_mac.o COBJS-y += cmd_mem.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o -COBJS-$(CONFIG_MII)$(CONFIG_CMD_MII) += miiphyutil.o +COBJS-$(CONFIG_MII) += miiphyutil.o +COBJS-$(CONFIG_CMD_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += cmd_mii.o COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o @@ -151,8 +153,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o -COBJS-y += $(COBJS-yy) -COBJS := $(COBJS-y) +COBJS := $(sort COBJS-y) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS)) -- cgit v1.1 From 9ba2e2c8191353d75b2d535e672a125be7b84c03 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 8 Sep 2008 13:57:12 -0500 Subject: Remove support for booting ARTOS images Pantelis Antoniou stated: AFAIK, it is still used but the products using PPC are long gone. Nuke it plz (from orbit). So remove it since it cleans up a usage of env_get_char outside of the environment code. Signed-off-by: Kumar Gala --- common/cmd_bootm.c | 99 ------------------------------------------------------ common/image.c | 3 -- 2 files changed, 102 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 8dbab02..08a014f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -108,9 +108,6 @@ static boot_os_fn do_bootm_qnxelf; int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); #endif -#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) -static boot_os_fn do_bootm_artos; -#endif ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */ @@ -455,11 +452,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; #endif -#ifdef CONFIG_ARTOS - case IH_OS_ARTOS: - do_bootm_artos (0, argc, argv, &images); - break; -#endif } show_boot_progress (-9); @@ -1152,94 +1144,3 @@ static int do_bootm_qnxelf(int flag, int argc, char *argv[], return 1; } #endif - -#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) -static int do_bootm_artos (int flag, int argc, char *argv[], - bootm_headers_t *images) -{ - ulong top; - char *s, *cmdline; - char **fwenv, **ss; - int i, j, nxt, len, envno, envsz; - bd_t *kbd; - void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top); - -#if defined(CONFIG_FIT) - if (!images->legacy_hdr_valid) { - fit_unsupported_reset ("ARTOS"); - return 1; - } -#endif - - /* - * Booting an ARTOS kernel image + application - */ - - /* this used to be the top of memory, but was wrong... */ -#ifdef CONFIG_PPC - /* get stack pointer */ - asm volatile ("mr %0,1" : "=r"(top) ); -#endif - debug ("## Current stack ends at 0x%08lX ", top); - - top -= 2048; /* just to be sure */ - if (top > CFG_BOOTMAPSZ) - top = CFG_BOOTMAPSZ; - top &= ~0xF; - - debug ("=> set upper limit to 0x%08lX\n", top); - - /* first check the artos specific boot args, then the linux args*/ - if ((s = getenv( "abootargs")) == NULL && (s = getenv ("bootargs")) == NULL) - s = ""; - - /* get length of cmdline, and place it */ - len = strlen (s); - top = (top - (len + 1)) & ~0xF; - cmdline = (char *)top; - debug ("## cmdline at 0x%08lX ", top); - strcpy (cmdline, s); - - /* copy bdinfo */ - top = (top - sizeof (bd_t)) & ~0xF; - debug ("## bd at 0x%08lX ", top); - kbd = (bd_t *)top; - memcpy (kbd, gd->bd, sizeof (bd_t)); - - /* first find number of env entries, and their size */ - envno = 0; - envsz = 0; - for (i = 0; env_get_char (i) != '\0'; i = nxt + 1) { - for (nxt = i; env_get_char (nxt) != '\0'; ++nxt) - ; - envno++; - envsz += (nxt - i) + 1; /* plus trailing zero */ - } - envno++; /* plus the terminating zero */ - debug ("## %u envvars total size %u ", envno, envsz); - - top = (top - sizeof (char **) * envno) & ~0xF; - fwenv = (char **)top; - debug ("## fwenv at 0x%08lX ", top); - - top = (top - envsz) & ~0xF; - s = (char *)top; - ss = fwenv; - - /* now copy them */ - for (i = 0; env_get_char (i) != '\0'; i = nxt + 1) { - for (nxt = i; env_get_char (nxt) != '\0'; ++nxt) - ; - *ss++ = s; - for (j = i; j < nxt; ++j) - *s++ = env_get_char (j); - *s++ = '\0'; - } - *ss++ = NULL; /* terminate */ - - entry = (void (*)(bd_t *, char *, char **, ulong))images->ep; - (*entry) (kbd, cmdline, fwenv, top); - - return 1; -} -#endif diff --git a/common/image.c b/common/image.c index 94f01ad..78efe2e 100644 --- a/common/image.c +++ b/common/image.c @@ -105,9 +105,6 @@ static table_entry_t uimage_arch[] = { static table_entry_t uimage_os[] = { { IH_OS_INVALID, NULL, "Invalid OS", }, -#if defined(CONFIG_ARTOS) || defined(USE_HOSTCC) - { IH_OS_ARTOS, "artos", "ARTOS", }, -#endif { IH_OS_LINUX, "linux", "Linux", }, #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC) { IH_OS_LYNXOS, "lynxos", "LynxOS", }, -- cgit v1.1 From f5ed9e39088ecfa5a5f3ef47b08e5bda7890d764 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 8 Sep 2008 14:56:49 -0500 Subject: Add support for booting of INTEGRITY operating system uImages Signed-off-by: Peter Tyser --- common/cmd_bootm.c | 38 ++++++++++++++++++++++++++++++++++++++ common/image.c | 3 +++ 2 files changed, 41 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 08a014f..b023e26 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -108,6 +108,9 @@ static boot_os_fn do_bootm_qnxelf; int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); #endif +#if defined(CONFIG_INTEGRITY) +static boot_os_fn do_bootm_integrity; +#endif ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */ @@ -452,6 +455,11 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; #endif +#ifdef CONFIG_INTEGRITY + case IH_OS_INTEGRITY: + do_bootm_integrity (0, argc, argv, &images); + break; +#endif } show_boot_progress (-9); @@ -1144,3 +1152,33 @@ static int do_bootm_qnxelf(int flag, int argc, char *argv[], return 1; } #endif + +#ifdef CONFIG_INTEGRITY +static int do_bootm_integrity (int flag, int argc, char *argv[], + bootm_headers_t *images) +{ + void (*entry_point)(void); + +#if defined(CONFIG_FIT) + if (!images->legacy_hdr_valid) { + fit_unsupported_reset ("INTEGRITY"); + return 1; + } +#endif + + entry_point = (void (*)(void))images->ep; + + printf ("## Transferring control to INTEGRITY (at address %08lx) ...\n", + (ulong)entry_point); + + show_boot_progress (15); + + /* + * INTEGRITY Parameters: + * None + */ + (*entry_point)(); + + return 1; +} +#endif diff --git a/common/image.c b/common/image.c index 78efe2e..b011932 100644 --- a/common/image.c +++ b/common/image.c @@ -116,6 +116,9 @@ static table_entry_t uimage_os[] = { { IH_OS_QNX, "qnx", "QNX", }, { IH_OS_VXWORKS, "vxworks", "VxWorks", }, #endif +#if defined(CONFIG_INTEGRITY) || defined(USE_HOSTCC) + { IH_OS_INTEGRITY,"integrity", "INTEGRITY", }, +#endif #ifdef USE_HOSTCC { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", }, { IH_OS_DELL, "dell", "Dell", }, -- cgit v1.1 From 919f550dc11a13abf01c6bc713c968de790b8d7c Mon Sep 17 00:00:00 2001 From: Bartlomiej Sieka Date: Tue, 9 Sep 2008 12:58:15 +0200 Subject: FIT: add ability to check hashes of all images in FIT, improve output - add function fit_all_image_check_hashes() that verifies if all hashes of all images in the FIT are valid - improve output of fit_image_check_hashes() when the hash check fails Signed-off-by: Bartlomiej Sieka --- common/image.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/image.c b/common/image.c index b011932..f7e8606 100644 --- a/common/image.c +++ b/common/image.c @@ -2645,27 +2645,29 @@ int fit_image_check_hashes (const void *fit, int image_noffset) continue; if (fit_image_hash_get_algo (fit, noffset, &algo)) { - err_msg = "Can't get hash algo property"; + err_msg = " error!\nCan't get hash algo " + "property"; goto error; } printf ("%s", algo); if (fit_image_hash_get_value (fit, noffset, &fit_value, &fit_value_len)) { - err_msg = "Can't get hash value property"; + err_msg = " error!\nCan't get hash value " + "property"; goto error; } if (calculate_hash (data, size, algo, value, &value_len)) { - err_msg = "Unsupported hash algorithm"; + err_msg = " error!\nUnsupported hash algorithm"; goto error; } if (value_len != fit_value_len) { - err_msg = "Bad hash value len"; + err_msg = " error !\nBad hash value len"; goto error; } else if (memcmp (value, fit_value, value_len) != 0) { - err_msg = "Bad hash value"; + err_msg = " error!\nBad hash value"; goto error; } printf ("+ "); @@ -2682,6 +2684,55 @@ error: } /** + * fit_all_image_check_hashes - verify data intergity for all images + * @fit: pointer to the FIT format image header + * + * fit_all_image_check_hashes() goes over all images in the FIT and + * for every images checks if all it's hashes are valid. + * + * returns: + * 1, if all hashes of all images are valid + * 0, otherwise (or on error) + */ +int fit_all_image_check_hashes (const void *fit) +{ + int images_noffset; + int noffset; + int ndepth; + int count; + + /* Find images parent node offset */ + images_noffset = fdt_path_offset (fit, FIT_IMAGES_PATH); + if (images_noffset < 0) { + printf ("Can't find images parent node '%s' (%s)\n", + FIT_IMAGES_PATH, fdt_strerror (images_noffset)); + return 0; + } + + /* Process all image subnodes, check hashes for each */ + printf ("## Checking hash(es) for FIT Image at %08lx ...\n", + (ulong)fit); + for (ndepth = 0, count = 0, + noffset = fdt_next_node (fit, images_noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node (fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* + * Direct child node of the images parent node, + * i.e. component image node. + */ + printf (" Hash(es) for Image %u (%s): ", count++, + fit_get_name (fit, noffset, NULL)); + + if (!fit_image_check_hashes (fit, noffset)) + return 0; + printf ("\n"); + } + } + return 1; +} + +/** * fit_image_check_os - check whether image node is of a given os type * @fit: pointer to the FIT format image header * @noffset: component image node offset -- cgit v1.1 From a4f243452cc8ce0c2c9b51a2520db4bde5f472de Mon Sep 17 00:00:00 2001 From: Bartlomiej Sieka Date: Tue, 9 Sep 2008 12:58:16 +0200 Subject: FIT: make iminfo check hashes of all images in FIT, return 1 on failed check Signed-off-by: Bartlomiej Sieka --- common/cmd_bootm.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index b023e26..861712b 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -854,6 +854,12 @@ static int image_info (ulong addr) } fit_print_contents (hdr); + + if (!fit_all_image_check_hashes (hdr)) { + puts ("Bad hash in FIT image!\n"); + return 1; + } + return 0; #endif default: -- cgit v1.1 From 2c8ccf2728f5e67d991cecf76c4057db75a87b67 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 9 Sep 2008 16:55:47 +0200 Subject: Makefile: fix bug introduced by commit 47ffd6c2 --- common/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index d3888d6..8d4a426 100644 --- a/common/Makefile +++ b/common/Makefile @@ -153,7 +153,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o -COBJS := $(sort COBJS-y) +COBJS := $(sort $(COBJS-y)) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS)) -- cgit v1.1 From eba1f2fc75f128a9a6c1328d786996a93fd7a707 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Wed, 20 Aug 2008 11:22:02 +0200 Subject: Make usb-stop() safe to call multiple times in a row. A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel. However, the usb_ohci driver hangs up (at least on AT91SAM) if the driver is stopped twice (e.g. the peripheral clock is stopped on AT91). If some other piece of code calls usb_stop() before the bootm command, this command will hangup the system during boot. (usb start and stop is typically used while booting from usb memory stick) But, stopping the usb stack twice is useless anyway, and a flag already existed that kept track on the usb_init()/usb_stop() calls. So, we now check if the usb stack is really started before we stop it. This problem is now fixed in both the upper as low-level layer. Signed-off-by: Remy Bohmer Acked-by: Markus Klotzbuecher --- common/usb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index 9502f39..52e5964 100644 --- a/common/usb.c +++ b/common/usb.c @@ -126,10 +126,15 @@ int usb_init(void) */ int usb_stop(void) { - asynch_allowed=1; - usb_started = 0; - usb_hub_reset(); - return usb_lowlevel_stop(); + int res = 0; + + if (usb_started) { + asynch_allowed = 1; + usb_started = 0; + usb_hub_reset(); + res = usb_lowlevel_stop(); + } + return res; } /* -- cgit v1.1 From 3b20fd83c73c22acfcb0c6663be747bd5c8b7011 Mon Sep 17 00:00:00 2001 From: Ryan CHEN Date: Wed, 20 Aug 2008 13:00:17 -0400 Subject: Correct drv_usb_kbd_init function The patch is that check if usb_get_dev_index() function return valid pointer. If valid, continue. Otherwise return -1. Signed-off-by: Ryan Chen Acked-by: Markus Klotzbuecher --- common/usb_kbd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 108bd60..920bb0f 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -162,6 +162,8 @@ int drv_usb_kbd_init(void) /* scan all USB Devices */ for(i=0;idevnum!=-1) { if(usb_kbd_probe(dev,0)==1) { /* Ok, we found a keyboard */ /* check, if it is already registered */ -- cgit v1.1 From 748b5274e76f81df85cfcffaffedc323678d0623 Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Tue, 9 Sep 2008 18:51:05 +0200 Subject: common/cmd_mem.c: remove nested #if defined(CONFIG_CMD_MEMORY) Signed-off-by: Markus Heidelberg --- common/cmd_mem.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'common') diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 4766c24..d0a6ca8 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -1227,7 +1227,6 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /**************************************************/ -#if defined(CONFIG_CMD_MEMORY) U_BOOT_CMD( md, 3, 1, do_mem_md, "md - memory display\n", @@ -1338,4 +1337,3 @@ U_BOOT_CMD( #endif /* CONFIG_CMD_UNZIP */ #endif -#endif -- cgit v1.1 From 1d9af0be764960e6cc1c093e97176c3542796820 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 9 Sep 2008 22:18:23 +0200 Subject: bootm: enable fdt support only on ppc, m68k and sparc ...as done in image.c Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_bootm.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 861712b..2b4df80 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -251,6 +251,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #if defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) /* find flattened device tree */ ret = boot_get_fdt (flag, argc, argv, &images, &images.ft_addr, &images.ft_len); @@ -261,6 +262,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) set_working_fdt_addr(images.ft_addr); #endif +#endif } images.os.start = (ulong)os_hdr; -- cgit v1.1 From 54b4ab3c961a2012a1c2a09c259a6343323ec551 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 9 Sep 2008 22:18:24 +0200 Subject: bootm_load_os: fix load_end debug message print load_end value not pointer Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_bootm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 2b4df80..9c63e04 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -339,13 +339,13 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) return BOOTM_ERR_UNIMPLEMENTED; } puts ("OK\n"); - debug (" kernel loaded at 0x%08lx, end = 0x%8p\n", load, load_end); + debug (" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end); if (boot_progress) show_boot_progress (7); if ((load < blob_end) && (*load_end > blob_start)) { debug ("images.os.start = 0x%lX, images.os.end = 0x%lx\n", blob_start, blob_end); - debug ("images.os.load = 0x%lx, load_end = 0x%p\n", load, load_end); + debug ("images.os.load = 0x%lx, load_end = 0x%lx\n", load, *load_end); return BOOTM_ERR_OVERLAP; } -- cgit v1.1 From 5251469943895de4bb9a04d5053352cc22acb7d5 Mon Sep 17 00:00:00 2001 From: Andrew Klossner Date: Thu, 21 Aug 2008 07:12:26 -0700 Subject: Fix printf errors under -DDEBUG Fix printf format-string/arg mismatches under -DDEBUG. These warnings occur with DEBUG defined for a platform using cpu/mpc85xx. Users of other architectures can unearth similar problems by adding the line "CFLAGS += -DDEBUG=1" in config.mk right after "CFLAGS += $(call cc-option,-fno-stack-protector)". Signed-off-by: Andrew Klossner Signed-off-by: Andy Fleming --- common/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/image.c b/common/image.c index f7e8606..d7fcd1d 100644 --- a/common/image.c +++ b/common/image.c @@ -1563,7 +1563,7 @@ int boot_get_fdt (int flag, int argc, char *argv[], bootm_headers_t *images, *of_flat_tree = fdt_blob; *of_size = be32_to_cpu (fdt_totalsize (fdt_blob)); debug (" of_flat_tree at 0x%08lx size 0x%08lx\n", - *of_flat_tree, *of_size); + (ulong)*of_flat_tree, *of_size); return 0; -- cgit v1.1 From 3591293509e0c0bcf244b0f974775bff2e25697e Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Wed, 10 Sep 2008 09:43:49 +0300 Subject: autoscr: Fix one-character lines and non-newline terminated scripts When not using hush, the autoscr command now executes lines that are only one character long. It also runs the last line of scripts even if it does not end in a newline. Signed-off-by: Petri Lehtinen --- common/cmd_autoscript.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c index c2e7e66..0439da2 100644 --- a/common/cmd_autoscript.c +++ b/common/cmd_autoscript.c @@ -180,7 +180,7 @@ autoscript (ulong addr, const char *fit_uname) if (*next == '\n') { *next = '\0'; /* run only non-empty commands */ - if ((next - line) > 1) { + if (*line) { debug ("** exec: \"%s\"\n", line); if (run_command (line, 0) < 0) { @@ -192,6 +192,8 @@ autoscript (ulong addr, const char *fit_uname) } ++next; } + if (rcode == 0 && *line) + rcode = (run_command(line, 0) >= 0); } #endif free (cmd); -- cgit v1.1 From 0d92d4a699fb1a39381d98571dc51fb97e5bcf9e Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 30 Aug 2008 23:29:57 +0200 Subject: cmd_vfd: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/cmd_vfd.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 8d4a426..3547766 100644 --- a/common/Makefile +++ b/common/Makefile @@ -144,7 +144,7 @@ COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o endif COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o -COBJS-y += cmd_vfd.o +COBJS-$(CONFIG_VFD) += cmd_vfd.o COBJS-$(CONFIG_CMD_DOC) += docecc.o COBJS-y += flash.o COBJS-y += kgdb.o diff --git a/common/cmd_vfd.c b/common/cmd_vfd.c index 104c310..45f4271 100644 --- a/common/cmd_vfd.c +++ b/common/cmd_vfd.c @@ -75,7 +75,6 @@ U_BOOT_CMD( ); #endif -#ifdef CONFIG_VFD int trab_vfd (ulong bitmap) { uchar *addr; @@ -103,4 +102,3 @@ int trab_vfd (ulong bitmap) transfer_pic(3, addr, VFD_LOGO_HEIGHT, VFD_LOGO_WIDTH); return 0; } -#endif /* CONFIG_VFD */ -- cgit v1.1 From 2d02d91d530e831f2dab228085963fc1d5b71cb0 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 30 Aug 2008 23:47:38 +0200 Subject: common/Makefile: add core command section Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 3547766..1d8ec87 100644 --- a/common/Makefile +++ b/common/Makefile @@ -42,6 +42,11 @@ COBJS-y += s_record.o COBJS-y += serial.o COBJS-y += xyzModem.o +#core command +COBJS-y += cmd_boot.o +COBJS-y += cmd_bootm.o +COBJS-y += cmd_nvedit.o + # environment COBJS-y += environment.o COBJS-y += env_common.o @@ -61,9 +66,7 @@ COBJS-$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o -COBJS-y += cmd_boot.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o -COBJS-y += cmd_bootm.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o @@ -119,7 +122,6 @@ COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o COBJS-$(CONFIG_MP) += cmd_mp.o COBJS-y += cmd_nand.o COBJS-$(CONFIG_CMD_NET) += cmd_net.o -COBJS-y += cmd_nvedit.o COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o COBJS-$(CONFIG_CMD_OTP) += cmd_otp.o ifdef CONFIG_PCI -- cgit v1.1 From e5648acab153f0f429bfc714902c5aaa7879f71b Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 30 Aug 2008 23:47:41 +0200 Subject: cmd_fdc: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/cmd_fdc.c | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 1d8ec87..e9f75f4 100644 --- a/common/Makefile +++ b/common/Makefile @@ -84,7 +84,7 @@ COBJS-y += cmd_eeprom.o COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o -COBJS-y += cmd_fdc.o +COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o COBJS-$(CONFIG_CMD_FDOS) += cmd_fdos.o COBJS-$(CONFIG_CMD_FLASH) += cmd_flash.o diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index 8493def..b663d60 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -50,8 +50,6 @@ /*#include */ /*#endif */ -#if defined(CONFIG_CMD_FDC) || defined(CONFIG_CMD_FDOS) - typedef struct { int flags; /* connected drives ect */ unsigned long blnr; /* Logical block nr */ @@ -705,7 +703,6 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG) return TRUE; } -#endif #if defined(CONFIG_CMD_FDOS) @@ -903,15 +900,6 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return rcode; } - -#endif - - -/***************************************************/ - - -#if defined(CONFIG_CMD_FDC) - U_BOOT_CMD( fdcboot, 3, 1, do_fdcboot, "fdcboot - boot from floppy device\n", -- cgit v1.1 From 32628c5008105a732212003d83b75f05e5243bb2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 30 Aug 2008 23:54:58 +0200 Subject: cmd_mac: Move conditional compilation to Makefile finish remaning CFG_ID_EEPROM in CONFIG_ID_EEPROM start in commit ad8f8687b78c3e917b173f038926695383c55555 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/cmd_mac.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index e9f75f4..a9a02b2 100644 --- a/common/Makefile +++ b/common/Makefile @@ -111,7 +111,7 @@ COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o COBJS-y += cmd_load.o COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o -COBJS-y += cmd_mac.o +COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o COBJS-y += cmd_mem.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_MII) += miiphyutil.o diff --git a/common/cmd_mac.c b/common/cmd_mac.c index faed8f7..4453299 100644 --- a/common/cmd_mac.c +++ b/common/cmd_mac.c @@ -24,8 +24,6 @@ #include #include -#ifdef CFG_ID_EEPROM - extern int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( @@ -63,4 +61,3 @@ U_BOOT_CMD( "mac 7\n" " - program the MAC address for port 7\n" ); -#endif /* CFG_ID_EEPROM */ -- cgit v1.1 From bb1f8b4f8bb0bfce52e0faa4637b975b745824b3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 5 Sep 2008 09:19:30 +0200 Subject: rename CFG_ENV_IS_IN_EEPROM in CONFIG_ENV_IS_IN_EEPROM Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_eeprom.c | 4 ++-- common/cmd_nvedit.c | 6 +++--- common/env_eeprom.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index e5000e9..5034b5e 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -42,7 +42,7 @@ #include #include -#if defined(CFG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) +#if defined(CONFIG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) extern void eeprom_init (void); extern int eeprom_read (unsigned dev_addr, unsigned offset, @@ -121,7 +121,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * 0x00000nxx for EEPROM address selectors and page number at n. */ -#if defined(CFG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) +#if defined(CONFIG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) #ifndef CONFIG_SPI #if !defined(CFG_I2C_EEPROM_ADDR_LEN) || CFG_I2C_EEPROM_ADDR_LEN < 1 || CFG_I2C_EEPROM_ADDR_LEN > 2 diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 7089706..8b6b46b 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -53,7 +53,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CFG_ENV_IS_IN_NVRAM) && \ - !defined(CFG_ENV_IS_IN_EEPROM) && \ + !defined(CONFIG_ENV_IS_IN_EEPROM) && \ !defined(CFG_ENV_IS_IN_FLASH) && \ !defined(CFG_ENV_IS_IN_DATAFLASH) && \ !defined(CFG_ENV_IS_IN_NAND) && \ @@ -540,7 +540,7 @@ int getenv_r (char *name, char *buf, unsigned len) return (-1); } -#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ +#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ @@ -596,7 +596,7 @@ U_BOOT_CMD( " - delete environment variable 'name'\n" ); -#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ +#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ diff --git a/common/env_eeprom.c b/common/env_eeprom.c index 9e1a201..1a03f43 100644 --- a/common/env_eeprom.c +++ b/common/env_eeprom.c @@ -26,7 +26,7 @@ #include -#if defined(CFG_ENV_IS_IN_EEPROM) /* Environment is in EEPROM */ +#if defined(CONFIG_ENV_IS_IN_EEPROM) /* Environment is in EEPROM */ #include #include @@ -107,4 +107,4 @@ int env_init(void) return (0); } -#endif /* CFG_ENV_IS_IN_EEPROM */ +#endif /* CONFIG_ENV_IS_IN_EEPROM */ -- cgit v1.1 From bf5a7710ec70e90e98f451b4ba0eb65f9ffc34eb Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 5 Sep 2008 09:19:54 +0200 Subject: env_eeprom: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_eeprom.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index a9a02b2..9001237 100644 --- a/common/Makefile +++ b/common/Makefile @@ -51,7 +51,7 @@ COBJS-y += cmd_nvedit.o COBJS-y += environment.o COBJS-y += env_common.o COBJS-y += env_dataflash.o -COBJS-y += env_eeprom.o +COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_flash.o COBJS-y += env_nand.o COBJS-y += env_nvram.o diff --git a/common/env_eeprom.c b/common/env_eeprom.c index 1a03f43..df3e31e 100644 --- a/common/env_eeprom.c +++ b/common/env_eeprom.c @@ -25,9 +25,6 @@ */ #include - -#if defined(CONFIG_ENV_IS_IN_EEPROM) /* Environment is in EEPROM */ - #include #include #include @@ -106,5 +103,3 @@ int env_init(void) return (0); } - -#endif /* CONFIG_ENV_IS_IN_EEPROM */ -- cgit v1.1 From d1034bc8db60fa6bd419328baf6a75cb0645cee8 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:52 +0200 Subject: cmd_eeprom: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 3 ++- common/cmd_eeprom.c | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 9001237..fea0caf 100644 --- a/common/Makefile +++ b/common/Makefile @@ -80,7 +80,8 @@ endif COBJS-$(CONFIG_CMD_DISPLAY) += cmd_display.o COBJS-$(CONFIG_CMD_DOC) += cmd_doc.o COBJS-$(CONFIG_CMD_DTT) += cmd_dtt.o -COBJS-y += cmd_eeprom.o +COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o +COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index 5034b5e..44d44fe 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -42,8 +42,6 @@ #include #include -#if defined(CONFIG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) - extern void eeprom_init (void); extern int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); @@ -52,7 +50,6 @@ extern int eeprom_write (unsigned dev_addr, unsigned offset, #if defined(CFG_EEPROM_WREN) extern int eeprom_write_enable (unsigned dev_addr, int state); #endif -#endif #if defined(CFG_EEPROM_X40430) @@ -121,8 +118,6 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * 0x00000nxx for EEPROM address selectors and page number at n. */ -#if defined(CONFIG_ENV_IS_IN_EEPROM) || defined(CONFIG_CMD_EEPROM) - #ifndef CONFIG_SPI #if !defined(CFG_I2C_EEPROM_ADDR_LEN) || CFG_I2C_EEPROM_ADDR_LEN < 1 || CFG_I2C_EEPROM_ADDR_LEN > 2 #error CFG_I2C_EEPROM_ADDR_LEN must be 1 or 2 @@ -422,7 +417,6 @@ void eeprom_init (void) } /*----------------------------------------------------------------------- */ -#endif /***************************************************/ -- cgit v1.1 From 057c849c45b9ee19df8ff3acdeee66be52819962 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:58 +0200 Subject: rename CFG_ENV_IS_IN_DATAFLASH in CONFIG_ENV_IS_IN_DATAFLASH Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- common/env_dataflash.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 8b6b46b..f3d8408 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -55,7 +55,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CFG_ENV_IS_IN_NVRAM) && \ !defined(CONFIG_ENV_IS_IN_EEPROM) && \ !defined(CFG_ENV_IS_IN_FLASH) && \ - !defined(CFG_ENV_IS_IN_DATAFLASH) && \ + !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ !defined(CFG_ENV_IS_IN_NAND) && \ !defined(CFG_ENV_IS_IN_ONENAND) && \ !defined(CFG_ENV_IS_IN_SPI_FLASH) && \ diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 2945364..1d55a27 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -19,7 +19,7 @@ */ #include -#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */ +#if defined(CONFIG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */ #include #include @@ -101,4 +101,4 @@ int env_init(void) return (0); } -#endif /* CFG_ENV_IS_IN_DATAFLASH */ +#endif /* CONFIG_ENV_IS_IN_DATAFLASH */ -- cgit v1.1 From d8cc04d0ac9c7c0d12454708aaf5489f8532bbf9 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:58 +0200 Subject: env_dataflash: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_dataflash.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index fea0caf..27f515b 100644 --- a/common/Makefile +++ b/common/Makefile @@ -50,7 +50,7 @@ COBJS-y += cmd_nvedit.o # environment COBJS-y += environment.o COBJS-y += env_common.o -COBJS-y += env_dataflash.o +COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_flash.o COBJS-y += env_nand.o diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 1d55a27..2254b9b 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -18,9 +18,6 @@ * */ #include - -#if defined(CONFIG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */ - #include #include #include @@ -100,5 +97,3 @@ int env_init(void) return (0); } - -#endif /* CONFIG_ENV_IS_IN_DATAFLASH */ -- cgit v1.1 From 51bfee192099206a4397f15f3b93516e01f58ab0 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:58 +0200 Subject: rename CFG_ENV_IS_IN_NAND in CONFIG_ENV_IS_IN_NAND Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- common/env_common.c | 2 +- common/env_nand.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index f3d8408..dc6d13a 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -56,7 +56,7 @@ DECLARE_GLOBAL_DATA_PTR; !defined(CONFIG_ENV_IS_IN_EEPROM) && \ !defined(CFG_ENV_IS_IN_FLASH) && \ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ - !defined(CFG_ENV_IS_IN_NAND) && \ + !defined(CONFIG_ENV_IS_IN_NAND) && \ !defined(CFG_ENV_IS_IN_ONENAND) && \ !defined(CFG_ENV_IS_IN_SPI_FLASH) && \ !defined(CFG_ENV_IS_NOWHERE) diff --git a/common/env_common.c b/common/env_common.c index d51c211..e89f192 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -133,7 +133,7 @@ uchar default_environment[] = { "\0" }; -#if defined(CFG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \ +#if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \ || defined(CFG_ENV_IS_IN_SPI_FLASH) int default_environment_size = sizeof(default_environment); #endif diff --git a/common/env_nand.c b/common/env_nand.c index a8f0de7..53e3183 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -34,7 +34,7 @@ #include -#if defined(CFG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ +#if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ #include #include @@ -367,4 +367,4 @@ static void use_default() } #endif -#endif /* CFG_ENV_IS_IN_NAND */ +#endif /* CONFIG_ENV_IS_IN_NAND */ -- cgit v1.1 From 06f61354397911a4c121dfa51b6ccbf7e300d48b Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:59 +0200 Subject: env_nand: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_nand.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 27f515b..2e0fa26 100644 --- a/common/Makefile +++ b/common/Makefile @@ -53,7 +53,7 @@ COBJS-y += env_common.o COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_flash.o -COBJS-y += env_nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-y += env_nvram.o COBJS-y += env_onenand.o COBJS-y += env_sf.o diff --git a/common/env_nand.c b/common/env_nand.c index 53e3183..9d01d7c 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -33,9 +33,6 @@ /* #define DEBUG */ #include - -#if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ - #include #include #include @@ -366,5 +363,3 @@ static void use_default() set_default_env(); } #endif - -#endif /* CONFIG_ENV_IS_IN_NAND */ -- cgit v1.1 From 9314cee6917444ab88bd4e758da7a30975120187 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:59 +0200 Subject: rename CFG_ENV_IS_IN_NVRAM in CONFIG_ENV_IS_IN_NVRAM Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 6 +++--- common/env_nvram.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index dc6d13a..08671f2 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -52,7 +52,7 @@ DECLARE_GLOBAL_DATA_PTR; -#if !defined(CFG_ENV_IS_IN_NVRAM) && \ +#if !defined(CONFIG_ENV_IS_IN_NVRAM) && \ !defined(CONFIG_ENV_IS_IN_EEPROM) && \ !defined(CFG_ENV_IS_IN_FLASH) && \ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ @@ -540,7 +540,7 @@ int getenv_r (char *name, char *buf, unsigned len) return (-1); } -#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ +#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ @@ -596,7 +596,7 @@ U_BOOT_CMD( " - delete environment variable 'name'\n" ); -#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ +#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ diff --git a/common/env_nvram.c b/common/env_nvram.c index fa77719..c877f00 100644 --- a/common/env_nvram.c +++ b/common/env_nvram.c @@ -44,7 +44,7 @@ DECLARE_GLOBAL_DATA_PTR; -#ifdef CFG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */ +#ifdef CONFIG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */ #include #include @@ -157,4 +157,4 @@ int env_init (void) return (0); } -#endif /* CFG_ENV_IS_IN_NVRAM */ +#endif /* CONFIG_ENV_IS_IN_NVRAM */ -- cgit v1.1 From 957a0e69575683efd70ace147746bbb3d8e7c501 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:59 +0200 Subject: env_nvram: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_nvram.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 2e0fa26..cb3a742 100644 --- a/common/Makefile +++ b/common/Makefile @@ -54,7 +54,7 @@ COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o -COBJS-y += env_nvram.o +COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-y += env_onenand.o COBJS-y += env_sf.o COBJS-y += env_nowhere.o diff --git a/common/env_nvram.c b/common/env_nvram.c index c877f00..c59bf9f 100644 --- a/common/env_nvram.c +++ b/common/env_nvram.c @@ -41,15 +41,12 @@ */ #include - -DECLARE_GLOBAL_DATA_PTR; - -#ifdef CONFIG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */ - #include #include #include +DECLARE_GLOBAL_DATA_PTR; + #ifdef CFG_NVRAM_ACCESS_ROUTINE extern void *nvram_read(void *dest, const long src, size_t count); extern void nvram_write(long dest, const void *src, size_t count); @@ -156,5 +153,3 @@ int env_init (void) #endif return (0); } - -#endif /* CONFIG_ENV_IS_IN_NVRAM */ -- cgit v1.1 From 9656138ff1a34d4c4768db6b490deffc40ee674b Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:47:59 +0200 Subject: rename CFG_ENV_IS_IN_ONENAND in CONFIG_ENV_IS_IN_ONENAND Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- common/env_onenand.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 08671f2..bfd097f 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -57,7 +57,7 @@ DECLARE_GLOBAL_DATA_PTR; !defined(CFG_ENV_IS_IN_FLASH) && \ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ !defined(CONFIG_ENV_IS_IN_NAND) && \ - !defined(CFG_ENV_IS_IN_ONENAND) && \ + !defined(CONFIG_ENV_IS_IN_ONENAND) && \ !defined(CFG_ENV_IS_IN_SPI_FLASH) && \ !defined(CFG_ENV_IS_NOWHERE) # error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} diff --git a/common/env_onenand.c b/common/env_onenand.c index d5c907c..4e466ea 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -23,7 +23,7 @@ #include -#if defined(CFG_ENV_IS_IN_ONENAND) /* Environment is in OneNAND */ +#if defined(CONFIG_ENV_IS_IN_ONENAND) /* Environment is in OneNAND */ #include #include @@ -127,4 +127,4 @@ int env_init(void) return 0; } -#endif /* CFG_ENV_IS_IN_ONENAND */ +#endif /* CONFIG_ENV_IS_IN_ONENAND */ -- cgit v1.1 From 55c5f49910ec8225347aa1d211352a84de6649b4 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:00 +0200 Subject: env_onenand: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_onenand.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index cb3a742..a9d66ae 100644 --- a/common/Makefile +++ b/common/Makefile @@ -55,7 +55,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o -COBJS-y += env_onenand.o +COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o COBJS-y += env_sf.o COBJS-y += env_nowhere.o diff --git a/common/env_onenand.c b/common/env_onenand.c index 4e466ea..09a79d0 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -22,9 +22,6 @@ */ #include - -#if defined(CONFIG_ENV_IS_IN_ONENAND) /* Environment is in OneNAND */ - #include #include #include @@ -126,5 +123,3 @@ int env_init(void) return 0; } - -#endif /* CONFIG_ENV_IS_IN_ONENAND */ -- cgit v1.1 From 0b5099a8419bf9c828df5e3e2c6878dc300d98e3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:00 +0200 Subject: rename CFG_ENV_IS_IN_SPI_FLASH in CONFIG_ENV_IS_IN_SPI_FLASH Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- common/env_common.c | 2 +- common/env_sf.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index bfd097f..85d7108 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -58,7 +58,7 @@ DECLARE_GLOBAL_DATA_PTR; !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ !defined(CONFIG_ENV_IS_IN_NAND) && \ !defined(CONFIG_ENV_IS_IN_ONENAND) && \ - !defined(CFG_ENV_IS_IN_SPI_FLASH) && \ + !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ !defined(CFG_ENV_IS_NOWHERE) # error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} #endif diff --git a/common/env_common.c b/common/env_common.c index e89f192..36c46f0 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -134,7 +134,7 @@ uchar default_environment[] = { }; #if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \ - || defined(CFG_ENV_IS_IN_SPI_FLASH) + || defined(CONFIG_ENV_IS_IN_SPI_FLASH) int default_environment_size = sizeof(default_environment); #endif diff --git a/common/env_sf.c b/common/env_sf.c index 9077d78..a442776 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -27,7 +27,7 @@ */ #include -#ifdef CFG_ENV_IS_IN_SPI_FLASH +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH #include #include @@ -136,4 +136,4 @@ int env_init(void) return 0; } -#endif /* CFG_ENV_IS_IN_SPI_FLASH */ +#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */ -- cgit v1.1 From 2556ef78113b5f089dfcac5da90bf31dd568397b Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:00 +0200 Subject: env_sf: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_sf.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index a9d66ae..e171ae0 100644 --- a/common/Makefile +++ b/common/Makefile @@ -56,7 +56,7 @@ COBJS-y += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o -COBJS-y += env_sf.o +COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o COBJS-y += env_nowhere.o # command diff --git a/common/env_sf.c b/common/env_sf.c index a442776..faf6260 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -26,9 +26,6 @@ * MA 02111-1307 USA */ #include - -#ifdef CONFIG_ENV_IS_IN_SPI_FLASH - #include #include @@ -135,5 +132,3 @@ int env_init(void) return 0; } - -#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */ -- cgit v1.1 From 93f6d72544da4510a146bc4c93d609b0116cde37 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:00 +0200 Subject: rename CFG_ENV_IS_NOWHERE in CONFIG_ENV_IS_NOWHERE Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 6 +++--- common/env_common.c | 2 +- common/env_nowhere.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 85d7108..fc9b94e 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -59,7 +59,7 @@ DECLARE_GLOBAL_DATA_PTR; !defined(CONFIG_ENV_IS_IN_NAND) && \ !defined(CONFIG_ENV_IS_IN_ONENAND) && \ !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ - !defined(CFG_ENV_IS_NOWHERE) + !defined(CONFIG_ENV_IS_NOWHERE) # error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} #endif @@ -544,7 +544,7 @@ int getenv_r (char *name, char *buf, unsigned len) || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CFG_ENV_IS_NOWHERE)) + && !defined(CONFIG_ENV_IS_NOWHERE)) int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { extern char * env_name_spec; @@ -600,7 +600,7 @@ U_BOOT_CMD( || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CFG_ENV_IS_NOWHERE)) + && !defined(CONFIG_ENV_IS_NOWHERE)) U_BOOT_CMD( saveenv, 1, 0, do_saveenv, "saveenv - save environment variables to persistent storage\n", diff --git a/common/env_common.c b/common/env_common.c index 36c46f0..c3946f0 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -246,7 +246,7 @@ void env_relocate (void) #endif if (gd->env_valid == 0) { -#if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */ +#if defined(CONFIG_GTH) || defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ puts ("Using default environment\n\n"); #else puts ("*** Warning - bad CRC, using default environment\n\n"); diff --git a/common/env_nowhere.c b/common/env_nowhere.c index 17ecc77..8dd4867 100644 --- a/common/env_nowhere.c +++ b/common/env_nowhere.c @@ -26,7 +26,7 @@ #include -#if defined(CFG_ENV_IS_NOWHERE) /* Environment is nowhere */ +#if defined(CONFIG_ENV_IS_NOWHERE) /* Environment is nowhere */ #include #include @@ -62,4 +62,4 @@ int env_init(void) return (0); } -#endif /* CFG_ENV_IS_NOWHERE) */ +#endif /* CONFIG_ENV_IS_NOWHERE) */ -- cgit v1.1 From c0878af6e32f0fd8e13a6ca315b9add64441115a Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:01 +0200 Subject: env_nowhere: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_nowhere.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index e171ae0..cf861c5 100644 --- a/common/Makefile +++ b/common/Makefile @@ -57,7 +57,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o -COBJS-y += env_nowhere.o +COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o # command COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o diff --git a/common/env_nowhere.c b/common/env_nowhere.c index 8dd4867..78e8f8e 100644 --- a/common/env_nowhere.c +++ b/common/env_nowhere.c @@ -25,9 +25,6 @@ */ #include - -#if defined(CONFIG_ENV_IS_NOWHERE) /* Environment is nowhere */ - #include #include #include @@ -61,5 +58,3 @@ int env_init(void) return (0); } - -#endif /* CONFIG_ENV_IS_NOWHERE) */ -- cgit v1.1 From 0cf4fd3cf8d0e00605bec5fc56f89c6415015a46 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:01 +0200 Subject: rename environment.c in env_embedded.c to reflect is functionality Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 6 +- common/env_embedded.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++ common/environment.c | 208 -------------------------------------------------- 3 files changed, 211 insertions(+), 211 deletions(-) create mode 100644 common/env_embedded.c delete mode 100644 common/environment.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index cf861c5..fad9bc1 100644 --- a/common/Makefile +++ b/common/Makefile @@ -48,10 +48,10 @@ COBJS-y += cmd_bootm.o COBJS-y += cmd_nvedit.o # environment -COBJS-y += environment.o COBJS-y += env_common.o COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o +COBJS-y += env_embedded.o COBJS-y += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o @@ -167,10 +167,10 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) -$(obj)environment.o: $(src)environment.c $(obj)../tools/envcrc +$(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(CC) $(AFLAGS) -Wa,--no-warn \ -DENV_CRC=$(shell $(obj)../tools/envcrc) \ - -c -o $@ $(src)environment.c + -c -o $@ $(src)env_embedded.c $(obj)../tools/envcrc: $(MAKE) -C ../tools diff --git a/common/env_embedded.c b/common/env_embedded.c new file mode 100644 index 0000000..3b9914f --- /dev/null +++ b/common/env_embedded.c @@ -0,0 +1,208 @@ +/* + * (C) Copyright 2001 + * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. + * + * 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 + */ + +#ifndef __ASSEMBLY__ +#define __ASSEMBLY__ /* Dirty trick to get only #defines */ +#endif +#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ +#include +#undef __ASSEMBLY__ +#include + +/* + * Handle HOSTS that have prepended + * crap on symbol names, not TARGETS. + */ +#if defined(__APPLE__) +/* Leading underscore on symbols */ +# define SYM_CHAR "_" +#else /* No leading character on symbols */ +# define SYM_CHAR +#endif + +/* + * Generate embedded environment table + * inside U-Boot image, if needed. + */ +#if defined(ENV_IS_EMBEDDED) +/* + * Only put the environment in it's own section when we are building + * U-Boot proper. The host based program "tools/envcrc" does not need + * a seperate section. Note that ENV_CRC is only defined when building + * U-Boot itself. + */ +#if (defined(CFG_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ + defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */ +/* XXX - This only works with GNU C */ +# define __PPCENV__ __attribute__ ((section(".ppcenv"))) +# define __PPCTEXT__ __attribute__ ((section(".text"))) + +#elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ +# define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ +# define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ + +#else /* Environment is embedded in U-Boot's .text section */ +/* XXX - This only works with GNU C */ +# define __PPCENV__ __attribute__ ((section(".text"))) +# define __PPCTEXT__ __attribute__ ((section(".text"))) +#endif + +/* + * Macros to generate global absolutes. + */ +#if defined(__bfin__) +# define GEN_SET_VALUE(name, value) asm (".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) +#else +# define GEN_SET_VALUE(name, value) asm (GEN_SYMNAME(name) " = " GEN_VALUE(value)) +#endif +#define GEN_SYMNAME(str) SYM_CHAR #str +#define GEN_VALUE(str) #str +#define GEN_ABS(name, value) \ + asm (".globl " GEN_SYMNAME(name)); \ + GEN_SET_VALUE(name, value) + +/* + * Macros to transform values + * into environment strings. + */ +#define XMK_STR(x) #x +#define MK_STR(x) XMK_STR(x) + +/* + * Check to see if we are building with a + * computed CRC. Otherwise define it as ~0. + */ +#if !defined(ENV_CRC) +# define ENV_CRC ~0 +#endif + +env_t environment __PPCENV__ = { + ENV_CRC, /* CRC Sum */ +#ifdef CFG_REDUNDAND_ENVIRONMENT + 1, /* Flags: valid */ +#endif + { +#if defined(CONFIG_BOOTARGS) + "bootargs=" CONFIG_BOOTARGS "\0" +#endif +#if defined(CONFIG_BOOTCOMMAND) + "bootcmd=" CONFIG_BOOTCOMMAND "\0" +#endif +#if defined(CONFIG_RAMBOOTCOMMAND) + "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" +#endif +#if defined(CONFIG_NFSBOOTCOMMAND) + "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" +#endif +#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) + "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" +#endif +#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) + "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" +#endif +#ifdef CONFIG_LOADS_ECHO + "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" +#endif +#ifdef CONFIG_ETHADDR + "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" +#endif +#ifdef CONFIG_ETH1ADDR + "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" +#endif +#ifdef CONFIG_ETH2ADDR + "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" +#endif +#ifdef CONFIG_ETH3ADDR + "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" +#endif +#ifdef CONFIG_ETHPRIME + "ethprime=" CONFIG_ETHPRIME "\0" +#endif +#ifdef CONFIG_IPADDR + "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" +#endif +#ifdef CONFIG_SERVERIP + "serverip=" MK_STR(CONFIG_SERVERIP) "\0" +#endif +#ifdef CFG_AUTOLOAD + "autoload=" CFG_AUTOLOAD "\0" +#endif +#ifdef CONFIG_ROOTPATH + "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" +#endif +#ifdef CONFIG_GATEWAYIP + "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" +#endif +#ifdef CONFIG_NETMASK + "netmask=" MK_STR(CONFIG_NETMASK) "\0" +#endif +#ifdef CONFIG_HOSTNAME + "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" +#endif +#ifdef CONFIG_BOOTFILE + "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" +#endif +#ifdef CONFIG_LOADADDR + "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" +#endif +#ifdef CONFIG_PREBOOT + "preboot=" CONFIG_PREBOOT "\0" +#endif +#ifdef CONFIG_CLOCKS_IN_MHZ + "clocks_in_mhz=" "1" "\0" +#endif +#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) + "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" +#endif +#ifdef CONFIG_EXTRA_ENV_SETTINGS + CONFIG_EXTRA_ENV_SETTINGS +#endif + "\0" /* Term. env_t.data with 2 NULs */ + } +}; +#ifdef CFG_ENV_ADDR_REDUND +env_t redundand_environment __PPCENV__ = { + 0, /* CRC Sum: invalid */ + 0, /* Flags: invalid */ + { + "\0" + } +}; +#endif /* CFG_ENV_ADDR_REDUND */ + +/* + * These will end up in the .text section + * if the environment strings are embedded + * in the image. When this is used for + * tools/envcrc, they are placed in the + * .data/.sdata section. + * + */ +unsigned long env_size __PPCTEXT__ = sizeof(env_t); + +/* + * Add in absolutes. + */ +GEN_ABS(env_offset, CFG_ENV_OFFSET); + +#endif /* ENV_IS_EMBEDDED */ diff --git a/common/environment.c b/common/environment.c deleted file mode 100644 index 3b9914f..0000000 --- a/common/environment.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (C) Copyright 2001 - * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. - * - * 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 - */ - -#ifndef __ASSEMBLY__ -#define __ASSEMBLY__ /* Dirty trick to get only #defines */ -#endif -#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ -#include -#undef __ASSEMBLY__ -#include - -/* - * Handle HOSTS that have prepended - * crap on symbol names, not TARGETS. - */ -#if defined(__APPLE__) -/* Leading underscore on symbols */ -# define SYM_CHAR "_" -#else /* No leading character on symbols */ -# define SYM_CHAR -#endif - -/* - * Generate embedded environment table - * inside U-Boot image, if needed. - */ -#if defined(ENV_IS_EMBEDDED) -/* - * Only put the environment in it's own section when we are building - * U-Boot proper. The host based program "tools/envcrc" does not need - * a seperate section. Note that ENV_CRC is only defined when building - * U-Boot itself. - */ -#if (defined(CFG_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ - defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */ -/* XXX - This only works with GNU C */ -# define __PPCENV__ __attribute__ ((section(".ppcenv"))) -# define __PPCTEXT__ __attribute__ ((section(".text"))) - -#elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ -# define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ -# define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ - -#else /* Environment is embedded in U-Boot's .text section */ -/* XXX - This only works with GNU C */ -# define __PPCENV__ __attribute__ ((section(".text"))) -# define __PPCTEXT__ __attribute__ ((section(".text"))) -#endif - -/* - * Macros to generate global absolutes. - */ -#if defined(__bfin__) -# define GEN_SET_VALUE(name, value) asm (".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) -#else -# define GEN_SET_VALUE(name, value) asm (GEN_SYMNAME(name) " = " GEN_VALUE(value)) -#endif -#define GEN_SYMNAME(str) SYM_CHAR #str -#define GEN_VALUE(str) #str -#define GEN_ABS(name, value) \ - asm (".globl " GEN_SYMNAME(name)); \ - GEN_SET_VALUE(name, value) - -/* - * Macros to transform values - * into environment strings. - */ -#define XMK_STR(x) #x -#define MK_STR(x) XMK_STR(x) - -/* - * Check to see if we are building with a - * computed CRC. Otherwise define it as ~0. - */ -#if !defined(ENV_CRC) -# define ENV_CRC ~0 -#endif - -env_t environment __PPCENV__ = { - ENV_CRC, /* CRC Sum */ -#ifdef CFG_REDUNDAND_ENVIRONMENT - 1, /* Flags: valid */ -#endif - { -#if defined(CONFIG_BOOTARGS) - "bootargs=" CONFIG_BOOTARGS "\0" -#endif -#if defined(CONFIG_BOOTCOMMAND) - "bootcmd=" CONFIG_BOOTCOMMAND "\0" -#endif -#if defined(CONFIG_RAMBOOTCOMMAND) - "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" -#endif -#if defined(CONFIG_NFSBOOTCOMMAND) - "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" -#endif -#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) - "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" -#endif -#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) - "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" -#endif -#ifdef CONFIG_LOADS_ECHO - "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" -#endif -#ifdef CONFIG_ETHADDR - "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" -#endif -#ifdef CONFIG_ETH1ADDR - "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" -#endif -#ifdef CONFIG_ETH2ADDR - "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" -#endif -#ifdef CONFIG_ETH3ADDR - "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" -#endif -#ifdef CONFIG_ETHPRIME - "ethprime=" CONFIG_ETHPRIME "\0" -#endif -#ifdef CONFIG_IPADDR - "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" -#endif -#ifdef CONFIG_SERVERIP - "serverip=" MK_STR(CONFIG_SERVERIP) "\0" -#endif -#ifdef CFG_AUTOLOAD - "autoload=" CFG_AUTOLOAD "\0" -#endif -#ifdef CONFIG_ROOTPATH - "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" -#endif -#ifdef CONFIG_GATEWAYIP - "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" -#endif -#ifdef CONFIG_NETMASK - "netmask=" MK_STR(CONFIG_NETMASK) "\0" -#endif -#ifdef CONFIG_HOSTNAME - "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" -#endif -#ifdef CONFIG_BOOTFILE - "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" -#endif -#ifdef CONFIG_LOADADDR - "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" -#endif -#ifdef CONFIG_PREBOOT - "preboot=" CONFIG_PREBOOT "\0" -#endif -#ifdef CONFIG_CLOCKS_IN_MHZ - "clocks_in_mhz=" "1" "\0" -#endif -#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) - "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" -#endif -#ifdef CONFIG_EXTRA_ENV_SETTINGS - CONFIG_EXTRA_ENV_SETTINGS -#endif - "\0" /* Term. env_t.data with 2 NULs */ - } -}; -#ifdef CFG_ENV_ADDR_REDUND -env_t redundand_environment __PPCENV__ = { - 0, /* CRC Sum: invalid */ - 0, /* Flags: invalid */ - { - "\0" - } -}; -#endif /* CFG_ENV_ADDR_REDUND */ - -/* - * These will end up in the .text section - * if the environment strings are embedded - * in the image. When this is used for - * tools/envcrc, they are placed in the - * .data/.sdata section. - * - */ -unsigned long env_size __PPCTEXT__ = sizeof(env_t); - -/* - * Add in absolutes. - */ -GEN_ABS(env_offset, CFG_ENV_OFFSET); - -#endif /* ENV_IS_EMBEDDED */ -- cgit v1.1 From 5a1aceb0689e2f731491838970884a673ef7e7d3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:04 +0200 Subject: rename CFG_ENV_IS_IN_FLASH in CONFIG_ENV_IS_IN_FLASH Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- common/env_flash.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index fc9b94e..f5b93df 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -54,7 +54,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CONFIG_ENV_IS_IN_NVRAM) && \ !defined(CONFIG_ENV_IS_IN_EEPROM) && \ - !defined(CFG_ENV_IS_IN_FLASH) && \ + !defined(CONFIG_ENV_IS_IN_FLASH) && \ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ !defined(CONFIG_ENV_IS_IN_NAND) && \ !defined(CONFIG_ENV_IS_IN_ONENAND) && \ diff --git a/common/env_flash.c b/common/env_flash.c index a92160d..c287b17 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -28,7 +28,7 @@ #include -#if defined(CFG_ENV_IS_IN_FLASH) /* Environment is in Flash */ +#if defined(CONFIG_ENV_IS_IN_FLASH) /* Environment is in Flash */ #include #include @@ -384,4 +384,4 @@ void env_relocate_spec (void) #endif /* ! ENV_IS_EMBEDDED || CFG_ENV_ADDR_REDUND */ } -#endif /* CFG_ENV_IS_IN_FLASH */ +#endif /* CONFIG_ENV_IS_IN_FLASH */ -- cgit v1.1 From 507641d2491980531932b9f25dab37fe5e6c3a1a Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:04 +0200 Subject: env_flash: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/env_flash.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index fad9bc1..a6fd97e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -52,7 +52,7 @@ COBJS-y += env_common.o COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_embedded.o -COBJS-y += env_flash.o +COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o diff --git a/common/env_flash.c b/common/env_flash.c index c287b17..84166af 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -27,9 +27,6 @@ /* #define DEBUG */ #include - -#if defined(CONFIG_ENV_IS_IN_FLASH) /* Environment is in Flash */ - #include #include #include @@ -383,5 +380,3 @@ void env_relocate_spec (void) #endif #endif /* ! ENV_IS_EMBEDDED || CFG_ENV_ADDR_REDUND */ } - -#endif /* CONFIG_ENV_IS_IN_FLASH */ -- cgit v1.1 From 8a40fb148efa442d6526eac46a2001e4c64d28ff Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:05 +0200 Subject: move cmd_get_data_size to command.c add CMD_DATA_SIZE macro to enable it Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_i2c.c | 1 - common/cmd_itest.c | 2 -- common/cmd_mem.c | 29 ----------------------------- common/cmd_pci.c | 2 -- common/cmd_portio.c | 2 -- common/command.c | 24 ++++++++++++++++++++++++ 6 files changed, 24 insertions(+), 36 deletions(-) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 91bf25b..ef3928e 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -127,7 +127,6 @@ static uchar i2c_no_probes[] = CFG_I2C_NOPROBES; static int mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]); -extern int cmd_get_data_size(char* arg, int default_size); /* * Syntax: diff --git a/common/cmd_itest.c b/common/cmd_itest.c index ce98872..9e77fa9 100644 --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -64,8 +64,6 @@ op_tbl_t op_table [] = { #define op_tbl_size (sizeof(op_table)/sizeof(op_table[0])) -extern int cmd_get_data_size(char* arg, int default_size); - static long evalexp(char *s, int w) { long l, *p; diff --git a/common/cmd_mem.c b/common/cmd_mem.c index d0a6ca8..672218b 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -37,35 +37,6 @@ #endif #include -#if defined(CONFIG_CMD_MEMORY) \ - || defined(CONFIG_CMD_I2C) \ - || defined(CONFIG_CMD_ITEST) \ - || defined(CONFIG_CMD_PCI) \ - || defined(CONFIG_CMD_PORTIO) - -int cmd_get_data_size(char* arg, int default_size) -{ - /* Check for a size specification .b, .w or .l. - */ - int len = strlen(arg); - if (len > 2 && arg[len-2] == '.') { - switch(arg[len-1]) { - case 'b': - return 1; - case 'w': - return 2; - case 'l': - return 4; - case 's': - return -2; - default: - return -1; - } - } - return default_size; -} -#endif - #if defined(CONFIG_CMD_MEMORY) #ifdef CMD_MEM_DEBUG diff --git a/common/cmd_pci.c b/common/cmd_pci.c index 8968701..b2aa833 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -35,8 +35,6 @@ #include #include -extern int cmd_get_data_size(char* arg, int default_size); - unsigned char ShortPCIListing = 1; /* diff --git a/common/cmd_portio.c b/common/cmd_portio.c index a06cac0..c88fcd5 100644 --- a/common/cmd_portio.c +++ b/common/cmd_portio.c @@ -30,8 +30,6 @@ #include #include -extern int cmd_get_data_size (char *arg, int default_size); - /* Display values from last command. * Memory modify remembered values are different from display memory. */ diff --git a/common/command.c b/common/command.c index 861796d..aca57b2 100644 --- a/common/command.c +++ b/common/command.c @@ -654,3 +654,27 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) } #endif + +#ifdef CMD_DATA_SIZE +int cmd_get_data_size(char* arg, int default_size) +{ + /* Check for a size specification .b, .w or .l. + */ + int len = strlen(arg); + if (len > 2 && arg[len-2] == '.') { + switch(arg[len-1]) { + case 'b': + return 1; + case 'w': + return 2; + case 'l': + return 4; + case 's': + return -2; + default: + return -1; + } + } + return default_size; +} +#endif -- cgit v1.1 From b64b775e7546ed138df360ceb3a71ee358cb9a01 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:05 +0200 Subject: cmd_mem: Move conditional compilation to Makefile Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 2 +- common/cmd_mem.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index a6fd97e..8bddf8e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -113,7 +113,7 @@ COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o COBJS-y += cmd_load.o COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o -COBJS-y += cmd_mem.o +COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 672218b..07b08fb 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -37,8 +37,6 @@ #endif #include -#if defined(CONFIG_CMD_MEMORY) - #ifdef CMD_MEM_DEBUG #define PRINTF(fmt,args...) printf (fmt ,##args) #else @@ -1306,5 +1304,3 @@ U_BOOT_CMD( "srcaddr dstaddr [dstsize]\n" ); #endif /* CONFIG_CMD_UNZIP */ - -#endif -- cgit v1.1 From 1ede78710c3bf9ad6f4a53aaddc3bcc86fedd9df Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:05 +0200 Subject: nvedit: rename error comment to CONFIG_ENV_IS_IN_ Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_nvedit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index f5b93df..f449715 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -60,7 +60,7 @@ DECLARE_GLOBAL_DATA_PTR; !defined(CONFIG_ENV_IS_IN_ONENAND) && \ !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ !defined(CONFIG_ENV_IS_NOWHERE) -# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} +# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} #endif #define XMK_STR(x) #x -- cgit v1.1 From 0e8d158664a913392cb01fb11a948d83f72e105e Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 10 Sep 2008 22:48:06 +0200 Subject: rename CFG_ENV macros to CONFIG_ENV Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_bdinfo.c | 2 +- common/cmd_nvedit.c | 4 +-- common/env_common.c | 2 +- common/env_dataflash.c | 14 ++++----- common/env_eeprom.c | 14 ++++----- common/env_embedded.c | 6 ++-- common/env_flash.c | 84 +++++++++++++++++++++++++------------------------- common/env_nand.c | 80 +++++++++++++++++++++++------------------------ common/env_nvram.c | 20 ++++++------ common/env_onenand.c | 6 ++-- common/env_sf.c | 34 ++++++++++---------- 11 files changed, 133 insertions(+), 133 deletions(-) (limited to 'common') diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 24ff9b9..f4d9d40 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -224,7 +224,7 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) print_lnum("memsize ", bd->bi_memsize); print_num("flashstart ", bd->bi_flashstart); print_num("CFG_MONITOR_BASE ", CFG_MONITOR_BASE); - print_num("CFG_ENV_ADDR ", CFG_ENV_ADDR); + print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR); printf("CFG_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CFG_RELOC_MONITOR_BASE, CFG_MONITOR_LEN); printf("CFG_MALLOC_BASE = 0x%lx (%d)\n", CFG_MALLOC_BASE, diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index f449715..637d6c9 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -503,7 +503,7 @@ char *getenv (char *name) int val; for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { - if (nxt >= CFG_ENV_SIZE) { + if (nxt >= CONFIG_ENV_SIZE) { return (NULL); } } @@ -523,7 +523,7 @@ int getenv_r (char *name, char *buf, unsigned len) int val, n; for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { - if (nxt >= CFG_ENV_SIZE) { + if (nxt >= CONFIG_ENV_SIZE) { return (-1); } } diff --git a/common/env_common.c b/common/env_common.c index c3946f0..77f9944 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -241,7 +241,7 @@ void env_relocate (void) /* * We must allocate a buffer for the environment */ - env_ptr = (env_t *)malloc (CFG_ENV_SIZE); + env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE); DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); #endif diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 2254b9b..fed919e 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -41,22 +41,22 @@ extern uchar default_environment[]; uchar env_get_char_spec (int index) { uchar c; - read_dataflash(CFG_ENV_ADDR + index + offsetof(env_t,data), + read_dataflash(CONFIG_ENV_ADDR + index + offsetof(env_t,data), 1, (char *)&c); return (c); } void env_relocate_spec (void) { - read_dataflash(CFG_ENV_ADDR, CFG_ENV_SIZE, (char *)env_ptr); + read_dataflash(CONFIG_ENV_ADDR, CONFIG_ENV_SIZE, (char *)env_ptr); } int saveenv(void) { /* env must be copied to do not alter env structure in memory*/ - unsigned char temp[CFG_ENV_SIZE]; - memcpy(temp, env_ptr, CFG_ENV_SIZE); - return write_dataflash(CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE); + unsigned char temp[CONFIG_ENV_SIZE]; + memcpy(temp, env_ptr, CONFIG_ENV_SIZE); + return write_dataflash(CONFIG_ENV_ADDR, (unsigned long)temp, CONFIG_ENV_SIZE); } /************************************************************************ @@ -74,14 +74,14 @@ int env_init(void) AT91F_DataflashInit(); /* prepare for DATAFLASH read/write */ /* read old CRC */ - read_dataflash(CFG_ENV_ADDR + offsetof(env_t, crc), + read_dataflash(CONFIG_ENV_ADDR + offsetof(env_t, crc), sizeof(ulong), (char *)&crc); new = 0; len = ENV_SIZE; off = offsetof(env_t,data); while (len > 0) { int n = (len > sizeof(buf)) ? sizeof(buf) : len; - read_dataflash(CFG_ENV_ADDR + off, n, (char *)buf); + read_dataflash(CONFIG_ENV_ADDR + off, n, (char *)buf); new = crc32 (new, buf, n); len -= n; off += n; diff --git a/common/env_eeprom.c b/common/env_eeprom.c index df3e31e..1f0f413 100644 --- a/common/env_eeprom.c +++ b/common/env_eeprom.c @@ -40,7 +40,7 @@ uchar env_get_char_spec (int index) uchar c; eeprom_read (CFG_DEF_EEPROM_ADDR, - CFG_ENV_OFFSET+index+offsetof(env_t,data), + CONFIG_ENV_OFFSET+index+offsetof(env_t,data), &c, 1); return (c); @@ -49,17 +49,17 @@ uchar env_get_char_spec (int index) void env_relocate_spec (void) { eeprom_read (CFG_DEF_EEPROM_ADDR, - CFG_ENV_OFFSET, + CONFIG_ENV_OFFSET, (uchar*)env_ptr, - CFG_ENV_SIZE); + CONFIG_ENV_SIZE); } int saveenv(void) { return eeprom_write (CFG_DEF_EEPROM_ADDR, - CFG_ENV_OFFSET, + CONFIG_ENV_OFFSET, (uchar *)env_ptr, - CFG_ENV_SIZE); + CONFIG_ENV_SIZE); } /************************************************************************ @@ -78,7 +78,7 @@ int env_init(void) /* read old CRC */ eeprom_read (CFG_DEF_EEPROM_ADDR, - CFG_ENV_OFFSET+offsetof(env_t,crc), + CONFIG_ENV_OFFSET+offsetof(env_t,crc), (uchar *)&crc, sizeof(ulong)); new = 0; @@ -87,7 +87,7 @@ int env_init(void) while (len > 0) { int n = (len > sizeof(buf)) ? sizeof(buf) : len; - eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n); + eeprom_read (CFG_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n); new = crc32 (new, buf, n); len -= n; off += n; diff --git a/common/env_embedded.c b/common/env_embedded.c index 3b9914f..77e5619 100644 --- a/common/env_embedded.c +++ b/common/env_embedded.c @@ -180,7 +180,7 @@ env_t environment __PPCENV__ = { "\0" /* Term. env_t.data with 2 NULs */ } }; -#ifdef CFG_ENV_ADDR_REDUND +#ifdef CONFIG_ENV_ADDR_REDUND env_t redundand_environment __PPCENV__ = { 0, /* CRC Sum: invalid */ 0, /* Flags: invalid */ @@ -188,7 +188,7 @@ env_t redundand_environment __PPCENV__ = { "\0" } }; -#endif /* CFG_ENV_ADDR_REDUND */ +#endif /* CONFIG_ENV_ADDR_REDUND */ /* * These will end up in the .text section @@ -203,6 +203,6 @@ unsigned long env_size __PPCTEXT__ = sizeof(env_t); /* * Add in absolutes. */ -GEN_ABS(env_offset, CFG_ENV_OFFSET); +GEN_ABS(env_offset, CONFIG_ENV_OFFSET); #endif /* ENV_IS_EMBEDDED */ diff --git a/common/env_flash.c b/common/env_flash.c index 84166af..75ee8dd 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -36,17 +36,17 @@ DECLARE_GLOBAL_DATA_PTR; #if defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH) #define CMD_SAVEENV -#elif defined(CFG_ENV_ADDR_REDUND) -#error Cannot use CFG_ENV_ADDR_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_FLASH +#elif defined(CONFIG_ENV_ADDR_REDUND) +#error Cannot use CONFIG_ENV_ADDR_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_FLASH #endif -#if defined(CFG_ENV_SIZE_REDUND) && (CFG_ENV_SIZE_REDUND < CFG_ENV_SIZE) -#error CFG_ENV_SIZE_REDUND should not be less then CFG_ENV_SIZE +#if defined(CONFIG_ENV_SIZE_REDUND) && (CONFIG_ENV_SIZE_REDUND < CONFIG_ENV_SIZE) +#error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE #endif #ifdef CONFIG_INFERNO -# ifdef CFG_ENV_ADDR_REDUND -#error CFG_ENV_ADDR_REDUND is not implemented for CONFIG_INFERNO +# ifdef CONFIG_ENV_ADDR_REDUND +#error CONFIG_ENV_ADDR_REDUND is not implemented for CONFIG_INFERNO # endif #endif @@ -59,28 +59,28 @@ env_t *env_ptr = (env_t *)(&environment[0]); #ifdef CMD_SAVEENV /* static env_t *flash_addr = (env_t *)(&environment[0]);-broken on ARM-wd-*/ -static env_t *flash_addr = (env_t *)CFG_ENV_ADDR; +static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR; #endif #else /* ! ENV_IS_EMBEDDED */ -env_t *env_ptr = (env_t *)CFG_ENV_ADDR; +env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; #ifdef CMD_SAVEENV -static env_t *flash_addr = (env_t *)CFG_ENV_ADDR; +static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR; #endif #endif /* ENV_IS_EMBEDDED */ -#ifdef CFG_ENV_ADDR_REDUND -static env_t *flash_addr_new = (env_t *)CFG_ENV_ADDR_REDUND; +#ifdef CONFIG_ENV_ADDR_REDUND +static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND; -/* CFG_ENV_ADDR is supposed to be on sector boundary */ -static ulong end_addr = CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1; -static ulong end_addr_new = CFG_ENV_ADDR_REDUND + CFG_ENV_SECT_SIZE - 1; +/* CONFIG_ENV_ADDR is supposed to be on sector boundary */ +static ulong end_addr = CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1; +static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1; #define ACTIVE_FLAG 1 #define OBSOLETE_FLAG 0 -#endif /* CFG_ENV_ADDR_REDUND */ +#endif /* CONFIG_ENV_ADDR_REDUND */ extern uchar default_environment[]; extern int default_environment_size; @@ -91,7 +91,7 @@ uchar env_get_char_spec (int index) return ( *((uchar *)(gd->env_addr + index)) ); } -#ifdef CFG_ENV_ADDR_REDUND +#ifdef CONFIG_ENV_ADDR_REDUND int env_init(void) { @@ -142,7 +142,7 @@ int saveenv(void) char *saved_data = NULL; int rc = 1; char flag = OBSOLETE_FLAG, new_flag = ACTIVE_FLAG; -#if CFG_ENV_SECT_SIZE > CFG_ENV_SIZE +#if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE ulong up_data = 0; #endif @@ -160,8 +160,8 @@ int saveenv(void) goto Done; } -#if CFG_ENV_SECT_SIZE > CFG_ENV_SIZE - up_data = (end_addr_new + 1 - ((long)flash_addr_new + CFG_ENV_SIZE)); +#if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE + up_data = (end_addr_new + 1 - ((long)flash_addr_new + CONFIG_ENV_SIZE)); debug ("Data to save 0x%x\n", up_data); if (up_data) { if ((saved_data = malloc(up_data)) == NULL) { @@ -170,9 +170,9 @@ int saveenv(void) goto Done; } memcpy(saved_data, - (void *)((long)flash_addr_new + CFG_ENV_SIZE), up_data); + (void *)((long)flash_addr_new + CONFIG_ENV_SIZE), up_data); debug ("Data (start 0x%x, len 0x%x) saved at 0x%x\n", - (long)flash_addr_new + CFG_ENV_SIZE, + (long)flash_addr_new + CONFIG_ENV_SIZE, up_data, saved_data); } #endif @@ -206,12 +206,12 @@ int saveenv(void) } puts ("done\n"); -#if CFG_ENV_SECT_SIZE > CFG_ENV_SIZE +#if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE if (up_data) { /* restore the rest of sector */ debug ("Restoring the rest of data to 0x%x len 0x%x\n", - (long)flash_addr_new + CFG_ENV_SIZE, up_data); + (long)flash_addr_new + CONFIG_ENV_SIZE, up_data); if (flash_write(saved_data, - (long)flash_addr_new + CFG_ENV_SIZE, + (long)flash_addr_new + CONFIG_ENV_SIZE, up_data)) { flash_perror(rc); goto Done; @@ -242,7 +242,7 @@ Done: } #endif /* CMD_SAVEENV */ -#else /* ! CFG_ENV_ADDR_REDUND */ +#else /* ! CONFIG_ENV_ADDR_REDUND */ int env_init(void) { @@ -264,36 +264,36 @@ int saveenv(void) int len, rc; ulong end_addr; ulong flash_sect_addr; -#if defined(CFG_ENV_SECT_SIZE) && (CFG_ENV_SECT_SIZE > CFG_ENV_SIZE) +#if defined(CONFIG_ENV_SECT_SIZE) && (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) ulong flash_offset; - uchar env_buffer[CFG_ENV_SECT_SIZE]; + uchar env_buffer[CONFIG_ENV_SECT_SIZE]; #else uchar *env_buffer = (uchar *)env_ptr; -#endif /* CFG_ENV_SECT_SIZE */ +#endif /* CONFIG_ENV_SECT_SIZE */ int rcode = 0; -#if defined(CFG_ENV_SECT_SIZE) && (CFG_ENV_SECT_SIZE > CFG_ENV_SIZE) +#if defined(CONFIG_ENV_SECT_SIZE) && (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) - flash_offset = ((ulong)flash_addr) & (CFG_ENV_SECT_SIZE-1); - flash_sect_addr = ((ulong)flash_addr) & ~(CFG_ENV_SECT_SIZE-1); + flash_offset = ((ulong)flash_addr) & (CONFIG_ENV_SECT_SIZE-1); + flash_sect_addr = ((ulong)flash_addr) & ~(CONFIG_ENV_SECT_SIZE-1); debug ( "copy old content: " "sect_addr: %08lX env_addr: %08lX offset: %08lX\n", flash_sect_addr, (ulong)flash_addr, flash_offset); /* copy old contents to temporary buffer */ - memcpy (env_buffer, (void *)flash_sect_addr, CFG_ENV_SECT_SIZE); + memcpy (env_buffer, (void *)flash_sect_addr, CONFIG_ENV_SECT_SIZE); /* copy current environment to temporary buffer */ memcpy ((uchar *)((unsigned long)env_buffer + flash_offset), env_ptr, - CFG_ENV_SIZE); + CONFIG_ENV_SIZE); - len = CFG_ENV_SECT_SIZE; + len = CONFIG_ENV_SECT_SIZE; #else flash_sect_addr = (ulong)flash_addr; - len = CFG_ENV_SIZE; -#endif /* CFG_ENV_SECT_SIZE */ + len = CONFIG_ENV_SIZE; +#endif /* CONFIG_ENV_SECT_SIZE */ #ifndef CONFIG_INFERNO end_addr = flash_sect_addr + len - 1; @@ -329,12 +329,12 @@ int saveenv(void) #endif /* CMD_SAVEENV */ -#endif /* CFG_ENV_ADDR_REDUND */ +#endif /* CONFIG_ENV_ADDR_REDUND */ void env_relocate_spec (void) { -#if !defined(ENV_IS_EMBEDDED) || defined(CFG_ENV_ADDR_REDUND) -#ifdef CFG_ENV_ADDR_REDUND +#if !defined(ENV_IS_EMBEDDED) || defined(CONFIG_ENV_ADDR_REDUND) +#ifdef CONFIG_ENV_ADDR_REDUND if (gd->env_addr != (ulong)&(flash_addr->data)) { env_t * etmp = flash_addr; ulong ltmp = end_addr; @@ -374,9 +374,9 @@ void env_relocate_spec (void) if (gd->env_valid == 2) puts ("*** Warning - some problems detected " "reading environment; recovered successfully\n\n"); -#endif /* CFG_ENV_ADDR_REDUND */ +#endif /* CONFIG_ENV_ADDR_REDUND */ #ifdef CMD_SAVEENV - memcpy (env_ptr, (void*)flash_addr, CFG_ENV_SIZE); + memcpy (env_ptr, (void*)flash_addr, CONFIG_ENV_SIZE); #endif -#endif /* ! ENV_IS_EMBEDDED || CFG_ENV_ADDR_REDUND */ +#endif /* ! ENV_IS_EMBEDDED || CONFIG_ENV_ADDR_REDUND */ } diff --git a/common/env_nand.c b/common/env_nand.c index 9d01d7c..8af9e74 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -41,20 +41,20 @@ #if defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND) #define CMD_SAVEENV -#elif defined(CFG_ENV_OFFSET_REDUND) -#error Cannot use CFG_ENV_OFFSET_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_NAND +#elif defined(CONFIG_ENV_OFFSET_REDUND) +#error Cannot use CONFIG_ENV_OFFSET_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_NAND #endif -#if defined(CFG_ENV_SIZE_REDUND) && (CFG_ENV_SIZE_REDUND != CFG_ENV_SIZE) -#error CFG_ENV_SIZE_REDUND should be the same as CFG_ENV_SIZE +#if defined(CONFIG_ENV_SIZE_REDUND) && (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE) +#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE #endif #ifdef CONFIG_INFERNO #error CONFIG_INFERNO not supported yet #endif -#ifndef CFG_ENV_RANGE -#define CFG_ENV_RANGE CFG_ENV_SIZE +#ifndef CONFIG_ENV_RANGE +#define CONFIG_ENV_RANGE CONFIG_ENV_SIZE #endif int nand_legacy_rw (struct nand_chip* nand, int cmd, @@ -107,10 +107,10 @@ int env_init(void) int crc1_ok = 0, crc2_ok = 0; env_t *tmp_env1, *tmp_env2; - total = CFG_ENV_SIZE; + total = CONFIG_ENV_SIZE; tmp_env1 = env_ptr; - tmp_env2 = (env_t *)((ulong)env_ptr + CFG_ENV_SIZE); + tmp_env2 = (env_t *)((ulong)env_ptr + CONFIG_ENV_SIZE); crc1_ok = (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc); crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); @@ -154,16 +154,16 @@ int env_init(void) */ int writeenv(size_t offset, u_char *buf) { - size_t end = offset + CFG_ENV_RANGE; + size_t end = offset + CONFIG_ENV_RANGE; size_t amount_saved = 0; size_t blocksize, len; u_char *char_ptr; blocksize = nand_info[0].erasesize; - len = min(blocksize, CFG_ENV_SIZE); + len = min(blocksize, CONFIG_ENV_SIZE); - while (amount_saved < CFG_ENV_SIZE && offset < end) { + while (amount_saved < CONFIG_ENV_SIZE && offset < end) { if (nand_block_isbad(&nand_info[0], offset)) { offset += blocksize; } else { @@ -175,12 +175,12 @@ int writeenv(size_t offset, u_char *buf) amount_saved += len; } } - if (amount_saved != CFG_ENV_SIZE) + if (amount_saved != CONFIG_ENV_SIZE) return 1; return 0; } -#ifdef CFG_ENV_OFFSET_REDUND +#ifdef CONFIG_ENV_OFFSET_REDUND int saveenv(void) { size_t total; @@ -188,31 +188,31 @@ int saveenv(void) nand_erase_options_t nand_erase_options; env_ptr->flags++; - total = CFG_ENV_SIZE; + total = CONFIG_ENV_SIZE; - nand_erase_options.length = CFG_ENV_RANGE; + nand_erase_options.length = CONFIG_ENV_RANGE; nand_erase_options.quiet = 0; nand_erase_options.jffs2 = 0; nand_erase_options.scrub = 0; - if (CFG_ENV_RANGE < CFG_ENV_SIZE) + if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE) return 1; if(gd->env_valid == 1) { puts ("Erasing redundant Nand...\n"); - nand_erase_options.offset = CFG_ENV_OFFSET_REDUND; + nand_erase_options.offset = CONFIG_ENV_OFFSET_REDUND; if (nand_erase_opts(&nand_info[0], &nand_erase_options)) return 1; puts ("Writing to redundant Nand... "); - ret = writeenv(CFG_ENV_OFFSET_REDUND, (u_char *) env_ptr); + ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) env_ptr); } else { puts ("Erasing Nand...\n"); - nand_erase_options.offset = CFG_ENV_OFFSET; + nand_erase_options.offset = CONFIG_ENV_OFFSET; if (nand_erase_opts(&nand_info[0], &nand_erase_options)) return 1; puts ("Writing to Nand... "); - ret = writeenv(CFG_ENV_OFFSET, (u_char *) env_ptr); + ret = writeenv(CONFIG_ENV_OFFSET, (u_char *) env_ptr); } if (ret) { puts("FAILED!\n"); @@ -223,28 +223,28 @@ int saveenv(void) gd->env_valid = (gd->env_valid == 2 ? 1 : 2); return ret; } -#else /* ! CFG_ENV_OFFSET_REDUND */ +#else /* ! CONFIG_ENV_OFFSET_REDUND */ int saveenv(void) { size_t total; int ret = 0; nand_erase_options_t nand_erase_options; - nand_erase_options.length = CFG_ENV_RANGE; + nand_erase_options.length = CONFIG_ENV_RANGE; nand_erase_options.quiet = 0; nand_erase_options.jffs2 = 0; nand_erase_options.scrub = 0; - nand_erase_options.offset = CFG_ENV_OFFSET; + nand_erase_options.offset = CONFIG_ENV_OFFSET; - if (CFG_ENV_RANGE < CFG_ENV_SIZE) + if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE) return 1; puts ("Erasing Nand...\n"); if (nand_erase_opts(&nand_info[0], &nand_erase_options)) return 1; puts ("Writing to Nand... "); - total = CFG_ENV_SIZE; - if (writeenv(CFG_ENV_OFFSET, (u_char *) env_ptr)) { + total = CONFIG_ENV_SIZE; + if (writeenv(CONFIG_ENV_OFFSET, (u_char *) env_ptr)) { puts("FAILED!\n"); return 1; } @@ -252,21 +252,21 @@ int saveenv(void) puts ("done\n"); return ret; } -#endif /* CFG_ENV_OFFSET_REDUND */ +#endif /* CONFIG_ENV_OFFSET_REDUND */ #endif /* CMD_SAVEENV */ int readenv (size_t offset, u_char * buf) { - size_t end = offset + CFG_ENV_RANGE; + size_t end = offset + CONFIG_ENV_RANGE; size_t amount_loaded = 0; size_t blocksize, len; u_char *char_ptr; blocksize = nand_info[0].erasesize; - len = min(blocksize, CFG_ENV_SIZE); + len = min(blocksize, CONFIG_ENV_SIZE); - while (amount_loaded < CFG_ENV_SIZE && offset < end) { + while (amount_loaded < CONFIG_ENV_SIZE && offset < end) { if (nand_block_isbad(&nand_info[0], offset)) { offset += blocksize; } else { @@ -277,13 +277,13 @@ int readenv (size_t offset, u_char * buf) amount_loaded += len; } } - if (amount_loaded != CFG_ENV_SIZE) + if (amount_loaded != CONFIG_ENV_SIZE) return 1; return 0; } -#ifdef CFG_ENV_OFFSET_REDUND +#ifdef CONFIG_ENV_OFFSET_REDUND void env_relocate_spec (void) { #if !defined(ENV_IS_EMBEDDED) @@ -291,14 +291,14 @@ void env_relocate_spec (void) int crc1_ok = 0, crc2_ok = 0; env_t *tmp_env1, *tmp_env2; - total = CFG_ENV_SIZE; + total = CONFIG_ENV_SIZE; - tmp_env1 = (env_t *) malloc(CFG_ENV_SIZE); - tmp_env2 = (env_t *) malloc(CFG_ENV_SIZE); + tmp_env1 = (env_t *) malloc(CONFIG_ENV_SIZE); + tmp_env2 = (env_t *) malloc(CONFIG_ENV_SIZE); - if (readenv(CFG_ENV_OFFSET, (u_char *) tmp_env1)) + if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1)) puts("No Valid Environment Area Found\n"); - if (readenv(CFG_ENV_OFFSET_REDUND, (u_char *) tmp_env2)) + if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2)) puts("No Valid Reundant Environment Area Found\n"); crc1_ok = (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc); @@ -336,7 +336,7 @@ void env_relocate_spec (void) #endif /* ! ENV_IS_EMBEDDED */ } -#else /* ! CFG_ENV_OFFSET_REDUND */ +#else /* ! CONFIG_ENV_OFFSET_REDUND */ /* * The legacy NAND code saved the environment in the first NAND device i.e., * nand_dev_desc + 0. This is also the behaviour using the new NAND code. @@ -346,7 +346,7 @@ void env_relocate_spec (void) #if !defined(ENV_IS_EMBEDDED) int ret; - ret = readenv(CFG_ENV_OFFSET, (u_char *) env_ptr); + ret = readenv(CONFIG_ENV_OFFSET, (u_char *) env_ptr); if (ret) return use_default(); @@ -354,7 +354,7 @@ void env_relocate_spec (void) return use_default(); #endif /* ! ENV_IS_EMBEDDED */ } -#endif /* CFG_ENV_OFFSET_REDUND */ +#endif /* CONFIG_ENV_OFFSET_REDUND */ #if !defined(ENV_IS_EMBEDDED) static void use_default() diff --git a/common/env_nvram.c b/common/env_nvram.c index c59bf9f..a8b7959 100644 --- a/common/env_nvram.c +++ b/common/env_nvram.c @@ -52,7 +52,7 @@ extern void *nvram_read(void *dest, const long src, size_t count); extern void nvram_write(long dest, const void *src, size_t count); env_t *env_ptr = NULL; #else -env_t *env_ptr = (env_t *)CFG_ENV_ADDR; +env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; #endif char * env_name_spec = "NVRAM"; @@ -66,7 +66,7 @@ uchar env_get_char_spec (int index) #ifdef CFG_NVRAM_ACCESS_ROUTINE uchar c; - nvram_read(&c, CFG_ENV_ADDR+index, 1); + nvram_read(&c, CONFIG_ENV_ADDR+index, 1); return c; #else @@ -83,7 +83,7 @@ uchar env_get_char_spec (int index) #ifdef CFG_NVRAM_ACCESS_ROUTINE uchar c; - nvram_read(&c, CFG_ENV_ADDR+index, 1); + nvram_read(&c, CONFIG_ENV_ADDR+index, 1); return c; #else @@ -95,9 +95,9 @@ uchar env_get_char_spec (int index) void env_relocate_spec (void) { #if defined(CFG_NVRAM_ACCESS_ROUTINE) - nvram_read(env_ptr, CFG_ENV_ADDR, CFG_ENV_SIZE); + nvram_read(env_ptr, CONFIG_ENV_ADDR, CONFIG_ENV_SIZE); #else - memcpy (env_ptr, (void*)CFG_ENV_ADDR, CFG_ENV_SIZE); + memcpy (env_ptr, (void*)CONFIG_ENV_ADDR, CONFIG_ENV_SIZE); #endif } @@ -108,9 +108,9 @@ int saveenv (void) enable_nvram(); #endif #ifdef CFG_NVRAM_ACCESS_ROUTINE - nvram_write(CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE); + nvram_write(CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE); #else - if (memcpy ((char *)CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE) == NULL) + if (memcpy ((char *)CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE) == NULL) rcode = 1 ; #endif #ifdef CONFIG_AMIGAONEG3SE @@ -134,11 +134,11 @@ int env_init (void) #if defined(CFG_NVRAM_ACCESS_ROUTINE) ulong crc; uchar data[ENV_SIZE]; - nvram_read (&crc, CFG_ENV_ADDR, sizeof(ulong)); - nvram_read (data, CFG_ENV_ADDR+sizeof(ulong), ENV_SIZE); + nvram_read (&crc, CONFIG_ENV_ADDR, sizeof(ulong)); + nvram_read (data, CONFIG_ENV_ADDR+sizeof(ulong), ENV_SIZE); if (crc32(0, data, ENV_SIZE) == crc) { - gd->env_addr = (ulong)CFG_ENV_ADDR + sizeof(long); + gd->env_addr = (ulong)CONFIG_ENV_ADDR + sizeof(long); #else if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { gd->env_addr = (ulong)&(env_ptr->data); diff --git a/common/env_onenand.c b/common/env_onenand.c index 09a79d0..3c65b3e 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -62,7 +62,7 @@ void env_relocate_spec(void) int use_default = 0; size_t retlen; - env_addr = CFG_ENV_ADDR; + env_addr = CONFIG_ENV_ADDR; /* Check OneNAND exist */ if (onenand_mtd.writesize) @@ -89,13 +89,13 @@ void env_relocate_spec(void) int saveenv(void) { - unsigned long env_addr = CFG_ENV_ADDR; + unsigned long env_addr = CONFIG_ENV_ADDR; struct erase_info instr = { .callback = NULL, }; size_t retlen; - instr.len = CFG_ENV_SIZE; + instr.len = CONFIG_ENV_SIZE; instr.addr = env_addr; if (onenand_erase(&onenand_mtd, &instr)) { printf("OneNAND: erase failed at 0x%08lx\n", env_addr); diff --git a/common/env_sf.c b/common/env_sf.c index faf6260..1bbf93f 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -29,17 +29,17 @@ #include #include -#ifndef CFG_ENV_SPI_BUS -# define CFG_ENV_SPI_BUS 0 +#ifndef CONFIG_ENV_SPI_BUS +# define CONFIG_ENV_SPI_BUS 0 #endif -#ifndef CFG_ENV_SPI_CS -# define CFG_ENV_SPI_CS 0 +#ifndef CONFIG_ENV_SPI_CS +# define CONFIG_ENV_SPI_CS 0 #endif -#ifndef CFG_ENV_SPI_MAX_HZ -# define CFG_ENV_SPI_MAX_HZ 1000000 +#ifndef CONFIG_ENV_SPI_MAX_HZ +# define CONFIG_ENV_SPI_MAX_HZ 1000000 #endif -#ifndef CFG_ENV_SPI_MODE -# define CFG_ENV_SPI_MODE SPI_MODE_3 +#ifndef CONFIG_ENV_SPI_MODE +# define CONFIG_ENV_SPI_MODE SPI_MODE_3 #endif DECLARE_GLOBAL_DATA_PTR; @@ -67,18 +67,18 @@ int saveenv(void) return 1; } - if (CFG_ENV_SIZE > CFG_ENV_SECT_SIZE) { - sector = CFG_ENV_SIZE / CFG_ENV_SECT_SIZE; - if (CFG_ENV_SIZE % CFG_ENV_SECT_SIZE) + if (CONFIG_ENV_SIZE > CONFIG_ENV_SECT_SIZE) { + sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE; + if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE) sector++; } puts("Erasing SPI flash..."); - if (spi_flash_erase(env_flash, CFG_ENV_OFFSET, sector * CFG_ENV_SECT_SIZE)) + if (spi_flash_erase(env_flash, CONFIG_ENV_OFFSET, sector * CONFIG_ENV_SECT_SIZE)) return 1; puts("Writing to SPI flash..."); - if (spi_flash_write(env_flash, CFG_ENV_OFFSET, CFG_ENV_SIZE, env_ptr)) + if (spi_flash_write(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr)) return 1; puts("done\n"); @@ -89,12 +89,12 @@ void env_relocate_spec(void) { int ret; - env_flash = spi_flash_probe(CFG_ENV_SPI_BUS, CFG_ENV_SPI_CS, - CFG_ENV_SPI_MAX_HZ, CFG_ENV_SPI_MODE); + env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); if (!env_flash) goto err_probe; - ret = spi_flash_read(env_flash, CFG_ENV_OFFSET, CFG_ENV_SIZE, env_ptr); + ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr); if (ret) goto err_read; @@ -112,7 +112,7 @@ err_probe: err_crc: puts("*** Warning - bad CRC, using default environment\n\n"); - if (default_environment_size > CFG_ENV_SIZE) { + if (default_environment_size > CONFIG_ENV_SIZE) { gd->env_valid = 0; puts("*** Error - default environment is too large\n\n"); return; -- cgit v1.1 From fc9c1727b5b3483ce49c3cb668e8332fb001b8a7 Mon Sep 17 00:00:00 2001 From: Luigi 'Comio' Mantellini Date: Mon, 8 Sep 2008 02:46:13 +0200 Subject: Add support for LZMA uncompression algorithm. Signed-off-by: Luigi 'Comio' Mantellini Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/cmd_bootm.c | 23 +++++++++++++++++++++++ common/image.c | 1 + 2 files changed, 24 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 9c63e04..19257bb 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -50,6 +50,13 @@ #include #endif +#ifdef CONFIG_LZMA +#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */ +#include +#include +#include +#endif /* CONFIG_LZMA */ + DECLARE_GLOBAL_DATA_PTR; extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp); @@ -334,6 +341,22 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) *load_end = load + unc_len; break; #endif /* CONFIG_BZIP2 */ +#ifdef CONFIG_LZMA + case IH_COMP_LZMA: + printf (" Uncompressing %s ... ", type_name); + + int ret = lzmaBuffToBuffDecompress( + (unsigned char *)load, &unc_len, + (unsigned char *)image_start, image_start); + if (ret != LZMA_RESULT_OK) { + printf ("LZMA: uncompress or overwrite error %d " + "- must RESET board to recover\n", ret); + show_boot_progress (-6); + return BOOTM_ERR_RESET; + } + *load_end = load + unc_len; + break; +#endif /* CONFIG_LZMA */ default: printf ("Unimplemented compression type %d\n", comp); return BOOTM_ERR_UNIMPLEMENTED; diff --git a/common/image.c b/common/image.c index d7fcd1d..dc8d7dd 100644 --- a/common/image.c +++ b/common/image.c @@ -152,6 +152,7 @@ static table_entry_t uimage_comp[] = { { IH_COMP_NONE, "none", "uncompressed", }, { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", }, { IH_COMP_GZIP, "gzip", "gzip compressed", }, + { IH_COMP_LZMA, "lzma", "lzma compressed", }, { -1, "", "", }, }; -- cgit v1.1 From 56844a22b76c719e600047e23b80465a44d76abd Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Thu, 11 Sep 2008 08:11:23 +0200 Subject: powerpc: Fix bootm to boot up again with a Ramdisk Commit 2a1a2cb6 didnt remove the dummy mem reservation in fdt_chosen, and this stopped Linux from booting with a Ramdisk. This patch fixes this, by deleting the useless dummy mem reservation. When booting with a Ramdisk, a fix offset FDT_RAMDISK_OVERHEAD is now added to of_size, so we dont need anymore a dummy mem reservation. I measured the value of FDT_RAMDISK_OVERHEAD on a MPC8270 based system (=0x44 bytes) and rounded it up to 0x80). Signed-off-by: Heiko Schocher Acked-by: Kumar Gala --- common/cmd_fdt.c | 3 ++- common/fdt_support.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 0593bad..288a5c4 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -450,7 +450,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) initrd_end = simple_strtoul(argv[3], NULL, 16); } - fdt_chosen(working_fdt, initrd_start, initrd_end, 1); + fdt_chosen(working_fdt, 1); + fdt_initrd(working_fdt, initrd_start, initrd_end, 1); } /* resize the fdt */ else if (strncmp(argv[1], "re", 2) == 0) { diff --git a/common/fdt_support.c b/common/fdt_support.c index a7773ab..8ceeb0f 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -165,7 +165,7 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force) return 0; } -int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) +int fdt_chosen(void *fdt, int force) { int nodeoffset; int err; @@ -215,8 +215,6 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) } } - fdt_initrd(fdt, initrd_start, initrd_end, force); - #ifdef CONFIG_OF_STDOUT_VIA_ALIAS path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL); if ((path == NULL) || force) -- cgit v1.1 From be19d324edc1a1d7f393d24e10d164cd94c91a00 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Tue, 16 Sep 2008 14:55:42 +0200 Subject: Fix for USB sticks not working on ARM while using GCC 4.x compilers The GCC-compiler makes an optimisation error while optimising the routine usb_set_maxpacket(). This should be fixed in the compiler in the first place, but there lots of compilers out there that makes this error, that it is probably wiser to workaround it in U-boot itself. What happens is that the register r3 is used as loop-counter 'i', but gets overwritten later on. From there it starts using register r3 for several other things and the assembler code is becoming a big mess. This is clearly a compiler bug. This error occurs on at least several versions of Code Sourcery Lite compilers for ARM. Like the Edition 2008q1, and 2008q3, It has also been seen on other compilers, while compiling for armv4t, or armv5te with Os, O1 and O2. We work around it by splitting up this routine in 2 parts, and making sure that the split out part is NOT inlined any longer. This will make GCC spit out assembler that do not show this problem. Another possibility is to adapt the Makefile to stop optimisation for the complete file. I think this solution is nicer. Signed-off-by: Remy Bohmer Signed-off-by: Markus Klotzbuecher --- common/usb.c | 73 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index 52e5964..4d64ccb 100644 --- a/common/usb.c +++ b/common/usb.c @@ -245,40 +245,59 @@ int usb_maxpacket(struct usb_device *dev,unsigned long pipe) return(dev->epmaxpacketin[((pipe>>15) & 0xf)]); } +/* The routine usb_set_maxpacket_ep() is extracted from the loop of routine + * usb_set_maxpacket(), because the optimizer of GCC 4.x chokes on this routine + * when it is inlined in 1 single routine. What happens is that the register r3 + * is used as loop-count 'i', but gets overwritten later on. + * This is clearly a compiler bug, but it is easier to workaround it here than + * to update the compiler (Occurs with at least several GCC 4.{1,2},x + * CodeSourcery compilers like e.g. 2007q3, 2008q1, 2008q3 lite editions on ARM) + */ +static void __attribute__((noinline)) +usb_set_maxpacket_ep(struct usb_device *dev, struct usb_endpoint_descriptor *ep) +{ + int b; + + b = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + + if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == + USB_ENDPOINT_XFER_CONTROL) { + /* Control => bidirectional */ + dev->epmaxpacketout[b] = ep->wMaxPacketSize; + dev->epmaxpacketin [b] = ep->wMaxPacketSize; + USB_PRINTF("##Control EP epmaxpacketout/in[%d] = %d\n", + b, dev->epmaxpacketin[b]); + } else { + if ((ep->bEndpointAddress & 0x80) == 0) { + /* OUT Endpoint */ + if (ep->wMaxPacketSize > dev->epmaxpacketout[b]) { + dev->epmaxpacketout[b] = ep->wMaxPacketSize; + USB_PRINTF("##EP epmaxpacketout[%d] = %d\n", + b, dev->epmaxpacketout[b]); + } + } else { + /* IN Endpoint */ + if (ep->wMaxPacketSize > dev->epmaxpacketin[b]) { + dev->epmaxpacketin[b] = ep->wMaxPacketSize; + USB_PRINTF("##EP epmaxpacketin[%d] = %d\n", + b, dev->epmaxpacketin[b]); + } + } /* if out */ + } /* if control */ +} + /* * set the max packed value of all endpoints in the given configuration */ int usb_set_maxpacket(struct usb_device *dev) { - int i,ii,b; - struct usb_endpoint_descriptor *ep; + int i, ii; - for(i=0; iconfig.bNumInterfaces;i++) { - for(ii=0; iiconfig.if_desc[i].bNumEndpoints; ii++) { - ep = &dev->config.if_desc[i].ep_desc[ii]; - b=ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + for (i = 0; i < dev->config.bNumInterfaces; i++) + for (ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++) + usb_set_maxpacket_ep(dev, + &dev->config.if_desc[i].ep_desc[ii]); - if((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)==USB_ENDPOINT_XFER_CONTROL) { /* Control => bidirectional */ - dev->epmaxpacketout[b] = ep->wMaxPacketSize; - dev->epmaxpacketin [b] = ep->wMaxPacketSize; - USB_PRINTF("##Control EP epmaxpacketout/in[%d] = %d\n",b,dev->epmaxpacketin[b]); - } - else { - if ((ep->bEndpointAddress & 0x80)==0) { /* OUT Endpoint */ - if(ep->wMaxPacketSize > dev->epmaxpacketout[b]) { - dev->epmaxpacketout[b] = ep->wMaxPacketSize; - USB_PRINTF("##EP epmaxpacketout[%d] = %d\n",b,dev->epmaxpacketout[b]); - } - } - else { /* IN Endpoint */ - if(ep->wMaxPacketSize > dev->epmaxpacketin[b]) { - dev->epmaxpacketin[b] = ep->wMaxPacketSize; - USB_PRINTF("##EP epmaxpacketin[%d] = %d\n",b,dev->epmaxpacketin[b]); - } - } /* if out */ - } /* if control */ - } /* for each endpoint */ - } return 0; } -- cgit v1.1 From 6f5794a6f78b313231256958fd73673c6aacc116 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Tue, 16 Sep 2008 14:55:43 +0200 Subject: Refactoring parts of the common USB OHCI code This patch refactors some large routines of the USB OHCI code by making some routines smaller and more readable which helps debugging and understanding the code. (Makes the code looks somewhat more like the Linux implementation.) Also made entire file compliant to Linux Coding Rules (checkpatch.pl compliant) Signed-off-by: Remy Bohmer Signed-off-by: Markus Klotzbuecher --- common/usb.c | 542 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 306 insertions(+), 236 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index 4d64ccb..be81aaf 100644 --- a/common/usb.c +++ b/common/usb.c @@ -58,9 +58,9 @@ #undef USB_DEBUG #ifdef USB_DEBUG -#define USB_PRINTF(fmt,args...) printf (fmt ,##args) +#define USB_PRINTF(fmt, args...) printf (fmt , ##args) #else -#define USB_PRINTF(fmt,args...) +#define USB_PRINTF(fmt, args...) #endif #define USB_BUFSIZ 512 @@ -88,7 +88,7 @@ void usb_hub_reset(void); void __inline__ wait_ms(unsigned long ms) { - while(ms-->0) + while (ms-- > 0) udelay(1000); } /*************************************************************************** @@ -99,22 +99,22 @@ int usb_init(void) { int result; - running=0; - dev_index=0; - asynch_allowed=1; + running = 0; + dev_index = 0; + asynch_allowed = 1; usb_hub_reset(); /* init low_level USB */ printf("USB: "); result = usb_lowlevel_init(); - /* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */ - if(result==0) { + /* if lowlevel init is OK, scan the bus for devices + * i.e. search HUBs and configure them */ + if (result == 0) { printf("scanning bus for devices... "); - running=1; + running = 1; usb_scan_devices(); usb_started = 1; return 0; - } - else { + } else { printf("Error, couldn't init Lowlevel part\n"); usb_started = 0; return -1; @@ -143,7 +143,7 @@ int usb_stop(void) */ void usb_disable_asynch(int disable) { - asynch_allowed=!disable; + asynch_allowed = !disable; } @@ -156,9 +156,9 @@ void usb_disable_asynch(int disable) * submits an Interrupt Message */ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer,int transfer_len, int interval) + void *buffer, int transfer_len, int interval) { - return submit_int_msg(dev,pipe,buffer,transfer_len,interval); + return submit_int_msg(dev, pipe, buffer, transfer_len, interval); } /* @@ -175,8 +175,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, unsigned short value, unsigned short index, void *data, unsigned short size, int timeout) { - if((timeout==0)&&(!asynch_allowed)) /* request for a asynch control pipe is not allowed */ + if ((timeout == 0) && (!asynch_allowed)) { + /* request for a asynch control pipe is not allowed */ return -1; + } /* set setup command */ setup_packet.requesttype = requesttype; @@ -184,24 +186,24 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, setup_packet.value = cpu_to_le16(value); setup_packet.index = cpu_to_le16(index); setup_packet.length = cpu_to_le16(size); - USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\n", - request,requesttype,value,index,size); - dev->status=USB_ST_NOT_PROC; /*not yet processed */ + USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X, " \ + "value 0x%X index 0x%X length 0x%X\n", + request, requesttype, value, index, size); + dev->status = USB_ST_NOT_PROC; /*not yet processed */ - submit_control_msg(dev,pipe,data,size,&setup_packet); - if(timeout==0) { + submit_control_msg(dev, pipe, data, size, &setup_packet); + if (timeout == 0) return (int)size; - } - while(timeout--) { - if(!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) + + while (timeout--) { + if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) break; wait_ms(1); } - if(dev->status==0) + if (dev->status == 0) return dev->act_len; - else { + else return -1; - } } /*------------------------------------------------------------------- @@ -214,15 +216,15 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, { if (len < 0) return -1; - dev->status=USB_ST_NOT_PROC; /*not yet processed */ - submit_bulk_msg(dev,pipe,data,len); - while(timeout--) { - if(!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) + dev->status = USB_ST_NOT_PROC; /*not yet processed */ + submit_bulk_msg(dev, pipe, data, len); + while (timeout--) { + if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) break; wait_ms(1); } - *actual_length=dev->act_len; - if(dev->status==0) + *actual_length = dev->act_len; + if (dev->status == 0) return 0; else return -1; @@ -237,9 +239,10 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, * returns the max packet size, depending on the pipe direction and * the configurations values */ -int usb_maxpacket(struct usb_device *dev,unsigned long pipe) +int usb_maxpacket(struct usb_device *dev, unsigned long pipe) { - if((pipe & USB_DIR_IN)==0) /* direction is out -> use emaxpacket out */ + /* direction is out -> use emaxpacket out */ + if ((pipe & USB_DIR_IN) == 0) return(dev->epmaxpacketout[((pipe>>15) & 0xf)]); else return(dev->epmaxpacketin[((pipe>>15) & 0xf)]); @@ -318,8 +321,9 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno) dev->configno = cfgno; head = (struct usb_descriptor_header *) &buffer[0]; - if(head->bDescriptorType != USB_DT_CONFIG) { - printf(" ERROR: NOT USB_CONFIG_DESC %x\n", head->bDescriptorType); + if (head->bDescriptorType != USB_DT_CONFIG) { + printf(" ERROR: NOT USB_CONFIG_DESC %x\n", + head->bDescriptorType); return -1; } memcpy(&dev->config, buffer, buffer[0]); @@ -327,45 +331,52 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno) dev->config.no_of_if = 0; index = dev->config.bLength; - /* Ok the first entry must be a configuration entry, now process the others */ + /* Ok the first entry must be a configuration entry, + * now process the others */ head = (struct usb_descriptor_header *) &buffer[index]; - while(index + 1 < dev->config.wTotalLength) { - switch(head->bDescriptorType) { - case USB_DT_INTERFACE: - if(((struct usb_interface_descriptor *) &buffer[index])-> - bInterfaceNumber != curr_if_num) { - /* this is a new interface, copy new desc */ - ifno = dev->config.no_of_if; - dev->config.no_of_if++; - memcpy(&dev->config.if_desc[ifno], - &buffer[index], buffer[index]); - dev->config.if_desc[ifno].no_of_ep = 0; - dev->config.if_desc[ifno].num_altsetting = 1; - curr_if_num = dev->config.if_desc[ifno].bInterfaceNumber; - } else { - /* found alternate setting for the interface */ - dev->config.if_desc[ifno].num_altsetting++; - } - break; - case USB_DT_ENDPOINT: - epno = dev->config.if_desc[ifno].no_of_ep; - dev->config.if_desc[ifno].no_of_ep++; /* found an endpoint */ - memcpy(&dev->config.if_desc[ifno].ep_desc[epno], + while (index + 1 < dev->config.wTotalLength) { + switch (head->bDescriptorType) { + case USB_DT_INTERFACE: + if (((struct usb_interface_descriptor *) \ + &buffer[index])->bInterfaceNumber != curr_if_num) { + /* this is a new interface, copy new desc */ + ifno = dev->config.no_of_if; + dev->config.no_of_if++; + memcpy(&dev->config.if_desc[ifno], &buffer[index], buffer[index]); - le16_to_cpus(&(dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize)); - USB_PRINTF("if %d, ep %d\n", ifno, epno); - break; - default: - if(head->bLength == 0) - return 1; - USB_PRINTF("unknown Description Type : %x\n", head->bDescriptorType); - { - ch = (unsigned char *)head; - for(i = 0; i < head->bLength; i++) - USB_PRINTF("%02X ", *ch++); - USB_PRINTF("\n\n\n"); - } - break; + dev->config.if_desc[ifno].no_of_ep = 0; + dev->config.if_desc[ifno].num_altsetting = 1; + curr_if_num = + dev->config.if_desc[ifno].bInterfaceNumber; + } else { + /* found alternate setting for the interface */ + dev->config.if_desc[ifno].num_altsetting++; + } + break; + case USB_DT_ENDPOINT: + epno = dev->config.if_desc[ifno].no_of_ep; + /* found an endpoint */ + dev->config.if_desc[ifno].no_of_ep++; + memcpy(&dev->config.if_desc[ifno].ep_desc[epno], + &buffer[index], buffer[index]); + le16_to_cpus(&(dev->config.if_desc[ifno].ep_desc[epno].\ + wMaxPacketSize)); + USB_PRINTF("if %d, ep %d\n", ifno, epno); + break; + default: + if (head->bLength == 0) + return 1; + + USB_PRINTF("unknown Description Type : %x\n", + head->bDescriptorType); + + { + ch = (unsigned char *)head; + for (i = 0; i < head->bLength; i++) + USB_PRINTF("%02X ", *ch++); + USB_PRINTF("\n\n\n"); + } + break; } index += head->bLength; head = (struct usb_descriptor_header *)&buffer[index]; @@ -384,7 +395,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe) int endp = usb_pipeendpoint(pipe)|(usb_pipein(pipe)<<7); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, USB_CNTL_TIMEOUT * 3); + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, + endp, NULL, 0, USB_CNTL_TIMEOUT * 3); /* don't clear if failed */ if (result < 0) @@ -406,7 +418,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe) /********************************************************************** * get_descriptor type */ -int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size) +int usb_get_descriptor(struct usb_device *dev, unsigned char type, + unsigned char index, void *buf, int size) { int res; res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), @@ -419,32 +432,36 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char /********************************************************************** * gets configuration cfgno and store it in the buffer */ -int usb_get_configuration_no(struct usb_device *dev,unsigned char *buffer,int cfgno) +int usb_get_configuration_no(struct usb_device *dev, + unsigned char *buffer, int cfgno) { int result; unsigned int tmp; struct usb_config_descriptor *config; - config=(struct usb_config_descriptor *)&buffer[0]; + config = (struct usb_config_descriptor *)&buffer[0]; result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8); if (result < 8) { if (result < 0) - printf("unable to get descriptor, error %lX\n",dev->status); + printf("unable to get descriptor, error %lX\n", + dev->status); else - printf("config descriptor too short (expected %i, got %i)\n",8,result); + printf("config descriptor too short " \ + "(expected %i, got %i)\n", 8, result); return -1; } tmp = le16_to_cpu(config->wTotalLength); if (tmp > USB_BUFSIZ) { - USB_PRINTF("usb_get_configuration_no: failed to get descriptor - too long: %d\n", - tmp); + USB_PRINTF("usb_get_configuration_no: failed to get " \ + "descriptor - too long: %d\n", tmp); return -1; } result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, tmp); - USB_PRINTF("get_conf_no %d Result %d, wLength %d\n",cfgno,result,tmp); + USB_PRINTF("get_conf_no %d Result %d, wLength %d\n", + cfgno, result, tmp); return result; } @@ -456,11 +473,11 @@ int usb_set_address(struct usb_device *dev) { int res; - USB_PRINTF("set address %d\n",dev->devnum); - res=usb_control_msg(dev, usb_snddefctrl(dev), - USB_REQ_SET_ADDRESS, 0, - (dev->devnum),0, - NULL,0, USB_CNTL_TIMEOUT); + USB_PRINTF("set address %d\n", dev->devnum); + res = usb_control_msg(dev, usb_snddefctrl(dev), + USB_REQ_SET_ADDRESS, 0, + (dev->devnum), 0, + NULL, 0, USB_CNTL_TIMEOUT); return res; } @@ -484,16 +501,19 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) } /* * We should return now for devices with only one alternate setting. - * According to 9.4.10 of the Universal Serial Bus Specification Revision 2.0 - * such devices can return with a STALL. This results in some USB sticks - * timeouting during initialization and then being unusable in U-Boot. + * According to 9.4.10 of the Universal Serial Bus Specification + * Revision 2.0 such devices can return with a STALL. This results in + * some USB sticks timeouting during initialization and then being + * unusable in U-Boot. */ if (if_face->num_altsetting == 1) return 0; - if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, alternate, - interface, NULL, 0, USB_CNTL_TIMEOUT * 5)) < 0) + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, + alternate, interface, NULL, 0, + USB_CNTL_TIMEOUT * 5); + if (ret < 0) return ret; return 0; @@ -505,18 +525,17 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) int usb_set_configuration(struct usb_device *dev, int configuration) { int res; - USB_PRINTF("set configuration %d\n",configuration); + USB_PRINTF("set configuration %d\n", configuration); /* set setup command */ - res=usb_control_msg(dev, usb_sndctrlpipe(dev,0), - USB_REQ_SET_CONFIGURATION, 0, - configuration,0, - NULL,0, USB_CNTL_TIMEOUT); - if(res==0) { + res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + USB_REQ_SET_CONFIGURATION, 0, + configuration, 0, + NULL, 0, USB_CNTL_TIMEOUT); + if (res == 0) { dev->toggle[0] = 0; dev->toggle[1] = 0; return 0; - } - else + } else return -1; } @@ -543,11 +562,13 @@ int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id) /******************************************************************** * get report */ -int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size) +int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, + unsigned char id, void *buf, int size) { return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - USB_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - (type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT); + USB_REQ_GET_REPORT, + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + (type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT); } /******************************************************************** @@ -564,7 +585,8 @@ int usb_get_class_descriptor(struct usb_device *dev, int ifnum, /******************************************************************** * get string index in buffer */ -int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size) +int usb_get_string(struct usb_device *dev, unsigned short langid, + unsigned char index, void *buf, int size) { int i; int result; @@ -655,17 +677,19 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) if (!dev->have_langid) { err = usb_string_sub(dev, 0, 0, tbuf); if (err < 0) { - USB_PRINTF("error getting string descriptor 0 (error=%x)\n",dev->status); + USB_PRINTF("error getting string descriptor 0 " \ + "(error=%x)\n", dev->status); return -1; } else if (tbuf[0] < 4) { USB_PRINTF("string descriptor 0 too short\n"); return -1; } else { dev->have_langid = -1; - dev->string_langid = tbuf[2] | (tbuf[3]<< 8); + dev->string_langid = tbuf[2] | (tbuf[3] << 8); /* always use the first langid listed */ - USB_PRINTF("USB device number %d default language ID 0x%x\n", - dev->devnum, dev->string_langid); + USB_PRINTF("USB device number %d default " \ + "language ID 0x%x\n", + dev->devnum, dev->string_langid); } } @@ -697,9 +721,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) /* returns a pointer to the device with the index [index]. * if the device is not assigned (dev->devnum==-1) returns NULL */ -struct usb_device * usb_get_dev_index(int index) +struct usb_device *usb_get_dev_index(int index) { - if(usb_dev[index].devnum==-1) + if (usb_dev[index].devnum == -1) return NULL; else return &usb_dev[index]; @@ -709,21 +733,22 @@ struct usb_device * usb_get_dev_index(int index) /* returns a pointer of a new device structure or NULL, if * no device struct is available */ -struct usb_device * usb_alloc_new_device(void) +struct usb_device *usb_alloc_new_device(void) { int i; - USB_PRINTF("New Device %d\n",dev_index); - if(dev_index==USB_MAX_DEVICE) { - printf("ERROR, too many USB Devices, max=%d\n",USB_MAX_DEVICE); + USB_PRINTF("New Device %d\n", dev_index); + if (dev_index == USB_MAX_DEVICE) { + printf("ERROR, too many USB Devices, max=%d\n", USB_MAX_DEVICE); return NULL; } - usb_dev[dev_index].devnum=dev_index+1; /* default Address is 0, real addresses start with 1 */ - usb_dev[dev_index].maxchild=0; - for(i=0;idescriptor, 8); if (err < 8) { - printf("\n USB device not responding, giving up (status=%lX)\n",dev->status); + printf("\n USB device not responding, " \ + "giving up (status=%lX)\n", dev->status); return 1; } #endif @@ -811,17 +837,18 @@ int usb_new_device(struct usb_device *dev) dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0; dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0; switch (dev->descriptor.bMaxPacketSize0) { - case 8: dev->maxpacketsize = 0; break; - case 16: dev->maxpacketsize = 1; break; - case 32: dev->maxpacketsize = 2; break; - case 64: dev->maxpacketsize = 3; break; + case 8: dev->maxpacketsize = 0; break; + case 16: dev->maxpacketsize = 1; break; + case 32: dev->maxpacketsize = 2; break; + case 64: dev->maxpacketsize = 3; break; } dev->devnum = addr; err = usb_set_address(dev); /* set address */ if (err < 0) { - printf("\n USB device not accepting new address (error=%lX)\n", dev->status); + printf("\n USB device not accepting new address " \ + "(error=%lX)\n", dev->status); return 1; } @@ -829,12 +856,15 @@ int usb_new_device(struct usb_device *dev) tmp = sizeof(dev->descriptor); - err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, sizeof(dev->descriptor)); + err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, + &dev->descriptor, sizeof(dev->descriptor)); if (err < tmp) { if (err < 0) - printf("unable to get device descriptor (error=%d)\n",err); + printf("unable to get device descriptor (error=%d)\n", + err); else - printf("USB device descriptor short read (expected %i, got %i)\n",tmp,err); + printf("USB device descriptor short read " \ + "(expected %i, got %i)\n", tmp, err); return 1; } /* correct le values */ @@ -843,30 +873,35 @@ int usb_new_device(struct usb_device *dev) le16_to_cpus(&dev->descriptor.idProduct); le16_to_cpus(&dev->descriptor.bcdDevice); /* only support for one config for now */ - usb_get_configuration_no(dev,&tmpbuf[0],0); - usb_parse_config(dev,&tmpbuf[0],0); + usb_get_configuration_no(dev, &tmpbuf[0], 0); + usb_parse_config(dev, &tmpbuf[0], 0); usb_set_maxpacket(dev); /* we set the default configuration here */ if (usb_set_configuration(dev, dev->config.bConfigurationValue)) { - printf("failed to set default configuration len %d, status %lX\n",dev->act_len,dev->status); + printf("failed to set default configuration " \ + "len %d, status %lX\n", dev->act_len, dev->status); return -1; } USB_PRINTF("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n", - dev->descriptor.iManufacturer, dev->descriptor.iProduct, dev->descriptor.iSerialNumber); + dev->descriptor.iManufacturer, dev->descriptor.iProduct, + dev->descriptor.iSerialNumber); memset(dev->mf, 0, sizeof(dev->mf)); memset(dev->prod, 0, sizeof(dev->prod)); memset(dev->serial, 0, sizeof(dev->serial)); if (dev->descriptor.iManufacturer) - usb_string(dev, dev->descriptor.iManufacturer, dev->mf, sizeof(dev->mf)); + usb_string(dev, dev->descriptor.iManufacturer, + dev->mf, sizeof(dev->mf)); if (dev->descriptor.iProduct) - usb_string(dev, dev->descriptor.iProduct, dev->prod, sizeof(dev->prod)); + usb_string(dev, dev->descriptor.iProduct, + dev->prod, sizeof(dev->prod)); if (dev->descriptor.iSerialNumber) - usb_string(dev, dev->descriptor.iSerialNumber, dev->serial, sizeof(dev->serial)); + usb_string(dev, dev->descriptor.iSerialNumber, + dev->serial, sizeof(dev->serial)); USB_PRINTF("Manufacturer %s\n", dev->mf); USB_PRINTF("Product %s\n", dev->prod); USB_PRINTF("SerialNumber %s\n", dev->serial); /* now prode if the device is a hub */ - usb_hub_probe(dev,0); + usb_hub_probe(dev, 0); return 0; } @@ -877,15 +912,15 @@ void usb_scan_devices(void) struct usb_device *dev; /* first make all devices unknown */ - for(i=0;ipusb_dev; + dev = hub->pusb_dev; /* Enable power to the ports */ USB_HUB_PRINTF("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); - USB_HUB_PRINTF("port %d returns %lX\n",i+1,dev->status); + USB_HUB_PRINTF("port %d returns %lX\n", i + 1, dev->status); wait_ms(hub->desc.bPwrOn2PwrGood * 2); } } void usb_hub_reset(void) { - usb_hub_index=0; + usb_hub_index = 0; } struct usb_hub_device *usb_hub_allocate(void) { - if(usb_hub_indexstatus); + if (usb_get_port_status(dev, port + 1, &portsts) < 0) { + USB_HUB_PRINTF("get_port_status failed status %lX\n", + dev->status); return -1; } portstatus = le16_to_cpu(portsts.wPortStatus); portchange = le16_to_cpu(portsts.wPortChange); - USB_HUB_PRINTF("portstatus %x, change %x, %s\n", portstatus ,portchange, - portstatus&(1<children[port])) { + (!(portstatus & USB_PORT_STAT_ENABLE))) || (dev->children[port])) { USB_HUB_PRINTF("usb_disconnect(&hub->children[port]);\n"); /* Return now if nothing is connected */ if (!(portstatus & USB_PORT_STAT_CONNECTION)) @@ -1073,11 +1115,11 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) wait_ms(200); /* Allocate a new device struct for it */ - usb=usb_alloc_new_device(); + usb = usb_alloc_new_device(); usb->slow = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0; dev->children[port] = usb; - usb->parent=dev; + usb->parent = dev; /* Run it through the hoops (find a driver, etc) */ if (usb_new_device(usb)) { /* Woops, disable the port */ @@ -1096,13 +1138,14 @@ int usb_hub_configure(struct usb_device *dev) struct usb_hub_device *hub; /* "allocate" Hub device */ - hub=usb_hub_allocate(); - if(hub==NULL) + hub = usb_hub_allocate(); + if (hub == NULL) return -1; - hub->pusb_dev=dev; + hub->pusb_dev = dev; /* Get the the hub descriptor */ if (usb_get_hub_descriptor(dev, buffer, 4) < 0) { - USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor, giving up %lX\n",dev->status); + USB_HUB_PRINTF("usb_hub_configure: failed to get hub " \ + "descriptor, giving up %lX\n", dev->status); return -1; } descriptor = (struct usb_hub_descriptor *)buffer; @@ -1110,43 +1153,48 @@ int usb_hub_configure(struct usb_device *dev) /* silence compiler warning if USB_BUFSIZ is > 256 [= sizeof(char)] */ i = descriptor->bLength; if (i > USB_BUFSIZ) { - USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor - too long: %d\n", - descriptor->bLength); + USB_HUB_PRINTF("usb_hub_configure: failed to get hub " \ + "descriptor - too long: %d\n", + descriptor->bLength); return -1; } if (usb_get_hub_descriptor(dev, buffer, descriptor->bLength) < 0) { - USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor 2nd giving up %lX\n",dev->status); + USB_HUB_PRINTF("usb_hub_configure: failed to get hub " \ + "descriptor 2nd giving up %lX\n", dev->status); return -1; } - memcpy((unsigned char *)&hub->desc,buffer,descriptor->bLength); + memcpy((unsigned char *)&hub->desc, buffer, descriptor->bLength); /* adjust 16bit values */ - hub->desc.wHubCharacteristics = le16_to_cpu(descriptor->wHubCharacteristics); + hub->desc.wHubCharacteristics = + le16_to_cpu(descriptor->wHubCharacteristics); /* set the bitmap */ - bitmap=(unsigned char *)&hub->desc.DeviceRemovable[0]; - memset(bitmap,0xff,(USB_MAXCHILDREN+1+7)/8); /* devices not removable by default */ - bitmap=(unsigned char *)&hub->desc.PortPowerCtrlMask[0]; - memset(bitmap,0xff,(USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */ - for(i=0;i<((hub->desc.bNbrPorts + 1 + 7)/8);i++) { - hub->desc.DeviceRemovable[i]=descriptor->DeviceRemovable[i]; - } - for(i=0;i<((hub->desc.bNbrPorts + 1 + 7)/8);i++) { - hub->desc.DeviceRemovable[i]=descriptor->PortPowerCtrlMask[i]; - } + bitmap = (unsigned char *)&hub->desc.DeviceRemovable[0]; + /* devices not removable by default */ + memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); + bitmap = (unsigned char *)&hub->desc.PortPowerCtrlMask[0]; + memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */ + + for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++) + hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i]; + + for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++) + hub->desc.DeviceRemovable[i] = descriptor->PortPowerCtrlMask[i]; + dev->maxchild = descriptor->bNbrPorts; USB_HUB_PRINTF("%d ports detected\n", dev->maxchild); switch (hub->desc.wHubCharacteristics & HUB_CHAR_LPSM) { - case 0x00: - USB_HUB_PRINTF("ganged power switching\n"); - break; - case 0x01: - USB_HUB_PRINTF("individual port power switching\n"); - break; - case 0x02: - case 0x03: - USB_HUB_PRINTF("unknown reserved power switching mode\n"); - break; + case 0x00: + USB_HUB_PRINTF("ganged power switching\n"); + break; + case 0x01: + USB_HUB_PRINTF("individual port power switching\n"); + break; + case 0x02: + case 0x03: + USB_HUB_PRINTF("unknown reserved power switching mode\n"); + break; } if (hub->desc.wHubCharacteristics & HUB_CHAR_COMPOUND) @@ -1155,40 +1203,52 @@ int usb_hub_configure(struct usb_device *dev) USB_HUB_PRINTF("standalone hub\n"); switch (hub->desc.wHubCharacteristics & HUB_CHAR_OCPM) { - case 0x00: - USB_HUB_PRINTF("global over-current protection\n"); - break; - case 0x08: - USB_HUB_PRINTF("individual port over-current protection\n"); - break; - case 0x10: - case 0x18: - USB_HUB_PRINTF("no over-current protection\n"); - break; + case 0x00: + USB_HUB_PRINTF("global over-current protection\n"); + break; + case 0x08: + USB_HUB_PRINTF("individual port over-current protection\n"); + break; + case 0x10: + case 0x18: + USB_HUB_PRINTF("no over-current protection\n"); + break; } - USB_HUB_PRINTF("power on to power good time: %dms\n", descriptor->bPwrOn2PwrGood * 2); - USB_HUB_PRINTF("hub controller current requirement: %dmA\n", descriptor->bHubContrCurrent); + + USB_HUB_PRINTF("power on to power good time: %dms\n", + descriptor->bPwrOn2PwrGood * 2); + USB_HUB_PRINTF("hub controller current requirement: %dmA\n", + descriptor->bHubContrCurrent); + for (i = 0; i < dev->maxchild; i++) USB_HUB_PRINTF("port %d is%s removable\n", i + 1, - hub->desc.DeviceRemovable[(i + 1)/8] & (1 << ((i + 1)%8)) ? " not" : ""); + hub->desc.DeviceRemovable[(i + 1) / 8] & \ + (1 << ((i + 1) % 8)) ? " not" : ""); + if (sizeof(struct usb_hub_status) > USB_BUFSIZ) { - USB_HUB_PRINTF("usb_hub_configure: failed to get Status - too long: %d\n", - descriptor->bLength); + USB_HUB_PRINTF("usb_hub_configure: failed to get Status - " \ + "too long: %d\n", descriptor->bLength); return -1; } if (usb_get_hub_status(dev, buffer) < 0) { - USB_HUB_PRINTF("usb_hub_configure: failed to get Status %lX\n",dev->status); + USB_HUB_PRINTF("usb_hub_configure: failed to get Status %lX\n", + dev->status); return -1; } + hubsts = (struct usb_hub_status *)buffer; USB_HUB_PRINTF("get_hub_status returned status %X, change %X\n", - le16_to_cpu(hubsts->wHubStatus),le16_to_cpu(hubsts->wHubChange)); + le16_to_cpu(hubsts->wHubStatus), + le16_to_cpu(hubsts->wHubChange)); USB_HUB_PRINTF("local power source is %s\n", - (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_LOCAL_POWER) ? "lost (inactive)" : "good"); + (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_LOCAL_POWER) ? \ + "lost (inactive)" : "good"); USB_HUB_PRINTF("%sover-current condition exists\n", - (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? "" : "no "); + (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \ + "" : "no "); usb_hub_power_on(hub); + for (i = 0; i < dev->maxchild; i++) { struct usb_port_status portsts; unsigned short portstatus, portchange; @@ -1197,41 +1257,51 @@ int usb_hub_configure(struct usb_device *dev) USB_HUB_PRINTF("get_port_status failed\n"); continue; } + portstatus = le16_to_cpu(portsts.wPortStatus); portchange = le16_to_cpu(portsts.wPortChange); - USB_HUB_PRINTF("Port %d Status %X Change %X\n",i+1,portstatus,portchange); + USB_HUB_PRINTF("Port %d Status %X Change %X\n", + i + 1, portstatus, portchange); + if (portchange & USB_PORT_STAT_C_CONNECTION) { USB_HUB_PRINTF("port %d connection change\n", i + 1); usb_hub_port_connect_change(dev, i); } if (portchange & USB_PORT_STAT_C_ENABLE) { - USB_HUB_PRINTF("port %d enable change, status %x\n", i + 1, portstatus); - usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE); - - /* EM interference sometimes causes bad shielded USB devices to - * be shutdown by the hub, this hack enables them again. - * Works at least with mouse driver */ + USB_HUB_PRINTF("port %d enable change, status %x\n", + i + 1, portstatus); + usb_clear_port_feature(dev, i + 1, + USB_PORT_FEAT_C_ENABLE); + + /* EM interference sometimes causes bad shielded USB + * devices to be shutdown by the hub, this hack enables + * them again. Works at least with mouse driver */ if (!(portstatus & USB_PORT_STAT_ENABLE) && - (portstatus & USB_PORT_STAT_CONNECTION) && (dev->children[i])) { - USB_HUB_PRINTF("already running port %i disabled by hub (EMI?), re-enabling...\n", - i + 1); + (portstatus & USB_PORT_STAT_CONNECTION) && + ((dev->children[i]))) { + USB_HUB_PRINTF("already running port %i " \ + "disabled by hub (EMI?), " \ + "re-enabling...\n", i + 1); usb_hub_port_connect_change(dev, i); } } if (portstatus & USB_PORT_STAT_SUSPEND) { USB_HUB_PRINTF("port %d suspend change\n", i + 1); - usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_SUSPEND); + usb_clear_port_feature(dev, i + 1, + USB_PORT_FEAT_SUSPEND); } if (portchange & USB_PORT_STAT_C_OVERCURRENT) { USB_HUB_PRINTF("port %d over-current change\n", i + 1); - usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_OVER_CURRENT); + usb_clear_port_feature(dev, i + 1, + USB_PORT_FEAT_C_OVER_CURRENT); usb_hub_power_on(hub); } if (portchange & USB_PORT_STAT_C_RESET) { USB_HUB_PRINTF("port %d reset change\n", i + 1); - usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET); + usb_clear_port_feature(dev, i + 1, + USB_PORT_FEAT_C_RESET); } } /* end for i all ports */ @@ -1265,7 +1335,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) return 0; /* We found a hub */ USB_HUB_PRINTF("USB hub found\n"); - ret=usb_hub_configure(dev); + ret = usb_hub_configure(dev); return ret; } -- cgit v1.1 From c9e8436b10cca53fca4904ecbadcd6231ad72c38 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Tue, 16 Sep 2008 14:55:44 +0200 Subject: USB layer of U-Boot causes USB protocol errors while using USB memory sticks There are several differences between Linux, Windows and U-boot for initialising the USB devices. While analysing the behaviour of U-boot it turned out that U-boot does things really different, and some are wrong (compared to the USB standard). This patch fixes some errors: * The NEW_init procedure that was already in the code is good, while the old procedure is wrong. See code comments for more info. * On a Control request the data returned by the device can be more than 8 bytes, while the host limits it to 8 bytes. This caused the host to generate a DataOverrun error. This results in a lot of USB sticks not being recognised, and the transmission ended frequently with a CTL:TIMEOUT Error. * Added a flag CONFIG_LEGACY_USB_INIT_SEQ to allow users to use the old init procedure. Signed-off-by: Remy Bohmer Signed-off-by: Markus Klotzbuecher --- common/usb.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index be81aaf..db65d7d 100644 --- a/common/usb.c +++ b/common/usb.c @@ -80,7 +80,8 @@ void usb_scan_devices(void); int usb_hub_probe(struct usb_device *dev, int ifnum); void usb_hub_reset(void); - +static int hub_port_reset(struct usb_device *dev, int port, + unsigned short *portstat); /*********************************************************************** * wait_ms @@ -765,20 +766,34 @@ int usb_new_device(struct usb_device *dev) int tmp; unsigned char tmpbuf[USB_BUFSIZ]; - dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */ - dev->maxpacketsize = 0; /* Default to 8 byte max packet size */ - dev->epmaxpacketin [0] = 8; - dev->epmaxpacketout[0] = 8; - /* We still haven't set the Address yet */ addr = dev->devnum; dev->devnum = 0; -#undef NEW_INIT_SEQ -#ifdef NEW_INIT_SEQ +#ifdef CONFIG_LEGACY_USB_INIT_SEQ + /* this is the old and known way of initializing devices, it is + * different than what Windows and Linux are doing. Windows and Linux + * both retrieve 64 bytes while reading the device descriptor + * Several USB stick devices report ERR: CTL_TIMEOUT, caused by an + * invalid header while reading 8 bytes as device descriptor. */ + dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */ + dev->maxpacketsize = 0; /* Default to 8 byte max packet size */ + dev->epmaxpacketin [0] = 8; + dev->epmaxpacketout[0] = 8; + + err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8); + if (err < 8) { + printf("\n USB device not responding, " \ + "giving up (status=%lX)\n",dev->status); + return 1; + } +#else /* this is a Windows scheme of initialization sequence, with double - * reset of the device. Some equipment is said to work only with such - * init sequence; this patch is based on the work by Alan Stern: + * reset of the device (Linux uses the same sequence, but without double + * reset. This double reset is not considered harmful and matches the + * Windows behaviour) + * Some equipment is said to work only with such init sequence; this + * patch is based on the work by Alan Stern: * http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398 */ int j; @@ -790,10 +805,13 @@ int usb_new_device(struct usb_device *dev) /* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is * only 18 bytes long, this will terminate with a short packet. But if * the maxpacket size is 8 or 16 the device may be waiting to transmit - * some more. */ + * some more, or keeps on retransmitting the 8 byte header. */ desc = (struct usb_device_descriptor *)tmpbuf; - desc->bMaxPacketSize0 = 0; + dev->descriptor.bMaxPacketSize0 = 64; /* Start off at 64 bytes */ + dev->maxpacketsize = 64; /* Default to 64 byte max packet size */ + dev->epmaxpacketin [0] = 64; + dev->epmaxpacketout[0] = 64; for (j = 0; j < 3; ++j) { err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); if (err < 0) { @@ -824,14 +842,6 @@ int usb_new_device(struct usb_device *dev) return 1; } } -#else - /* and this is the old and known way of initializing devices */ - err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8); - if (err < 8) { - printf("\n USB device not responding, " \ - "giving up (status=%lX)\n", dev->status); - return 1; - } #endif dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0; -- cgit v1.1 From d977a57356657ba241256231efca32828a5822f9 Mon Sep 17 00:00:00 2001 From: Luigi 'Comio' Mantellini Date: Sat, 13 Sep 2008 10:04:32 +0200 Subject: Fix lzma uncompress call (image_start wrongly used instead image_len) Signed-off-by: Luigi 'Comio' Mantellini --- common/cmd_bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 19257bb..897e9f6 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -347,7 +347,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) int ret = lzmaBuffToBuffDecompress( (unsigned char *)load, &unc_len, - (unsigned char *)image_start, image_start); + (unsigned char *)image_start, image_len); if (ret != LZMA_RESULT_OK) { printf ("LZMA: uncompress or overwrite error %d " "- must RESET board to recover\n", ret); -- cgit v1.1 From d5fd0b49210c941de8a1fce3947ace92243ab5ca Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 14 Oct 2008 07:05:24 -0400 Subject: strings cmd: drop old CONFIG_CFG_STRINGS define We don't need CONFIG_CFG_STRINGS anymore now that we have the define CONFIG_CMD_STRINGS and Makefile control. Signed-off-by: Mike Frysinger --- common/cmd_strings.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'common') diff --git a/common/cmd_strings.c b/common/cmd_strings.c index bbf56a0..db54f29 100644 --- a/common/cmd_strings.c +++ b/common/cmd_strings.c @@ -10,8 +10,6 @@ #include #include -#ifdef CONFIG_CFG_STRINGS - static char *start_addr, *last_addr; int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) @@ -45,5 +43,3 @@ U_BOOT_CMD(strings, 3, 1, do_strings, "strings - display strings\n", " [byte count]\n" " - display strings at for at least [byte count] or first double NUL\n"); - -#endif -- cgit v1.1 From c46980f6d2135ade345dadc1fb1f1f4c8bbf255a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 14 Oct 2008 07:04:38 -0400 Subject: cmd_spi: remove broken signed casting for display Since we're working with unsigned data, you can't apply a signed pointer cast and then attempt to print the result. Otherwise you get wrong output when the sign bit is set like "0xFF" incorrectly extended to "0xFFFFFFFF". Signed-off-by: Mike Frysinger --- common/cmd_spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_spi.c b/common/cmd_spi.c index 40ee7e7..1f0727b 100644 --- a/common/cmd_spi.c +++ b/common/cmd_spi.c @@ -123,9 +123,8 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf("Error with the SPI transaction.\n"); rcode = 1; } else { - cp = (char *)din; for(j = 0; j < ((bitlen + 7) / 8); j++) { - printf("%02X", *cp++); + printf("%02X", din[j]); } printf("\n"); } -- cgit v1.1 From 48867208444cb2a82e2af9c3249e90b7ed4a1751 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Fri, 10 Oct 2008 10:23:21 +0200 Subject: fix USB initialisation procedure The max packet size is encoded as 0,1,2,3 for 8,16,32,64 bytes. At some places directly 8,16,32,64 was used instead of the encoded value. Made a enum for the options to make this more clear and to help preventing similar errors in the future. After fixing this bug it became clear that another bug existed where the 'pipe' is and-ed with PIPE_* flags, where it should have been 'usb_pipetype(pipe)', or even better usb_pipeint(pipe). Also removed the triple 'get_device_descriptor' sequence, it has no use, and Windows nor Linux behaves that way. There is also a poll going on with a timeout when usb_control_msg() fails. However, the poll is useless, because the flag will never be set on a error, because there is no code that runs in a parallel that can set this flag. Changed this to something more logical. Tested on AT91SAM9261ek and compared the flow on the USB bus to what Linux is doing. There is no difference anymore in the early initialisation sequence. Signed-off-by: Remy Bohmer Signed-off-by: Markus Klotzbuecher --- common/usb.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index db65d7d..7ab5df6 100644 --- a/common/usb.c +++ b/common/usb.c @@ -196,15 +196,16 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, if (timeout == 0) return (int)size; - while (timeout--) { - if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) - break; - wait_ms(1); - } - if (dev->status == 0) - return dev->act_len; - else + if (dev->status != 0) { + /* + * Let's wait a while for the timeout to elapse. + * It has no real use, but it keeps the interface happy. + */ + wait_ms(timeout); return -1; + } + + return dev->act_len; } /*------------------------------------------------------------------- @@ -442,14 +443,14 @@ int usb_get_configuration_no(struct usb_device *dev, config = (struct usb_config_descriptor *)&buffer[0]; - result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8); - if (result < 8) { + result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9); + if (result < 9) { if (result < 0) printf("unable to get descriptor, error %lX\n", dev->status); else printf("config descriptor too short " \ - "(expected %i, got %i)\n", 8, result); + "(expected %i, got %i)\n", 9, result); return -1; } tmp = le16_to_cpu(config->wTotalLength); @@ -777,7 +778,7 @@ int usb_new_device(struct usb_device *dev) * Several USB stick devices report ERR: CTL_TIMEOUT, caused by an * invalid header while reading 8 bytes as device descriptor. */ dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */ - dev->maxpacketsize = 0; /* Default to 8 byte max packet size */ + dev->maxpacketsize = PACKET_SIZE_8; dev->epmaxpacketin [0] = 8; dev->epmaxpacketout[0] = 8; @@ -788,15 +789,12 @@ int usb_new_device(struct usb_device *dev) return 1; } #else - /* this is a Windows scheme of initialization sequence, with double - * reset of the device (Linux uses the same sequence, but without double - * reset. This double reset is not considered harmful and matches the - * Windows behaviour) + /* This is a Windows scheme of initialization sequence, with double + * reset of the device (Linux uses the same sequence) * Some equipment is said to work only with such init sequence; this * patch is based on the work by Alan Stern: * http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398 */ - int j; struct usb_device_descriptor *desc; int port = -1; struct usb_device *parent = dev->parent; @@ -809,20 +807,22 @@ int usb_new_device(struct usb_device *dev) desc = (struct usb_device_descriptor *)tmpbuf; dev->descriptor.bMaxPacketSize0 = 64; /* Start off at 64 bytes */ - dev->maxpacketsize = 64; /* Default to 64 byte max packet size */ + /* Default to 64 byte max packet size */ + dev->maxpacketsize = PACKET_SIZE_64; dev->epmaxpacketin [0] = 64; dev->epmaxpacketout[0] = 64; - for (j = 0; j < 3; ++j) { - err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); - if (err < 0) { - USB_PRINTF("usb_new_device: 64 byte descr\n"); - break; - } + + err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); + if (err < 0) { + USB_PRINTF("usb_new_device: usb_get_descriptor() failed\n"); + return 1; } + dev->descriptor.bMaxPacketSize0 = desc->bMaxPacketSize0; /* find the port number we're at */ if (parent) { + int j; for (j = 0; j < parent->maxchild; j++) { if (parent->children[j] == dev) { @@ -847,10 +847,10 @@ int usb_new_device(struct usb_device *dev) dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0; dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0; switch (dev->descriptor.bMaxPacketSize0) { - case 8: dev->maxpacketsize = 0; break; - case 16: dev->maxpacketsize = 1; break; - case 32: dev->maxpacketsize = 2; break; - case 64: dev->maxpacketsize = 3; break; + case 8: dev->maxpacketsize = PACKET_SIZE_8; break; + case 16: dev->maxpacketsize = PACKET_SIZE_16; break; + case 32: dev->maxpacketsize = PACKET_SIZE_32; break; + case 64: dev->maxpacketsize = PACKET_SIZE_64; break; } dev->devnum = addr; -- cgit v1.1 From 9bc2e4eee3bcb8e63847d7a733e0c607807d6141 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Wed, 1 Oct 2008 12:25:04 -0500 Subject: cmd_i2c: Fix help for CONFIG_I2C_CMD_TREE && !CONFIG_I2C_MULTI_BUS Original code displayed: => help i2c i2c i2c speed [speed] - show or set I2C bus speed i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device ... Signed-off-by: Peter Tyser --- common/cmd_i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index ef3928e..ea80e8a 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1220,12 +1220,12 @@ int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { + if (!strncmp(argv[1], "sp", 2)) + return do_i2c_bus_speed(cmdtp, flag, --argc, ++argv); #if defined(CONFIG_I2C_MULTI_BUS) if (!strncmp(argv[1], "de", 2)) return do_i2c_bus_num(cmdtp, flag, --argc, ++argv); #endif /* CONFIG_I2C_MULTI_BUS */ - if (!strncmp(argv[1], "sp", 2)) - return do_i2c_bus_speed(cmdtp, flag, --argc, ++argv); if (!strncmp(argv[1], "md", 2)) return do_i2c_md(cmdtp, flag, --argc, ++argv); if (!strncmp(argv[1], "mm", 2)) @@ -1256,10 +1256,10 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( i2c, 6, 1, do_i2c, "i2c - I2C sub-system\n", + "speed [speed] - show or set I2C bus speed\n" #if defined(CONFIG_I2C_MULTI_BUS) - "dev [dev] - show or set current I2C bus\n" + "i2c dev [dev] - show or set current I2C bus\n" #endif /* CONFIG_I2C_MULTI_BUS */ - "i2c speed [speed] - show or set I2C bus speed\n" "i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device\n" "i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)\n" "i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)\n" -- cgit v1.1 From c68a05feeb88de9fcf158e67ff6423c4cc988f88 Mon Sep 17 00:00:00 2001 From: richardretanubun Date: Mon, 29 Sep 2008 18:28:23 -0400 Subject: Adds two more ethernet interface to 83xx Added as a convenience for other platforms that uses MPC8360 (has 8 UCC). Six eth interface is chosen because the platform I am using combines UCC1&2 and UCC3&4 as 1000 Eth and the other four UCCs as 10/100 Eth. Signed-off-by: Richard Retanubun Signed-off-by: Ben Warren --- common/cmd_bdinfo.c | 14 ++++++++++++++ common/env_common.c | 6 ++++++ common/env_embedded.c | 6 ++++++ 3 files changed, 26 insertions(+) (limited to 'common') diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index f4d9d40..5018930 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -117,6 +117,20 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif +#if defined(CONFIG_HAS_ETH4) + puts ("\neth4addr ="); + for (i=0; i<6; ++i) { + printf ("%c%02X", i ? ':' : ' ', bd->bi_enet4addr[i]); + } +#endif + +#if defined(CONFIG_HAS_ETH5) + puts ("\neth5addr ="); + for (i=0; i<6; ++i) { + printf ("%c%02X", i ? ':' : ' ', bd->bi_enet5addr[i]); + } +#endif + #ifdef CONFIG_HERMES print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed)); #endif diff --git a/common/env_common.c b/common/env_common.c index 77f9944..0fee3af 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -91,6 +91,12 @@ uchar default_environment[] = { #ifdef CONFIG_ETH3ADDR "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" #endif +#ifdef CONFIG_ETH4ADDR + "eth4addr=" MK_STR(CONFIG_ETH4ADDR) "\0" +#endif +#ifdef CONFIG_ETH5ADDR + "eth5addr=" MK_STR(CONFIG_ETH5ADDR) "\0" +#endif #ifdef CONFIG_IPADDR "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" #endif diff --git a/common/env_embedded.c b/common/env_embedded.c index 77e5619..e79f843 100644 --- a/common/env_embedded.c +++ b/common/env_embedded.c @@ -135,6 +135,12 @@ env_t environment __PPCENV__ = { #ifdef CONFIG_ETH3ADDR "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" #endif +#ifdef CONFIG_ETH4ADDR + "eth4addr=" MK_STR(CONFIG_ETH4ADDR) "\0" +#endif +#ifdef CONFIG_ETH5ADDR + "eth5addr=" MK_STR(CONFIG_ETH5ADDR) "\0" +#endif #ifdef CONFIG_ETHPRIME "ethprime=" CONFIG_ETHPRIME "\0" #endif -- cgit v1.1 From 3f0cf51dabacc2724731c5079a60ea989103bb8f Mon Sep 17 00:00:00 2001 From: Bartlomiej Sieka Date: Wed, 1 Oct 2008 15:26:27 +0200 Subject: flash: factor out adjusting of Flash address to the end of sector The upcoming automatic update feature needs the ability to adjust an address within Flash to the end of its respective sector. Factor out this functionality to a new function flash_sect_roundb(). Signed-off-by: Rafal Czubak Signed-off-by: Bartlomiej Sieka Signed-off-by: Stefan Roese --- common/cmd_flash.c | 75 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'common') diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 18d2250..29e5b6d 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -105,6 +105,47 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl) } /* + * Take *addr in Flash and adjust it to fall on the end of its sector + */ +int flash_sect_roundb (ulong *addr) +{ + flash_info_t *info; + ulong bank, sector_end_addr; + char found; + int i; + + /* find the end addr of the sector where the *addr is */ + found = 0; + for (bank = 0; bank < CFG_MAX_FLASH_BANKS && !found; ++bank) { + info = &flash_info[bank]; + for (i = 0; i < info->sector_count && !found; ++i) { + /* get the end address of the sector */ + if (i == info->sector_count - 1) { + sector_end_addr = info->start[0] + + info->size - 1; + } else { + sector_end_addr = info->start[i+1] - 1; + } + + if (*addr <= sector_end_addr && + *addr >= info->start[i]) { + found = 1; + /* adjust *addr if necessary */ + if (*addr < sector_end_addr) + *addr = sector_end_addr; + } /* sector */ + } /* bank */ + } + if (!found) { + /* error, addres not in flash */ + printf("Error: end address (0x%08lx) not in flash!\n", *addr); + return 1; + } + + return 0; +} + +/* * This function computes the start and end addresses for both * erase and protect commands. The range of the addresses on which * either of the commands is to operate can be given in two forms: @@ -126,8 +167,6 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) { char *ep; char len_used; /* indicates if the "start +length" form used */ - char found; - ulong bank; *addr_first = simple_strtoul(arg1, &ep, 16); if (ep == arg1 || *ep != '\0') @@ -157,38 +196,8 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) * sector boundary, so that the commands don't fail later on. */ - /* find the end addr of the sector where the *addr_last is */ - found = 0; - for (bank = 0; bank < CFG_MAX_FLASH_BANKS && !found; ++bank){ - int i; - flash_info_t *info = &flash_info[bank]; - for (i = 0; i < info->sector_count && !found; ++i){ - /* get the end address of the sector */ - ulong sector_end_addr; - if (i == info->sector_count - 1){ - sector_end_addr = - info->start[0] + info->size - 1; - } else { - sector_end_addr = - info->start[i+1] - 1; - } - if (*addr_last <= sector_end_addr && - *addr_last >= info->start[i]){ - /* sector found */ - found = 1; - /* adjust *addr_last if necessary */ - if (*addr_last < sector_end_addr){ - *addr_last = sector_end_addr; - } - } - } /* sector */ - } /* bank */ - if (!found){ - /* error, addres not in flash */ - printf("Error: end address (0x%08lx) not in flash!\n", - *addr_last); + if (flash_sect_roundb(addr_last) > 0) return -1; - } } /* "start +length" from used */ return 1; -- cgit v1.1 From 4bae90904b69ce3deb9f7c334ef12ed74e18a275 Mon Sep 17 00:00:00 2001 From: Bartlomiej Sieka Date: Wed, 1 Oct 2008 15:26:31 +0200 Subject: Automatic software update from TFTP server The auto-update feature allows to automatically download software updates from a TFTP server and store them in Flash memory during boot. Updates are contained in a FIT file and protected with SHA-1 checksum. More detailed description can be found in doc/README.update. Signed-off-by: Rafal Czubak Signed-off-by: Bartlomiej Sieka --- common/Makefile | 1 + common/main.c | 7 ++ common/update.c | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100644 common/update.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 8bddf8e..f00cbd9 100644 --- a/common/Makefile +++ b/common/Makefile @@ -153,6 +153,7 @@ COBJS-y += flash.o COBJS-y += kgdb.o COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o +COBJS-$(CONFIG_UPDATE_TFTP) += update.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o diff --git a/common/main.c b/common/main.c index 187ef8a..c06ea07 100644 --- a/common/main.c +++ b/common/main.c @@ -56,6 +56,9 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /* fo extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); +#if defined(CONFIG_UPDATE_TFTP) +void update_tftp (void); +#endif /* CONFIG_UPDATE_TFTP */ #define MAX_DELAY_STOP_STR 32 @@ -301,6 +304,10 @@ void main_loop (void) trab_vfd (bmp); #endif /* CONFIG_VFD && VFD_TEST_LOGO */ +#if defined(CONFIG_UPDATE_TFTP) + update_tftp (); +#endif /* CONFIG_UPDATE_TFTP */ + #ifdef CONFIG_BOOTCOUNT_LIMIT bootcount = bootcount_load(); bootcount++; diff --git a/common/update.c b/common/update.c new file mode 100644 index 0000000..938cc06 --- /dev/null +++ b/common/update.c @@ -0,0 +1,315 @@ +/* + * (C) Copyright 2008 Semihalf + * + * Written by: Rafal Czubak + * Bartlomiej Sieka + * + * 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 + * + */ + +#include + +#if !(defined(CONFIG_FIT) && defined(CONFIG_OF_LIBFDT)) +#error "CONFIG_FIT and CONFIG_OF_LIBFDT are required for auto-update feature" +#endif + +#if defined(CFG_NO_FLASH) +#error "CFG_NO_FLASH defined, but FLASH is required for auto-update feature" +#endif + +#include +#include +#include +#include + +/* env variable holding the location of the update file */ +#define UPDATE_FILE_ENV "updatefile" + +/* set configuration defaults if needed */ +#ifndef CONFIG_UPDATE_LOAD_ADDR +#define CONFIG_UPDATE_LOAD_ADDR 0x100000 +#endif + +#ifndef CONFIG_UPDATE_TFTP_MSEC_MAX +#define CONFIG_UPDATE_TFTP_MSEC_MAX 100 +#endif + +#ifndef CONFIG_UPDATE_TFTP_CNT_MAX +#define CONFIG_UPDATE_TFTP_CNT_MAX 0 +#endif + +extern ulong TftpRRQTimeoutMSecs; +extern int TftpRRQTimeoutCountMax; +extern flash_info_t flash_info[]; +extern ulong load_addr; + +static uchar *saved_prot_info; + +static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr) +{ + int size, rv; + ulong saved_timeout_msecs; + int saved_timeout_count; + char *saved_netretry, *saved_bootfile; + + rv = 0; + /* save used globals and env variable */ + saved_timeout_msecs = TftpRRQTimeoutMSecs; + saved_timeout_count = TftpRRQTimeoutCountMax; + saved_netretry = strdup(getenv("netretry")); + saved_bootfile = strdup(BootFile); + + /* set timeouts for auto-update */ + TftpRRQTimeoutMSecs = msec_max; + TftpRRQTimeoutCountMax = cnt_max; + + /* we don't want to retry the connection if errors occur */ + setenv("netretry", "no"); + + /* download the update file */ + load_addr = addr; + copy_filename(BootFile, filename, sizeof(BootFile)); + size = NetLoop(TFTP); + + if (size < 0) + rv = 1; + else if (size > 0) + flush_cache(addr, size); + + /* restore changed globals and env variable */ + TftpRRQTimeoutMSecs = saved_timeout_msecs; + TftpRRQTimeoutCountMax = saved_timeout_count; + + setenv("netretry", saved_netretry); + if (saved_netretry != NULL) + free(saved_netretry); + + if (saved_bootfile != NULL) { + copy_filename(BootFile, saved_bootfile, sizeof(BootFile)); + free(saved_bootfile); + } + + return rv; +} + +static int update_flash_protect(int prot, ulong addr_first, ulong addr_last) +{ + uchar *sp_info_ptr; + ulong s; + int i, bank, cnt; + flash_info_t *info; + + sp_info_ptr = NULL; + + if (prot == 0) { + saved_prot_info = + calloc(CFG_MAX_FLASH_BANKS * CFG_MAX_FLASH_SECT, 1); + if (!saved_prot_info) + return 1; + } + + for (bank = 0; bank < CFG_MAX_FLASH_BANKS; ++bank) { + cnt = 0; + info = &flash_info[bank]; + + /* Nothing to do if the bank doesn't exist */ + if (info->sector_count == 0) + return 0; + + /* Point to current bank protection information */ + sp_info_ptr = saved_prot_info + (bank * CFG_MAX_FLASH_SECT); + + /* + * Adjust addr_first or addr_last if we are on bank boundary. + * Address space between banks must be continuous for other + * flash functions (like flash_sect_erase or flash_write) to + * succeed. Banks must also be numbered in correct order, + * according to increasing addresses. + */ + if (addr_last > info->start[0] + info->size - 1) + addr_last = info->start[0] + info->size - 1; + if (addr_first < info->start[0]) + addr_first = info->start[0]; + + for (i = 0; i < info->sector_count; i++) { + /* Save current information about protected sectors */ + if (prot == 0) { + s = info->start[i]; + if ((s >= addr_first) && (s <= addr_last)) + sp_info_ptr[i] = info->protect[i]; + + } + + /* Protect/unprotect sectors */ + if (sp_info_ptr[i] == 1) { +#if defined(CFG_FLASH_PROTECTION) + if (flash_real_protect(info, i, prot)) + return 1; +#else + info->protect[i] = prot; +#endif + cnt++; + } + } + + if (cnt) { + printf("%sProtected %d sectors\n", + prot ? "": "Un-", cnt); + } + } + + if((prot == 1) && saved_prot_info) + free(saved_prot_info); + + return 0; +} + +static int update_flash(ulong addr_source, ulong addr_first, ulong size) +{ + ulong addr_last = addr_first + size - 1; + + /* round last address to the sector boundary */ + if (flash_sect_roundb(&addr_last) > 0) + return 1; + + if (addr_first >= addr_last) { + printf("Error: end address exceeds addressing space\n"); + return 1; + } + + /* remove protection on processed sectors */ + if (update_flash_protect(0, addr_first, addr_last) > 0) { + printf("Error: could not unprotect flash sectors\n"); + return 1; + } + + printf("Erasing 0x%08lx - 0x%08lx", addr_first, addr_last); + if (flash_sect_erase(addr_first, addr_last) > 0) { + printf("Error: could not erase flash\n"); + return 1; + } + + printf("Copying to flash..."); + if (flash_write((char *)addr_source, addr_first, size) > 0) { + printf("Error: could not copy to flash\n"); + return 1; + } + printf("done\n"); + + /* enable protection on processed sectors */ + if (update_flash_protect(1, addr_first, addr_last) > 0) { + printf("Error: could not protect flash sectors\n"); + return 1; + } + + return 0; +} + +static int update_fit_getparams(const void *fit, int noffset, ulong *addr, + ulong *fladdr, ulong *size) +{ + const void *data; + + if (fit_image_get_data(fit, noffset, &data, (size_t *)size)) + return 1; + + if (fit_image_get_load(fit, noffset, (ulong *)fladdr)) + return 1; + + *addr = (ulong)data; + + return 0; +} + +void update_tftp(void) +{ + char *filename, *env_addr; + int images_noffset, ndepth, noffset; + ulong update_addr, update_fladdr, update_size; + ulong addr; + void *fit; + + printf("Auto-update from TFTP: "); + + /* get the file name of the update file */ + filename = getenv(UPDATE_FILE_ENV); + if (filename == NULL) { + printf("failed, env. variable '%s' not found\n", + UPDATE_FILE_ENV); + return; + } + + printf("trying update file '%s'\n", filename); + + /* get load address of downloaded update file */ + if ((env_addr = getenv("loadaddr")) != NULL) + addr = simple_strtoul(env_addr, NULL, 16); + else + addr = CONFIG_UPDATE_LOAD_ADDR; + + + if (update_load(filename, CONFIG_UPDATE_TFTP_MSEC_MAX, + CONFIG_UPDATE_TFTP_CNT_MAX, addr)) { + printf("Can't load update file, aborting auto-update\n"); + return; + } + + fit = (void *)addr; + + if (!fit_check_format((void *)fit)) { + printf("Bad FIT format of the update file, aborting " + "auto-update\n"); + return; + } + + /* process updates */ + images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); + + ndepth = 0; + noffset = fdt_next_node(fit, images_noffset, &ndepth); + while (noffset >= 0 && ndepth > 0) { + if (ndepth != 1) + goto next_node; + + printf("Processing update '%s' :", + fit_get_name(fit, noffset, NULL)); + + if (!fit_image_check_hashes(fit, noffset)) { + printf("Error: invalid update hash, aborting\n"); + goto next_node; + } + + printf("\n"); + if (update_fit_getparams(fit, noffset, &update_addr, + &update_fladdr, &update_size)) { + printf("Error: can't get update parameteres, " + "aborting\n"); + goto next_node; + } + if (update_flash(update_addr, update_fladdr, update_size)) { + printf("Error: can't flash update, aborting\n"); + goto next_node; + } +next_node: + noffset = fdt_next_node(fit, noffset, &ndepth); + } + + return; +} -- cgit v1.1 From fbc87dc0546dff709b38f358e2c5d5e39c4ca374 Mon Sep 17 00:00:00 2001 From: Bartlomiej Sieka Date: Wed, 1 Oct 2008 15:26:32 +0200 Subject: FIT: output image load address for type 'firmware', fix message while there Now that the auto-update feature uses the 'firmware' type for updates, it is useful to inspect the load address of such images. Signed-off-by: Bartlomiej Sieka --- common/image.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/image.c b/common/image.c index dc8d7dd..0b7bd8d 100644 --- a/common/image.c +++ b/common/image.c @@ -1852,7 +1852,10 @@ void fit_print_contents (const void *fit) * @p: pointer to prefix string * * fit_image_print() lists all mandatory properies for the processed component - * image. If present, hash nodes are printed out as well. + * image. If present, hash nodes are printed out as well. Load + * address for images of type firmware is also printed out. Since the load + * address is not mandatory for firmware images, it will be output as + * "unavailable" when not present. * * returns: * no returned results @@ -1911,14 +1914,17 @@ void fit_image_print (const void *fit, int image_noffset, const char *p) printf ("%s OS: %s\n", p, genimg_get_os_name (os)); } - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE)) { + if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) || + (type == IH_TYPE_FIRMWARE)) { ret = fit_image_get_load (fit, image_noffset, &load); printf ("%s Load Address: ", p); if (ret) printf ("unavailable\n"); else printf ("0x%08lx\n", load); + } + if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE)) { fit_image_get_entry (fit, image_noffset, &entry); printf ("%s Entry Point: ", p); if (ret) @@ -2844,7 +2850,7 @@ int fit_check_format (const void *fit) #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) /* mandatory / node 'timestamp' property */ if (fdt_getprop (fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) { - debug ("Wrong FIT format: no description\n"); + debug ("Wrong FIT format: no timestamp\n"); return 0; } #endif -- cgit v1.1 From fbd85ad65dd9c98f36ed3fb12fe41f381b7d4794 Mon Sep 17 00:00:00 2001 From: richardretanubun Date: Mon, 6 Oct 2008 16:10:53 -0400 Subject: CONFIG_EFI_PARTITION: Added support for EFI partition in cmd_ext2fs.c Added support for CONFIG_EFI_PARTITION to ext2 commands. Signed-off-by: Richard Retanubun --- common/cmd_ext2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index f569406..cfd4f64 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -44,8 +44,8 @@ #include #endif -#ifndef CONFIG_DOS_PARTITION -#error DOS partition support must be selected +#if !defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_EFI_PARTITION) +#error DOS or EFI partition support must be selected #endif /* #define EXT2_DEBUG */ -- cgit v1.1 From e43a27c49712203fe8848a17714330623edfb2eb Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 15 Oct 2008 09:33:30 +0200 Subject: I2C: add new command i2c reset. If I2C Bus is blocked (see doc/I2C_Edge_Conditions), it is not possible to get out of this, until the complete Hardware gets a reset. This new commando calls again i2c_init (and that calls i2c_init_board if defined), which will deblock the I2C Bus. Signed-off-by: Heiko Schocher Signed-off-by: Wolfgang Denk --- common/cmd_i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index ea80e8a..ef9123e 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1182,6 +1182,12 @@ int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #endif #if defined(CONFIG_I2C_CMD_TREE) +int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) +{ + i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + return 0; +} + #if defined(CONFIG_I2C_MULTI_BUS) int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { @@ -1238,6 +1244,8 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return do_i2c_crc(cmdtp, flag, --argc, ++argv); if (!strncmp(argv[1], "pr", 2)) return do_i2c_probe(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[1], "re", 2)) + return do_i2c_reset(cmdtp, flag, --argc, ++argv); if (!strncmp(argv[1], "lo", 2)) return do_i2c_loop(cmdtp, flag, --argc, ++argv); #if defined(CONFIG_CMD_SDRAM) @@ -1266,6 +1274,7 @@ U_BOOT_CMD( "i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)\n" "i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n" "i2c probe - show devices on the I2C bus\n" + "i2c reset - re-init the I2C Controller\n" "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n" #if defined(CONFIG_CMD_SDRAM) "i2c sdram chip - print SDRAM configuration information\n" -- cgit v1.1 From 67b23a322848d828a5e45c0567b72762bfde7abf Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 15 Oct 2008 09:39:47 +0200 Subject: I2C: adding new "i2c bus" Command to the I2C Subsystem. With this Command it is possible to add new I2C Busses, which are behind 1 .. n I2C Muxes. Details see README. Signed-off-by: Heiko Schocher --- common/cmd_i2c.c | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index ef9123e..8d287fe 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -83,7 +83,9 @@ #include #include +#include #include +#include #include /* Display values from last command. @@ -125,6 +127,14 @@ static uchar i2c_no_probes[] = CFG_I2C_NOPROBES; #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0])) #endif +#if defined(CONFIG_I2C_MUX) +static I2C_MUX_DEVICE *i2c_mux_devices = NULL; +static int i2c_mux_busid = CFG_MAX_I2C_BUS; + +DECLARE_GLOBAL_DATA_PTR; + +#endif + static int mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]); @@ -1188,6 +1198,37 @@ int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 0; } +#if defined(CONFIG_I2C_MUX) +int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) +{ + int ret=0; + + if (argc == 1) { + /* show all busses */ + I2C_MUX *mux; + I2C_MUX_DEVICE *device = i2c_mux_devices; + + printf ("Busses reached over muxes:\n"); + while (device != NULL) { + printf ("Bus ID: %x\n", device->busid); + printf (" reached over Mux(es):\n"); + mux = device->mux; + while (mux != NULL) { + printf (" %s@%x ch: %x\n", mux->name, mux->chip, mux->channel); + mux = mux->next; + } + device = device->next; + } + } else { + I2C_MUX_DEVICE *dev; + + dev = i2c_mux_ident_muxstring ((uchar *)argv[1]); + ret = 0; + } + return ret; +} +#endif /* CONFIG_I2C_MUX */ + #if defined(CONFIG_I2C_MULTI_BUS) int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { @@ -1226,6 +1267,10 @@ int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { +#if defined(CONFIG_I2C_MUX) + if (!strncmp(argv[1], "bu", 2)) + return do_i2c_add_bus(cmdtp, flag, --argc, ++argv); +#endif /* CONFIG_I2C_MUX */ if (!strncmp(argv[1], "sp", 2)) return do_i2c_bus_speed(cmdtp, flag, --argc, ++argv); #if defined(CONFIG_I2C_MULTI_BUS) @@ -1264,6 +1309,9 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( i2c, 6, 1, do_i2c, "i2c - I2C sub-system\n", +#if defined(CONFIG_I2C_MUX) + "bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes.\n" +#endif /* CONFIG_I2C_MUX */ "speed [speed] - show or set I2C bus speed\n" #if defined(CONFIG_I2C_MULTI_BUS) "i2c dev [dev] - show or set current I2C bus\n" @@ -1335,3 +1383,222 @@ U_BOOT_CMD( " (valid chip values 50..57)\n" ); #endif + +#if defined(CONFIG_I2C_MUX) + +int i2c_mux_add_device(I2C_MUX_DEVICE *dev) +{ + I2C_MUX_DEVICE *devtmp = i2c_mux_devices; + + if (i2c_mux_devices == NULL) { + i2c_mux_devices = dev; + return 0; + } + while (devtmp->next != NULL) + devtmp = devtmp->next; + + devtmp->next = dev; + return 0; +} + +I2C_MUX_DEVICE *i2c_mux_search_device(int id) +{ + I2C_MUX_DEVICE *device = i2c_mux_devices; + + while (device != NULL) { + if (device->busid == id) + return device; + device = device->next; + } + return NULL; +} + +/* searches in the buf from *pos the next ':'. + * returns: + * 0 if found (with *pos = where) + * < 0 if an error occured + * > 0 if the end of buf is reached + */ +static int i2c_mux_search_next (int *pos, uchar *buf, int len) +{ + while ((buf[*pos] != ':') && (*pos < len)) { + *pos += 1; + } + if (*pos >= len) + return 1; + if (buf[*pos] != ':') + return -1; + return 0; +} + +static int i2c_mux_get_busid (void) +{ + int tmp = i2c_mux_busid; + + i2c_mux_busid ++; + return tmp; +} + +/* Analyses a Muxstring and sends immediately the + Commands to the Muxes. Runs from Flash. + */ +int i2c_mux_ident_muxstring_f (uchar *buf) +{ + int pos = 0; + int oldpos; + int ret = 0; + int len = strlen((char *)buf); + int chip; + uchar channel; + int was = 0; + + while (ret == 0) { + oldpos = pos; + /* search name */ + ret = i2c_mux_search_next(&pos, buf, len); + if (ret != 0) + printf ("ERROR\n"); + /* search address */ + pos ++; + oldpos = pos; + ret = i2c_mux_search_next(&pos, buf, len); + if (ret != 0) + printf ("ERROR\n"); + buf[pos] = 0; + chip = simple_strtoul((char *)&buf[oldpos], NULL, 16); + buf[pos] = ':'; + /* search channel */ + pos ++; + oldpos = pos; + ret = i2c_mux_search_next(&pos, buf, len); + if (ret < 0) + printf ("ERROR\n"); + was = 0; + if (buf[pos] != 0) { + buf[pos] = 0; + was = 1; + } + channel = simple_strtoul((char *)&buf[oldpos], NULL, 16); + if (was) + buf[pos] = ':'; + if (i2c_write(chip, 0, 0, &channel, 1) != 0) { + printf ("Error setting Mux: chip:%x channel: \ + %x\n", chip, channel); + return -1; + } + pos ++; + oldpos = pos; + + } + + return 0; +} + +/* Analyses a Muxstring and if this String is correct + * adds a new I2C Bus. + */ +I2C_MUX_DEVICE *i2c_mux_ident_muxstring (uchar *buf) +{ + I2C_MUX_DEVICE *device; + I2C_MUX *mux; + int pos = 0; + int oldpos; + int ret = 0; + int len = strlen((char *)buf); + int was = 0; + + device = (I2C_MUX_DEVICE *)malloc (sizeof(I2C_MUX_DEVICE)); + device->mux = NULL; + device->busid = i2c_mux_get_busid (); + device->next = NULL; + while (ret == 0) { + mux = (I2C_MUX *)malloc (sizeof(I2C_MUX)); + mux->next = NULL; + /* search name of mux */ + oldpos = pos; + ret = i2c_mux_search_next(&pos, buf, len); + if (ret != 0) + printf ("%s no name.\n", __FUNCTION__); + mux->name = (char *)malloc (pos - oldpos + 1); + memcpy (mux->name, &buf[oldpos], pos - oldpos); + mux->name[pos - oldpos] = 0; + /* search address */ + pos ++; + oldpos = pos; + ret = i2c_mux_search_next(&pos, buf, len); + if (ret != 0) + printf ("%s no mux address.\n", __FUNCTION__); + buf[pos] = 0; + mux->chip = simple_strtoul((char *)&buf[oldpos], NULL, 16); + buf[pos] = ':'; + /* search channel */ + pos ++; + oldpos = pos; + ret = i2c_mux_search_next(&pos, buf, len); + if (ret < 0) + printf ("%s no mux channel.\n", __FUNCTION__); + was = 0; + if (buf[pos] != 0) { + buf[pos] = 0; + was = 1; + } + mux->channel = simple_strtoul((char *)&buf[oldpos], NULL, 16); + if (was) + buf[pos] = ':'; + if (device->mux == NULL) + device->mux = mux; + else { + I2C_MUX *muxtmp = device->mux; + while (muxtmp->next != NULL) { + muxtmp = muxtmp->next; + } + muxtmp->next = mux; + } + pos ++; + oldpos = pos; + } + if (ret > 0) { + /* Add Device */ + i2c_mux_add_device (device); + return device; + } + + return NULL; +} + +int i2x_mux_select_mux(int bus) +{ + I2C_MUX_DEVICE *dev; + I2C_MUX *mux; + + if ((gd->flags & GD_FLG_RELOC) != GD_FLG_RELOC) { + /* select Default Mux Bus */ +#if defined(CFG_I2C_IVM_BUS) + i2c_mux_ident_muxstring_f ((uchar *)CFG_I2C_IVM_BUS); +#else + { + unsigned char *buf; + buf = (unsigned char *) getenv("EEprom_ivm"); + if (buf != NULL) + i2c_mux_ident_muxstring_f (buf); + } +#endif + return 0; + } + dev = i2c_mux_search_device(bus); + if (dev == NULL) + return -1; + + mux = dev->mux; + while (mux != NULL) { + if (i2c_write(mux->chip, 0, 0, &mux->channel, 1) != 0) { + printf ("Error setting Mux: chip:%x channel: \ + %x\n", mux->chip, mux->channel); + return -1; + } + mux = mux->next; + } + return 0; +} +#endif /* CONFIG_I2C_MUX */ + -- cgit v1.1 From 81473f67810c4c9b7efaed8dee258ed6bc4c7983 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 15 Oct 2008 09:40:28 +0200 Subject: hush: add showvar command for hush shell. This new command shows the local variables defined in the hush shell: => help showvar showvar - print values of all hushshell variables showvar name ... - print value of hushshell variable 'name' Also make the set_local_var() and unset_local_var () no longer static, so it is possible to define local hush shell variables at boot time. If CONFIG_HUSH_INIT_VAR is defined, u-boot calls hush_init_var (), where boardspecific code can define local hush shell variables at boottime. Signed-off-by: Heiko Schocher --- common/hush.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- common/main.c | 4 ++++ 2 files changed, 56 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/hush.c b/common/hush.c index 093c428..67bed39 100644 --- a/common/hush.c +++ b/common/hush.c @@ -501,10 +501,6 @@ static void remove_bg_job(struct pipe *pi); static char **make_list_in(char **inp, char *name); static char *insert_var_value(char *inp); static char *get_local_var(const char *var); -#ifndef __U_BOOT__ -static void unset_local_var(const char *name); -#endif -static int set_local_var(const char *s, int flg_export); #ifndef __U_BOOT__ /* Table of built-in functions. They can be forked or not, depending on @@ -2204,7 +2200,7 @@ static char *get_local_var(const char *s) flg_export==0 if only local (not exporting) variable flg_export==1 if "new" exporting environ flg_export>1 if current startup environ (not call putenv()) */ -static int set_local_var(const char *s, int flg_export) +int set_local_var(const char *s, int flg_export) { char *name, *value; int result=0; @@ -2295,8 +2291,7 @@ static int set_local_var(const char *s, int flg_export) return result; } -#ifndef __U_BOOT__ -static void unset_local_var(const char *name) +void unset_local_var(const char *name) { struct variables *cur; @@ -2311,8 +2306,10 @@ static void unset_local_var(const char *name) error_msg("%s: readonly variable", name); return; } else { +#ifndef __U_BOOT__ if(cur->flg_export) unsetenv(cur->name); +#endif free(cur->name); free(cur->value); while (next->next != cur) @@ -2323,7 +2320,6 @@ static void unset_local_var(const char *name) } } } -#endif static int is_assignment(const char *s) { @@ -3588,5 +3584,53 @@ static char * make_string(char ** inp) return str; } +#ifdef __U_BOOT__ +int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i, k; + int rcode = 0; + struct variables *cur; + + if (argc == 1) { /* Print all env variables */ + for (cur = top_vars; cur; cur = cur->next) { + printf ("%s=%s\n", cur->name, cur->value); + if (ctrlc ()) { + puts ("\n ** Abort\n"); + return 1; + } + } + return 0; + } + for (i = 1; i < argc; ++i) { /* print single env variables */ + char *name = argv[i]; + + k = -1; + for (cur = top_vars; cur; cur = cur->next) { + if(strcmp (cur->name, name) == 0) { + k = 0; + printf ("%s=%s\n", cur->name, cur->value); + } + if (ctrlc ()) { + puts ("\n ** Abort\n"); + return 1; + } + } + if (k < 0) { + printf ("## Error: \"%s\" not defined\n", name); + rcode ++; + } + } + return rcode; +} + +U_BOOT_CMD( + showvar, CFG_MAXARGS, 1, do_showvar, + "showvar- print local hushshell variables\n", + "\n - print values of all hushshell variables\n" + "showvar name ...\n" + " - print value of hushshell variable 'name'\n" +); + +#endif #endif /* CFG_HUSH_PARSER */ /****************************************************************************/ diff --git a/common/main.c b/common/main.c index c06ea07..9a9fc9d 100644 --- a/common/main.c +++ b/common/main.c @@ -341,6 +341,10 @@ void main_loop (void) u_boot_hush_start (); #endif +#if defined(CONFIG_HUSH_INIT_VAR) + hush_init_var (); +#endif + #ifdef CONFIG_AUTO_COMPLETE install_auto_complete(); #endif -- cgit v1.1 From b799cb4c0eebb0762e91e9653d8b9cc9a98440e3 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 23 Sep 2008 10:05:02 -0500 Subject: Expose command table search for sub-commands Sub-command can benefit from using the same table and search functions that top level commands have. Expose this functionality by refactoring find_cmd() and introducing find_cmd_tbl() that sub-command processing can call. Signed-off-by: Kumar Gala --- common/command.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/command.c b/common/command.c index aca57b2..fc9d79c 100644 --- a/common/command.c +++ b/common/command.c @@ -341,10 +341,10 @@ cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = { /*************************************************************************** * find command table entry for a command */ -cmd_tbl_t *find_cmd (const char *cmd) +cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len) { cmd_tbl_t *cmdtp; - cmd_tbl_t *cmdtp_temp = &__u_boot_cmd_start; /*Init value */ + cmd_tbl_t *cmdtp_temp = table; /*Init value */ const char *p; int len; int n_found = 0; @@ -355,8 +355,8 @@ cmd_tbl_t *find_cmd (const char *cmd) */ len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd); - for (cmdtp = &__u_boot_cmd_start; - cmdtp != &__u_boot_cmd_end; + for (cmdtp = table; + cmdtp != table + table_len; cmdtp++) { if (strncmp (cmd, cmdtp->name, len) == 0) { if (len == strlen (cmdtp->name)) @@ -373,6 +373,12 @@ cmd_tbl_t *find_cmd (const char *cmd) return NULL; /* not found or ambiguous command */ } +cmd_tbl_t *find_cmd (const char *cmd) +{ + int len = &__u_boot_cmd_end - &__u_boot_cmd_start; + return find_cmd_tbl(cmd, &__u_boot_cmd_start, len); +} + #ifdef CONFIG_AUTO_COMPLETE int var_complete(int argc, char *argv[], char last_char, int maxv, char *cmdv[]) -- cgit v1.1 From 6d0f6bcf337c5261c08fabe12982178c2c489d76 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Thu, 16 Oct 2008 15:01:15 +0200 Subject: rename CFG_ macros to CONFIG_SYS Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/ACEX1K.c | 16 ++--- common/cmd_autoscript.c | 6 +- common/cmd_bdinfo.c | 30 +++++----- common/cmd_bedbug.c | 2 +- common/cmd_bmp.c | 10 ++-- common/cmd_boot.c | 2 +- common/cmd_bootm.c | 20 +++---- common/cmd_date.c | 2 +- common/cmd_diag.c | 2 +- common/cmd_display.c | 8 +-- common/cmd_doc.c | 30 +++++----- common/cmd_dtt.c | 2 +- common/cmd_eeprom.c | 86 +++++++++++++------------- common/cmd_elf.c | 8 +-- common/cmd_ext2.c | 2 +- common/cmd_fat.c | 2 +- common/cmd_fdc.c | 32 +++++----- common/cmd_fdos.c | 4 +- common/cmd_fdt.c | 4 +- common/cmd_flash.c | 104 ++++++++++++++++---------------- common/cmd_i2c.c | 28 ++++----- common/cmd_ide.c | 156 ++++++++++++++++++++++++------------------------ common/cmd_immap.c | 12 ++-- common/cmd_jffs2.c | 10 ++-- common/cmd_load.c | 40 ++++++------- common/cmd_log.c | 2 +- common/cmd_mem.c | 18 +++--- common/cmd_misc.c | 2 +- common/cmd_mp.c | 2 +- common/cmd_nand.c | 38 ++++++------ common/cmd_nvedit.c | 20 +++---- common/cmd_pci.c | 2 +- common/cmd_pcmcia.c | 4 +- common/cmd_reginfo.c | 6 +- common/cmd_reiser.c | 2 +- common/cmd_sata.c | 14 ++--- common/cmd_scsi.c | 20 +++---- common/cmd_usb.c | 2 +- common/command.c | 28 ++++----- common/console.c | 40 ++++++------- common/cyclon2.c | 16 ++--- common/devices.c | 14 ++--- common/env_common.c | 6 +- common/env_eeprom.c | 10 ++-- common/env_embedded.c | 8 +-- common/env_nvram.c | 14 ++--- common/flash.c | 14 ++--- common/hush.c | 16 ++--- common/image.c | 30 +++++----- common/kgdb.c | 2 +- common/lcd.c | 14 ++--- common/main.c | 44 +++++++------- common/miiphyutil.c | 2 +- common/serial.c | 14 ++--- common/spartan2.c | 44 +++++++------- common/spartan3.c | 44 +++++++------- common/update.c | 12 ++-- common/usb_kbd.c | 6 +- common/virtex2.c | 68 ++++++++++----------- 59 files changed, 598 insertions(+), 598 deletions(-) (limited to 'common') diff --git a/common/ACEX1K.c b/common/ACEX1K.c index 53677b8..3f79677 100644 --- a/common/ACEX1K.c +++ b/common/ACEX1K.c @@ -44,8 +44,8 @@ #define CONFIG_FPGA_DELAY() #endif -#ifndef CFG_FPGA_WAIT -#define CFG_FPGA_WAIT CFG_HZ/10 /* 100 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT +#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/10 /* 100 ms */ #endif static int ACEX1K_ps_load( Altera_desc *desc, void *buf, size_t bsize ); @@ -154,7 +154,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) "done:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->config, fn->status, fn->clk, fn->data, fn->done); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...", cookie); #endif @@ -185,7 +185,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) ts = get_timer (0); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for STATUS to go high.\n"); (*fn->abort) (cookie); return FPGA_FAIL; @@ -199,7 +199,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) /* Load the data */ while (bytecount < bsize) { unsigned char val=0; -#ifdef CFG_FPGA_CHECK_CTRLC +#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC if (ctrlc ()) { (*fn->abort) (cookie); return FPGA_FAIL; @@ -230,7 +230,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) i --; } while (i > 0); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -238,7 +238,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc (' '); /* terminate the dotted line */ #endif @@ -265,7 +265,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) ret_val = FPGA_SUCCESS; -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); } diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c index 0439da2..4517ac8 100644 --- a/common/cmd_autoscript.c +++ b/common/cmd_autoscript.c @@ -43,7 +43,7 @@ #if defined(CONFIG_8xx) #include #endif -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER #include #endif @@ -164,7 +164,7 @@ autoscript (ulong addr, const char *fit_uname) memmove (cmd, (char *)data, len); *(cmd + len) = 0; -#ifdef CFG_HUSH_PARSER /*?? */ +#ifdef CONFIG_SYS_HUSH_PARSER /*?? */ rcode = parse_string_outer (cmd, FLAG_PARSE_SEMICOLON); #else { @@ -211,7 +211,7 @@ do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* Find script image */ if (argc < 2) { - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; debug ("* autoscr: default load address = 0x%08lx\n", addr); #if defined(CONFIG_FIT) } else if (fit_parse_subimage (argv[1], load_addr, &addr, &fit_uname)) { diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 5018930..6675241 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -178,7 +178,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) print_num ("flash size", (ulong)bd->bi_flashsize); print_num ("flash offset", (ulong)bd->bi_flashoffset); -#if defined(CFG_SRAM_BASE) +#if defined(CONFIG_SYS_SRAM_BASE) print_num ("sram start", (ulong)bd->bi_sramstart); print_num ("sram size", (ulong)bd->bi_sramsize); #endif @@ -207,7 +207,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) print_num ("flash start ", (ulong)bd->bi_flashstart); print_num ("flash size ", (ulong)bd->bi_flashsize); print_num ("flash offset ", (ulong)bd->bi_flashoffset); -#if defined(CFG_SRAM_BASE) +#if defined(CONFIG_SYS_SRAM_BASE) print_num ("sram start ", (ulong)bd->bi_sramstart); print_num ("sram size ", (ulong)bd->bi_sramsize); #endif @@ -237,18 +237,18 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) print_num("memstart ", bd->bi_memstart); print_lnum("memsize ", bd->bi_memsize); print_num("flashstart ", bd->bi_flashstart); - print_num("CFG_MONITOR_BASE ", CFG_MONITOR_BASE); + print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE); print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR); - printf("CFG_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CFG_RELOC_MONITOR_BASE, - CFG_MONITOR_LEN); - printf("CFG_MALLOC_BASE = 0x%lx (%d)\n", CFG_MALLOC_BASE, - CFG_MALLOC_LEN); - printf("CFG_INIT_SP_OFFSET = 0x%lx (%d)\n", CFG_INIT_SP_OFFSET, - CFG_STACK_SIZE); - printf("CFG_PROM_OFFSET = 0x%lx (%d)\n", CFG_PROM_OFFSET, - CFG_PROM_SIZE); - printf("CFG_GBL_DATA_OFFSET = 0x%lx (%d)\n", CFG_GBL_DATA_OFFSET, - CFG_GBL_DATA_SIZE); + printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE, + CONFIG_SYS_MONITOR_LEN); + printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE, + CONFIG_SYS_MALLOC_LEN); + printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET, + CONFIG_SYS_STACK_SIZE); + printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET, + CONFIG_SYS_PROM_SIZE); + printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET, + CONFIG_SYS_GBL_DATA_SIZE); #if defined(CONFIG_CMD_NET) puts("ethaddr ="); @@ -276,11 +276,11 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) print_num ("flashstart", (ulong)bd->bi_flashstart); print_num ("flashsize", (ulong)bd->bi_flashsize); print_num ("flashoffset", (ulong)bd->bi_flashoffset); -#if defined(CFG_INIT_RAM_ADDR) +#if defined(CONFIG_SYS_INIT_RAM_ADDR) print_num ("sramstart", (ulong)bd->bi_sramstart); print_num ("sramsize", (ulong)bd->bi_sramsize); #endif -#if defined(CFG_MBAR) +#if defined(CONFIG_SYS_MBAR) print_num ("mbar", bd->bi_mbar_base); #endif print_str ("busfreq", strmhz(buf, bd->bi_busfreq)); diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c index 94f7e08..3e597f9 100644 --- a/common/cmd_bedbug.c +++ b/common/cmd_bedbug.c @@ -218,7 +218,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs) int flag; /* Command flags */ int rc = 0; /* Result from run_command */ char prompt_str[20]; /* Prompt string */ - static char lastcommand[CFG_CBSIZE] = { 0 }; /* previous command */ + static char lastcommand[CONFIG_SYS_CBSIZE] = { 0 }; /* previous command */ /* -------------------------------------------------- */ if (bug_ctx.clear) diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 197e5e8..bc08b26 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -55,19 +55,19 @@ static bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) /* * Decompress bmp image */ - len = CFG_VIDEO_LOGO_MAX_SIZE; - dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); + len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; + dst = malloc(CONFIG_SYS_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) { + if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { free(dst); return NULL; } - if (len == CFG_VIDEO_LOGO_MAX_SIZE) + if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) puts("Image could be truncated" - " (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); + " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); bmp = dst; diff --git a/common/cmd_boot.c b/common/cmd_boot.c index d83f5af..6024ffe 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -63,7 +63,7 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* -------------------------------------------------------------------- */ U_BOOT_CMD( - go, CFG_MAXARGS, 1, do_go, + go, CONFIG_SYS_MAXARGS, 1, do_go, "go - start application at address 'addr'\n", "addr [arg ...]\n - start application at address 'addr'\n" " passing 'arg' as arguments\n" diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 897e9f6..2a9c59f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -40,7 +40,7 @@ #include #endif -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER #include #endif @@ -60,8 +60,8 @@ DECLARE_GLOBAL_DATA_PTR; extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp); -#ifndef CFG_BOOTM_LEN -#define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */ +#ifndef CONFIG_SYS_BOOTM_LEN +#define CONFIG_SYS_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */ #endif #ifdef CONFIG_BZIP2 @@ -119,7 +119,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); static boot_os_fn do_bootm_integrity; #endif -ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ +ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */ void __board_lmb_reserve(struct lmb *lmb) @@ -289,7 +289,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) ulong blob_end = os.end; ulong image_start = os.image_start; ulong image_len = os.image_len; - uint unc_len = CFG_BOOTM_LEN; + uint unc_len = CONFIG_SYS_BOOTM_LEN; const char *type_name = genimg_get_type_name (os.type); @@ -329,7 +329,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) */ int i = BZ2_bzBuffToBuffDecompress ((char*)load, &unc_len, (char *)image_start, image_len, - CFG_MALLOC_LEN < (4096 * 1024), 0); + CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0); if (i != BZ_OK) { printf ("BUNZIP2: uncompress or overwrite error %d " "- must RESET board to recover\n", i); @@ -762,7 +762,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] } U_BOOT_CMD( - bootm, CFG_MAXARGS, 1, do_bootm, + bootm, CONFIG_SYS_MAXARGS, 1, do_bootm, "bootm - boot application image from memory\n", "[addr [arg ...]]\n - boot application image stored in memory\n" "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n" @@ -792,7 +792,7 @@ int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int rcode = 0; -#ifndef CFG_HUSH_PARSER +#ifndef CONFIG_SYS_HUSH_PARSER if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1; #else @@ -896,7 +896,7 @@ static int image_info (ulong addr) } U_BOOT_CMD( - iminfo, CFG_MAXARGS, 1, do_iminfo, + iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo, "iminfo - print header information for application image\n", "addr [addr ...]\n" " - print header information for application image starting at\n" @@ -917,7 +917,7 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) void *hdr; for (i = 0, info = &flash_info[0]; - i < CFG_MAX_FLASH_BANKS; ++i, ++info) { + i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) { if (info->flash_id == FLASH_UNKNOWN) goto next_bank; diff --git a/common/cmd_date.c b/common/cmd_date.c index d6cd565..b4d9649 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -47,7 +47,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* switch to correct I2C bus */ old_bus = I2C_GET_BUS(); - I2C_SET_BUS(CFG_RTC_BUS_NUM); + I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM); switch (argc) { case 2: /* set date & time */ diff --git a/common/cmd_diag.c b/common/cmd_diag.c index 82d5ad3..13d4225 100644 --- a/common/cmd_diag.c +++ b/common/cmd_diag.c @@ -65,7 +65,7 @@ int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /***************************************************/ U_BOOT_CMD( - diag, CFG_MAXARGS, 0, do_diag, + diag, CONFIG_SYS_MAXARGS, 0, do_diag, "diag - perform board diagnostics\n", " - print list of available tests\n" "diag [test1 [test2]]\n" diff --git a/common/cmd_display.c b/common/cmd_display.c index a29345c..982e09d 100644 --- a/common/cmd_display.c +++ b/common/cmd_display.c @@ -36,7 +36,7 @@ int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int pos; /* Clear display */ - *((volatile char*)(CFG_DISP_CWORD)) = CWORD_CLEAR; + *((volatile char*)(CONFIG_SYS_DISP_CWORD)) = CWORD_CLEAR; udelay(1000 * CLEAR_DELAY); if (argc < 2) @@ -46,14 +46,14 @@ int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) char *p = argv[i], c; if (i > 1) { - *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = ' '; + *((volatile uchar *) (CONFIG_SYS_DISP_CHR_RAM + pos++)) = ' '; #ifdef DEBUG_DISP putc(' '); #endif } while ((c = *p++) != '\0' && pos < DISP_SIZE) { - *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = c; + *((volatile uchar *) (CONFIG_SYS_DISP_CHR_RAM + pos++)) = c; #ifdef DEBUG_DISP putc(c); #endif @@ -70,7 +70,7 @@ int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /***************************************************/ U_BOOT_CMD( - display, CFG_MAXARGS, 1, do_display, + display, CONFIG_SYS_MAXARGS, 1, do_display, "display- display string on dot matrix display\n", "[]\n" " - with argument: display on dot matrix display\n" diff --git a/common/cmd_doc.c b/common/cmd_doc.c index a55ca41..02502cc 100644 --- a/common/cmd_doc.c +++ b/common/cmd_doc.c @@ -20,19 +20,19 @@ * TODO: must be implemented and tested by someone with HW */ #if 0 -#ifdef CFG_DOC_SUPPORT_2000 +#ifdef CONFIG_SYS_DOC_SUPPORT_2000 #define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k) #else #define DoC_is_2000(doc) (0) #endif -#ifdef CFG_DOC_SUPPORT_MILLENNIUM +#ifdef CONFIG_SYS_DOC_SUPPORT_MILLENNIUM #define DoC_is_Millennium(doc) (doc->ChipID == DOC_ChipID_DocMil) #else #define DoC_is_Millennium(doc) (0) #endif -/* CFG_DOC_PASSIVE_PROBE: +/* CONFIG_SYS_DOC_PASSIVE_PROBE: In order to ensure that the BIOS checksum is correct at boot time, and hence that the onboard BIOS extension gets executed, the DiskOnChip goes into reset mode when it is read sequentially: all registers @@ -48,7 +48,7 @@ the machine. If you have this problem, uncomment the following line: -#define CFG_DOC_PASSIVE_PROBE +#define CONFIG_SYS_DOC_PASSIVE_PROBE */ #undef DOC_DEBUG @@ -56,7 +56,7 @@ #undef PSYCHO_DEBUG #undef NFTL_DEBUG -static struct DiskOnChip doc_dev_desc[CFG_MAX_DOC_DEVICE]; +static struct DiskOnChip doc_dev_desc[CONFIG_SYS_MAX_DOC_DEVICE]; /* Current DOC Device */ static int curr_device = -1; @@ -104,7 +104,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) putc ('\n'); - for (i=0; i= CFG_MAX_DOC_DEVICE)) { + if ((curr_device < 0) || (curr_device >= CONFIG_SYS_MAX_DOC_DEVICE)) { puts ("\nno devices available\n"); return 1; } @@ -128,7 +128,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int dev = (int)simple_strtoul(argv[2], NULL, 10); printf ("\nDevice %d: ", dev); - if (dev >= CFG_MAX_DOC_DEVICE) { + if (dev >= CONFIG_SYS_MAX_DOC_DEVICE) { puts ("unknown device\n"); return 1; } @@ -218,7 +218,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) show_boot_progress (34); switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: @@ -250,7 +250,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dev = simple_strtoul(boot_device, &ep, 16); - if ((dev >= CFG_MAX_DOC_DEVICE) || + if ((dev >= CONFIG_SYS_MAX_DOC_DEVICE) || (doc_dev_desc[dev].ChipID == DOC_ChipID_UNKNOWN)) { printf ("\n** Device %d not available\n", dev); show_boot_progress (-37); @@ -439,7 +439,7 @@ static int _DoC_WaitReady(struct DiskOnChip *doc) /* Out-of-line routine to wait for chip response */ while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { -#ifdef CFG_DOC_SHORT_TIMEOUT +#ifdef CONFIG_SYS_DOC_SHORT_TIMEOUT /* it seems that after a certain time the DoC deasserts * the CDSN_CTRL_FR_B although it is not ready... * using a short timout solve this (timer increments every ms) */ @@ -1525,12 +1525,12 @@ static inline int doccheck(unsigned long potential, unsigned long physadr) /* Routine copied from the Linux DOC driver */ -#ifdef CFG_DOCPROBE_55AA +#ifdef CONFIG_SYS_DOCPROBE_55AA /* Check for 0x55 0xAA signature at beginning of window, this is no longer true once we remove the IPL (for Millennium */ if (ReadDOC(window, Sig1) != 0x55 || ReadDOC(window, Sig2) != 0xaa) return 0; -#endif /* CFG_DOCPROBE_55AA */ +#endif /* CONFIG_SYS_DOCPROBE_55AA */ #ifndef DOC_PASSIVE_PROBE /* It's not possible to cleanly detect the DiskOnChip - the @@ -1574,7 +1574,7 @@ static inline int doccheck(unsigned long potential, unsigned long physadr) break; default: -#ifndef CFG_DOCPROBE_55AA +#ifndef CONFIG_SYS_DOCPROBE_55AA /* * if the ID isn't the DoC2000 or DoCMillenium ID, so we can assume * the DOC is missing @@ -1609,7 +1609,7 @@ void doc_probe(unsigned long physadr) if ((ChipID = doccheck(physadr, physadr))) { - for (i=0; i 2 -#error CFG_I2C_EEPROM_ADDR_LEN must be 1 or 2 +#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1 || CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2 +#error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2 #endif #endif @@ -136,11 +136,11 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt */ while (offset < end) { unsigned alen, len; -#if !defined(CFG_I2C_FRAM) +#if !defined(CONFIG_SYS_I2C_FRAM) unsigned maxlen; #endif -#if CFG_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) uchar addr[2]; blk_off = offset & 0xFF; /* block offset */ @@ -157,7 +157,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt addr[1] = offset >> 8; /* upper address octet */ addr[2] = blk_off; /* lower address octet */ alen = 3; -#endif /* CFG_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ +#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ addr[0] |= dev_addr; /* insert device address */ @@ -168,7 +168,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt * bytes that can be ccessed with the single read or write * operation. */ -#if !defined(CFG_I2C_FRAM) +#if !defined(CONFIG_SYS_I2C_FRAM) maxlen = 0x100 - blk_off; if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN; @@ -191,10 +191,10 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt /*----------------------------------------------------------------------- * - * for CFG_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is + * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is * 0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM. * - * for CFG_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is + * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is * 0x00000nxx for EEPROM address selectors and page number at n. */ @@ -204,7 +204,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn unsigned blk_off; int rcode = 0; -#if defined(CFG_EEPROM_X40430) +#if defined(CONFIG_SYS_EEPROM_X40430) uchar contr_r_addr[2]; uchar addr_void[2]; uchar contr_reg[2]; @@ -212,7 +212,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn int i; #endif -#if defined(CFG_EEPROM_WREN) +#if defined(CONFIG_SYS_EEPROM_WREN) eeprom_write_enable (dev_addr,1); #endif /* Write data until done or would cross a write page boundary. @@ -222,11 +222,11 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn while (offset < end) { unsigned alen, len; -#if !defined(CFG_I2C_FRAM) +#if !defined(CONFIG_SYS_I2C_FRAM) unsigned maxlen; #endif -#if CFG_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) uchar addr[2]; blk_off = offset & 0xFF; /* block offset */ @@ -243,7 +243,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn addr[1] = offset >> 8; /* upper address octet */ addr[2] = blk_off; /* lower address octet */ alen = 3; -#endif /* CFG_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ +#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ addr[0] |= dev_addr; /* insert device address */ @@ -254,11 +254,11 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn * bytes that can be ccessed with the single read or write * operation. */ -#if !defined(CFG_I2C_FRAM) +#if !defined(CONFIG_SYS_I2C_FRAM) -#if defined(CFG_EEPROM_PAGE_WRITE_BITS) +#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS) -#define EEPROM_PAGE_SIZE (1 << CFG_EEPROM_PAGE_WRITE_BITS) +#define EEPROM_PAGE_SIZE (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS) #define EEPROM_PAGE_OFFSET(x) ((x) & (EEPROM_PAGE_SIZE - 1)) maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off); @@ -275,7 +275,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn #ifdef CONFIG_SPI spi_write (addr, alen, buffer, len); #else -#if defined(CFG_EEPROM_X40430) +#if defined(CONFIG_SYS_EEPROM_X40430) /* Get the value of the control register. * Set current address (internal pointer in the x40430) * to 0x1ff. @@ -284,9 +284,9 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn contr_r_addr[1] = 0xff; addr_void[0] = 0; addr_void[1] = addr[1]; -#ifdef CFG_I2C_EEPROM_ADDR - contr_r_addr[0] |= CFG_I2C_EEPROM_ADDR; - addr_void[0] |= CFG_I2C_EEPROM_ADDR; +#ifdef CONFIG_SYS_I2C_EEPROM_ADDR + contr_r_addr[0] |= CONFIG_SYS_I2C_EEPROM_ADDR; + addr_void[0] |= CONFIG_SYS_I2C_EEPROM_ADDR; #endif contr_reg[0] = 0xff; if (i2c_read (contr_r_addr[0], contr_r_addr[1], 1, contr_reg, 1) != 0) { @@ -334,8 +334,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn for (i = 0; i < MAX_ACKNOWLEDGE_POLLS; i++) { if (i2c_read (addr_void[0], addr_void[1], 1, contr_reg, 1) == 0) break; /* got ack */ -#if defined(CFG_EEPROM_PAGE_WRITE_DELAY_MS) - udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000); +#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS) + udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000); #endif } if (i == MAX_ACKNOWLEDGE_POLLS) { @@ -364,11 +364,11 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn buffer += len; offset += len; -#if defined(CFG_EEPROM_PAGE_WRITE_DELAY_MS) - udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000); +#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS) + udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000); #endif } -#if defined(CFG_EEPROM_WREN) +#if defined(CONFIG_SYS_EEPROM_WREN) eeprom_write_enable (dev_addr,0); #endif return rcode; @@ -382,11 +382,11 @@ eeprom_probe (unsigned dev_addr, unsigned offset) /* Probe the chip address */ -#if CFG_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) chip = offset >> 8; /* block number */ #else chip = offset >> 16; /* block number */ -#endif /* CFG_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ +#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ chip |= dev_addr; /* insert device address */ @@ -397,12 +397,12 @@ eeprom_probe (unsigned dev_addr, unsigned offset) /*----------------------------------------------------------------------- * Set default values */ -#ifndef CFG_I2C_SPEED -#define CFG_I2C_SPEED 50000 +#ifndef CONFIG_SYS_I2C_SPEED +#define CONFIG_SYS_I2C_SPEED 50000 #endif -#ifndef CFG_I2C_SLAVE -#define CFG_I2C_SLAVE 0xFE +#ifndef CONFIG_SYS_I2C_SLAVE +#define CONFIG_SYS_I2C_SLAVE 0xFE #endif void eeprom_init (void) @@ -412,7 +412,7 @@ void eeprom_init (void) #endif #if defined(CONFIG_HARD_I2C) || \ defined(CONFIG_SOFT_I2C) - i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); #endif } /*----------------------------------------------------------------------- @@ -422,7 +422,7 @@ void eeprom_init (void) #if defined(CONFIG_CMD_EEPROM) -#ifdef CFG_I2C_MULTI_EEPROMS +#ifdef CONFIG_SYS_I2C_MULTI_EEPROMS U_BOOT_CMD( eeprom, 6, 1, do_eeprom, "eeprom - EEPROM sub-system\n", @@ -438,6 +438,6 @@ U_BOOT_CMD( "eeprom write addr off cnt\n" " - read/write `cnt' bytes at EEPROM offset `off'\n" ); -#endif /* CFG_I2C_MULTI_EEPROMS */ +#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */ #endif diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 62e5e76..3ebb6d9 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -19,7 +19,7 @@ #include #include -#if defined(CONFIG_WALNUT) || defined(CFG_VXWORKS_MAC_PTR) +#if defined(CONFIG_WALNUT) || defined(CONFIG_SYS_VXWORKS_MAC_PTR) DECLARE_GLOBAL_DATA_PTR; #endif @@ -135,10 +135,10 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) */ #if defined(CONFIG_WALNUT) - tmp = (char *) CFG_NVRAM_BASE_ADDR + 0x500; + tmp = (char *) CONFIG_SYS_NVRAM_BASE_ADDR + 0x500; memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[3], 3); -#elif defined(CFG_VXWORKS_MAC_PTR) - tmp = (char *) CFG_VXWORKS_MAC_PTR; +#elif defined(CONFIG_SYS_VXWORKS_MAC_PTR) + tmp = (char *) CONFIG_SYS_VXWORKS_MAC_PTR; memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[0], 6); #else puts ("## Ethernet MAC address not copied to NV RAM\n"); diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index cfd4f64..9c43792 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -142,7 +142,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (addr_str != NULL) { addr = simple_strtoul (addr_str, NULL, 16); } else { - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; } filename = getenv ("bootfile"); count = 0; diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 9576cdf..ebe9e09 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -188,7 +188,7 @@ int find_fat_partition (void) unsigned char *part_table; unsigned char buffer[ATA_BLOCKSIZE]; - for (i = 0; i < CFG_IDE_MAXDEVICE; i++) { + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { dev_desc = ide_get_dev (i); if (!dev_desc) { debug ("couldn't get ide device!\n"); diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index b663d60..d995ff2 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -170,17 +170,17 @@ const static FD_GEO_STRUCT floppy_type[2] = { static FDC_COMMAND_STRUCT cmd; /* global command struct */ /* If the boot drive number is undefined, we assume it's drive 0 */ -#ifndef CFG_FDC_DRIVE_NUMBER -#define CFG_FDC_DRIVE_NUMBER 0 +#ifndef CONFIG_SYS_FDC_DRIVE_NUMBER +#define CONFIG_SYS_FDC_DRIVE_NUMBER 0 #endif /* Hardware access */ -#ifndef CFG_ISA_IO_STRIDE -#define CFG_ISA_IO_STRIDE 1 +#ifndef CONFIG_SYS_ISA_IO_STRIDE +#define CONFIG_SYS_ISA_IO_STRIDE 1 #endif -#ifndef CFG_ISA_IO_OFFSET -#define CFG_ISA_IO_OFFSET 0 +#ifndef CONFIG_SYS_ISA_IO_OFFSET +#define CONFIG_SYS_ISA_IO_OFFSET 0 #endif @@ -213,9 +213,9 @@ int wait_for_fdc_int(void) unsigned char read_fdc_reg(unsigned int addr) { volatile unsigned char *val = - (volatile unsigned char *)(CFG_ISA_IO_BASE_ADDRESS + - (addr * CFG_ISA_IO_STRIDE) + - CFG_ISA_IO_OFFSET); + (volatile unsigned char *)(CONFIG_SYS_ISA_IO_BASE_ADDRESS + + (addr * CONFIG_SYS_ISA_IO_STRIDE) + + CONFIG_SYS_ISA_IO_OFFSET); return val [0]; } @@ -224,9 +224,9 @@ unsigned char read_fdc_reg(unsigned int addr) void write_fdc_reg(unsigned int addr, unsigned char val) { volatile unsigned char *tmp = - (volatile unsigned char *)(CFG_ISA_IO_BASE_ADDRESS + - (addr * CFG_ISA_IO_STRIDE) + - CFG_ISA_IO_OFFSET); + (volatile unsigned char *)(CONFIG_SYS_ISA_IO_BASE_ADDRESS + + (addr * CONFIG_SYS_ISA_IO_STRIDE) + + CONFIG_SYS_ISA_IO_OFFSET); tmp[0]=val; } @@ -652,7 +652,7 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG) i8259_unmask_irq(6); #endif -#ifdef CFG_FDC_HW_INIT +#ifdef CONFIG_SYS_FDC_HW_INIT fdc_hw_init (); #endif /* first, we reset the FDC via the DOR */ @@ -789,12 +789,12 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 1: - addr = CFG_LOAD_ADDR; - boot_drive=CFG_FDC_DRIVE_NUMBER; + addr = CONFIG_SYS_LOAD_ADDR; + boot_drive=CONFIG_SYS_FDC_DRIVE_NUMBER; break; case 2: addr = simple_strtoul(argv[1], NULL, 16); - boot_drive=CFG_FDC_DRIVE_NUMBER; + boot_drive=CONFIG_SYS_FDC_DRIVE_NUMBER; break; case 3: addr = simple_strtoul(argv[1], NULL, 16); diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c index b3dbd19..aa13b52 100644 --- a/common/cmd_fdos.c +++ b/common/cmd_fdos.c @@ -42,7 +42,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int size; int rcode = 0; char buf [12]; - int drive = CFG_FDC_DRIVE_NUMBER; + int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; /* pre-set load_addr */ if ((ep = getenv("loadaddr")) != NULL) { @@ -118,7 +118,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char *path = ""; - int drive = CFG_FDC_DRIVE_NUMBER; + int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; switch (argc) { case 1: diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 288a5c4..4274a77 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -364,7 +364,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (strncmp(argv[1], "me", 2) == 0) { uint64_t addr, size; int err; -#ifdef CFG_64BIT_STRTOUL +#ifdef CONFIG_SYS_64BIT_STRTOUL addr = simple_strtoull(argv[2], NULL, 16); size = simple_strtoull(argv[3], NULL, 16); #else @@ -402,7 +402,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (argv[2][0] == 'a') { uint64_t addr, size; int err; -#ifdef CFG_64BIT_STRTOUL +#ifdef CONFIG_SYS_64BIT_STRTOUL addr = simple_strtoull(argv[3], NULL, 16); size = simple_strtoull(argv[4], NULL, 16); #else diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 29e5b6d..93eefa9 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -41,7 +41,7 @@ int find_dev_and_part(const char *id, struct mtd_device **dev, u8 *part_num, struct part_info **part); #endif -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH extern flash_info_t flash_info[]; /* info for FLASH chips */ /* @@ -76,7 +76,7 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl) bank = simple_strtoul (str, &ep, 10); if (ep == str || *ep != '\0' || - bank < 1 || bank > CFG_MAX_FLASH_BANKS || + bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS || (fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN) return -1; @@ -116,7 +116,7 @@ int flash_sect_roundb (ulong *addr) /* find the end addr of the sector where the *addr is */ found = 0; - for (bank = 0; bank < CFG_MAX_FLASH_BANKS && !found; ++bank) { + for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS && !found; ++bank) { info = &flash_info[bank]; for (i = 0; i < info->sector_count && !found; ++i) { /* get the end address of the sector */ @@ -214,13 +214,13 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last, *s_count = 0; - for (bank=0; bank < CFG_MAX_FLASH_BANKS; ++bank) { + for (bank=0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { s_first[bank] = -1; /* first sector to erase */ s_last [bank] = -1; /* last sector to erase */ } for (bank=0,info = &flash_info[0]; - (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last); + (bank < CONFIG_SYS_MAX_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) { ulong b_end; int sect; @@ -285,11 +285,11 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last, return rcode; } -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH ulong bank; #endif @@ -297,9 +297,9 @@ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dataflash_print_info(); #endif -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH if (argc == 1) { /* print info for all FLASH banks */ - for (bank=0; bank CFG_MAX_FLASH_BANKS)) { + if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", - CFG_MAX_FLASH_BANKS); + CONFIG_SYS_MAX_FLASH_BANKS); return 1; } printf ("\nBank # %ld: ", bank); flash_print_info (&flash_info[bank-1]); -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ return 0; } int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; @@ -338,7 +338,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (strcmp(argv[1], "all") == 0) { - for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { + for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); @@ -390,9 +390,9 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); - if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { + if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", - CFG_MAX_FLASH_BANKS); + CONFIG_SYS_MAX_FLASH_BANKS); return 1; } printf ("Erase Flash Bank # %ld ", bank); @@ -415,18 +415,18 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return rcode; #else return 0; -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ } -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH int flash_sect_erase (ulong addr_first, ulong addr_last) { flash_info_t *info; ulong bank; -#ifdef CFG_MAX_FLASH_BANKS_DETECT - int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT]; +#ifdef CONFIG_SYS_MAX_FLASH_BANKS_DETECT + int s_first[CONFIG_SYS_MAX_FLASH_BANKS_DETECT], s_last[CONFIG_SYS_MAX_FLASH_BANKS_DETECT]; #else - int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS]; + int s_first[CONFIG_SYS_MAX_FLASH_BANKS], s_last[CONFIG_SYS_MAX_FLASH_BANKS]; #endif int erased = 0; int planned; @@ -437,7 +437,7 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) if (planned && (rcode == 0)) { for (bank=0,info = &flash_info[0]; - (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0); + (bank < CONFIG_SYS_MAX_FLASH_BANKS) && (rcode == 0); ++bank, ++info) { if (s_first[bank]>=0) { erased += s_last[bank] - s_first[bank] + 1; @@ -459,15 +459,15 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) } return rcode; } -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH flash_info_t *info; ulong bank; int i, n, sect_first, sect_last; -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ ulong addr_first, addr_last; int p; #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) @@ -512,9 +512,9 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH if (strcmp(argv[2], "all") == 0) { - for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { + for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { continue; @@ -523,17 +523,17 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) p ? "" : "Un-", bank); for (i=0; isector_count; ++i) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ } -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ } return rcode; } @@ -547,18 +547,18 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) p ? "" : "Un-", sect_first, sect_last, (info-flash_info)+1); for (i = sect_first; i <= sect_last; i++) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ } -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ return rcode; } @@ -597,9 +597,9 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); - if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { + if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", - CFG_MAX_FLASH_BANKS); + CONFIG_SYS_MAX_FLASH_BANKS); return 1; } printf ("%sProtect Flash Bank # %ld\n", @@ -611,18 +611,18 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } for (i=0; isector_count; ++i) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ } -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ return rcode; } @@ -637,19 +637,19 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } rcode = flash_sect_protect (p, addr_first, addr_last); -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ return rcode; } -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH int flash_sect_protect (int p, ulong addr_first, ulong addr_last) { flash_info_t *info; ulong bank; -#ifdef CFG_MAX_FLASH_BANKS_DETECT - int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT]; +#ifdef CONFIG_SYS_MAX_FLASH_BANKS_DETECT + int s_first[CONFIG_SYS_MAX_FLASH_BANKS_DETECT], s_last[CONFIG_SYS_MAX_FLASH_BANKS_DETECT]; #else - int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS]; + int s_first[CONFIG_SYS_MAX_FLASH_BANKS], s_last[CONFIG_SYS_MAX_FLASH_BANKS]; #endif int protected, i; int planned; @@ -660,7 +660,7 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last) protected = 0; if (planned && (rcode == 0)) { - for (bank=0,info = &flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) { + for (bank=0,info = &flash_info[0]; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank, ++info) { if (info->flash_id == FLASH_UNKNOWN) { continue; } @@ -671,19 +671,19 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last) s_first[bank], s_last[bank], bank+1); protected += s_last[bank] - s_first[bank] + 1; for (i=s_first[bank]; i<=s_last[bank]; ++i) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ } } } -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) puts (" done\n"); -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ printf ("%sProtected %d sectors\n", p ? "" : "Un-", protected); @@ -694,7 +694,7 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last) } return rcode; } -#endif /* CFG_NO_FLASH */ +#endif /* CONFIG_SYS_NO_FLASH */ /**************************************************/ diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 8d287fe..84ecf49 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -65,7 +65,7 @@ * significant 1, 2, or 3 bits of address into the chip address byte. * This effectively makes one chip (logically) look like 2, 4, or * 8 chips. This is handled (awkwardly) by #defining - * CFG_I2C_EEPROM_ADDR_OVERFLOW and using the .1 modifier on the + * CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW and using the .1 modifier on the * {addr} field (since .1 is the default, it doesn't actually have to * be specified). Examples: given a memory chip at I2C chip address * 0x50, the following would happen... @@ -105,19 +105,19 @@ static uint i2c_mm_last_alen; * When multiple buses are present, the list is an array of bus-address * pairs. The following macros take care of this */ -#if defined(CFG_I2C_NOPROBES) +#if defined(CONFIG_SYS_I2C_NOPROBES) #if defined(CONFIG_I2C_MULTI_BUS) static struct { uchar bus; uchar addr; -} i2c_no_probes[] = CFG_I2C_NOPROBES; +} i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES; #define GET_BUS_NUM i2c_get_bus_num() #define COMPARE_BUS(b,i) (i2c_no_probes[(i)].bus == (b)) #define COMPARE_ADDR(a,i) (i2c_no_probes[(i)].addr == (a)) #define NO_PROBE_ADDR(i) i2c_no_probes[(i)].addr #else /* single bus */ -static uchar i2c_no_probes[] = CFG_I2C_NOPROBES; +static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES; #define GET_BUS_NUM 0 #define COMPARE_BUS(b,i) ((b) == 0) /* Make compiler happy */ #define COMPARE_ADDR(a,i) (i2c_no_probes[(i)] == (a)) @@ -129,7 +129,7 @@ static uchar i2c_no_probes[] = CFG_I2C_NOPROBES; #if defined(CONFIG_I2C_MUX) static I2C_MUX_DEVICE *i2c_mux_devices = NULL; -static int i2c_mux_busid = CFG_MAX_I2C_BUS; +static int i2c_mux_busid = CONFIG_SYS_MAX_I2C_BUS; DECLARE_GLOBAL_DATA_PTR; @@ -323,7 +323,7 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* * No write delay with FRAM devices. */ -#if !defined(CFG_I2C_FRAM) +#if !defined(CONFIG_SYS_I2C_FRAM) udelay(11000); #endif @@ -529,8 +529,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) #endif if (i2c_write(chip, addr, alen, (uchar *)&data, size) != 0) puts ("Error writing the chip.\n"); -#ifdef CFG_EEPROM_PAGE_WRITE_DELAY_MS - udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000); +#ifdef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS + udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000); #endif if (incrflag) addr += size; @@ -552,14 +552,14 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int j; -#if defined(CFG_I2C_NOPROBES) +#if defined(CONFIG_SYS_I2C_NOPROBES) int k, skip; uchar bus = GET_BUS_NUM; #endif /* NOPROBES */ puts ("Valid chip addresses:"); for (j = 0; j < 128; j++) { -#if defined(CFG_I2C_NOPROBES) +#if defined(CONFIG_SYS_I2C_NOPROBES) skip = 0; for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) { if (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) { @@ -575,7 +575,7 @@ int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } putc ('\n'); -#if defined(CFG_I2C_NOPROBES) +#if defined(CONFIG_SYS_I2C_NOPROBES) puts ("Excluded chip addresses:"); for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) { if (COMPARE_BUS(bus,k)) @@ -1194,7 +1194,7 @@ int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #if defined(CONFIG_I2C_CMD_TREE) int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { - i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); return 0; } @@ -1573,8 +1573,8 @@ int i2x_mux_select_mux(int bus) if ((gd->flags & GD_FLG_RELOC) != GD_FLG_RELOC) { /* select Default Mux Bus */ -#if defined(CFG_I2C_IVM_BUS) - i2c_mux_ident_muxstring_f ((uchar *)CFG_I2C_IVM_BUS); +#if defined(CONFIG_SYS_I2C_IVM_BUS) + i2c_mux_ident_muxstring_f ((uchar *)CONFIG_SYS_I2C_IVM_BUS); #else { unsigned char *buf; diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 2fcaff8..2564c2b 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -92,10 +92,10 @@ const static pio_config_t pio_config_ns [IDE_MAX_PIO_MODE+1] = static pio_config_t pio_config_clk [IDE_MAX_PIO_MODE+1]; -#ifndef CFG_PIO_MODE -#define CFG_PIO_MODE 0 /* use a relaxed default */ +#ifndef CONFIG_SYS_PIO_MODE +#define CONFIG_SYS_PIO_MODE 0 /* use a relaxed default */ #endif -static int pio_mode = CFG_PIO_MODE; +static int pio_mode = CONFIG_SYS_PIO_MODE; /* Make clock cycles and always round up */ @@ -109,23 +109,23 @@ static int pio_mode = CFG_PIO_MODE; static int curr_device = -1; /* Current offset for IDE0 / IDE1 bus access */ -ulong ide_bus_offset[CFG_IDE_MAXBUS] = { -#if defined(CFG_ATA_IDE0_OFFSET) - CFG_ATA_IDE0_OFFSET, +ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { +#if defined(CONFIG_SYS_ATA_IDE0_OFFSET) + CONFIG_SYS_ATA_IDE0_OFFSET, #endif -#if defined(CFG_ATA_IDE1_OFFSET) && (CFG_IDE_MAXBUS > 1) - CFG_ATA_IDE1_OFFSET, +#if defined(CONFIG_SYS_ATA_IDE1_OFFSET) && (CONFIG_SYS_IDE_MAXBUS > 1) + CONFIG_SYS_ATA_IDE1_OFFSET, #endif }; #ifndef CONFIG_AMIGAONEG3SE -static int ide_bus_ok[CFG_IDE_MAXBUS]; +static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS]; #else -static int ide_bus_ok[CFG_IDE_MAXBUS] = {0,}; +static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS] = {0,}; #endif -block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE]; +block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; /* ------------------------------------------------------------------------- */ #ifdef CONFIG_IDE_LED @@ -165,8 +165,8 @@ static void input_data(int dev, ulong *sect_buf, int words); static void output_data(int dev, ulong *sect_buf, int words); static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len); -#ifndef CFG_ATA_PORT_ADDR -#define CFG_ATA_PORT_ADDR(port) (port) +#ifndef CONFIG_SYS_ATA_PORT_ADDR +#define CONFIG_SYS_ATA_PORT_ADDR(port) (port) #endif #ifdef CONFIG_ATAPI @@ -205,7 +205,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) putc ('\n'); - for (i=0; i= CFG_IDE_MAXDEVICE)) { + if ((curr_device < 0) || (curr_device >= CONFIG_SYS_IDE_MAXDEVICE)) { puts ("\nno IDE devices available\n"); return 1; } @@ -224,7 +224,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else if (strncmp(argv[1],"part",4) == 0) { int dev, ok; - for (ok=0, dev=0; dev= CFG_IDE_MAXDEVICE) { + if (dev >= CONFIG_SYS_IDE_MAXDEVICE) { puts ("unknown device\n"); return 1; } @@ -296,7 +296,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; -#ifdef CFG_64BIT_LBA +#ifdef CONFIG_SYS_64BIT_LBA lbaint_t blk = simple_strtoull(argv[3], NULL, 16); printf ("\nIDE read: device %d block # %qd, count %ld ... ", @@ -325,7 +325,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; -#ifdef CFG_64BIT_LBA +#ifdef CONFIG_SYS_64BIT_LBA lbaint_t blk = simple_strtoull(argv[3], NULL, 16); printf ("\nIDE write: device %d block # %qd, count %ld ... ", @@ -371,7 +371,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) show_boot_progress (41); switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: @@ -525,8 +525,8 @@ void inline __ide_outb(int dev, int port, unsigned char val) { debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", - dev, port, val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port))); - outb(val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port))); + dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); + outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); } void inline ide_outb (int dev, int port, unsigned char val) __attribute__((weak, alias("__ide_outb"))); @@ -535,9 +535,9 @@ unsigned char inline __ide_inb(int dev, int port) { uchar val; - val = inb((ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port))); + val = inb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n", - dev, port, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)), val); + dev, port, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)), val); return val; } unsigned char inline ide_inb(int dev, int port) @@ -557,7 +557,7 @@ void ide_init (void) { #ifdef CONFIG_IDE_8xx_DIRECT - volatile immap_t *immr = (immap_t *)CFG_IMMR; + volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; volatile pcmconf8xx_t *pcmp = &(immr->im_pcmcia); #endif unsigned char c; @@ -639,17 +639,17 @@ void ide_init (void) * According to spec, this can take up to 31 seconds! */ #ifndef CONFIG_AMIGAONEG3SE - for (bus=0; busim_pcmcia); ulong timings; @@ -775,33 +775,33 @@ set_pcmcia_timing (int pmode) /* IDE 0 */ - pcmp->pcmc_pbr0 = CFG_PCMCIA_PBR0; - pcmp->pcmc_por0 = CFG_PCMCIA_POR0 -#if (CFG_PCMCIA_POR0 != 0) + pcmp->pcmc_pbr0 = CONFIG_SYS_PCMCIA_PBR0; + pcmp->pcmc_por0 = CONFIG_SYS_PCMCIA_POR0 +#if (CONFIG_SYS_PCMCIA_POR0 != 0) | timings #endif ; debug ("PBR0: %08x POR0: %08x\n", pcmp->pcmc_pbr0, pcmp->pcmc_por0); - pcmp->pcmc_pbr1 = CFG_PCMCIA_PBR1; - pcmp->pcmc_por1 = CFG_PCMCIA_POR1 -#if (CFG_PCMCIA_POR1 != 0) + pcmp->pcmc_pbr1 = CONFIG_SYS_PCMCIA_PBR1; + pcmp->pcmc_por1 = CONFIG_SYS_PCMCIA_POR1 +#if (CONFIG_SYS_PCMCIA_POR1 != 0) | timings #endif ; debug ("PBR1: %08x POR1: %08x\n", pcmp->pcmc_pbr1, pcmp->pcmc_por1); - pcmp->pcmc_pbr2 = CFG_PCMCIA_PBR2; - pcmp->pcmc_por2 = CFG_PCMCIA_POR2 -#if (CFG_PCMCIA_POR2 != 0) + pcmp->pcmc_pbr2 = CONFIG_SYS_PCMCIA_PBR2; + pcmp->pcmc_por2 = CONFIG_SYS_PCMCIA_POR2 +#if (CONFIG_SYS_PCMCIA_POR2 != 0) | timings #endif ; debug ("PBR2: %08x POR2: %08x\n", pcmp->pcmc_pbr2, pcmp->pcmc_por2); - pcmp->pcmc_pbr3 = CFG_PCMCIA_PBR3; - pcmp->pcmc_por3 = CFG_PCMCIA_POR3 -#if (CFG_PCMCIA_POR3 != 0) + pcmp->pcmc_pbr3 = CONFIG_SYS_PCMCIA_PBR3; + pcmp->pcmc_por3 = CONFIG_SYS_PCMCIA_POR3 +#if (CONFIG_SYS_PCMCIA_POR3 != 0) | timings #endif ; @@ -809,33 +809,33 @@ set_pcmcia_timing (int pmode) /* IDE 1 */ - pcmp->pcmc_pbr4 = CFG_PCMCIA_PBR4; - pcmp->pcmc_por4 = CFG_PCMCIA_POR4 -#if (CFG_PCMCIA_POR4 != 0) + pcmp->pcmc_pbr4 = CONFIG_SYS_PCMCIA_PBR4; + pcmp->pcmc_por4 = CONFIG_SYS_PCMCIA_POR4 +#if (CONFIG_SYS_PCMCIA_POR4 != 0) | timings #endif ; debug ("PBR4: %08x POR4: %08x\n", pcmp->pcmc_pbr4, pcmp->pcmc_por4); - pcmp->pcmc_pbr5 = CFG_PCMCIA_PBR5; - pcmp->pcmc_por5 = CFG_PCMCIA_POR5 -#if (CFG_PCMCIA_POR5 != 0) + pcmp->pcmc_pbr5 = CONFIG_SYS_PCMCIA_PBR5; + pcmp->pcmc_por5 = CONFIG_SYS_PCMCIA_POR5 +#if (CONFIG_SYS_PCMCIA_POR5 != 0) | timings #endif ; debug ("PBR5: %08x POR5: %08x\n", pcmp->pcmc_pbr5, pcmp->pcmc_por5); - pcmp->pcmc_pbr6 = CFG_PCMCIA_PBR6; - pcmp->pcmc_por6 = CFG_PCMCIA_POR6 -#if (CFG_PCMCIA_POR6 != 0) + pcmp->pcmc_pbr6 = CONFIG_SYS_PCMCIA_PBR6; + pcmp->pcmc_por6 = CONFIG_SYS_PCMCIA_POR6 +#if (CONFIG_SYS_PCMCIA_POR6 != 0) | timings #endif ; debug ("PBR6: %08x POR6: %08x\n", pcmp->pcmc_pbr6, pcmp->pcmc_por6); - pcmp->pcmc_pbr7 = CFG_PCMCIA_PBR7; - pcmp->pcmc_por7 = CFG_PCMCIA_POR7 -#if (CFG_PCMCIA_POR7 != 0) + pcmp->pcmc_pbr7 = CONFIG_SYS_PCMCIA_PBR7; + pcmp->pcmc_por7 = CONFIG_SYS_PCMCIA_POR7 +#if (CONFIG_SYS_PCMCIA_POR7 != 0) | timings #endif ; @@ -1079,7 +1079,7 @@ static void ide_ident (block_dev_desc_t *dev_desc) if (s) { max_bus_scan = simple_strtol(s, NULL, 10); } else { - max_bus_scan = CFG_IDE_MAXBUS; + max_bus_scan = CONFIG_SYS_IDE_MAXBUS; } if (device >= max_bus_scan*2) { dev_desc->type=DEV_TYPE_UNKNOWN; @@ -1359,7 +1359,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer) /* write high bits */ ide_outb (device, ATA_SECT_CNT, 0); ide_outb (device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); -#ifdef CFG_64BIT_LBA +#ifdef CONFIG_SYS_64BIT_LBA ide_outb (device, ATA_LBA_MID, (blknr >> 32) & 0xFF); ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF); #else @@ -1397,7 +1397,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer) } if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) { -#if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF) +#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF) printf ("Error (no IRQ) dev %d blk %qd: status 0x%02x\n", device, blknr, c); #else @@ -1454,7 +1454,7 @@ ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, void *buffer) /* write high bits */ ide_outb (device, ATA_SECT_CNT, 0); ide_outb (device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); -#ifdef CFG_64BIT_LBA +#ifdef CONFIG_SYS_64BIT_LBA ide_outb (device, ATA_LBA_MID, (blknr >> 32) & 0xFF); ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF); #else @@ -1487,7 +1487,7 @@ ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, void *buffer) c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */ if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) { -#if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF) +#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF) printf ("Error (no IRQ) dev %d blk %qd: status 0x%02x\n", device, blknr, c); #else @@ -1567,15 +1567,15 @@ extern void ide_set_reset(int idereset); static void ide_reset (void) { -#if defined(CFG_PB_12V_ENABLE) || defined(CFG_PB_IDE_MOTOR) - volatile immap_t *immr = (immap_t *)CFG_IMMR; +#if defined(CONFIG_SYS_PB_12V_ENABLE) || defined(CONFIG_SYS_PB_IDE_MOTOR) + volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; #endif int i; curr_device = -1; - for (i=0; iim_cpm.cp_pbdat &= ~(CFG_PB_12V_ENABLE); /* 12V Enable output OFF */ - immr->im_cpm.cp_pbpar &= ~(CFG_PB_12V_ENABLE); - immr->im_cpm.cp_pbodr &= ~(CFG_PB_12V_ENABLE); - immr->im_cpm.cp_pbdir |= CFG_PB_12V_ENABLE; +#ifdef CONFIG_SYS_PB_12V_ENABLE + immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE); /* 12V Enable output OFF */ + immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_12V_ENABLE); + immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_12V_ENABLE); + immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE; /* wait 500 ms for the voltage to stabilize */ @@ -1597,19 +1597,19 @@ static void ide_reset (void) udelay (1000); } - immr->im_cpm.cp_pbdat |= CFG_PB_12V_ENABLE; /* 12V Enable output ON */ -#endif /* CFG_PB_12V_ENABLE */ + immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE; /* 12V Enable output ON */ +#endif /* CONFIG_SYS_PB_12V_ENABLE */ -#ifdef CFG_PB_IDE_MOTOR +#ifdef CONFIG_SYS_PB_IDE_MOTOR /* configure IDE Motor voltage monitor pin as input */ - immr->im_cpm.cp_pbpar &= ~(CFG_PB_IDE_MOTOR); - immr->im_cpm.cp_pbodr &= ~(CFG_PB_IDE_MOTOR); - immr->im_cpm.cp_pbdir &= ~(CFG_PB_IDE_MOTOR); + immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_IDE_MOTOR); + immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_IDE_MOTOR); + immr->im_cpm.cp_pbdir &= ~(CONFIG_SYS_PB_IDE_MOTOR); /* wait up to 1 s for the motor voltage to stabilize */ for (i=0; i<1000; ++i) { - if ((immr->im_cpm.cp_pbdat & CFG_PB_IDE_MOTOR) != 0) { + if ((immr->im_cpm.cp_pbdat & CONFIG_SYS_PB_IDE_MOTOR) != 0) { break; } udelay (1000); @@ -1626,7 +1626,7 @@ static void ide_reset (void) # endif # endif /* CONFIG_STATUS_LED */ } -#endif /* CFG_PB_IDE_MOTOR */ +#endif /* CONFIG_SYS_PB_IDE_MOTOR */ WATCHDOG_RESET(); diff --git a/common/cmd_immap.c b/common/cmd_immap.c index d758269..13ad94e 100644 --- a/common/cmd_immap.c +++ b/common/cmd_immap.c @@ -52,7 +52,7 @@ unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile sysconf8xx_t *sc = &immap->im_siu_conf; @@ -83,7 +83,7 @@ do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile memctl8xx_t *memctl = &immap->im_memctl; @@ -151,7 +151,7 @@ do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile car8xx_t *car = &immap->im_clkrst; @@ -235,7 +235,7 @@ static void binary (char *label, uint value, int nbits) int do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile iop8xx_t *iop = &immap->im_ioport; @@ -500,7 +500,7 @@ static void prbrg (int n, uint val) int do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile cpm8xx_t *cp = &immap->im_cpm; @@ -524,7 +524,7 @@ do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; #if defined(CONFIG_8xx) volatile i2c8xx_t *i2c = &immap->im_i2c; diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index c6920c9..791a572 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -772,7 +772,7 @@ static int device_validate(u8 type, u8 num, u32 *size) { if (type == MTD_DEV_TYPE_NOR) { #if defined(CONFIG_CMD_FLASH) - if (num < CFG_MAX_FLASH_BANKS) { + if (num < CONFIG_SYS_MAX_FLASH_BANKS) { extern flash_info_t flash_info[]; *size = flash_info[num].size; @@ -780,24 +780,24 @@ static int device_validate(u8 type, u8 num, u32 *size) } printf("no such FLASH device: %s%d (valid range 0 ... %d\n", - MTD_DEV_TYPE(type), num, CFG_MAX_FLASH_BANKS - 1); + MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_FLASH_BANKS - 1); #else printf("support for FLASH devices not present\n"); #endif } else if (type == MTD_DEV_TYPE_NAND) { #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) - if (num < CFG_MAX_NAND_DEVICE) { + if (num < CONFIG_SYS_MAX_NAND_DEVICE) { #ifndef CONFIG_NAND_LEGACY *size = nand_info[num].size; #else - extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; + extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE]; *size = nand_dev_desc[num].totlen; #endif return 0; } printf("no such NAND device: %s%d (valid range 0 ... %d)\n", - MTD_DEV_TYPE(type), num, CFG_MAX_NAND_DEVICE - 1); + MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_NAND_DEVICE - 1); #else printf("support for NAND devices not present\n"); #endif diff --git a/common/cmd_load.c b/common/cmd_load.c index 1351fe2..65a4d69 100644 --- a/common/cmd_load.c +++ b/common/cmd_load.c @@ -58,7 +58,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int i; char *env_echo; int rcode = 0; -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE int load_baudrate, current_baudrate; load_baudrate = current_baudrate = gd->baudrate; @@ -70,7 +70,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) do_echo = 0; } -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE if (argc >= 2) { offset = simple_strtol(argv[1], NULL, 16); } @@ -93,11 +93,11 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; } } -#else /* ! CFG_LOADS_BAUD_CHANGE */ +#else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ if (argc == 2) { offset = simple_strtol(argv[1], NULL, 16); } -#endif /* CFG_LOADS_BAUD_CHANGE */ +#endif /* CONFIG_SYS_LOADS_BAUD_CHANGE */ printf ("## Ready for S-Record download ...\n"); @@ -123,7 +123,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) load_addr = addr; } -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE if (load_baudrate != current_baudrate) { printf ("## Switch baudrate to %d bps and press ESC ...\n", current_baudrate); @@ -167,7 +167,7 @@ load_serial (long offset) case SREC_DATA3: case SREC_DATA4: store_addr = addr + offset; -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH if (addr2info(store_addr)) { int rc; @@ -259,7 +259,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong offset = 0; ulong size = 0; -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE int save_baudrate, current_baudrate; save_baudrate = current_baudrate = gd->baudrate; @@ -268,7 +268,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argc >= 2) { offset = simple_strtoul(argv[1], NULL, 16); } -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE if (argc >= 3) { size = simple_strtoul(argv[2], NULL, 16); } @@ -291,11 +291,11 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; } } -#else /* ! CFG_LOADS_BAUD_CHANGE */ +#else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ if (argc == 3) { size = simple_strtoul(argv[2], NULL, 16); } -#endif /* CFG_LOADS_BAUD_CHANGE */ +#endif /* CONFIG_SYS_LOADS_BAUD_CHANGE */ printf ("## Ready for S-Record upload, press ENTER to proceed ...\n"); for (;;) { @@ -307,7 +307,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else { printf ("## S-Record upload complete\n"); } -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE if (save_baudrate != current_baudrate) { printf ("## Switch baudrate to %d bps and press ESC ...\n", (int)current_baudrate); @@ -441,8 +441,8 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int rcode = 0; char *s; - /* pre-set offset from CFG_LOAD_ADDR */ - offset = CFG_LOAD_ADDR; + /* pre-set offset from CONFIG_SYS_LOAD_ADDR */ + offset = CONFIG_SYS_LOAD_ADDR; /* pre-set offset from $loadaddr */ if ((s = getenv("loadaddr")) != NULL) { @@ -1001,7 +1001,7 @@ static ulong load_serial_ymodem (ulong offset) store_addr = addr + offset; size += res; addr += res; -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH if (addr2info (store_addr)) { int rc; @@ -1042,7 +1042,7 @@ static ulong load_serial_ymodem (ulong offset) #if defined(CONFIG_CMD_LOADS) -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE U_BOOT_CMD( loads, 3, 0, do_load_serial, "loads - load S-Record file over serial line\n", @@ -1051,14 +1051,14 @@ U_BOOT_CMD( " with offset 'off' and baudrate 'baud'\n" ); -#else /* ! CFG_LOADS_BAUD_CHANGE */ +#else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ U_BOOT_CMD( loads, 2, 0, do_load_serial, "loads - load S-Record file over serial line\n", "[ off ]\n" " - load S-Record file over serial line with offset 'off'\n" ); -#endif /* CFG_LOADS_BAUD_CHANGE */ +#endif /* CONFIG_SYS_LOADS_BAUD_CHANGE */ /* * SAVES always requires LOADS support, but not vice versa @@ -1066,7 +1066,7 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_SAVES) -#ifdef CFG_LOADS_BAUD_CHANGE +#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE U_BOOT_CMD( saves, 4, 0, do_save_serial, "saves - save S-Record file over serial line\n", @@ -1074,14 +1074,14 @@ U_BOOT_CMD( " - save S-Record file over serial line" " with offset 'off', size 'size' and baudrate 'baud'\n" ); -#else /* ! CFG_LOADS_BAUD_CHANGE */ +#else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */ U_BOOT_CMD( saves, 3, 0, do_save_serial, "saves - save S-Record file over serial line\n", "[ off ] [size]\n" " - save S-Record file over serial line with offset 'off' and size 'size'\n" ); -#endif /* CFG_LOADS_BAUD_CHANGE */ +#endif /* CONFIG_SYS_LOADS_BAUD_CHANGE */ #endif #endif diff --git a/common/cmd_log.c b/common/cmd_log.c index fdcc575..febdb90 100644 --- a/common/cmd_log.c +++ b/common/cmd_log.c @@ -68,7 +68,7 @@ static char *lbuf; unsigned long __logbuffer_base(void) { - return CFG_SDRAM_BASE + gd->bd->bi_memsize - LOGBUFF_LEN; + return CONFIG_SYS_SDRAM_BASE + gd->bd->bi_memsize - LOGBUFF_LEN; } unsigned long logbuffer_base (void) __attribute__((weak, alias("__logbuffer_base"))); diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 07b08fb..d7666c2 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -383,7 +383,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH /* check if we are copying to Flash */ if ( (addr2info(dest) != NULL) #ifdef CONFIG_HAS_DATAFLASH @@ -463,7 +463,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* Check if we are copying from DataFlash to RAM */ if (addr_dataflash(addr) && !addr_dataflash(dest) -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH && (addr2info(dest) == NULL) #endif ){ @@ -663,7 +663,7 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* * Perform a memory test. A more complete alternative test can be - * configured using CFG_ALT_MEMTEST. The complete test loops until + * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until * interrupted by ctrl-c or by a failure of one of the sub-tests. */ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) @@ -673,7 +673,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong readback; int rcode = 0; -#if defined(CFG_ALT_MEMTEST) +#if defined(CONFIG_SYS_ALT_MEMTEST) vu_long len; vu_long offset; vu_long test_offset; @@ -681,8 +681,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) vu_long temp; vu_long anti_pattern; vu_long num_words; -#if defined(CFG_MEMTEST_SCRATCH) - vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH; +#if defined(CONFIG_SYS_MEMTEST_SCRATCH) + vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH; #else vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */ #endif @@ -707,13 +707,13 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (argc > 1) { start = (ulong *)simple_strtoul(argv[1], NULL, 16); } else { - start = (ulong *)CFG_MEMTEST_START; + start = (ulong *)CONFIG_SYS_MEMTEST_START; } if (argc > 2) { end = (ulong *)simple_strtoul(argv[2], NULL, 16); } else { - end = (ulong *)(CFG_MEMTEST_END); + end = (ulong *)(CONFIG_SYS_MEMTEST_END); } if (argc > 3) { @@ -722,7 +722,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pattern = 0; } -#if defined(CFG_ALT_MEMTEST) +#if defined(CONFIG_SYS_ALT_MEMTEST) printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end); PRINTF("%s:%d: start 0x%p end 0x%p\n", __FUNCTION__, __LINE__, start, end); diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 126b538..3ea8ee0 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -37,7 +37,7 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - delay = simple_strtoul(argv[1], NULL, 10) * CFG_HZ; + delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ; while (get_timer(start) < delay) { if (ctrlc ()) { diff --git a/common/cmd_mp.c b/common/cmd_mp.c index c8444fb..f3a7f49 100644 --- a/common/cmd_mp.c +++ b/common/cmd_mp.c @@ -82,7 +82,7 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif U_BOOT_CMD( - cpu, CFG_MAXARGS, 1, cpu_cmd, + cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd, "cpu - Multiprocessor CPU boot manipulation and release\n", " reset - Reset cpu \n" "cpu status - Status of cpu \n" diff --git a/common/cmd_nand.c b/common/cmd_nand.c index b94a2bf..ea43f4f 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -171,8 +171,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) size_t size; char *cmd, *s; nand_info_t *nand; -#ifdef CFG_NAND_QUIET - int quiet = CFG_NAND_QUIET; +#ifdef CONFIG_SYS_NAND_QUIET + int quiet = CONFIG_SYS_NAND_QUIET; #else int quiet = 0; #endif @@ -190,7 +190,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) if (strcmp(cmd, "info") == 0) { putc('\n'); - for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) { + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { if (nand_info[i].name) printf("Device %d: %s, sector size %u KiB\n", i, nand_info[i].name, @@ -203,7 +203,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) if (argc < 3) { if ((nand_curr_device < 0) || - (nand_curr_device >= CFG_MAX_NAND_DEVICE)) + (nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) puts("\nno devices available\n"); else printf("\nDevice %d: %s\n", nand_curr_device, @@ -211,7 +211,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 0; } dev = (int)simple_strtoul(argv[2], NULL, 10); - if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) { + if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev].name) { puts("No such device\n"); return 1; } @@ -219,7 +219,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) puts("... is now current device\n"); nand_curr_device = dev; -#ifdef CFG_NAND_SELECT_DEVICE +#ifdef CONFIG_SYS_NAND_SELECT_DEVICE /* * Select the chip in the board/cpu specific driver */ @@ -238,7 +238,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) goto usage; /* the following commands operate on the current device */ - if (nand_curr_device < 0 || nand_curr_device >= CFG_MAX_NAND_DEVICE || + if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[nand_curr_device].name) { puts("\nno devices available\n"); return 1; @@ -606,7 +606,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) if (argc == 3) addr = simple_strtoul(argv[1], NULL, 16); else - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; return nand_load_image(cmdtp, &nand_info[dev->id->num], part->offset, addr, argv[0]); } @@ -616,7 +616,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) show_boot_progress(52); switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv("bootdevice"); break; case 2: @@ -651,7 +651,7 @@ usage: idx = simple_strtoul(boot_device, NULL, 16); - if (idx < 0 || idx >= CFG_MAX_NAND_DEVICE || !nand_info[idx].name) { + if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx].name) { printf("\n** Device %d not available\n", idx); show_boot_progress(-55); return 1; @@ -728,7 +728,7 @@ void archflashwp(void *archdata, int wp); /* * Imports from nand_legacy.c */ -extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; +extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE]; extern int curr_device; extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, size_t len, int clean); @@ -757,7 +757,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) putc ('\n'); - for (i = 0; i < CFG_MAX_NAND_DEVICE; ++i) { + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; ++i) { if (nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN) continue; /* list only known devices */ @@ -768,7 +768,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (strcmp (argv[1], "device") == 0) { if ((curr_device < 0) - || (curr_device >= CFG_MAX_NAND_DEVICE)) { + || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) { puts ("\nno devices available\n"); return 1; } @@ -778,7 +778,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (strcmp (argv[1], "bad") == 0) { if ((curr_device < 0) - || (curr_device >= CFG_MAX_NAND_DEVICE)) { + || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) { puts ("\nno devices available\n"); return 1; } @@ -794,7 +794,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int dev = (int) simple_strtoul (argv[2], NULL, 10); printf ("\nDevice %d: ", dev); - if (dev >= CFG_MAX_NAND_DEVICE) { + if (dev >= CONFIG_SYS_MAX_NAND_DEVICE) { puts ("unknown device\n"); return 1; } @@ -866,7 +866,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) else if (cmdtail && !strcmp (cmdtail, ".e")) cmd |= NANDRW_JFFS2; /* skip bad blocks */ #endif -#ifdef CFG_NAND_SKIP_BAD_DOT_I +#ifdef CONFIG_SYS_NAND_SKIP_BAD_DOT_I /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */ /* ".i" for image -> read skips bad block (no 0xff) */ else if (cmdtail && !strcmp (cmdtail, ".i")) { @@ -874,7 +874,7 @@ int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) if (cmd & NANDRW_READ) cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */ } -#endif /* CFG_NAND_SKIP_BAD_DOT_I */ +#endif /* CONFIG_SYS_NAND_SKIP_BAD_DOT_I */ else if (cmdtail) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; @@ -952,7 +952,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) show_boot_progress (52); switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: @@ -984,7 +984,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dev = simple_strtoul(boot_device, &ep, 16); - if ((dev >= CFG_MAX_NAND_DEVICE) || + if ((dev >= CONFIG_SYS_MAX_NAND_DEVICE) || (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) { printf ("\n** Device %d not available\n", dev); show_boot_progress (-55); diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 637d6c9..d280cb0 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -72,7 +72,7 @@ DECLARE_GLOBAL_DATA_PTR; /* * Table with supported baudrates (defined in config_xyz.h) */ -static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE; +static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE; #define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0])) @@ -416,9 +416,9 @@ int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #if defined(CONFIG_CMD_ASKENV) int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - extern char console_buffer[CFG_CBSIZE]; - char message[CFG_CBSIZE]; - int size = CFG_CBSIZE - 1; + extern char console_buffer[CONFIG_SYS_CBSIZE]; + char message[CONFIG_SYS_CBSIZE]; + int size = CONFIG_SYS_CBSIZE - 1; int len; char *local_args[4]; @@ -464,8 +464,8 @@ int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; } - if (size >= CFG_CBSIZE) - size = CFG_CBSIZE - 1; + if (size >= CONFIG_SYS_CBSIZE) + size = CONFIG_SYS_CBSIZE - 1; if (size <= 0) return 1; @@ -580,7 +580,7 @@ int envmatch (uchar *s1, int i2) /**************************************************/ U_BOOT_CMD( - printenv, CFG_MAXARGS, 1, do_printenv, + printenv, CONFIG_SYS_MAXARGS, 1, do_printenv, "printenv- print environment variables\n", "\n - print values of all environment variables\n" "printenv name ...\n" @@ -588,7 +588,7 @@ U_BOOT_CMD( ); U_BOOT_CMD( - setenv, CFG_MAXARGS, 0, do_setenv, + setenv, CONFIG_SYS_MAXARGS, 0, do_setenv, "setenv - set environment variables\n", "name value ...\n" " - set environment variable 'name' to 'value ...'\n" @@ -612,7 +612,7 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_ASKENV) U_BOOT_CMD( - askenv, CFG_MAXARGS, 1, do_askenv, + askenv, CONFIG_SYS_MAXARGS, 1, do_askenv, "askenv - get environment variables from stdin\n", "name [message] [size]\n" " - get environment variable 'name' from stdin (max 'size' chars)\n" @@ -629,7 +629,7 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_RUN) int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( - run, CFG_MAXARGS, 1, do_run, + run, CONFIG_SYS_MAXARGS, 1, do_run, "run - run commands in an environment variable\n", "var [...]\n" " - run the commands in the environment variable(s) 'var'\n" diff --git a/common/cmd_pci.c b/common/cmd_pci.c index b2aa833..67ff2fb 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -48,7 +48,7 @@ void pci_header_show_brief(pci_dev_t dev); * Subroutine: pciinfo * * Description: Show information about devices on PCI bus. - * Depending on the define CFG_SHORT_PCI_LISTING + * Depending on the define CONFIG_SYS_SHORT_PCI_LISTING * the output will be more or less exhaustive. * * Inputs: bus_no the number of the bus to be scanned. diff --git a/common/cmd_pcmcia.c b/common/cmd_pcmcia.c index dcd07c0..23fad3b 100644 --- a/common/cmd_pcmcia.c +++ b/common/cmd_pcmcia.c @@ -278,8 +278,8 @@ int check_ide_device (int slot) int found = 0; int i; - addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR + - CFG_PCMCIA_MEM_SIZE * (slot * 4)); + addr = (volatile uchar *)(CONFIG_SYS_PCMCIA_MEM_ADDR + + CONFIG_SYS_PCMCIA_MEM_SIZE * (slot * 4)); debug ("PCMCIA MEM: %08lX\n", (ulong)addr); start = p = (volatile uchar *) addr; diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c index c0a1459..4c8e61a 100644 --- a/common/cmd_reginfo.c +++ b/common/cmd_reginfo.c @@ -38,7 +38,7 @@ extern void mpc86xx_reginfo(void); int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { #if defined(CONFIG_8xx) - volatile immap_t *immap = (immap_t *)CFG_IMMR; + volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; volatile sysconf8xx_t *sysconf = &immap->im_siu_conf; volatile sit8xx_t *timers = &immap->im_sit; @@ -244,7 +244,7 @@ int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) puts ("\n\n"); #elif defined(CONFIG_5xx) - volatile immap_t *immap = (immap_t *)CFG_IMMR; + volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; volatile memctl5xx_t *memctl = &immap->im_memctl; volatile sysconf5xx_t *sysconf = &immap->im_siu_conf; volatile sit5xx_t *timers = &immap->im_sit; @@ -279,7 +279,7 @@ int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #elif defined(CONFIG_MPC5200) puts ("\nMPC5200 registers\n"); - printf ("MBAR=%08x\n", CFG_MBAR); + printf ("MBAR=%08x\n", CONFIG_SYS_MBAR); puts ("Memory map registers\n"); printf ("\tCS0: start %08lX\tstop %08lX\tconfig %08lX\ten %d\n", *(volatile ulong*)MPC5XXX_CS0_START, diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c index b7395d7..4f4117e 100644 --- a/common/cmd_reiser.c +++ b/common/cmd_reiser.c @@ -128,7 +128,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (addr_str != NULL) { addr = simple_strtoul (addr_str, NULL, 16); } else { - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; } filename = getenv ("bootfile"); count = 0; diff --git a/common/cmd_sata.c b/common/cmd_sata.c index 79c2495..dd6f1d9 100644 --- a/common/cmd_sata.c +++ b/common/cmd_sata.c @@ -29,14 +29,14 @@ #include int curr_device = -1; -block_dev_desc_t sata_dev_desc[CFG_SATA_MAX_DEVICE]; +block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; int sata_initialize(void) { int rc; int i; - for (i = 0; i < CFG_SATA_MAX_DEVICE; i++) { + for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) { memset(&sata_dev_desc[i], 0, sizeof(struct block_dev_desc)); sata_dev_desc[i].if_type = IF_TYPE_SATA; sata_dev_desc[i].dev = i; @@ -58,7 +58,7 @@ int sata_initialize(void) block_dev_desc_t *sata_get_dev(int dev) { - return (dev < CFG_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL; + return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL; } int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) @@ -74,7 +74,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (strncmp(argv[1],"inf", 3) == 0) { int i; putc('\n'); - for (i = 0; i < CFG_SATA_MAX_DEVICE; ++i) { + for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; ++i) { if (sata_dev_desc[i].type == DEV_TYPE_UNKNOWN) continue; printf ("SATA device %d: ", i); @@ -82,7 +82,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return 0; } else if (strncmp(argv[1],"dev", 3) == 0) { - if ((curr_device < 0) || (curr_device >= CFG_SATA_MAX_DEVICE)) { + if ((curr_device < 0) || (curr_device >= CONFIG_SYS_SATA_MAX_DEVICE)) { puts("\nno SATA devices available\n"); return 1; } @@ -92,7 +92,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else if (strncmp(argv[1],"part",4) == 0) { int dev, ok; - for (ok = 0, dev = 0; dev < CFG_SATA_MAX_DEVICE; ++dev) { + for (ok = 0, dev = 0; dev < CONFIG_SYS_SATA_MAX_DEVICE; ++dev) { if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) { ++ok; if (dev) @@ -113,7 +113,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int dev = (int)simple_strtoul(argv[2], NULL, 10); printf("\nSATA device %d: ", dev); - if (dev >= CFG_SATA_MAX_DEVICE) { + if (dev >= CONFIG_SYS_SATA_MAX_DEVICE) { puts ("unknown device\n"); return 1; } diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index f357465..066fd80 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -59,7 +59,7 @@ static int scsi_max_devs; /* number of highest available scsi device */ static int scsi_curr_dev; /* current device */ -static block_dev_desc_t scsi_dev_desc[CFG_SCSI_MAX_DEVICE]; +static block_dev_desc_t scsi_dev_desc[CONFIG_SYS_SCSI_MAX_DEVICE]; /******************************************************************************** * forward declerations of some Setup Routines @@ -88,7 +88,7 @@ void scsi_scan(int mode) if(mode==1) { printf("scanning bus for devices...\n"); } - for(i=0;itarget=i; - for(lun=0;lunlun=lun; pccb->pdata=(unsigned char *)&tempbuff; pccb->datalen=512; @@ -195,7 +195,7 @@ void scsi_init(void) block_dev_desc_t * scsi_get_dev(int dev) { - return (dev < CFG_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL; + return (dev < CONFIG_SYS_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL; } @@ -217,7 +217,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: @@ -356,7 +356,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (strncmp(argv[1],"inf",3) == 0) { int i; - for (i=0; i= CFG_SCSI_MAX_DEVICE)) { + if ((scsi_curr_dev < 0) || (scsi_curr_dev >= CONFIG_SYS_SCSI_MAX_DEVICE)) { printf("\nno SCSI devices available\n"); return 1; } @@ -379,7 +379,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (strncmp(argv[1],"part",4) == 0) { int dev, ok; - for (ok=0, dev=0; dev= CFG_SCSI_MAX_DEVICE) { + if (dev >= CONFIG_SYS_SCSI_MAX_DEVICE) { printf("unknown device\n"); return 1; } diff --git a/common/cmd_usb.c b/common/cmd_usb.c index c62ca97..99e551f 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -321,7 +321,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 1: - addr = CFG_LOAD_ADDR; + addr = CONFIG_SYS_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: diff --git a/common/command.c b/common/command.c index fc9d79c..a4a978c 100644 --- a/common/command.c +++ b/common/command.c @@ -70,7 +70,7 @@ do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD( - echo, CFG_MAXARGS, 1, do_echo, + echo, CONFIG_SYS_MAXARGS, 1, do_echo, "echo - echo args to console\n", "[args..]\n" " - echo args to console; \\c suppresses newline\n" @@ -78,7 +78,7 @@ U_BOOT_CMD( #endif -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER int do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) @@ -202,7 +202,7 @@ do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD( - test, CFG_MAXARGS, 1, do_test, + test, CONFIG_SYS_MAXARGS, 1, do_test, "test - minimal test like /bin/sh\n", "[args..]\n" " - test functionality\n" @@ -286,7 +286,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) */ for (i = 1; i < argc; ++i) { if ((cmdtp = find_cmd (argv[i])) != NULL) { -#ifdef CFG_LONGHELP +#ifdef CONFIG_SYS_LONGHELP /* found - print (long) help info */ puts (cmdtp->name); putc (' '); @@ -300,7 +300,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) #else /* no long help available */ if (cmdtp->usage) puts (cmdtp->usage); -#endif /* CFG_LONGHELP */ +#endif /* CONFIG_SYS_LONGHELP */ } else { printf ("Unknown command '%s' - try 'help'" " without arguments for list of all" @@ -314,7 +314,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( - help, CFG_MAXARGS, 1, do_help, + help, CONFIG_SYS_MAXARGS, 1, do_help, "help - print online help\n", "[command ...]\n" " - show help information (for 'command')\n" @@ -325,18 +325,18 @@ U_BOOT_CMD( ); /* This do not ust the U_BOOT_CMD macro as ? can't be used in symbol names */ -#ifdef CFG_LONGHELP +#ifdef CONFIG_SYS_LONGHELP cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = { - "?", CFG_MAXARGS, 1, do_help, + "?", CONFIG_SYS_MAXARGS, 1, do_help, "? - alias for 'help'\n", NULL }; #else cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = { - "?", CFG_MAXARGS, 1, do_help, + "?", CONFIG_SYS_MAXARGS, 1, do_help, "? - alias for 'help'\n" }; -#endif /* CFG_LONGHELP */ +#endif /* CONFIG_SYS_LONGHELP */ /*************************************************************************** * find command table entry for a command @@ -570,12 +570,12 @@ static int find_common_prefix(char *argv[]) return len; } -static char tmp_buf[CFG_CBSIZE]; /* copy of console I/O buffer */ +static char tmp_buf[CONFIG_SYS_CBSIZE]; /* copy of console I/O buffer */ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) { int n = *np, col = *colp; - char *argv[CFG_MAXARGS + 1]; /* NULL terminated */ + char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */ char *cmdv[20]; char *s, *t; const char *sep; @@ -583,7 +583,7 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) int cnt; char last_char; - if (strcmp(prompt, CFG_PROMPT) != 0) + if (strcmp(prompt, CONFIG_SYS_PROMPT) != 0) return 0; /* not in normal console */ cnt = strlen(buf); @@ -631,7 +631,7 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) if (s != NULL) { k = len + seplen; /* make sure it fits */ - if (n + k >= CFG_CBSIZE - 2) { + if (n + k >= CONFIG_SYS_CBSIZE - 2) { putc('\a'); return 1; } diff --git a/common/console.c b/common/console.c index 56d9118..6f0846f 100644 --- a/common/console.c +++ b/common/console.c @@ -33,20 +33,20 @@ DECLARE_GLOBAL_DATA_PTR; int console_changed = 0; #endif -#ifdef CFG_CONSOLE_IS_IN_ENV +#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV /* * if overwrite_console returns 1, the stdin, stderr and stdout * are switched to the serial port, else the settings in the * environment are used */ -#ifdef CFG_CONSOLE_OVERWRITE_ROUTINE +#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE extern int overwrite_console (void); #define OVERWRITE_CONSOLE overwrite_console () #else #define OVERWRITE_CONSOLE 0 -#endif /* CFG_CONSOLE_OVERWRITE_ROUTINE */ +#endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */ -#endif /* CFG_CONSOLE_IS_IN_ENV */ +#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */ static int console_setfile (int file, device_t * dev) { @@ -99,7 +99,7 @@ void serial_printf (const char *fmt, ...) { va_list args; uint i; - char printbuffer[CFG_PBSIZE]; + char printbuffer[CONFIG_SYS_PBSIZE]; va_start (args, fmt); @@ -144,7 +144,7 @@ void fprintf (int file, const char *fmt, ...) { va_list args; uint i; - char printbuffer[CFG_PBSIZE]; + char printbuffer[CONFIG_SYS_PBSIZE]; va_start (args, fmt); @@ -238,7 +238,7 @@ void printf (const char *fmt, ...) { va_list args; uint i; - char printbuffer[CFG_PBSIZE]; + char printbuffer[CONFIG_SYS_PBSIZE]; va_start (args, fmt); @@ -255,7 +255,7 @@ void printf (const char *fmt, ...) void vprintf (const char *fmt, va_list args) { uint i; - char printbuffer[CFG_PBSIZE]; + char printbuffer[CONFIG_SYS_PBSIZE]; /* For this to work, printbuffer must be larger than * anything we ever want to print. @@ -314,7 +314,7 @@ inline void dbg(const char *fmt, ...) { va_list args; uint i; - char printbuffer[CFG_PBSIZE]; + char printbuffer[CONFIG_SYS_PBSIZE]; if (!once) { memset(screen, 0, sizeof(screen)); @@ -398,15 +398,15 @@ int console_init_f (void) return (0); } -#ifdef CFG_CONSOLE_IS_IN_ENV +#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV /* Called after the relocation - use desired console functions */ int console_init_r (void) { char *stdinname, *stdoutname, *stderrname; device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL; -#ifdef CFG_CONSOLE_ENV_OVERWRITE +#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; -#endif /* CFG_CONSOLE_ENV_OVERWRITE */ +#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ /* set default handlers at first */ gd->jt[XF_getc] = serial_getc; @@ -449,7 +449,7 @@ int console_init_r (void) gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ -#ifndef CFG_CONSOLE_INFO_QUIET +#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET /* Print information */ puts ("In: "); if (stdio_devices[stdin] == NULL) { @@ -471,14 +471,14 @@ int console_init_r (void) } else { printf ("%s\n", stdio_devices[stderr]->name); } -#endif /* CFG_CONSOLE_INFO_QUIET */ +#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ -#ifdef CFG_CONSOLE_ENV_OVERWRITE +#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE /* set the environment variables (will overwrite previous env settings) */ for (i = 0; i < 3; i++) { setenv (stdio_names[i], stdio_devices[i]->name); } -#endif /* CFG_CONSOLE_ENV_OVERWRITE */ +#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ #if 0 /* If nothing usable installed, use only the initial console */ @@ -488,7 +488,7 @@ int console_init_r (void) return (0); } -#else /* CFG_CONSOLE_IS_IN_ENV */ +#else /* CONFIG_SYS_CONSOLE_IS_IN_ENV */ /* Called after the relocation - use desired console functions */ int console_init_r (void) @@ -533,7 +533,7 @@ int console_init_r (void) gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ -#ifndef CFG_CONSOLE_INFO_QUIET +#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET /* Print information */ puts ("In: "); if (stdio_devices[stdin] == NULL) { @@ -555,7 +555,7 @@ int console_init_r (void) } else { printf ("%s\n", stdio_devices[stderr]->name); } -#endif /* CFG_CONSOLE_INFO_QUIET */ +#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ /* Setting environment variables */ for (i = 0; i < 3; i++) { @@ -571,4 +571,4 @@ int console_init_r (void) return (0); } -#endif /* CFG_CONSOLE_IS_IN_ENV */ +#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */ diff --git a/common/cyclon2.c b/common/cyclon2.c index 479bebb..3ed64b2 100644 --- a/common/cyclon2.c +++ b/common/cyclon2.c @@ -43,8 +43,8 @@ #define CONFIG_FPGA_DELAY() #endif -#ifndef CFG_FPGA_WAIT -#define CFG_FPGA_WAIT CFG_HZ/10 /* 100 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT +#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/10 /* 100 ms */ #endif static int CYC2_ps_load( Altera_desc *desc, void *buf, size_t bsize ); @@ -147,7 +147,7 @@ static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) "done:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->config, fn->status, fn->write, fn->done); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...", cookie); #endif @@ -167,7 +167,7 @@ static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) ts = get_timer (0); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for STATUS to go high.\n"); (*fn->abort) (cookie); return FPGA_FAIL; @@ -183,13 +183,13 @@ static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) (*fn->abort) (cookie); return FPGA_FAIL; } -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts(" OK? ..."); #endif CONFIG_FPGA_DELAY (); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc (' '); /* terminate the dotted line */ #endif @@ -202,13 +202,13 @@ static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) (*fn->abort) (cookie); return (FPGA_FAIL); } -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts(" OK\n"); #endif ret_val = FPGA_SUCCESS; -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); } diff --git a/common/devices.c b/common/devices.c index 7d0ac2e..ce3b7a0 100644 --- a/common/devices.c +++ b/common/devices.c @@ -40,12 +40,12 @@ static device_t devs; device_t *stdio_devices[] = { NULL, NULL, NULL }; char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" }; -#if defined(CONFIG_SPLASH_SCREEN) && !defined(CFG_DEVICE_NULLDEV) -#define CFG_DEVICE_NULLDEV 1 +#if defined(CONFIG_SPLASH_SCREEN) && !defined(CONFIG_SYS_DEVICE_NULLDEV) +#define CONFIG_SYS_DEVICE_NULLDEV 1 #endif -#ifdef CFG_DEVICE_NULLDEV +#ifdef CONFIG_SYS_DEVICE_NULLDEV void nulldev_putc(const char c) { /* nulldev is empty! */ @@ -90,7 +90,7 @@ static void drv_system_init (void) device_register (&dev); -#ifdef CFG_DEVICE_NULLDEV +#ifdef CONFIG_SYS_DEVICE_NULLDEV memset (&dev, 0, sizeof (dev)); strcpy (dev.name, "nulldev"); @@ -162,7 +162,7 @@ int device_register (device_t * dev) /* deregister the device "devname". * returns 0 if success, -1 if device is assigned and 1 if devname not found */ -#ifdef CFG_DEVICE_DEREGISTER +#ifdef CONFIG_SYS_DEVICE_DEREGISTER int device_deregister(char *devname) { int l; @@ -197,7 +197,7 @@ int device_deregister(char *devname) } return 0; } -#endif /* CFG_DEVICE_DEREGISTER */ +#endif /* CONFIG_SYS_DEVICE_DEREGISTER */ int devices_init (void) { @@ -216,7 +216,7 @@ int devices_init (void) INIT_LIST_HEAD(&(devs.list)); #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) - i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); #endif #ifdef CONFIG_LCD drv_lcd_init (); diff --git a/common/env_common.c b/common/env_common.c index 0fee3af..6be3bb0 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -103,8 +103,8 @@ uchar default_environment[] = { #ifdef CONFIG_SERVERIP "serverip=" MK_STR(CONFIG_SERVERIP) "\0" #endif -#ifdef CFG_AUTOLOAD - "autoload=" CFG_AUTOLOAD "\0" +#ifdef CONFIG_SYS_AUTOLOAD + "autoload=" CONFIG_SYS_AUTOLOAD "\0" #endif #ifdef CONFIG_PREBOOT "preboot=" CONFIG_PREBOOT "\0" @@ -220,7 +220,7 @@ void set_default_env(void) memset(env_ptr, 0, sizeof(env_t)); memcpy(env_ptr->data, default_environment, sizeof(default_environment)); -#ifdef CFG_REDUNDAND_ENVIRONMENT +#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT env_ptr->flags = 0xFF; #endif env_crc_update (); diff --git a/common/env_eeprom.c b/common/env_eeprom.c index 1f0f413..1578d61 100644 --- a/common/env_eeprom.c +++ b/common/env_eeprom.c @@ -39,7 +39,7 @@ uchar env_get_char_spec (int index) { uchar c; - eeprom_read (CFG_DEF_EEPROM_ADDR, + eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+index+offsetof(env_t,data), &c, 1); @@ -48,7 +48,7 @@ uchar env_get_char_spec (int index) void env_relocate_spec (void) { - eeprom_read (CFG_DEF_EEPROM_ADDR, + eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET, (uchar*)env_ptr, CONFIG_ENV_SIZE); @@ -56,7 +56,7 @@ void env_relocate_spec (void) int saveenv(void) { - return eeprom_write (CFG_DEF_EEPROM_ADDR, + return eeprom_write (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET, (uchar *)env_ptr, CONFIG_ENV_SIZE); @@ -77,7 +77,7 @@ int env_init(void) eeprom_init (); /* prepare for EEPROM read/write */ /* read old CRC */ - eeprom_read (CFG_DEF_EEPROM_ADDR, + eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+offsetof(env_t,crc), (uchar *)&crc, sizeof(ulong)); @@ -87,7 +87,7 @@ int env_init(void) while (len > 0) { int n = (len > sizeof(buf)) ? sizeof(buf) : len; - eeprom_read (CFG_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n); + eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n); new = crc32 (new, buf, n); len -= n; off += n; diff --git a/common/env_embedded.c b/common/env_embedded.c index e79f843..ae6cac4 100644 --- a/common/env_embedded.c +++ b/common/env_embedded.c @@ -51,7 +51,7 @@ * a seperate section. Note that ENV_CRC is only defined when building * U-Boot itself. */ -#if (defined(CFG_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ +#if (defined(CONFIG_SYS_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */ /* XXX - This only works with GNU C */ # define __PPCENV__ __attribute__ ((section(".ppcenv"))) @@ -98,7 +98,7 @@ env_t environment __PPCENV__ = { ENV_CRC, /* CRC Sum */ -#ifdef CFG_REDUNDAND_ENVIRONMENT +#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT 1, /* Flags: valid */ #endif { @@ -150,8 +150,8 @@ env_t environment __PPCENV__ = { #ifdef CONFIG_SERVERIP "serverip=" MK_STR(CONFIG_SERVERIP) "\0" #endif -#ifdef CFG_AUTOLOAD - "autoload=" CFG_AUTOLOAD "\0" +#ifdef CONFIG_SYS_AUTOLOAD + "autoload=" CONFIG_SYS_AUTOLOAD "\0" #endif #ifdef CONFIG_ROOTPATH "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" diff --git a/common/env_nvram.c b/common/env_nvram.c index a8b7959..562edd0 100644 --- a/common/env_nvram.c +++ b/common/env_nvram.c @@ -35,7 +35,7 @@ * space using its address and data registers. To enable usage of * NVRAM in those cases I invented the functions 'nvram_read()' and * 'nvram_write()', which will be activated upon the configuration - * #define CFG_NVRAM_ACCESS_ROUTINE. Note, that those functions are + * #define CONFIG_SYS_NVRAM_ACCESS_ROUTINE. Note, that those functions are * strongly dependent on the used HW, and must be redefined for each * board that wants to use them. */ @@ -47,7 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; -#ifdef CFG_NVRAM_ACCESS_ROUTINE +#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE extern void *nvram_read(void *dest, const long src, size_t count); extern void nvram_write(long dest, const void *src, size_t count); env_t *env_ptr = NULL; @@ -63,7 +63,7 @@ extern int default_environment_size; #ifdef CONFIG_AMIGAONEG3SE uchar env_get_char_spec (int index) { -#ifdef CFG_NVRAM_ACCESS_ROUTINE +#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE uchar c; nvram_read(&c, CONFIG_ENV_ADDR+index, 1); @@ -80,7 +80,7 @@ uchar env_get_char_spec (int index) #else uchar env_get_char_spec (int index) { -#ifdef CFG_NVRAM_ACCESS_ROUTINE +#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE uchar c; nvram_read(&c, CONFIG_ENV_ADDR+index, 1); @@ -94,7 +94,7 @@ uchar env_get_char_spec (int index) void env_relocate_spec (void) { -#if defined(CFG_NVRAM_ACCESS_ROUTINE) +#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE) nvram_read(env_ptr, CONFIG_ENV_ADDR, CONFIG_ENV_SIZE); #else memcpy (env_ptr, (void*)CONFIG_ENV_ADDR, CONFIG_ENV_SIZE); @@ -107,7 +107,7 @@ int saveenv (void) #ifdef CONFIG_AMIGAONEG3SE enable_nvram(); #endif -#ifdef CFG_NVRAM_ACCESS_ROUTINE +#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE nvram_write(CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE); #else if (memcpy ((char *)CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE) == NULL) @@ -131,7 +131,7 @@ int env_init (void) #ifdef CONFIG_AMIGAONEG3SE enable_nvram(); #endif -#if defined(CFG_NVRAM_ACCESS_ROUTINE) +#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE) ulong crc; uchar data[ENV_SIZE]; nvram_read (&crc, CONFIG_ENV_ADDR, sizeof(ulong)); diff --git a/common/flash.c b/common/flash.c index fe39d55..eb4b2f5 100644 --- a/common/flash.c +++ b/common/flash.c @@ -26,7 +26,7 @@ #include #include -#if !defined(CFG_NO_FLASH) +#if !defined(CONFIG_SYS_NO_FLASH) extern flash_info_t flash_info[]; /* info for FLASH chips */ @@ -75,19 +75,19 @@ flash_protect (int flag, ulong from, ulong to, flash_info_t *info) */ if (from <= end && to >= info->start[i]) { if (flag & FLAG_PROTECT_CLEAR) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) flash_real_protect(info, i, 0); #else info->protect[i] = 0; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ debug ("protect off %d\n", i); } else if (flag & FLAG_PROTECT_SET) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) flash_real_protect(info, i, 1); #else info->protect[i] = 1; -#endif /* CFG_FLASH_PROTECTION */ +#endif /* CONFIG_SYS_FLASH_PROTECTION */ debug ("protect on %d\n", i); } } @@ -104,7 +104,7 @@ addr2info (ulong addr) flash_info_t *info; int i; - for (i=0, info = &flash_info[0]; iflash_id != FLASH_UNKNOWN && addr >= info->start[0] && /* WARNING - The '- 1' is needed if the flash @@ -225,4 +225,4 @@ void flash_perror (int err) /*----------------------------------------------------------------------- */ -#endif /* !CFG_NO_FLASH */ +#endif /* !CONFIG_SYS_NO_FLASH */ diff --git a/common/hush.c b/common/hush.c index 67bed39..9aef6e4 100644 --- a/common/hush.c +++ b/common/hush.c @@ -96,7 +96,7 @@ /*cmd_boot.c*/ extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /* do_bootd */ #endif -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER #ifndef __U_BOOT__ #include /* isalpha, isdigit */ #include /* getpid */ @@ -1019,9 +1019,9 @@ static void get_user_input(struct in_str *i) fflush(stdout); i->p = the_command; #else - extern char console_buffer[CFG_CBSIZE]; + extern char console_buffer[CONFIG_SYS_CBSIZE]; int n; - static char the_command[CFG_CBSIZE]; + static char the_command[CONFIG_SYS_CBSIZE]; #ifdef CONFIG_BOOT_RETRY_TIME # ifdef CONFIG_RESET_TO_RETRY @@ -1033,9 +1033,9 @@ static void get_user_input(struct in_str *i) #endif i->__promptme = 1; if (i->promptmode == 1) { - n = readline(CFG_PROMPT); + n = readline(CONFIG_SYS_PROMPT); } else { - n = readline(CFG_PROMPT_HUSH_PS2); + n = readline(CONFIG_SYS_PROMPT_HUSH_PS2); } #ifdef CONFIG_BOOT_RETRY_TIME if (n == -2) { @@ -1075,7 +1075,7 @@ static void get_user_input(struct in_str *i) else { if (console_buffer[0] != '\n') { if (strlen(the_command) + strlen(console_buffer) - < CFG_CBSIZE) { + < CONFIG_SYS_CBSIZE) { n = strlen(the_command); the_command[n-1] = ' '; strcpy(&the_command[n],console_buffer); @@ -3624,7 +3624,7 @@ int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD( - showvar, CFG_MAXARGS, 1, do_showvar, + showvar, CONFIG_SYS_MAXARGS, 1, do_showvar, "showvar- print local hushshell variables\n", "\n - print values of all hushshell variables\n" "showvar name ...\n" @@ -3632,5 +3632,5 @@ U_BOOT_CMD( ); #endif -#endif /* CFG_HUSH_PARSER */ +#endif /* CONFIG_SYS_HUSH_PARSER */ /****************************************************************************/ diff --git a/common/image.c b/common/image.c index 0b7bd8d..866edf6 100644 --- a/common/image.c +++ b/common/image.c @@ -426,8 +426,8 @@ ulong getenv_bootm_low(void) return tmp; } -#if defined(CFG_SDRAM_BASE) - return CFG_SDRAM_BASE; +#if defined(CONFIG_SYS_SDRAM_BASE) + return CONFIG_SYS_SDRAM_BASE; #elif defined(CONFIG_ARM) return gd->bd->bi_dram[0].start; #else @@ -440,7 +440,7 @@ phys_size_t getenv_bootm_size(void) char *s = getenv ("bootm_size"); if (s) { phys_size_t tmp; -#ifdef CFG_64BIT_STRTOUL +#ifdef CONFIG_SYS_64BIT_STRTOUL tmp = (phys_size_t)simple_strtoull (s, NULL, 16); #else tmp = (phys_size_t)simple_strtoul (s, NULL, 16); @@ -663,7 +663,7 @@ ulong genimg_get_image (ulong img_addr) if (addr_dataflash (img_addr)){ /* ger RAM address */ - ram_addr = CFG_LOAD_ADDR; + ram_addr = CONFIG_SYS_LOAD_ADDR; /* get header size */ h_size = image_get_header_size (); @@ -1154,8 +1154,8 @@ static int fit_check_fdt (const void *fit, int fdt_noffset, int verify) } #endif /* CONFIG_FIT */ -#ifndef CFG_FDT_PAD -#define CFG_FDT_PAD 0x3000 +#ifndef CONFIG_SYS_FDT_PAD +#define CONFIG_SYS_FDT_PAD 0x3000 #endif /** @@ -1190,7 +1190,7 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, goto error; } -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH /* move the blob if it is in flash (set relocate) */ if (addr2info ((ulong)fdt_blob) != NULL) relocate = 1; @@ -1202,8 +1202,8 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, if (fdt_blob < (char *)bootmap_base) relocate = 1; - if ((fdt_blob + *of_size + CFG_FDT_PAD) >= - ((char *)CFG_BOOTMAPSZ + bootmap_base)) + if ((fdt_blob + *of_size + CONFIG_SYS_FDT_PAD) >= + ((char *)CONFIG_SYS_BOOTMAPSZ + bootmap_base)) relocate = 1; /* move flattend device tree if needed */ @@ -1213,9 +1213,9 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, /* position on a 4K boundary before the alloc_current */ /* Pad the FDT by a specified amount */ - of_len = *of_size + CFG_FDT_PAD; + of_len = *of_size + CONFIG_SYS_FDT_PAD; of_start = (unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, - (CFG_BOOTMAPSZ + bootmap_base)); + (CONFIG_SYS_BOOTMAPSZ + bootmap_base)); if (of_start == 0) { puts("device tree - allocation error\n"); @@ -1240,7 +1240,7 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, *of_size = of_len; } else { *of_flat_tree = fdt_blob; - of_len = (CFG_BOOTMAPSZ + bootmap_base) - (ulong)fdt_blob; + of_len = (CONFIG_SYS_BOOTMAPSZ + bootmap_base) - (ulong)fdt_blob; lmb_reserve(lmb, (ulong)fdt_blob, of_len); fdt_set_totalsize(*of_flat_tree, of_len); @@ -1598,8 +1598,8 @@ int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end, char *cmdline; char *s; - cmdline = (char *)(ulong)lmb_alloc_base(lmb, CFG_BARGSIZE, 0xf, - CFG_BOOTMAPSZ + bootmap_base); + cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf, + CONFIG_SYS_BOOTMAPSZ + bootmap_base); if (cmdline == NULL) return -1; @@ -1635,7 +1635,7 @@ int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end, int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base) { *kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf, - CFG_BOOTMAPSZ + bootmap_base); + CONFIG_SYS_BOOTMAPSZ + bootmap_base); if (*kbd == NULL) return -1; diff --git a/common/kgdb.c b/common/kgdb.c index b14898b..adc15dd 100644 --- a/common/kgdb.c +++ b/common/kgdb.c @@ -574,7 +574,7 @@ do_kgdb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } U_BOOT_CMD( - kgdb, CFG_MAXARGS, 1, do_kgdb, + kgdb, CONFIG_SYS_MAXARGS, 1, do_kgdb, "kgdb - enter gdb remote debug mode\n", "[arg0 arg1 .. argN]\n" " - executes a breakpoint so that kgdb mode is\n" diff --git a/common/lcd.c b/common/lcd.c index 25f8664..d104b26 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -386,13 +386,13 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); #endif -#ifndef CFG_WHITE_ON_BLACK +#ifndef CONFIG_SYS_WHITE_ON_BLACK lcd_setfgcolor (CONSOLE_COLOR_BLACK); lcd_setbgcolor (CONSOLE_COLOR_WHITE); #else lcd_setfgcolor (CONSOLE_COLOR_WHITE); lcd_setbgcolor (CONSOLE_COLOR_BLACK); -#endif /* CFG_WHITE_ON_BLACK */ +#endif /* CONFIG_SYS_WHITE_ON_BLACK */ #ifdef LCD_TEST_PATTERN test_pattern(); @@ -531,7 +531,7 @@ void bitmap_plot (int x, int y) #if defined(CONFIG_PXA250) struct pxafb_info *fbi = &panel_info.pxa; #elif defined(CONFIG_MPC823) - volatile immap_t *immr = (immap_t *) CFG_IMMR; + volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; volatile cpm8xx_t *cp = &(immr->im_cpm); #endif @@ -571,7 +571,7 @@ void bitmap_plot (int x, int y) *(cmap + BMP_LOGO_OFFSET) = lut_entry; cmap++; #else /* !CONFIG_ATMEL_LCD */ -#ifdef CFG_INVERT_COLORS +#ifdef CONFIG_SYS_INVERT_COLORS *cmap++ = 0xffff - colreg; #else *cmap++ = colreg; @@ -627,7 +627,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) #if defined(CONFIG_PXA250) struct pxafb_info *fbi = &panel_info.pxa; #elif defined(CONFIG_MPC823) - volatile immap_t *immr = (immap_t *) CFG_IMMR; + volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; volatile cpm8xx_t *cp = &(immr->im_cpm); #endif @@ -681,7 +681,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) ( ((cte.red) << 8) & 0xf800) | ( ((cte.green) << 3) & 0x07e0) | ( ((cte.blue) >> 3) & 0x001f) ; -#ifdef CFG_INVERT_COLORS +#ifdef CONFIG_SYS_INVERT_COLORS *cmap = 0xffff - colreg; #else *cmap = colreg; @@ -845,7 +845,7 @@ static void *lcd_logo (void) for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; - for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) nand_size += nand_info[i].size; sprintf (info, " %ld MB SDRAM, %ld MB NAND", dram_size >> 20, diff --git a/common/main.c b/common/main.c index 9a9fc9d..a999a5d 100644 --- a/common/main.c +++ b/common/main.c @@ -34,7 +34,7 @@ #include /* for free() prototype */ #endif -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER #include #endif @@ -68,7 +68,7 @@ static int abortboot(int); #undef DEBUG_PARSER -char console_buffer[CFG_CBSIZE]; /* console I/O buffer */ +char console_buffer[CONFIG_SYS_CBSIZE]; /* console I/O buffer */ static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen); static char erase_seq[] = "\b \b"; /* erase sequence */ @@ -272,8 +272,8 @@ static __inline__ int abortboot(int bootdelay) void main_loop (void) { -#ifndef CFG_HUSH_PARSER - static char lastcommand[CFG_CBSIZE] = { 0, }; +#ifndef CONFIG_SYS_HUSH_PARSER + static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, }; int len; int rc = 1; int flag; @@ -337,7 +337,7 @@ void main_loop (void) } #endif /* CONFIG_VERSION_VARIABLE */ -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER u_boot_hush_start (); #endif @@ -355,7 +355,7 @@ void main_loop (void) int prev = disable_ctrlc(1); /* disable Control C checking */ # endif -# ifndef CFG_HUSH_PARSER +# ifndef CONFIG_SYS_HUSH_PARSER run_command (p, 0); # else parse_string_outer(p, FLAG_PARSE_SEMICOLON | @@ -401,7 +401,7 @@ void main_loop (void) int prev = disable_ctrlc(1); /* disable Control C checking */ # endif -# ifndef CFG_HUSH_PARSER +# ifndef CONFIG_SYS_HUSH_PARSER run_command (s, 0); # else parse_string_outer(s, FLAG_PARSE_SEMICOLON | @@ -417,7 +417,7 @@ void main_loop (void) if (menukey == CONFIG_MENUKEY) { s = getenv("menucmd"); if (s) { -# ifndef CFG_HUSH_PARSER +# ifndef CONFIG_SYS_HUSH_PARSER run_command (s, 0); # else parse_string_outer(s, FLAG_PARSE_SEMICOLON | @@ -438,7 +438,7 @@ void main_loop (void) /* * Main Loop for Monitor Command Processing */ -#ifdef CFG_HUSH_PARSER +#ifdef CONFIG_SYS_HUSH_PARSER parse_file_outer(); /* This point is never reached */ for (;;); @@ -452,7 +452,7 @@ void main_loop (void) reset_cmd_timeout(); } #endif - len = readline (CFG_PROMPT); + len = readline (CONFIG_SYS_PROMPT); flag = 0; /* assume no special flags for now */ if (len > 0) @@ -483,7 +483,7 @@ void main_loop (void) lastcommand[0] = 0; } } -#endif /*CFG_HUSH_PARSER*/ +#endif /*CONFIG_SYS_HUSH_PARSER*/ } #ifdef CONFIG_BOOT_RETRY_TIME @@ -1042,7 +1042,7 @@ int readline_into_buffer (const char *const prompt, char * buffer) /* * Must be a normal character then */ - if (n < CFG_CBSIZE-2) { + if (n < CONFIG_SYS_CBSIZE-2) { if (c == '\t') { /* expand TABs */ #ifdef CONFIG_AUTO_COMPLETE /* if auto completion triggered just continue */ @@ -1111,7 +1111,7 @@ int parse_line (char *line, char *argv[]) #ifdef DEBUG_PARSER printf ("parse_line: \"%s\"\n", line); #endif - while (nargs < CFG_MAXARGS) { + while (nargs < CONFIG_SYS_MAXARGS) { /* skip any white space */ while ((*line == ' ') || (*line == '\t')) { @@ -1144,7 +1144,7 @@ int parse_line (char *line, char *argv[]) *line++ = '\0'; /* terminate current arg */ } - printf ("** Too many args (max. %d) **\n", CFG_MAXARGS); + printf ("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS); #ifdef DEBUG_PARSER printf ("parse_line: nargs=%d\n", nargs); @@ -1159,7 +1159,7 @@ static void process_macros (const char *input, char *output) char c, prev; const char *varname_start = NULL; int inputcnt = strlen (input); - int outputcnt = CFG_CBSIZE; + int outputcnt = CONFIG_SYS_CBSIZE; int state = 0; /* 0 = waiting for '$' */ /* 1 = waiting for '(' or '{' */ @@ -1219,7 +1219,7 @@ static void process_macros (const char *input, char *output) case 2: /* Waiting for ) */ if (c == ')' || c == '}') { int i; - char envname[CFG_CBSIZE], *envval; + char envname[CONFIG_SYS_CBSIZE], *envval; int envcnt = input - varname_start - 1; /* Varname # of chars */ /* Get the varname */ @@ -1270,7 +1270,7 @@ static void process_macros (const char *input, char *output) * 0 - command executed but not repeatable, interrupted commands are * always considered not repeatable * -1 - not executed (unrecognized, bootd recursion or too many args) - * (If cmd is NULL or "" or longer than CFG_CBSIZE-1 it is + * (If cmd is NULL or "" or longer than CONFIG_SYS_CBSIZE-1 it is * considered unrecognized) * * WARNING: @@ -1284,12 +1284,12 @@ static void process_macros (const char *input, char *output) int run_command (const char *cmd, int flag) { cmd_tbl_t *cmdtp; - char cmdbuf[CFG_CBSIZE]; /* working copy of cmd */ + char cmdbuf[CONFIG_SYS_CBSIZE]; /* working copy of cmd */ char *token; /* start of token in cmdbuf */ char *sep; /* end of token (separator) in cmdbuf */ - char finaltoken[CFG_CBSIZE]; + char finaltoken[CONFIG_SYS_CBSIZE]; char *str = cmdbuf; - char *argv[CFG_MAXARGS + 1]; /* NULL terminated */ + char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */ int argc, inquotes; int repeatable = 1; int rc = 0; @@ -1306,7 +1306,7 @@ int run_command (const char *cmd, int flag) return -1; /* empty command */ } - if (strlen(cmd) >= CFG_CBSIZE) { + if (strlen(cmd) >= CONFIG_SYS_CBSIZE) { puts ("## Command too long!\n"); return -1; } @@ -1425,7 +1425,7 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) printf ("## Error: \"%s\" not defined\n", argv[i]); return 1; } -#ifndef CFG_HUSH_PARSER +#ifndef CONFIG_SYS_HUSH_PARSER if (run_command (arg, flag) == -1) return 1; #else diff --git a/common/miiphyutil.c b/common/miiphyutil.c index 5ef4a33..66fd9ca 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -462,7 +462,7 @@ int miiphy_is_1000base_x (char *devname, unsigned char addr) #endif } -#ifdef CFG_FAULT_ECHO_LINK_DOWN +#ifdef CONFIG_SYS_FAULT_ECHO_LINK_DOWN /***************************************************************************** * * Determine link status diff --git a/common/serial.c b/common/serial.c index bfda7ca..b38d1e7 100644 --- a/common/serial.c +++ b/common/serial.c @@ -43,7 +43,7 @@ struct serial_device *__default_serial_console (void) #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \ || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \ || defined(CONFIG_MPC5xxx) -#if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL) +#if defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL) #if (CONFIG_CONS_INDEX==1) return &eserial1_device; #elif (CONFIG_CONS_INDEX==2) @@ -110,20 +110,20 @@ void serial_initialize (void) serial_register(&serial1_device); #endif -#if defined(CFG_NS16550_SERIAL) -#if defined(CFG_NS16550_COM1) +#if defined(CONFIG_SYS_NS16550_SERIAL) +#if defined(CONFIG_SYS_NS16550_COM1) serial_register(&eserial1_device); #endif -#if defined(CFG_NS16550_COM2) +#if defined(CONFIG_SYS_NS16550_COM2) serial_register(&eserial2_device); #endif -#if defined(CFG_NS16550_COM3) +#if defined(CONFIG_SYS_NS16550_COM3) serial_register(&eserial3_device); #endif -#if defined(CFG_NS16550_COM4) +#if defined(CONFIG_SYS_NS16550_COM4) serial_register(&eserial4_device); #endif -#endif /* CFG_NS16550_SERIAL */ +#endif /* CONFIG_SYS_NS16550_SERIAL */ #if defined (CONFIG_FFUART) serial_register(&serial_ffuart_device); #endif diff --git a/common/spartan2.c b/common/spartan2.c index ebac388..f5ba7fc 100644 --- a/common/spartan2.c +++ b/common/spartan2.c @@ -32,8 +32,8 @@ #define PRINTF(fmt,args...) #endif -#undef CFG_FPGA_CHECK_BUSY -#undef CFG_FPGA_PROG_FEEDBACK +#undef CONFIG_SYS_FPGA_CHECK_BUSY +#undef CONFIG_SYS_FPGA_PROG_FEEDBACK /* Note: The assumption is that we cannot possibly run fast enough to * overrun the device (the Slave Parallel mode can free run at 50MHz). @@ -44,8 +44,8 @@ #define CONFIG_FPGA_DELAY() #endif -#ifndef CFG_FPGA_WAIT -#define CFG_FPGA_WAIT CFG_HZ/100 /* 10 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT +#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/100 /* 10 ms */ #endif static int Spartan2_sp_load( Xilinx_desc *desc, void *buf, size_t bsize ); @@ -180,7 +180,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) * Continuous Data Loading in Slave Parallel Mode for * the Spartan-II Family. */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif /* @@ -201,7 +201,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) /* Now wait for INIT and BUSY to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -223,7 +223,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ -#ifdef CFG_FPGA_CHECK_BUSY +#ifdef CONFIG_SYS_FPGA_CHECK_BUSY ts = get_timer (0); /* get current time */ while ((*fn->busy) (cookie)) { /* XXX - we should have a check in here somewhere to @@ -234,7 +234,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for BUSY to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -242,7 +242,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } #endif -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -252,7 +252,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->cs) (FALSE, TRUE, cookie); /* Deassert the chip select */ (*fn->wr) (FALSE, TRUE, cookie); /* Deassert the write pin */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif @@ -268,7 +268,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for DONE to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ ret_val = FPGA_FAIL; @@ -277,7 +277,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } if (ret_val == FPGA_SUCCESS) { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts ("Done.\n"); #endif } @@ -289,7 +289,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } else { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts ("Fail.\n"); #endif } @@ -323,7 +323,7 @@ static int Spartan2_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ (*fn->rdata) (&(data[bytecount++]), cookie); /* read the data */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -333,7 +333,7 @@ static int Spartan2_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif puts ("Done.\n"); @@ -460,7 +460,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) "done:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->pgm, fn->init, fn->clk, fn->wr, fn->done); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif @@ -478,7 +478,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) ts = get_timer (0); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to start.\n"); return FPGA_FAIL; } @@ -492,7 +492,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) /* Now wait for INIT to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to clear.\n"); return FPGA_FAIL; } @@ -523,7 +523,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) i --; } while (i > 0); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -531,7 +531,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif @@ -551,7 +551,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) putc ('*'); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for DONE to clear.\n"); ret_val = FPGA_FAIL; break; @@ -566,7 +566,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->post) (cookie); } -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); } diff --git a/common/spartan3.c b/common/spartan3.c index 8f1ab80..9ce41f1 100644 --- a/common/spartan3.c +++ b/common/spartan3.c @@ -37,8 +37,8 @@ #define PRINTF(fmt,args...) #endif -#undef CFG_FPGA_CHECK_BUSY -#undef CFG_FPGA_PROG_FEEDBACK +#undef CONFIG_SYS_FPGA_CHECK_BUSY +#undef CONFIG_SYS_FPGA_PROG_FEEDBACK /* Note: The assumption is that we cannot possibly run fast enough to * overrun the device (the Slave Parallel mode can free run at 50MHz). @@ -49,8 +49,8 @@ #define CONFIG_FPGA_DELAY() #endif -#ifndef CFG_FPGA_WAIT -#define CFG_FPGA_WAIT CFG_HZ/100 /* 10 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT +#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/100 /* 10 ms */ #endif static int Spartan3_sp_load( Xilinx_desc *desc, void *buf, size_t bsize ); @@ -185,7 +185,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) * Continuous Data Loading in Slave Parallel Mode for * the Spartan-II Family. */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif /* @@ -206,7 +206,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) /* Now wait for INIT and BUSY to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -228,7 +228,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ -#ifdef CFG_FPGA_CHECK_BUSY +#ifdef CONFIG_SYS_FPGA_CHECK_BUSY ts = get_timer (0); /* get current time */ while ((*fn->busy) (cookie)) { /* XXX - we should have a check in here somewhere to @@ -239,7 +239,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for BUSY to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -247,7 +247,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } #endif -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -257,7 +257,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->cs) (FALSE, TRUE, cookie); /* Deassert the chip select */ (*fn->wr) (FALSE, TRUE, cookie); /* Deassert the write pin */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif @@ -273,7 +273,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for DONE to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ ret_val = FPGA_FAIL; @@ -282,7 +282,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } if (ret_val == FPGA_SUCCESS) { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts ("Done.\n"); #endif } @@ -294,7 +294,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) } else { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK puts ("Fail.\n"); #endif } @@ -328,7 +328,7 @@ static int Spartan3_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ (*fn->rdata) (&(data[bytecount++]), cookie); /* read the data */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -338,7 +338,7 @@ static int Spartan3_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif puts ("Done.\n"); @@ -465,7 +465,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) "done:\t0x%p\n\n", __FUNCTION__, &fn, fn, fn->pgm, fn->init, fn->clk, fn->wr, fn->done); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Loading FPGA Device %d...\n", cookie); #endif @@ -483,7 +483,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) ts = get_timer (0); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to start.\n"); return FPGA_FAIL; } @@ -497,7 +497,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) /* Now wait for INIT to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for INIT to clear.\n"); return FPGA_FAIL; } @@ -528,7 +528,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) i --; } while (i > 0); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); /* let them know we are alive */ #endif @@ -536,7 +536,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); /* terminate the dotted line */ #endif @@ -556,7 +556,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) putc ('*'); - if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */ + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for DONE to clear.\n"); ret_val = FPGA_FAIL; break; @@ -571,7 +571,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->post) (cookie); } -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); } diff --git a/common/update.c b/common/update.c index 938cc06..7528474 100644 --- a/common/update.c +++ b/common/update.c @@ -30,8 +30,8 @@ #error "CONFIG_FIT and CONFIG_OF_LIBFDT are required for auto-update feature" #endif -#if defined(CFG_NO_FLASH) -#error "CFG_NO_FLASH defined, but FLASH is required for auto-update feature" +#if defined(CONFIG_SYS_NO_FLASH) +#error "CONFIG_SYS_NO_FLASH defined, but FLASH is required for auto-update feature" #endif #include @@ -120,12 +120,12 @@ static int update_flash_protect(int prot, ulong addr_first, ulong addr_last) if (prot == 0) { saved_prot_info = - calloc(CFG_MAX_FLASH_BANKS * CFG_MAX_FLASH_SECT, 1); + calloc(CONFIG_SYS_MAX_FLASH_BANKS * CONFIG_SYS_MAX_FLASH_SECT, 1); if (!saved_prot_info) return 1; } - for (bank = 0; bank < CFG_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { cnt = 0; info = &flash_info[bank]; @@ -134,7 +134,7 @@ static int update_flash_protect(int prot, ulong addr_first, ulong addr_last) return 0; /* Point to current bank protection information */ - sp_info_ptr = saved_prot_info + (bank * CFG_MAX_FLASH_SECT); + sp_info_ptr = saved_prot_info + (bank * CONFIG_SYS_MAX_FLASH_SECT); /* * Adjust addr_first or addr_last if we are on bank boundary. @@ -159,7 +159,7 @@ static int update_flash_protect(int prot, ulong addr_first, ulong addr_last) /* Protect/unprotect sectors */ if (sp_info_ptr[i] == 1) { -#if defined(CFG_FLASH_PROTECTION) +#if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, prot)) return 1; #else diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 920bb0f..cf14560 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -36,7 +36,7 @@ * are switched to the serial port, else the settings in the * environment are used */ -#ifdef CFG_CONSOLE_OVERWRITE_ROUTINE +#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE extern int overwrite_console (void); #else int overwrite_console (void) @@ -120,7 +120,7 @@ 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 +#ifdef CONFIG_SYS_USB_EVENT_POLL usb_event_poll(); #endif if(usb_in_pointer==usb_out_pointer) @@ -133,7 +133,7 @@ static int usb_kbd_getc(void) { char c; while(usb_in_pointer==usb_out_pointer) { -#ifdef CFG_USB_EVENT_POLL +#ifdef CONFIG_SYS_USB_EVENT_POLL usb_event_poll(); #endif } diff --git a/common/virtex2.c b/common/virtex2.c index 52da1b2..50d0921 100644 --- a/common/virtex2.c +++ b/common/virtex2.c @@ -43,34 +43,34 @@ /* * If the SelectMap interface can be overrun by the processor, define - * CFG_FPGA_CHECK_BUSY and/or CONFIG_FPGA_DELAY in the board configuration + * CONFIG_SYS_FPGA_CHECK_BUSY and/or CONFIG_FPGA_DELAY in the board configuration * file and add board-specific support for checking BUSY status. By default, * assume that the SelectMap interface cannot be overrun. */ -#ifndef CFG_FPGA_CHECK_BUSY -#undef CFG_FPGA_CHECK_BUSY +#ifndef CONFIG_SYS_FPGA_CHECK_BUSY +#undef CONFIG_SYS_FPGA_CHECK_BUSY #endif #ifndef CONFIG_FPGA_DELAY #define CONFIG_FPGA_DELAY() #endif -#ifndef CFG_FPGA_PROG_FEEDBACK -#define CFG_FPGA_PROG_FEEDBACK +#ifndef CONFIG_SYS_FPGA_PROG_FEEDBACK +#define CONFIG_SYS_FPGA_PROG_FEEDBACK #endif /* * Don't allow config cycle to be interrupted */ -#ifndef CFG_FPGA_CHECK_CTRLC -#undef CFG_FPGA_CHECK_CTRLC +#ifndef CONFIG_SYS_FPGA_CHECK_CTRLC +#undef CONFIG_SYS_FPGA_CHECK_CTRLC #endif /* * Check for errors during configuration by default */ -#ifndef CFG_FPGA_CHECK_ERROR -#define CFG_FPGA_CHECK_ERROR +#ifndef CONFIG_SYS_FPGA_CHECK_ERROR +#define CONFIG_SYS_FPGA_CHECK_ERROR #endif /* @@ -81,8 +81,8 @@ * which yields 11.44 mS. So let's make it bigger in order to handle * an XC2V1000, if anyone can ever get ahold of one. */ -#ifndef CFG_FPGA_WAIT_INIT -#define CFG_FPGA_WAIT_INIT CFG_HZ/2 /* 500 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT_INIT +#define CONFIG_SYS_FPGA_WAIT_INIT CONFIG_SYS_HZ/2 /* 500 ms */ #endif /* @@ -90,15 +90,15 @@ * This is normally not necessary since for most reasonable configuration * clock frequencies (i.e. 66 MHz or less), BUSY monitoring is unnecessary. */ -#ifndef CFG_FPGA_WAIT_BUSY -#define CFG_FPGA_WAIT_BUSY CFG_HZ/200 /* 5 ms*/ +#ifndef CONFIG_SYS_FPGA_WAIT_BUSY +#define CONFIG_SYS_FPGA_WAIT_BUSY CONFIG_SYS_HZ/200 /* 5 ms*/ #endif /* Default timeout for waiting for FPGA to enter operational mode after * configuration data has been written. */ -#ifndef CFG_FPGA_WAIT_CONFIG -#define CFG_FPGA_WAIT_CONFIG CFG_HZ/5 /* 200 ms */ +#ifndef CONFIG_SYS_FPGA_WAIT_CONFIG +#define CONFIG_SYS_FPGA_WAIT_CONFIG CONFIG_SYS_HZ/5 /* 200 ms */ #endif static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize); @@ -232,7 +232,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, fn->abort, fn->post); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Initializing FPGA Device %d...\n", cookie); #endif /* @@ -252,10 +252,10 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) udelay (10); ts = get_timer (0); do { - if (get_timer (ts) > CFG_FPGA_WAIT_INIT) { + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" " to assert.\n", __FUNCTION__, __LINE__, - CFG_FPGA_WAIT_INIT); + CONFIG_SYS_FPGA_WAIT_INIT); (*fn->abort) (cookie); return FPGA_FAIL; } @@ -271,10 +271,10 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) ts = get_timer (0); do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CFG_FPGA_WAIT_INIT) { + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" " to deassert.\n", __FUNCTION__, __LINE__, - CFG_FPGA_WAIT_INIT); + CONFIG_SYS_FPGA_WAIT_INIT); (*fn->abort) (cookie); return FPGA_FAIL; } @@ -289,7 +289,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) * Load the data byte by byte */ while (bytecount < bsize) { -#ifdef CFG_FPGA_CHECK_CTRLC +#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC if (ctrlc ()) { (*fn->abort) (cookie); return FPGA_FAIL; @@ -302,7 +302,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) break; } -#ifdef CFG_FPGA_CHECK_ERROR +#ifdef CONFIG_SYS_FPGA_CHECK_ERROR if ((*fn->init) (cookie)) { printf ("\n%s:%d: ** Error: INIT asserted during" " configuration\n", __FUNCTION__, __LINE__); @@ -323,20 +323,20 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); -#ifdef CFG_FPGA_CHECK_BUSY +#ifdef CONFIG_SYS_FPGA_CHECK_BUSY ts = get_timer (0); while ((*fn->busy) (cookie)) { - if (get_timer (ts) > CFG_FPGA_WAIT_BUSY) { + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_BUSY) { printf ("%s:%d: ** Timeout after %d ticks waiting for" " BUSY to deassert\n", - __FUNCTION__, __LINE__, CFG_FPGA_WAIT_BUSY); + __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_BUSY); (*fn->abort) (cookie); return FPGA_FAIL; } } #endif -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); #endif @@ -349,7 +349,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->cs) (FALSE, TRUE, cookie); (*fn->wr) (FALSE, TRUE, cookie); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); #endif @@ -360,10 +360,10 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) ts = get_timer (0); ret_val = FPGA_SUCCESS; while (((*fn->done) (cookie) == FPGA_FAIL) || (*fn->init) (cookie)) { - if (get_timer (ts) > CFG_FPGA_WAIT_CONFIG) { + if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_CONFIG) { printf ("%s:%d: ** Timeout after %d ticks waiting for DONE to" "assert and INIT to deassert\n", - __FUNCTION__, __LINE__, CFG_FPGA_WAIT_CONFIG); + __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_CONFIG); (*fn->abort) (cookie); ret_val = FPGA_FAIL; break; @@ -371,7 +371,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) } if (ret_val == FPGA_SUCCESS) { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("Initialization of FPGA device %d complete\n", cookie); #endif /* @@ -381,7 +381,7 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->post) (cookie); } } else { -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK printf ("** Initialization of FPGA device %d FAILED\n", cookie); #endif @@ -412,7 +412,7 @@ static int Virtex2_ssm_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (TRUE, TRUE, cookie); while (bytecount < bsize) { -#ifdef CFG_FPGA_CHECK_CTRLC +#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC if (ctrlc ()) { (*fn->abort) (cookie); return FPGA_FAIL; @@ -424,7 +424,7 @@ static int Virtex2_ssm_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); (*fn->clk) (TRUE, TRUE, cookie); (*fn->rdata) (&(data[bytecount++]), cookie); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK if (bytecount % (bsize / 40) == 0) putc ('.'); #endif @@ -437,7 +437,7 @@ static int Virtex2_ssm_dump (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (FALSE, TRUE, cookie); (*fn->clk) (TRUE, TRUE, cookie); -#ifdef CFG_FPGA_PROG_FEEDBACK +#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK putc ('\n'); #endif puts ("Done.\n"); -- cgit v1.1 From 76da19df5b8e186d269f29190696bd31fb6c836b Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 16 Oct 2008 21:52:08 -0500 Subject: Added arch_lmb_reserve to allow arch specific memory regions protection Each architecture has different ways of determine what regions of memory might not be valid to get overwritten when we boot. This provides a hook to allow them to reserve any regions they care about. Currently only ppc, m68k and sparc need/use this. Signed-off-by: Kumar Gala --- common/cmd_bootm.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 2a9c59f..b02da3e 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -128,6 +128,12 @@ void __board_lmb_reserve(struct lmb *lmb) } void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve"))); +void __arch_lmb_reserve(struct lmb *lmb) +{ + /* please define platform specific arch_lmb_reserve() */ +} +void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve"))); + #if defined(__ARM__) #define IH_INITRD_ARCH IH_ARCH_ARM #elif defined(__avr32__) @@ -173,6 +179,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size); + arch_lmb_reserve(&images.lmb); board_lmb_reserve(&images.lmb); /* get kernel image header, start address and length */ -- cgit v1.1 From 3bed2aaf2d50fd13273c14d17d4fd40ef42e0d0f Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 23 Oct 2008 00:05:47 -0500 Subject: fdt: Add fdt_getprop_u32_default helpers Add helper functions to return find a node and return it's property or a default value. Signed-off-by: Kumar Gala Signed-off-by: Andrew Fleming-AFLEMING Acked-by: Gerald Van Baren --- common/fdt_support.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'common') diff --git a/common/fdt_support.c b/common/fdt_support.c index 8ceeb0f..f430777 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -35,6 +35,33 @@ */ DECLARE_GLOBAL_DATA_PTR; +/** + * fdt_getprop_u32_default - Find a node and return it's property or a default + * + * @fdt: ptr to device tree + * @path: path of node + * @prop: property name + * @dflt: default value if the property isn't found + * + * Convenience function to find a node and return it's property or a + * default value if it doesn't exist. + */ +u32 fdt_getprop_u32_default(void *fdt, const char *path, const char *prop, + const u32 dflt) +{ + const u32 *val; + int off; + + off = fdt_path_offset(fdt, path); + if (off < 0) + return dflt; + + val = fdt_getprop(fdt, off, prop, NULL); + if (val) + return *val; + else + return dflt; +} /** * fdt_find_and_setprop: Find a node and set it's property -- cgit v1.1 From 8ab451c46b846f2bbd7122b29ffdd9a4a04da228 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 22 Oct 2008 23:33:56 -0500 Subject: fdt: Added helper to set PCI dma-ranges property Added fdt_pci_dma_ranges() that parses the pci_region info from the struct pci_controller and populates the dma-ranges based on it. The max # of windws/dma-ranges we support is 3 since on embedded PowerPC based systems this is the max number of windows. Signed-off-by: Kumar Gala Signed-off-by: Andrew Fleming-AFLEMING --- common/fdt_support.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'common') diff --git a/common/fdt_support.c b/common/fdt_support.c index f430777..d483d66 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -620,3 +620,72 @@ int fdt_resize(void *blob) return actualsize; } + +#ifdef CONFIG_PCI +#define CONFIG_SYS_PCI_NR_INBOUND_WIN 3 + +#define FDT_PCI_PREFETCH (0x40000000) +#define FDT_PCI_MEM32 (0x02000000) +#define FDT_PCI_IO (0x01000000) +#define FDT_PCI_MEM64 (0x03000000) + +int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) { + + int addrcell, sizecell, len, r; + u32 *dma_range; + /* sized based on pci addr cells, size-cells, & address-cells */ + u32 dma_ranges[(3 + 2 + 2) * CONFIG_SYS_PCI_NR_INBOUND_WIN]; + + addrcell = fdt_getprop_u32_default(blob, "/", "#address-cells", 1); + sizecell = fdt_getprop_u32_default(blob, "/", "#size-cells", 1); + + dma_range = &dma_ranges[0]; + for (r = 0; r < hose->region_count; r++) { + u64 bus_start, phys_start, size; + + /* skip if !PCI_REGION_MEMORY */ + if (!(hose->regions[r].flags & PCI_REGION_MEMORY)) + continue; + + bus_start = (u64)hose->regions[r].bus_start; + phys_start = (u64)hose->regions[r].phys_start; + size = (u64)hose->regions[r].size; + + dma_range[0] = 0; + if (size > 0x100000000ull) + dma_range[0] |= FDT_PCI_MEM64; + else + dma_range[0] |= FDT_PCI_MEM32; + if (hose->regions[r].flags & PCI_REGION_PREFETCH) + dma_range[0] |= FDT_PCI_PREFETCH; +#ifdef CONFIG_SYS_PCI_64BIT + dma_range[1] = bus_start >> 32; +#else + dma_range[1] = 0; +#endif + dma_range[2] = bus_start & 0xffffffff; + + if (addrcell == 2) { + dma_range[3] = phys_start >> 32; + dma_range[4] = phys_start & 0xffffffff; + } else { + dma_range[3] = phys_start & 0xffffffff; + } + + if (sizecell == 2) { + dma_range[3 + addrcell + 0] = size >> 32; + dma_range[3 + addrcell + 1] = size & 0xffffffff; + } else { + dma_range[3 + addrcell + 0] = size & 0xffffffff; + } + + dma_range += (3 + addrcell + sizecell); + } + + len = dma_range - &dma_ranges[0]; + if (len) + fdt_setprop(blob, phb_off, "dma-ranges", &dma_ranges[0], len*4); + + return 0; +} +#endif -- cgit v1.1 From 15b17ab52b7c15d46d9fc631cc06092e1e764de2 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 1 Sep 2008 16:21:20 +0200 Subject: lcd: Implement lcd_printf() lcd_printf() has a prototype in include/lcd.h but no implementation. Fix this by borrowing the lcd_printf() implementation from the cogent board code (which appears to use its own LCD framework.) Signed-off-by: Haavard Skinnemoen Signed-off-by: Anatolij Gustschin --- common/lcd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'common') diff --git a/common/lcd.c b/common/lcd.c index d104b26..03d5841 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -225,6 +225,20 @@ void lcd_puts (const char *s) } } +/*----------------------------------------------------------------------*/ + +void lcd_printf(const char *fmt, ...) +{ + va_list args; + char buf[CONFIG_SYS_PBSIZE]; + + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + + lcd_puts(buf); +} + /************************************************************************/ /* ** Low-Level Graphics Routines */ /************************************************************************/ -- cgit v1.1 From 6f93d2b8fca504200a5758f7c6dd2d6852900765 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 1 Sep 2008 16:21:21 +0200 Subject: lcd: Set lcd_is_enabled before clearing the screen This allows the logo/info rendering routines to use the regular lcd_putc/lcd_puts/lcd_printf calls. Signed-off-by: Haavard Skinnemoen Signed-off-by: Anatolij Gustschin --- common/lcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/lcd.c b/common/lcd.c index 03d5841..813c8d8 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -440,6 +440,7 @@ static int lcd_init (void *lcdbase) debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); lcd_ctrl_init (lcdbase); + lcd_is_enabled = 1; lcd_clear (NULL, 1, 1, NULL); /* dummy args */ lcd_enable (); @@ -450,7 +451,6 @@ static int lcd_init (void *lcdbase) #else console_row = 1; /* leave 1 blank line below logo */ #endif - lcd_is_enabled = 1; return 0; } -- cgit v1.1 From 6b59e03e0237a40a2305ea385defdfd92000978b Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 1 Sep 2008 16:21:22 +0200 Subject: lcd: Let the board code show board-specific info The information displayed when CONFIG_LCD_INFO is set is inherently board-specific, so it should be done by the board code. The current code dealing with this only handles two cases, and is already a horrible mess of #ifdeffery. Yes, this duplicates some code, but it also allows boards to print more board-specific information; this used to be very difficult. Signed-off-by: Haavard Skinnemoen Signed-off-by: Anatolij Gustschin --- common/lcd.c | 84 ++++-------------------------------------------------------- 1 file changed, 5 insertions(+), 79 deletions(-) (limited to 'common') diff --git a/common/lcd.c b/common/lcd.c index 813c8d8..31bb190 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -52,7 +52,6 @@ #if defined(CONFIG_ATMEL_LCD) #include -#include #endif /************************************************************************/ @@ -762,15 +761,6 @@ extern bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp); static void *lcd_logo (void) { -#ifdef CONFIG_LCD_INFO - char info[80]; - char temp[32]; -#ifdef CONFIG_ATMEL_LCD - int i; - ulong dram_size, nand_size; -#endif -#endif /* CONFIG_LCD_INFO */ - #ifdef CONFIG_SPLASH_SCREEN char *s; ulong addr; @@ -800,75 +790,11 @@ static void *lcd_logo (void) bitmap_plot (0, 0); #endif /* CONFIG_LCD_LOGO */ -#ifdef CONFIG_MPC823 -# ifdef CONFIG_LCD_INFO - sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info)); - - sprintf (info, "(C) 2008 DENX Software Engineering GmbH"); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT, - (uchar *)info, strlen(info)); - - sprintf (info, " Wolfgang DENK, wd@denx.de"); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2, - (uchar *)info, strlen(info)); -# ifdef CONFIG_LCD_INFO_BELOW_LOGO - sprintf (info, "MPC823 CPU at %s MHz", - strmhz(temp, gd->cpu_clk)); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, - info, strlen(info)); - sprintf (info, " %ld MB RAM, %ld MB Flash", - gd->ram_size >> 20, - gd->bd->bi_flashsize >> 20 ); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, - info, strlen(info)); -# else - /* leave one blank line */ - - sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash", - strmhz(temp, gd->cpu_clk), - gd->ram_size >> 20, - gd->bd->bi_flashsize >> 20 ); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, - (uchar *)info, strlen(info)); - -# endif /* CONFIG_LCD_INFO_BELOW_LOGO */ -# endif /* CONFIG_LCD_INFO */ -#endif /* CONFIG_MPC823 */ - -#ifdef CONFIG_ATMEL_LCD -# ifdef CONFIG_LCD_INFO - sprintf (info, "%s", U_BOOT_VERSION); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info)); - - sprintf (info, "(C) 2008 ATMEL Corp"); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT, - (uchar *)info, strlen(info)); - - sprintf (info, "at91support@atmel.com"); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2, - (uchar *)info, strlen(info)); - - sprintf (info, "%s CPU at %s MHz", - AT91_CPU_NAME, - strmhz(temp, AT91_MAIN_CLOCK)); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, - (uchar *)info, strlen(info)); - - dram_size = 0; - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) - dram_size += gd->bd->bi_dram[i].size; - nand_size = 0; - for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i].size; - sprintf (info, " %ld MB SDRAM, %ld MB NAND", - dram_size >> 20, - nand_size >> 20 ); - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, - (uchar *)info, strlen(info)); -# endif /* CONFIG_LCD_INFO */ -#endif /* CONFIG_ATMEL_LCD */ - +#ifdef CONFIG_LCD_INFO + console_col = LCD_INFO_X / VIDEO_FONT_WIDTH; + console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT; + lcd_show_board_info(); +#endif /* CONFIG_LCD_INFO */ #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length)); -- cgit v1.1 From be08315933537f061bc1ce61f33a29c56458bbad Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 21 Oct 2008 17:25:44 -0500 Subject: bootm: Move to using a function pointer table for the boot os function This removes a bit of code and makes it easier for the upcoming sub bootm command support to call into the proper OS specific handler. Signed-off-by: Kumar Gala Signed-off-by: Wolfgang Denk --- common/cmd_bootm.c | 68 +++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index b02da3e..b87ac49 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -119,6 +119,22 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); static boot_os_fn do_bootm_integrity; #endif +boot_os_fn * boot_os[] = { + [IH_OS_LINUX] = do_bootm_linux, + [IH_OS_NETBSD] = do_bootm_netbsd, +#ifdef CONFIG_LYNXKDI + [IH_OS_LYNXOS] = do_bootm_lynxkdi, +#endif + [IH_OS_RTEMS] = do_bootm_rtems, +#if defined(CONFIG_CMD_ELF) + [IH_OS_VXWORKS] = do_bootm_vxworks, + [IH_OS_QNX] = do_bootm_qnxelf, +#endif +#ifdef CONFIG_INTEGRITY + [IH_OS_INTEGRITY] = do_bootm_integrity, +#endif +}; + ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */ @@ -386,12 +402,22 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) /*******************************************************************/ /* bootm - boot application image from image in memory */ /*******************************************************************/ +static int relocated = 0; + int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - ulong iflag; ulong load_end = 0; int ret; + boot_os_fn *boot_fn; + + /* relocate boot function table */ + if (!relocated) { + int i; + for (i = 0; i < ARRAY_SIZE(boot_os); i++) + boot_os[i] += gd->reloc_off; + relocated = 1; + } if (bootm_start(cmdtp, flag, argc, argv)) return 1; @@ -454,45 +480,13 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) show_boot_progress (8); - switch (images.os.os) { - default: /* handled by (original) Linux case */ - case IH_OS_LINUX: #ifdef CONFIG_SILENT_CONSOLE - fixup_silent_linux(); -#endif - do_bootm_linux (0, argc, argv, &images); - break; - - case IH_OS_NETBSD: - do_bootm_netbsd (0, argc, argv, &images); - break; - -#ifdef CONFIG_LYNXKDI - case IH_OS_LYNXOS: - do_bootm_lynxkdi (0, argc, argv, &images); - break; + if (images.os.os == IH_OS_LINUX) + fixup_silent_linux(); #endif - case IH_OS_RTEMS: - do_bootm_rtems (0, argc, argv, &images); - break; - -#if defined(CONFIG_CMD_ELF) - case IH_OS_VXWORKS: - do_bootm_vxworks (0, argc, argv, &images); - break; - - case IH_OS_QNX: - do_bootm_qnxelf (0, argc, argv, &images); - break; -#endif - -#ifdef CONFIG_INTEGRITY - case IH_OS_INTEGRITY: - do_bootm_integrity (0, argc, argv, &images); - break; -#endif - } + boot_fn = boot_os[images.os.os]; + boot_fn(0, argc, argv, &images); show_boot_progress (-9); #ifdef DEBUG -- cgit v1.1 From 49c3a861d11735838f1f1b11999ce433006dc919 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 21 Oct 2008 17:25:45 -0500 Subject: bootm: Add subcommands Add the ability to break the steps of the bootm command into several subcommands: start, loados, ramdisk, fdt, bdt, cmdline, prep, go. This allows us to do things like manipulate device trees before they are passed to a booting kernel or setup memory for a secondary core in multicore situations. Not all OS types support all subcommands (currently only start, loados, ramdisk, fdt, and go are supported). Signed-off-by: Kumar Gala --- common/cmd_bootm.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index b87ac49..20c31a7 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #if defined(CONFIG_CMD_USB) @@ -296,7 +297,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } images.os.start = (ulong)os_hdr; - images.valid = 1; + images.state = BOOTM_STATE_START; return 0; } @@ -399,6 +400,121 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) return 0; } +/* we overload the cmd field with our state machine info instead of a + * function pointer */ +cmd_tbl_t cmd_bootm_sub[] = { + U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""), + U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""), +#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) + U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""), +#endif +#ifdef CONFIG_OF_LIBFDT + U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""), +#endif + U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""), + U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""), + U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""), + U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""), +}; + +int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret = 0; + int state; + cmd_tbl_t *c; + boot_os_fn *boot_fn; + + c = find_cmd_tbl(argv[1], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub)); + + if (c) { + state = (int)c->cmd; + + /* treat start special since it resets the state machine */ + if (state == BOOTM_STATE_START) { + argc--; + argv++; + return bootm_start(cmdtp, flag, argc, argv); + } + } + /* Unrecognized command */ + else { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + if (images.state >= state) { + printf ("Trying to execute a command out of order\n"); + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + images.state |= state; + boot_fn = boot_os[images.os.os]; + + switch (state) { + ulong load_end; + case BOOTM_STATE_START: + /* should never occur */ + break; + case BOOTM_STATE_LOADOS: + ret = bootm_load_os(images.os, &load_end, 0); + if (ret) + return ret; + + lmb_reserve(&images.lmb, images.os.load, + (load_end - images.os.load)); + break; +#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) + case BOOTM_STATE_RAMDISK: + { + ulong rd_len = images.rd_end - images.rd_start; + char str[17]; + + ret = boot_ramdisk_high(&images.lmb, images.rd_start, + rd_len, &images.initrd_start, &images.initrd_end); + if (ret) + return ret; + + sprintf(str, "%lx", images.initrd_start); + setenv("initrd_start", str); + sprintf(str, "%lx", images.initrd_end); + setenv("initrd_end", str); + } + break; +#endif +#ifdef CONFIG_OF_LIBFDT + case BOOTM_STATE_FDT: + { + ulong bootmap_base = getenv_bootm_low(); + ret = boot_relocate_fdt(&images.lmb, bootmap_base, + &images.ft_addr, &images.ft_len); + break; + } +#endif + case BOOTM_STATE_OS_CMDLINE: + ret = boot_fn(BOOTM_STATE_OS_CMDLINE, argc, argv, &images); + if (ret) + printf ("cmdline subcommand not supported\n"); + break; + case BOOTM_STATE_OS_BD_T: + ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, &images); + if (ret) + printf ("bdt subcommand not supported\n"); + break; + case BOOTM_STATE_OS_PREP: + ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, &images); + if (ret) + printf ("prep subcommand not supported\n"); + break; + case BOOTM_STATE_OS_GO: + disable_interrupts(); + boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images); + break; + } + + return ret; +} + /*******************************************************************/ /* bootm - boot application image from image in memory */ /*******************************************************************/ @@ -419,6 +535,23 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) relocated = 1; } + /* determine if we have a sub command */ + if (argc > 1) { + char *endp; + + simple_strtoul(argv[1], &endp, 16); + /* endp pointing to NULL means that argv[1] was just a + * valid number, pass it along to the normal bootm processing + * + * If endp is ':' or '#' assume a FIT identifier so pass + * along for normal processing. + * + * Right now we assume the first arg should never be '-' + */ + if ((*endp != 0) && (*endp != ':') && (*endp != '#')) + return do_bootm_subcommand(cmdtp, flag, argc, argv); + } + if (bootm_start(cmdtp, flag, argc, argv)) return 1; @@ -783,6 +916,21 @@ U_BOOT_CMD( "\tUse iminfo command to get the list of existing component\n" "\timages and configurations.\n" #endif + "\nSub-commands to do part of the bootm sequence. The sub-commands " + "must be\n" + "issued in the order below (it's ok to not issue all sub-commands):\n" + "\tstart [addr [arg ...]]\n" + "\tloados - load OS image\n" +#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) + "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n" +#endif +#if defined(CONFIG_OF_LIBFDT) + "\tfdt - relocate flat device tree\n" +#endif + "\tbdt - OS specific bd_t processing\n" + "\tcmdline - OS specific command line processing/setup\n" + "\tprep - OS specific prep before relocation or go\n" + "\tgo - start OS\n" ); /*******************************************************************/ @@ -1022,6 +1170,9 @@ static int do_bootm_netbsd (int flag, int argc, char *argv[], char *consdev; char *cmdline; + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("NetBSD"); @@ -1102,6 +1253,9 @@ static int do_bootm_lynxkdi (int flag, int argc, char *argv[], { image_header_t *hdr = &images->legacy_hdr_os_copy; + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("Lynx"); @@ -1120,6 +1274,9 @@ static int do_bootm_rtems (int flag, int argc, char *argv[], { void (*entry_point)(bd_t *); + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("RTEMS"); @@ -1149,6 +1306,9 @@ static int do_bootm_vxworks (int flag, int argc, char *argv[], { char str[80]; + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("VxWorks"); @@ -1169,6 +1329,9 @@ static int do_bootm_qnxelf(int flag, int argc, char *argv[], char *local_args[2]; char str[16]; + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("QNX"); @@ -1191,6 +1354,9 @@ static int do_bootm_integrity (int flag, int argc, char *argv[], { void (*entry_point)(void); + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + #if defined(CONFIG_FIT) if (!images->legacy_hdr_valid) { fit_unsupported_reset ("INTEGRITY"); -- cgit v1.1 From b1d0db1805c3395149777e507b6da53410abac4e Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 21 Oct 2008 17:25:47 -0500 Subject: bootm: Added CONFIG_BOOTM_{LINUX, NETBSD, RTEMS} Added the ability to config out bootm support for Linux, NetBSD, RTEMS Signed-off-by: Kumar Gala --- common/cmd_bootm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 20c31a7..a8f85e9 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -103,13 +103,23 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); typedef int boot_os_fn (int flag, int argc, char *argv[], bootm_headers_t *images); /* pointers to os/initrd/fdt */ +#define CONFIG_BOOTM_LINUX 1 +#define CONFIG_BOOTM_NETBSD 1 +#define CONFIG_BOOTM_RTEMS 1 + +#ifdef CONFIG_BOOTM_LINUX extern boot_os_fn do_bootm_linux; +#endif +#ifdef CONFIG_BOOTM_NETBSD static boot_os_fn do_bootm_netbsd; +#endif #if defined(CONFIG_LYNXKDI) static boot_os_fn do_bootm_lynxkdi; extern void lynxkdi_boot (image_header_t *); #endif +#ifdef CONFIG_BOOTM_RTEMS static boot_os_fn do_bootm_rtems; +#endif #if defined(CONFIG_CMD_ELF) static boot_os_fn do_bootm_vxworks; static boot_os_fn do_bootm_qnxelf; @@ -121,12 +131,18 @@ static boot_os_fn do_bootm_integrity; #endif boot_os_fn * boot_os[] = { +#ifdef CONFIG_BOOTM_LINUX [IH_OS_LINUX] = do_bootm_linux, +#endif +#ifdef CONFIG_BOOTM_NETBSD [IH_OS_NETBSD] = do_bootm_netbsd, +#endif #ifdef CONFIG_LYNXKDI [IH_OS_LYNXOS] = do_bootm_lynxkdi, #endif +#ifdef CONFIG_BOOTM_RTEMS [IH_OS_RTEMS] = do_bootm_rtems, +#endif #if defined(CONFIG_CMD_ELF) [IH_OS_VXWORKS] = do_bootm_vxworks, [IH_OS_QNX] = do_bootm_qnxelf, @@ -1161,6 +1177,7 @@ static void fixup_silent_linux () /* OS booting routines */ /*******************************************************************/ +#ifdef CONFIG_BOOTM_NETBSD static int do_bootm_netbsd (int flag, int argc, char *argv[], bootm_headers_t *images) { @@ -1246,6 +1263,7 @@ static int do_bootm_netbsd (int flag, int argc, char *argv[], return 1; } +#endif /* CONFIG_BOOTM_NETBSD*/ #ifdef CONFIG_LYNXKDI static int do_bootm_lynxkdi (int flag, int argc, char *argv[], @@ -1269,6 +1287,7 @@ static int do_bootm_lynxkdi (int flag, int argc, char *argv[], } #endif /* CONFIG_LYNXKDI */ +#ifdef CONFIG_BOOTM_RTEMS static int do_bootm_rtems (int flag, int argc, char *argv[], bootm_headers_t *images) { @@ -1299,6 +1318,7 @@ static int do_bootm_rtems (int flag, int argc, char *argv[], return 1; } +#endif /* CONFIG_BOOTM_RTEMS */ #if defined(CONFIG_CMD_ELF) static int do_bootm_vxworks (int flag, int argc, char *argv[], -- cgit v1.1 From 695c130e4bf75b444720ddfd83aca88f41c046cf Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Mon, 27 Oct 2008 15:38:30 -0500 Subject: NAND: Align right column of the shorthelp with other commands. I accidentally broke this in when making consistent the partial alignment of the longhelp. Signed-off-by: Scott Wood --- common/cmd_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index ea43f4f..0a366d3 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -469,7 +469,7 @@ usage: } U_BOOT_CMD(nand, 5, 1, do_nand, - "nand - NAND sub-system\n", + "nand - NAND sub-system\n", "info - show available NAND devices\n" "nand device [dev] - show or set current device\n" "nand read - addr off|partition size\n" -- cgit v1.1 From f242a08871839eac081ba5b599af979f3a148a0d Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Tue, 28 Oct 2008 08:26:52 +0100 Subject: fdt_resize(): ensure minimum padding fdt_add_mem_rsv() requires space for a struct fdt_reserve_entry (16 bytes), so make sure that fdt_resize at least adds that much padding, no matter what the location or size of the fdt is. Signed-off-by: Peter Korsgaard Acked-by: Andy Fleming --- common/fdt_support.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/fdt_support.c b/common/fdt_support.c index d483d66..5a83bca 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -602,9 +602,12 @@ int fdt_resize(void *blob) } } - /* Calculate the actual size of the fdt */ + /* + * Calculate the actual size of the fdt + * plus the size needed for fdt_add_mem_rsv + */ actualsize = fdt_off_dt_strings(blob) + - fdt_size_dt_strings(blob); + fdt_size_dt_strings(blob) + sizeof(struct fdt_reserve_entry); /* Make it so the fdt ends on a page boundary */ actualsize = ALIGN(actualsize, 0x1000); -- cgit v1.1 From 3cbd823116ea8b7c654e275a8c2fca87cd1f5dc5 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sun, 2 Nov 2008 16:14:22 +0100 Subject: Coding Style cleanup, update CHANGELOG Signed-off-by: Wolfgang Denk --- common/cmd_i2c.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'common') diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 84ecf49..448f2fe 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -249,7 +249,6 @@ int do_i2c_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return mod_i2c_mem (cmdtp, 1, flag, argc, argv); } - int do_i2c_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { return mod_i2c_mem (cmdtp, 0, flag, argc, argv); @@ -339,7 +338,6 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return (0); } - /* Calculate a CRC on memory * * Syntax: @@ -409,7 +407,6 @@ int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } - /* Modify memory. * * Syntax: @@ -587,7 +584,6 @@ int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } - /* * Syntax: * iloop {i2c_chip} {addr}{.0, .1, .2} [{length}] [{delay}] @@ -658,7 +654,6 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } - /* * The SDRAM command is separately configured because many * (most?) embedded boards don't use SDRAM DIMMs. @@ -1601,4 +1596,3 @@ int i2x_mux_select_mux(int bus) return 0; } #endif /* CONFIG_I2C_MUX */ - -- cgit v1.1 From 20d04774f4ef3f6e38974636e0e36ae0f0b5501f Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Thu, 30 Oct 2008 17:35:30 -0500 Subject: Consolidate MAX/MIN definitions There were several, now there is one (two if you count the lower-case versions). Signed-off-by: Andy Fleming --- common/cmd_bedbug.c | 4 ---- common/cmd_elf.c | 4 ---- 2 files changed, 8 deletions(-) (limited to 'common') diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c index 3e597f9..e6277c9 100644 --- a/common/cmd_bedbug.c +++ b/common/cmd_bedbug.c @@ -13,10 +13,6 @@ DECLARE_GLOBAL_DATA_PTR; -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - extern void show_regs __P ((struct pt_regs *)); extern int run_command __P ((const char *, int)); extern char console_buffer[]; diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 3ebb6d9..4d8e1d2 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -23,10 +23,6 @@ DECLARE_GLOBAL_DATA_PTR; #endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - int valid_elf_image (unsigned long addr); unsigned long load_elf_image (unsigned long addr); -- cgit v1.1 From a80b21d5127583171d6e9bc7f722947641898012 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 31 Oct 2008 12:12:12 +0100 Subject: common/Makefile: create others group for non core, environment and command files Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/Makefile b/common/Makefile index f00cbd9..6484b23 100644 --- a/common/Makefile +++ b/common/Makefile @@ -42,7 +42,7 @@ COBJS-y += s_record.o COBJS-y += serial.o COBJS-y += xyzModem.o -#core command +# core command COBJS-y += cmd_boot.o COBJS-y += cmd_bootm.o COBJS-y += cmd_nvedit.o @@ -148,6 +148,9 @@ endif COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o COBJS-$(CONFIG_VFD) += cmd_vfd.o + +# others +COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o COBJS-$(CONFIG_CMD_DOC) += docecc.o COBJS-y += flash.o COBJS-y += kgdb.o @@ -155,7 +158,7 @@ COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o -COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o + COBJS := $(sort $(COBJS-y)) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) -- cgit v1.1 From 694a0b3f1c0accd0de94b89555155d69f8022824 Mon Sep 17 00:00:00 2001 From: Kyungmin Park Date: Wed, 19 Nov 2008 11:47:05 +0100 Subject: UBI: Add UBI command support This patch adds these UBI commands: ubi part [nand|onenand] [part] - Show or set current partition ubi info [l[ayout]] -Display volume and UBI layout information ubi create[vol] volume [size] [type] - Create volume name with size ubi write[vol] address volume size - Write volume from address with size ubi read[vol] address volume [size] - Read volume to address with size ubi remove[vol] volume - Remove volume Signed-off-by: Kyungmin Park Signed-off-by: Stefan Roese --- common/Makefile | 1 + common/cmd_ubi.c | 628 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 629 insertions(+) create mode 100644 common/cmd_ubi.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 6484b23..9dec4ec 100644 --- a/common/Makefile +++ b/common/Makefile @@ -139,6 +139,7 @@ COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o +COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o ifdef CONFIG_CMD_USB COBJS-y += cmd_usb.o diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c new file mode 100644 index 0000000..a5c5064 --- /dev/null +++ b/common/cmd_ubi.c @@ -0,0 +1,628 @@ +/* + * Unsorted Block Image commands + * + * Copyright (C) 2008 Samsung Electronics + * Kyungmin Park + * + * Copyright 2008 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define DEV_TYPE_NONE 0 +#define DEV_TYPE_NAND 1 +#define DEV_TYPE_ONENAND 2 + +/* Private own data */ +static struct ubi_device *ubi; + +struct selected_dev { + char dev_name[32]; /* NAND/OneNAND etc */ + char part_name[80]; + int type; + int nr; + struct mtd_info *mtd_info; +}; + +static struct selected_dev ubi_dev; + +static void ubi_dump_vol_info(const struct ubi_volume *vol) +{ + ubi_msg("volume information dump:"); + ubi_msg("vol_id %d", vol->vol_id); + ubi_msg("reserved_pebs %d", vol->reserved_pebs); + ubi_msg("alignment %d", vol->alignment); + ubi_msg("data_pad %d", vol->data_pad); + ubi_msg("vol_type %d", vol->vol_type); + ubi_msg("name_len %d", vol->name_len); + ubi_msg("usable_leb_size %d", vol->usable_leb_size); + ubi_msg("used_ebs %d", vol->used_ebs); + ubi_msg("used_bytes %lld", vol->used_bytes); + ubi_msg("last_eb_bytes %d", vol->last_eb_bytes); + ubi_msg("corrupted %d", vol->corrupted); + ubi_msg("upd_marker %d", vol->upd_marker); + + if (vol->name_len <= UBI_VOL_NAME_MAX && + strnlen(vol->name, vol->name_len + 1) == vol->name_len) { + ubi_msg("name %s", vol->name); + } else { + ubi_msg("the 1st 5 characters of the name: %c%c%c%c%c", + vol->name[0], vol->name[1], vol->name[2], + vol->name[3], vol->name[4]); + } + printf("\n"); +} + +static void display_volume_info(struct ubi_device *ubi) +{ + int i; + + for (i = 0; i < (ubi->vtbl_slots + 1); i++) { + if (!ubi->volumes[i]) + continue; /* Empty record */ + ubi_dump_vol_info(ubi->volumes[i]); + } +} + +static void display_ubi_info(struct ubi_device *ubi) +{ + ubi_msg("MTD device name: \"%s\"", ubi->mtd->name); + ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20); + ubi_msg("physical eraseblock size: %d bytes (%d KiB)", + ubi->peb_size, ubi->peb_size >> 10); + ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size); + ubi_msg("number of good PEBs: %d", ubi->good_peb_count); + ubi_msg("number of bad PEBs: %d", ubi->bad_peb_count); + ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size); + ubi_msg("VID header offset: %d (aligned %d)", + ubi->vid_hdr_offset, ubi->vid_hdr_aloffset); + ubi_msg("data offset: %d", ubi->leb_start); + ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots); + ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD); + ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT); + ubi_msg("number of user volumes: %d", + ubi->vol_count - UBI_INT_VOL_COUNT); + ubi_msg("available PEBs: %d", ubi->avail_pebs); + ubi_msg("total number of reserved PEBs: %d", ubi->rsvd_pebs); + ubi_msg("number of PEBs reserved for bad PEB handling: %d", + ubi->beb_rsvd_pebs); + ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec); +} + +static int ubi_info(int layout) +{ + if (layout) + display_volume_info(ubi); + else + display_ubi_info(ubi); + + return 0; +} + +static int parse_num(size_t *num, const char *token) +{ + char *endp; + size_t n; + + n = (size_t) ustrtoul(token, &endp, 0); + if (*endp) + return -EINVAL; + + *num = n; + return 0; +} + +static int verify_mkvol_req(const struct ubi_device *ubi, + const struct ubi_mkvol_req *req) +{ + int n, err = -EINVAL; + + if (req->bytes < 0 || req->alignment < 0 || req->vol_type < 0 || + req->name_len < 0) + goto bad; + + if ((req->vol_id < 0 || req->vol_id >= ubi->vtbl_slots) && + req->vol_id != UBI_VOL_NUM_AUTO) + goto bad; + + if (req->alignment == 0) + goto bad; + + if (req->bytes == 0) + goto bad; + + if (req->vol_type != UBI_DYNAMIC_VOLUME && + req->vol_type != UBI_STATIC_VOLUME) + goto bad; + + if (req->alignment > ubi->leb_size) + goto bad; + + n = req->alignment % ubi->min_io_size; + if (req->alignment != 1 && n) + goto bad; + + if (req->name_len > UBI_VOL_NAME_MAX) { + err = -ENAMETOOLONG; + goto bad; + } + + return 0; +bad: + printf("bad volume creation request"); + return err; +} + +static int ubi_create_vol(char *volume, int size, int dynamic) +{ + struct ubi_mkvol_req req; + int err; + + if (dynamic) + req.vol_type = UBI_DYNAMIC_VOLUME; + else + req.vol_type = UBI_STATIC_VOLUME; + + req.vol_id = UBI_VOL_NUM_AUTO; + req.alignment = 1; + req.bytes = size; + + strcpy(req.name, volume); + req.name_len = strlen(volume); + req.name[req.name_len] = '\0'; + req.padding1 = 0; + /* It's duplicated at drivers/mtd/ubi/cdev.c */ + err = verify_mkvol_req(ubi, &req); + if (err) { + printf("verify_mkvol_req failed %d\n", err); + return err; + } + printf("Creating %s volume %s of size %d\n", + dynamic ? "dynamic" : "static", volume, size); + /* Call real ubi create volume */ + return ubi_create_volume(ubi, &req); +} + +static int ubi_remove_vol(char *volume) +{ + int i, err, reserved_pebs; + int found = 0, vol_id = 0; + struct ubi_volume *vol; + + for (i = 0; i < ubi->vtbl_slots; i++) { + vol = ubi->volumes[i]; + if (vol && !strcmp(vol->name, volume)) { + printf("Volume %s found at valid %d\n", volume, i); + vol_id = i; + found = 1; + break; + } + } + if (!found) { + printf("%s volume not found\n", volume); + return -ENODEV; + } + printf("remove UBI volume %s (id %d)\n", vol->name, vol->vol_id); + + if (ubi->ro_mode) { + printf("It's read-only mode\n"); + err = -EROFS; + goto out_err; + } + + err = ubi_change_vtbl_record(ubi, vol_id, NULL); + if (err) { + printf("Error changing Vol tabel record err=%x\n", err); + goto out_err; + } + reserved_pebs = vol->reserved_pebs; + for (i = 0; i < vol->reserved_pebs; i++) { + err = ubi_eba_unmap_leb(ubi, vol, i); + if (err) + goto out_err; + } + + kfree(vol->eba_tbl); + ubi->volumes[vol_id]->eba_tbl = NULL; + ubi->volumes[vol_id] = NULL; + + ubi->rsvd_pebs -= reserved_pebs; + ubi->avail_pebs += reserved_pebs; + i = ubi->beb_rsvd_level - ubi->beb_rsvd_pebs; + if (i > 0) { + i = ubi->avail_pebs >= i ? i : ubi->avail_pebs; + ubi->avail_pebs -= i; + ubi->rsvd_pebs += i; + ubi->beb_rsvd_pebs += i; + if (i > 0) + ubi_msg("reserve more %d PEBs", i); + } + ubi->vol_count -= 1; + + return 0; +out_err: + ubi_err("cannot remove volume %d, error %d", vol_id, err); + return err; +} + +static int ubi_volume_write(char *volume, void *buf, size_t size) +{ + int i = 0, err = -1; + int rsvd_bytes = 0; + int found = 0; + struct ubi_volume *vol; + + for (i = 0; i < ubi->vtbl_slots; i++) { + vol = ubi->volumes[i]; + if (vol && !strcmp(vol->name, volume)) { + printf("Volume \"%s\" found at volume id %d\n", volume, i); + found = 1; + break; + } + } + if (!found) { + printf("%s volume not found\n", volume); + return 1; + } + rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad); + if (size < 0 || size > rsvd_bytes) { + printf("rsvd_bytes=%d vol->reserved_pebs=%d ubi->leb_size=%d\n", + rsvd_bytes, vol->reserved_pebs, ubi->leb_size); + printf("vol->data_pad=%d\n", vol->data_pad); + printf("Size > volume size !!\n"); + return 1; + } + + err = ubi_start_update(ubi, vol, size); + if (err < 0) { + printf("Cannot start volume update\n"); + return err; + } + + err = ubi_more_update_data(ubi, vol, buf, size); + if (err < 0) { + printf("Couldnt or partially wrote data \n"); + return err; + } + + if (err) { + size = err; + + err = ubi_check_volume(ubi, vol->vol_id); + if ( err < 0 ) + return err; + + if (err) { + ubi_warn("volume %d on UBI device %d is corrupted", + vol->vol_id, ubi->ubi_num); + vol->corrupted = 1; + } + + vol->checked = 1; + ubi_gluebi_updated(vol); + } + + return 0; +} + +static int ubi_volume_read(char *volume, char *buf, size_t size) +{ + int err, lnum, off, len, tbuf_size, i = 0; + size_t count_save = size; + void *tbuf; + unsigned long long tmp; + struct ubi_volume *vol = NULL; + loff_t offp = 0; + + for (i = 0; i < ubi->vtbl_slots; i++) { + vol = ubi->volumes[i]; + if (vol && !strcmp(vol->name, volume)) { + printf("Volume %s found at volume id %d\n", + volume, vol->vol_id); + break; + } + } + if (i == ubi->vtbl_slots) { + printf("%s volume not found\n", volume); + return 0; + } + + printf("read %i bytes from volume %d to %x(buf address)\n", + (int) size, vol->vol_id, (unsigned)buf); + + if (vol->updating) { + printf("updating"); + return -EBUSY; + } + if (vol->upd_marker) { + printf("damaged volume, update marker is set"); + return -EBADF; + } + if (offp == vol->used_bytes) + return 0; + + if (size == 0) { + printf("Read [%lu] bytes\n", (unsigned long) vol->used_bytes); + size = vol->used_bytes; + } + + if (vol->corrupted) + printf("read from corrupted volume %d", vol->vol_id); + if (offp + size > vol->used_bytes) + count_save = size = vol->used_bytes - offp; + + tbuf_size = vol->usable_leb_size; + if (size < tbuf_size) + tbuf_size = ALIGN(size, ubi->min_io_size); + tbuf = malloc(tbuf_size); + if (!tbuf) { + printf("NO MEM\n"); + return -ENOMEM; + } + len = size > tbuf_size ? tbuf_size : size; + + tmp = offp; + off = do_div(tmp, vol->usable_leb_size); + lnum = tmp; + printf("off=%d lnum=%d\n", off, lnum); + do { + if (off + len >= vol->usable_leb_size) + len = vol->usable_leb_size - off; + + err = ubi_eba_read_leb(ubi, vol, lnum, tbuf, off, len, 0); + if (err) { + printf("read err %x\n", err); + break; + } + off += len; + if (off == vol->usable_leb_size) { + lnum += 1; + off -= vol->usable_leb_size; + } + + size -= len; + offp += len; + + printf("buf = %x\n", (unsigned)buf); + memcpy(buf, tbuf, len); + printf("buf[0] = %x\n", buf[0]); + + buf += len; + len = size > tbuf_size ? tbuf_size : size; + } while (size); + + free(tbuf); + return err ? err : count_save - size; +} + +static int ubi_dev_scan(struct mtd_info *info, char *ubidev) +{ + struct mtd_device *dev; + struct part_info *part; + struct mtd_partition mtd_part; + char buffer[32]; + u8 pnum; + int err; + + if (mtdparts_init() != 0) + return 1; + + if (find_dev_and_part(ubidev, &dev, &pnum, &part) != 0) + return 1; + + sprintf(buffer, "mtd=%d", pnum); + memset(&mtd_part, 0, sizeof(mtd_part)); + mtd_part.name = buffer; + mtd_part.size = part->size; + mtd_part.offset = part->offset; + add_mtd_partitions(info, &mtd_part, 1); + + err = ubi_mtd_param_parse(buffer, NULL); + if (err) { + del_mtd_partitions(info); + return err; + } + + err = ubi_init(); + if (err) { + del_mtd_partitions(info); + return err; + } + + return 0; +} + +static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) +{ + size_t size = 0; + ulong addr = 0; + int err = 0; + + if (argc < 2) { + printf("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + if (strcmp(argv[1], "part") == 0) { + /* Print current partition */ + if (argc == 2) { + if (ubi_dev.type == DEV_TYPE_NONE) { + printf("Error, no UBI device/partition selected!\n"); + return 1; + } + + printf("%s Device %d: %s, partition %s\n", ubi_dev.dev_name, + ubi_dev.nr, ubi_dev.mtd_info->name, ubi_dev.part_name); + return 0; + } + + if (argc < 4) { + printf("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + /* todo: get dev number for NAND... */ + ubi_dev.nr = 0; + + /* + * Check for nand|onenand selection + */ +#if defined(CONFIG_CMD_NAND) + if (strcmp(argv[2], "nand") == 0) { + strcpy(ubi_dev.dev_name, "NAND"); + ubi_dev.type = DEV_TYPE_NAND; + ubi_dev.mtd_info = &nand_info[ubi_dev.nr]; + } +#endif +#if defined(CONFIG_CMD_ONENAND) + if (strcmp(argv[2], "onenand") == 0) { + strcpy(ubi_dev.dev_name, "OneNAND"); + ubi_dev.type = DEV_TYPE_ONENAND; + ubi_dev.mtd_info = &onenand_mtd; + } +#endif + + if (ubi_dev.type == DEV_TYPE_NONE) { + printf("Error, no UBI device/partition selected!\n"); + return 1; + } + + strcpy(ubi_dev.part_name, argv[3]); + err = ubi_dev_scan(ubi_dev.mtd_info, ubi_dev.part_name); + if (err) { + printf("UBI init error %d\n", err); + return err; + } + + ubi = ubi_devices[0]; + + return 0; + } + + if ((strcmp(argv[1], "part") != 0) && (ubi_dev.type == DEV_TYPE_NONE)) { + printf("Error, no UBI device/partition selected!\n"); + return 1; + } + + if (strcmp(argv[1], "info") == 0) { + int layout = 0; + if (argc > 2 && !strncmp(argv[2], "l", 1)) + layout = 1; + return ubi_info(layout); + } + + if (strncmp(argv[1], "create", 6) == 0) { + int dynamic = 1; /* default: dynamic volume */ + + /* Use maximum available size */ + size = 0; + + /* E.g., create volume size type */ + if (argc == 5) { + if (strncmp(argv[4], "s", 1) == 0) + dynamic = 0; + else if (strncmp(argv[4], "d", 1) != 0) { + printf("Incorrect type\n"); + return 1; + } + argc--; + } + /* E.g., create volume size */ + if (argc == 4) { + err = parse_num(&size, argv[3]); + if (err) { + printf("Incorrect type\n"); + return err; + } + argc--; + } + /* Use maximum available size */ + if (!size) + size = ubi->avail_pebs * ubi->leb_size; + /* E.g., create volume */ + if (argc == 3) + return ubi_create_vol(argv[2], size, dynamic); + } + + if (strncmp(argv[1], "remove", 6) == 0) { + /* E.g., remove volume */ + if (argc == 3) + return ubi_remove_vol(argv[2]); + } + + if (strncmp(argv[1], "write", 5) == 0) { + if (argc < 5) { + printf("Please see usage\n"); + return 1; + } + + addr = simple_strtoul(argv[2], NULL, 16); + err = parse_num(&size, argv[4]); + if (err) { + printf("Please see usage\n"); + return err; + } + + return ubi_volume_write(argv[3], (void *)addr, size); + } + + if (strncmp(argv[1], "read", 4) == 0) { + size = 0; + + /* E.g., read volume size */ + if (argc == 5) { + err = parse_num(&size, argv[4]); + if (err) { + printf("Please see usage\n"); + return err; + } + argc--; + } + + /* E.g., read volume */ + if (argc == 4) { + addr = simple_strtoul(argv[2], NULL, 16); + argc--; + } + + if (argc == 3) + return ubi_volume_read(argv[3], (char *)addr, size); + } + + printf("Please see usage\n"); + return -1; +} + +U_BOOT_CMD(ubi, 6, 1, do_ubi, + "ubi - ubi commands\n", + "part [nand|onenand] [part]" + " - Show or set current partition\n" + "ubi info [l[ayout]]" + " - Display volume and ubi layout information\n" + "ubi create[vol] volume [size] [type]" + " - create volume name with size\n" + "ubi write[vol] address volume size" + " - Write volume from address with size\n" + "ubi read[vol] address volume [size]" + " - Read volume to address with size\n" + "ubi remove[vol] volume" + " - Remove volume\n" + "[Legends]\n" + " volume: charater name\n" + " size: KiB, MiB, GiB, and bytes\n" + " type: s[tatic] or d[ynamic] (default=dynamic)\n" +); -- cgit v1.1 From a5c4067017631d903e1afa6ad615f0ce19fea517 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Mon, 24 Nov 2008 08:31:16 +0100 Subject: UBI: Change parsing of size in commands to default to hex Currently the size parameters of the UBI commands (e.g. "ubi write") are decoded as decimal instead of hex as default. This patch now interprets all these values consistantly as hex, as all other standard U-Boot commands do. Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index a5c5064..57ce3cc 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -29,6 +29,7 @@ /* Private own data */ static struct ubi_device *ubi; +static char buffer[80]; struct selected_dev { char dev_name[32]; /* NAND/OneNAND etc */ @@ -113,19 +114,6 @@ static int ubi_info(int layout) return 0; } -static int parse_num(size_t *num, const char *token) -{ - char *endp; - size_t n; - - n = (size_t) ustrtoul(token, &endp, 0); - if (*endp) - return -EINVAL; - - *num = n; - return 0; -} - static int verify_mkvol_req(const struct ubi_device *ubi, const struct ubi_mkvol_req *req) { @@ -378,7 +366,6 @@ static int ubi_volume_read(char *volume, char *buf, size_t size) tmp = offp; off = do_div(tmp, vol->usable_leb_size); lnum = tmp; - printf("off=%d lnum=%d\n", off, lnum); do { if (off + len >= vol->usable_leb_size) len = vol->usable_leb_size - off; @@ -397,9 +384,7 @@ static int ubi_volume_read(char *volume, char *buf, size_t size) size -= len; offp += len; - printf("buf = %x\n", (unsigned)buf); memcpy(buf, tbuf, len); - printf("buf[0] = %x\n", buf[0]); buf += len; len = size > tbuf_size ? tbuf_size : size; @@ -414,7 +399,6 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev) struct mtd_device *dev; struct part_info *part; struct mtd_partition mtd_part; - char buffer[32]; u8 pnum; int err; @@ -543,11 +527,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* E.g., create volume size */ if (argc == 4) { - err = parse_num(&size, argv[3]); - if (err) { - printf("Incorrect type\n"); - return err; - } + addr = simple_strtoul(argv[3], NULL, 16); argc--; } /* Use maximum available size */ @@ -571,11 +551,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } addr = simple_strtoul(argv[2], NULL, 16); - err = parse_num(&size, argv[4]); - if (err) { - printf("Please see usage\n"); - return err; - } + size = simple_strtoul(argv[4], NULL, 16); return ubi_volume_write(argv[3], (void *)addr, size); } @@ -585,11 +561,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /* E.g., read volume size */ if (argc == 5) { - err = parse_num(&size, argv[4]); - if (err) { - printf("Please see usage\n"); - return err; - } + size = simple_strtoul(argv[4], NULL, 16); argc--; } -- cgit v1.1 From 25ea652e907516a283b38237e83712a918f125d7 Mon Sep 17 00:00:00 2001 From: Piotr Ziecik Date: Mon, 17 Nov 2008 15:58:00 +0100 Subject: UBI: Add proof-of-concept CFI flash support With this patch UBI can be used on CFI flash chips. Signed-off-by: Piotr Ziecik Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 57ce3cc..8446765 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -26,6 +26,7 @@ #define DEV_TYPE_NONE 0 #define DEV_TYPE_NAND 1 #define DEV_TYPE_ONENAND 2 +#define DEV_TYPE_NOR 3 /* Private own data */ static struct ubi_device *ubi; @@ -472,6 +473,13 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ubi_dev.mtd_info = &nand_info[ubi_dev.nr]; } #endif +#if defined(CONFIG_FLASH_CFI_MTD) + if (strcmp(argv[2], "nor") == 0) { + strcpy(ubi_dev.dev_name, "NOR"); + ubi_dev.type = DEV_TYPE_NOR; + ubi_dev.mtd_info = get_mtd_device_nm(CFI_MTD_DEV_NAME); + } +#endif #if defined(CONFIG_CMD_ONENAND) if (strcmp(argv[2], "onenand") == 0) { strcpy(ubi_dev.dev_name, "OneNAND"); @@ -581,7 +589,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD(ubi, 6, 1, do_ubi, "ubi - ubi commands\n", - "part [nand|onenand] [part]" + "part [nand|nor|onenand] [part]" " - Show or set current partition\n" "ubi info [l[ayout]]" " - Display volume and ubi layout information\n" -- cgit v1.1 From de39f8c19d7c12017248c49d432dcb81db68f724 Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Wed, 26 Nov 2008 17:41:34 +0100 Subject: USB style patch, 80 chars strict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit USB Code style patch Signed-off-by: Michael Trimarchi Signed-off-by: Remy Böhmer --- common/cmd_usb.c | 595 +++++++++++++++++++++++++++++-------------------------- common/usb.c | 40 ++-- 2 files changed, 341 insertions(+), 294 deletions(-) (limited to 'common') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 99e551f..8a8dca9 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -36,178 +36,210 @@ static int usb_stor_curr_dev = -1; /* current device */ #endif /* some display routines (info command) */ -char * usb_get_class_desc(unsigned char dclass) +char *usb_get_class_desc(unsigned char dclass) { - switch(dclass) { - case USB_CLASS_PER_INTERFACE: - return("See Interface"); - case USB_CLASS_AUDIO: - return("Audio"); - case USB_CLASS_COMM: - return("Communication"); - case USB_CLASS_HID: - return("Human Interface"); - case USB_CLASS_PRINTER: - return("Printer"); - case USB_CLASS_MASS_STORAGE: - return("Mass Storage"); - case USB_CLASS_HUB: - return("Hub"); - case USB_CLASS_DATA: - return("CDC Data"); - case USB_CLASS_VENDOR_SPEC: - return("Vendor specific"); - default : - return(""); + switch (dclass) { + case USB_CLASS_PER_INTERFACE: + return "See Interface"; + case USB_CLASS_AUDIO: + return "Audio"; + case USB_CLASS_COMM: + return "Communication"; + case USB_CLASS_HID: + return "Human Interface"; + case USB_CLASS_PRINTER: + return "Printer"; + case USB_CLASS_MASS_STORAGE: + return "Mass Storage"; + case USB_CLASS_HUB: + return "Hub"; + case USB_CLASS_DATA: + return "CDC Data"; + case USB_CLASS_VENDOR_SPEC: + return "Vendor specific"; + default: + return ""; } } -void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned char proto) +void usb_display_class_sub(unsigned char dclass, unsigned char subclass, + unsigned char proto) { - switch(dclass) { - case USB_CLASS_PER_INTERFACE: - printf("See Interface"); + switch (dclass) { + case USB_CLASS_PER_INTERFACE: + printf("See Interface"); + break; + case USB_CLASS_HID: + printf("Human Interface, Subclass: "); + switch (subclass) { + case USB_SUB_HID_NONE: + printf("None"); break; - case USB_CLASS_HID: - printf("Human Interface, Subclass: "); - switch(subclass) { - case USB_SUB_HID_NONE: - printf("None"); - break; - case USB_SUB_HID_BOOT: - printf("Boot "); - switch(proto) { - case USB_PROT_HID_NONE: - printf("None"); - break; - case USB_PROT_HID_KEYBOARD: - printf("Keyboard"); - break; - case USB_PROT_HID_MOUSE: - printf("Mouse"); - break; - default: - printf("reserved"); - } - break; - default: - printf("reserved"); + case USB_SUB_HID_BOOT: + printf("Boot "); + switch (proto) { + case USB_PROT_HID_NONE: + printf("None"); + break; + case USB_PROT_HID_KEYBOARD: + printf("Keyboard"); + break; + case USB_PROT_HID_MOUSE: + printf("Mouse"); + break; + default: + printf("reserved"); + break; } break; - case USB_CLASS_MASS_STORAGE: - printf("Mass Storage, "); - switch(subclass) { - case US_SC_RBC: - printf("RBC "); - break; - case US_SC_8020: - printf("SFF-8020i (ATAPI)"); - break; - case US_SC_QIC: - printf("QIC-157 (Tape)"); - break; - case US_SC_UFI: - printf("UFI"); - break; - case US_SC_8070: - printf("SFF-8070"); - break; - case US_SC_SCSI: - printf("Transp. SCSI"); - break; - default: - printf("reserved"); - break; - } - printf(", "); - switch(proto) { - case US_PR_CB: - printf("Command/Bulk"); - break; - case US_PR_CBI: - printf("Command/Bulk/Int"); - break; - case US_PR_BULK: - printf("Bulk only"); - break; - default: - printf("reserved"); - } + default: + printf("reserved"); + break; + } + break; + case USB_CLASS_MASS_STORAGE: + printf("Mass Storage, "); + switch (subclass) { + case US_SC_RBC: + printf("RBC "); + break; + case US_SC_8020: + printf("SFF-8020i (ATAPI)"); + break; + case US_SC_QIC: + printf("QIC-157 (Tape)"); + break; + case US_SC_UFI: + printf("UFI"); + break; + case US_SC_8070: + printf("SFF-8070"); + break; + case US_SC_SCSI: + printf("Transp. SCSI"); + break; + default: + printf("reserved"); + break; + } + printf(", "); + switch (proto) { + case US_PR_CB: + printf("Command/Bulk"); + break; + case US_PR_CBI: + printf("Command/Bulk/Int"); + break; + case US_PR_BULK: + printf("Bulk only"); break; default: - printf("%s",usb_get_class_desc(dclass)); + printf("reserved"); + break; + } + break; + default: + printf("%s", usb_get_class_desc(dclass)); + break; } } -void usb_display_string(struct usb_device *dev,int index) +void usb_display_string(struct usb_device *dev, int index) { char buffer[256]; - if (index!=0) { - if (usb_string(dev,index,&buffer[0],256)>0); - printf("String: \"%s\"",buffer); + if (index != 0) { + if (usb_string(dev, index, &buffer[0], 256) > 0) + printf("String: \"%s\"", buffer); } } void usb_display_desc(struct usb_device *dev) { - if (dev->descriptor.bDescriptorType==USB_DT_DEVICE) { - printf("%d: %s, USB Revision %x.%x\n",dev->devnum,usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), - (dev->descriptor.bcdUSB>>8) & 0xff,dev->descriptor.bcdUSB & 0xff); - if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial)) - printf(" - %s %s %s\n",dev->mf,dev->prod,dev->serial); + if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) { + printf("%d: %s, USB Revision %x.%x\n", dev->devnum, + usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), + (dev->descriptor.bcdUSB>>8) & 0xff, + dev->descriptor.bcdUSB & 0xff); + + if (strlen(dev->mf) || strlen(dev->prod) || + strlen(dev->serial)) + printf(" - %s %s %s\n", dev->mf, dev->prod, + dev->serial); if (dev->descriptor.bDeviceClass) { printf(" - Class: "); - usb_display_class_sub(dev->descriptor.bDeviceClass,dev->descriptor.bDeviceSubClass,dev->descriptor.bDeviceProtocol); + usb_display_class_sub(dev->descriptor.bDeviceClass, + dev->descriptor.bDeviceSubClass, + dev->descriptor.bDeviceProtocol); printf("\n"); + } else { + printf(" - Class: (from Interface) %s\n", + usb_get_class_desc( + dev->config.if_desc[0].bInterfaceClass)); } - else { - printf(" - Class: (from Interface) %s\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass)); - } - printf(" - PacketSize: %d Configurations: %d\n",dev->descriptor.bMaxPacketSize0,dev->descriptor.bNumConfigurations); - printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",dev->descriptor.idVendor,dev->descriptor.idProduct,(dev->descriptor.bcdDevice>>8) & 0xff,dev->descriptor.bcdDevice & 0xff); + printf(" - PacketSize: %d Configurations: %d\n", + dev->descriptor.bMaxPacketSize0, + dev->descriptor.bNumConfigurations); + printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n", + dev->descriptor.idVendor, dev->descriptor.idProduct, + (dev->descriptor.bcdDevice>>8) & 0xff, + dev->descriptor.bcdDevice & 0xff); } } -void usb_display_conf_desc(struct usb_config_descriptor *config,struct usb_device *dev) +void usb_display_conf_desc(struct usb_config_descriptor *config, + struct usb_device *dev) { - printf(" Configuration: %d\n",config->bConfigurationValue); - printf(" - Interfaces: %d %s%s%dmA\n",config->bNumInterfaces,(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ", - (config->bmAttributes & 0x20) ? "Remote Wakeup " : "",config->MaxPower*2); + printf(" Configuration: %d\n", config->bConfigurationValue); + printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces, + (config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ", + (config->bmAttributes & 0x20) ? "Remote Wakeup " : "", + config->MaxPower*2); if (config->iConfiguration) { printf(" - "); - usb_display_string(dev,config->iConfiguration); + usb_display_string(dev, config->iConfiguration); printf("\n"); } } -void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,struct usb_device *dev) +void usb_display_if_desc(struct usb_interface_descriptor *ifdesc, + struct usb_device *dev) { - printf(" Interface: %d\n",ifdesc->bInterfaceNumber); - printf(" - Alternate Setting %d, Endpoints: %d\n",ifdesc->bAlternateSetting,ifdesc->bNumEndpoints); + printf(" Interface: %d\n", ifdesc->bInterfaceNumber); + printf(" - Alternate Setting %d, Endpoints: %d\n", + ifdesc->bAlternateSetting, ifdesc->bNumEndpoints); printf(" - Class "); - usb_display_class_sub(ifdesc->bInterfaceClass,ifdesc->bInterfaceSubClass,ifdesc->bInterfaceProtocol); + usb_display_class_sub(ifdesc->bInterfaceClass, + ifdesc->bInterfaceSubClass, ifdesc->bInterfaceProtocol); printf("\n"); if (ifdesc->iInterface) { printf(" - "); - usb_display_string(dev,ifdesc->iInterface); + usb_display_string(dev, ifdesc->iInterface); printf("\n"); } } void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc) { - printf(" - Endpoint %d %s ",epdesc->bEndpointAddress & 0xf,(epdesc->bEndpointAddress & 0x80) ? "In" : "Out"); - switch((epdesc->bmAttributes & 0x03)) - { - case 0: printf("Control"); break; - case 1: printf("Isochronous"); break; - case 2: printf("Bulk"); break; - case 3: printf("Interrupt"); break; + printf(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf, + (epdesc->bEndpointAddress & 0x80) ? "In" : "Out"); + switch ((epdesc->bmAttributes & 0x03)) { + case 0: + printf("Control"); + break; + case 1: + printf("Isochronous"); + break; + case 2: + printf("Bulk"); + break; + case 3: + printf("Interrupt"); + break; } - printf(" MaxPacket %d",epdesc->wMaxPacketSize); - if ((epdesc->bmAttributes & 0x03)==0x3) - printf(" Interval %dms",epdesc->bInterval); + printf(" MaxPacket %d", epdesc->wMaxPacketSize); + if ((epdesc->bmAttributes & 0x03) == 0x3) + printf(" Interval %dms", epdesc->bInterval); printf("\n"); } @@ -217,15 +249,15 @@ void usb_display_config(struct usb_device *dev) struct usb_config_descriptor *config; struct usb_interface_descriptor *ifdesc; struct usb_endpoint_descriptor *epdesc; - int i,ii; - - config= &dev->config; - usb_display_conf_desc(config,dev); - for(i=0;ino_of_if;i++) { - ifdesc= &config->if_desc[i]; - usb_display_if_desc(ifdesc,dev); - for(ii=0;iino_of_ep;ii++) { - epdesc= &ifdesc->ep_desc[ii]; + int i, ii; + + config = &dev->config; + usb_display_conf_desc(config, dev); + for (i = 0; i < config->no_of_if; i++) { + ifdesc = &config->if_desc[i]; + usb_display_if_desc(ifdesc, dev); + for (ii = 0; ii < ifdesc->no_of_ep; ii++) { + epdesc = &ifdesc->ep_desc[ii]; usb_display_ep_desc(epdesc); } } @@ -233,31 +265,33 @@ void usb_display_config(struct usb_device *dev) } /* shows the device tree recursively */ -void usb_show_tree_graph(struct usb_device *dev,char *pre) +void usb_show_tree_graph(struct usb_device *dev, char *pre) { - int i,index; - int has_child,last_child,port; + int i, index; + int has_child, last_child, port; - index=strlen(pre); - printf(" %s",pre); + index = strlen(pre); + printf(" %s", pre); /* check if the device has connected children */ - has_child=0; - for(i=0;imaxchild;i++) { - if (dev->children[i]!=NULL) - has_child=1; + has_child = 0; + for (i = 0; i < dev->maxchild; i++) { + if (dev->children[i] != NULL) + has_child = 1; } /* check if we are the last one */ - last_child=1; - if (dev->parent!=NULL) { - for(i=0;iparent->maxchild;i++) { + last_child = 1; + if (dev->parent != NULL) { + for (i = 0; i < dev->parent->maxchild; i++) { /* search for children */ - if (dev->parent->children[i]==dev) { - /* found our pointer, see if we have a little sister */ - port=i; - while(i++parent->maxchild) { - if (dev->parent->children[i]!=NULL) { + if (dev->parent->children[i] == dev) { + /* found our pointer, see if we have a + * little sister + */ + port = i; + while (i++ < dev->parent->maxchild) { + if (dev->parent->children[i] != NULL) { /* found a sister */ - last_child=0; + last_child = 0; break; } /* if */ } /* while */ @@ -265,28 +299,27 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre) } /* for all children of the parent */ printf("\b+-"); /* correct last child */ - if (last_child) { - pre[index-1]=' '; - } + if (last_child) + pre[index-1] = ' '; } /* if not root hub */ else printf(" "); - printf("%d ",dev->devnum); - pre[index++]=' '; - pre[index++]= has_child ? '|' : ' '; - pre[index]=0; - printf(" %s (%s, %dmA)\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), - dev->slow ? "1.5MBit/s" : "12MBit/s",dev->config.MaxPower * 2); - if (strlen(dev->mf) || - strlen(dev->prod) || - strlen(dev->serial)) - printf(" %s %s %s %s\n",pre,dev->mf,dev->prod,dev->serial); - printf(" %s\n",pre); - if (dev->maxchild>0) { - for(i=0;imaxchild;i++) { - if (dev->children[i]!=NULL) { - usb_show_tree_graph(dev->children[i],pre); - pre[index]=0; + printf("%d ", dev->devnum); + pre[index++] = ' '; + pre[index++] = has_child ? '|' : ' '; + pre[index] = 0; + printf(" %s (%s, %dmA)\n", usb_get_class_desc( + dev->config.if_desc[0].bInterfaceClass), + dev->slow ? "1.5MBit/s" : "12MBit/s", + dev->config.MaxPower * 2); + if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial)) + printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial); + printf(" %s\n", pre); + if (dev->maxchild > 0) { + for (i = 0; i < dev->maxchild; i++) { + if (dev->children[i] != NULL) { + usb_show_tree_graph(dev->children[i], pre); + pre[index] = 0; } } } @@ -297,8 +330,8 @@ void usb_show_tree(struct usb_device *dev) { char preamble[32]; - memset(preamble,0,32); - usb_show_tree_graph(dev,&preamble[0]); + memset(preamble, 0, 32); + usb_show_tree_graph(dev, &preamble[0]); } @@ -306,11 +339,11 @@ void usb_show_tree(struct usb_device *dev) * usb boot command intepreter. Derived from diskboot */ #ifdef CONFIG_USB_STORAGE -int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char *boot_device = NULL; char *ep; - int dev, part=1, rcode; + int dev, part = 1, rcode; ulong addr, cnt; disk_partition_t info; image_header_t *hdr; @@ -322,95 +355,98 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (argc) { case 1: addr = CONFIG_SYS_LOAD_ADDR; - boot_device = getenv ("bootdevice"); + boot_device = getenv("bootdevice"); break; case 2: addr = simple_strtoul(argv[1], NULL, 16); - boot_device = getenv ("bootdevice"); + boot_device = getenv("bootdevice"); break; case 3: addr = simple_strtoul(argv[1], NULL, 16); boot_device = argv[2]; break; default: - printf ("Usage:\n%s\n", cmdtp->usage); + printf("Usage:\n%s\n", cmdtp->usage); return 1; } if (!boot_device) { - puts ("\n** No boot device **\n"); + puts("\n** No boot device **\n"); return 1; } dev = simple_strtoul(boot_device, &ep, 16); - stor_dev=usb_stor_get_dev(dev); + stor_dev = usb_stor_get_dev(dev); if (stor_dev->type == DEV_TYPE_UNKNOWN) { - printf ("\n** Device %d not available\n", dev); + printf("\n** Device %d not available\n", dev); return 1; } - if (stor_dev->block_read==NULL) { + if (stor_dev->block_read == NULL) { printf("storage device not initialized. Use usb scan\n"); return 1; } if (*ep) { if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); + puts("\n** Invalid boot device, use `dev[:part]' **\n"); return 1; } part = simple_strtoul(++ep, NULL, 16); } - if (get_partition_info (stor_dev, part, &info)) { + if (get_partition_info(stor_dev, part, &info)) { /* try to boot raw .... */ - strncpy((char *)&info.type[0], BOOT_PART_TYPE, sizeof(BOOT_PART_TYPE)); + strncpy((char *)&info.type[0], BOOT_PART_TYPE, + sizeof(BOOT_PART_TYPE)); strncpy((char *)&info.name[0], "Raw", 4); - info.start=0; - info.blksz=0x200; - info.size=2880; + info.start = 0; + info.blksz = 0x200; + info.size = 2880; printf("error reading partinfo...try to boot raw\n"); } - if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) && - (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) { - printf ("\n** Invalid partition type \"%.32s\"" + if ((strncmp((char *)info.type, BOOT_PART_TYPE, + sizeof(info.type)) != 0) && + (strncmp((char *)info.type, BOOT_PART_COMP, + sizeof(info.type)) != 0)) { + printf("\n** Invalid partition type \"%.32s\"" " (expect \"" BOOT_PART_TYPE "\")\n", info.type); return 1; } - printf ("\nLoading from USB device %d, partition %d: " + printf("\nLoading from USB device %d, partition %d: " "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type); - debug ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n", + debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n", info.start, info.size, info.blksz); if (stor_dev->block_read(dev, info.start, 1, (ulong *)addr) != 1) { - printf ("** Read error on %d:%d\n", dev, part); + printf("** Read error on %d:%d\n", dev, part); return 1; } - switch (genimg_get_format ((void *)addr)) { + switch (genimg_get_format((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr; - if (!image_check_hcrc (hdr)) { - puts ("\n** Bad Header Checksum **\n"); + if (!image_check_hcrc(hdr)) { + puts("\n** Bad Header Checksum **\n"); return 1; } - image_print_contents (hdr); + image_print_contents(hdr); - cnt = image_get_image_size (hdr); + cnt = image_get_image_size(hdr); break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: fit_hdr = (const void *)addr; - puts ("Fit image detected...\n"); + puts("Fit image detected...\n"); - cnt = fit_get_size (fit_hdr); + cnt = fit_get_size(fit_hdr); break; #endif default: - puts ("** Unknown image type\n"); + puts("** Unknown image type\n"); return 1; } @@ -418,36 +454,38 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) cnt /= info.blksz; cnt -= 1; - if (stor_dev->block_read (dev, info.start+1, cnt, + if (stor_dev->block_read(dev, info.start+1, cnt, (ulong *)(addr+info.blksz)) != cnt) { - printf ("\n** Read error on %d:%d\n", dev, part); + printf("\n** Read error on %d:%d\n", dev, part); return 1; } #if defined(CONFIG_FIT) - /* This cannot be done earlier, we need complete FIT image in RAM first */ - if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { - if (!fit_check_format (fit_hdr)) { - puts ("** Bad FIT image format\n"); + /* This cannot be done earlier, we need complete FIT image in RAM + * first + */ + if (genimg_get_format((void *)addr) == IMAGE_FORMAT_FIT) { + if (!fit_check_format(fit_hdr)) { + puts("** Bad FIT image format\n"); return 1; } - fit_print_contents (fit_hdr); + fit_print_contents(fit_hdr); } #endif /* Loading ok, update default load address */ load_addr = addr; - flush_cache (addr, (cnt+1)*info.blksz); + flush_cache(addr, (cnt+1)*info.blksz); /* Check if we should attempt an auto-start */ - if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) { + if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) { char *local_args[2]; - extern int do_bootm (cmd_tbl_t *, int, int, char *[]); + extern int do_bootm(cmd_tbl_t *, int, int, char *[]); local_args[0] = argv[0]; local_args[1] = NULL; - printf ("Automatic boot of image at addr 0x%08lX ...\n", addr); - rcode=do_bootm (cmdtp, 0, 1, local_args); + printf("Automatic boot of image at addr 0x%08lX ...\n", addr); + rcode = do_bootm(cmdtp, 0, 1, local_args); return rcode; } return 0; @@ -455,10 +493,10 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif /* CONFIG_USB_STORAGE */ -/********************************************************************************* +/****************************************************************************** * usb command intepreter */ -int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int i; @@ -469,7 +507,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif if ((strncmp(argv[1], "reset", 5) == 0) || - (strncmp(argv[1], "start", 5) == 0)){ + (strncmp(argv[1], "start", 5) == 0)) { usb_stop(); printf("(Re)start USB...\n"); i = usb_init(); @@ -480,16 +518,17 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif return 0; } - if (strncmp(argv[1],"stop",4) == 0) { + if (strncmp(argv[1], "stop", 4) == 0) { #ifdef CONFIG_USB_KEYBOARD - if (argc==2) { - if (usb_kbd_deregister()!=0) { - printf("USB not stopped: usbkbd still using USB\n"); + if (argc == 2) { + if (usb_kbd_deregister() != 0) { + printf("USB not stopped: usbkbd still" + " using USB\n"); return 1; } - } - else { /* forced stop, switch console in to serial */ - console_assign(stdin,"serial"); + } else { + /* forced stop, switch console in to serial */ + console_assign(stdin, "serial"); usb_kbd_deregister(); } #endif @@ -501,40 +540,38 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf("USB is stopped. Please issue 'usb start' first.\n"); return 1; } - if (strncmp(argv[1],"tree",4) == 0) { + if (strncmp(argv[1], "tree", 4) == 0) { printf("\nDevice Tree:\n"); usb_show_tree(usb_get_dev_index(0)); return 0; } - if (strncmp(argv[1],"inf",3) == 0) { + if (strncmp(argv[1], "inf", 3) == 0) { int d; - if (argc==2) { - for(d=0;ddevnum==i) + if (dev->devnum == i) break; } - if (dev==NULL) { + if (dev == NULL) { printf("*** NO Device avaiable ***\n"); return 0; - } - else { + } else { usb_display_desc(dev); usb_display_config(dev); } @@ -543,36 +580,36 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #ifdef CONFIG_USB_STORAGE if (strncmp(argv[1], "scan", 4) == 0) { - printf(" NOTE: this command is obsolete and will be phased out\n"); - printf(" please use 'usb storage' for USB storage devices information\n\n"); + printf(" NOTE: this command is obsolete and will be" + " phased out\n"); + printf(" please use 'usb storage' for USB storage devices" + " information\n\n"); usb_stor_info(); return 0; } - if (strncmp(argv[1], "stor", 4) == 0) { + if (strncmp(argv[1], "stor", 4) == 0) return usb_stor_info(); - } - if (strncmp(argv[1],"part",4) == 0) { + if (strncmp(argv[1], "part", 4) == 0) { int devno, ok = 0; - if (argc==2) { - for (devno=0; devnotype!=DEV_TYPE_UNKNOWN) { + if (argc == 2) { + for (devno = 0; devno < USB_MAX_STOR_DEV; ++devno) { + stor_dev = usb_stor_get_dev(devno); + if (stor_dev->type != DEV_TYPE_UNKNOWN) { ok++; if (devno) printf("\n"); - printf("print_part of %x\n",devno); + printf("print_part of %x\n", devno); print_part(stor_dev); } } - } - else { - devno=simple_strtoul(argv[2], NULL, 16); - stor_dev=usb_stor_get_dev(devno); - if (stor_dev->type!=DEV_TYPE_UNKNOWN) { + } else { + devno = simple_strtoul(argv[2], NULL, 16); + stor_dev = usb_stor_get_dev(devno); + if (stor_dev->type != DEV_TYPE_UNKNOWN) { ok++; - printf("print_part of %x\n",devno); + printf("print_part of %x\n", devno); print_part(stor_dev); } } @@ -582,22 +619,24 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return 0; } - if (strcmp(argv[1],"read") == 0) { - if (usb_stor_curr_dev<0) { + if (strcmp(argv[1], "read") == 0) { + if (usb_stor_curr_dev < 0) { printf("no current device selected\n"); return 1; } - if (argc==5) { + if (argc == 5) { unsigned long addr = simple_strtoul(argv[2], NULL, 16); unsigned long blk = simple_strtoul(argv[3], NULL, 16); unsigned long cnt = simple_strtoul(argv[4], NULL, 16); unsigned long n; - printf ("\nUSB read: device %d block # %ld, count %ld ... ", - usb_stor_curr_dev, blk, cnt); - stor_dev=usb_stor_get_dev(usb_stor_curr_dev); - n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, (ulong *)addr); - printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR"); - if (n==cnt) + printf("\nUSB read: device %d block # %ld, count %ld" + " ... ", usb_stor_curr_dev, blk, cnt); + stor_dev = usb_stor_get_dev(usb_stor_curr_dev); + n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, + (ulong *)addr); + printf("%ld blocks read: %s\n", n, + (n == cnt) ? "OK" : "ERROR"); + if (n == cnt) return 0; return 1; } @@ -605,34 +644,31 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (strncmp(argv[1], "dev", 3) == 0) { if (argc == 3) { int dev = (int)simple_strtoul(argv[2], NULL, 10); - printf ("\nUSB device %d: ", dev); + printf("\nUSB device %d: ", dev); if (dev >= USB_MAX_STOR_DEV) { printf("unknown device\n"); return 1; } - printf ("\n Device %d: ", dev); - stor_dev=usb_stor_get_dev(dev); + printf("\n Device %d: ", dev); + stor_dev = usb_stor_get_dev(dev); dev_print(stor_dev); - if (stor_dev->type == DEV_TYPE_UNKNOWN) { + if (stor_dev->type == DEV_TYPE_UNKNOWN) return 1; - } usb_stor_curr_dev = dev; printf("... is now current device\n"); return 0; - } - else { - printf ("\nUSB device %d: ", usb_stor_curr_dev); - stor_dev=usb_stor_get_dev(usb_stor_curr_dev); + } else { + printf("\nUSB device %d: ", usb_stor_curr_dev); + stor_dev = usb_stor_get_dev(usb_stor_curr_dev); dev_print(stor_dev); - if (stor_dev->type == DEV_TYPE_UNKNOWN) { + if (stor_dev->type == DEV_TYPE_UNKNOWN) return 1; - } return 0; } return 0; } #endif /* CONFIG_USB_STORAGE */ - printf ("Usage:\n%s\n", cmdtp->usage); + printf("Usage:\n%s\n", cmdtp->usage); return 1; } @@ -646,7 +682,8 @@ U_BOOT_CMD( "usb info [dev] - show available USB devices\n" "usb storage - show details of USB storage devices\n" "usb dev [dev] - show or set current USB storage device\n" - "usb part [dev] - print partition table of one or all USB storage devices\n" + "usb part [dev] - print partition table of one or all USB storage" + " devices\n" "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n" " to memory address `addr'\n" ); diff --git a/common/usb.c b/common/usb.c index 7ab5df6..ee18152 100644 --- a/common/usb.c +++ b/common/usb.c @@ -58,7 +58,7 @@ #undef USB_DEBUG #ifdef USB_DEBUG -#define USB_PRINTF(fmt, args...) printf (fmt , ##args) +#define USB_PRINTF(fmt, args...) printf(fmt , ##args) #else #define USB_PRINTF(fmt, args...) #endif @@ -87,11 +87,12 @@ static int hub_port_reset(struct usb_device *dev, int port, * wait_ms */ -void __inline__ wait_ms(unsigned long ms) +inline void wait_ms(unsigned long ms) { while (ms-- > 0) udelay(1000); } + /*************************************************************************** * Init USB Device */ @@ -245,9 +246,9 @@ int usb_maxpacket(struct usb_device *dev, unsigned long pipe) { /* direction is out -> use emaxpacket out */ if ((pipe & USB_DIR_IN) == 0) - return(dev->epmaxpacketout[((pipe>>15) & 0xf)]); + return dev->epmaxpacketout[((pipe>>15) & 0xf)]; else - return(dev->epmaxpacketin[((pipe>>15) & 0xf)]); + return dev->epmaxpacketin[((pipe>>15) & 0xf)]; } /* The routine usb_set_maxpacket_ep() is extracted from the loop of routine @@ -269,7 +270,7 @@ usb_set_maxpacket_ep(struct usb_device *dev, struct usb_endpoint_descriptor *ep) USB_ENDPOINT_XFER_CONTROL) { /* Control => bidirectional */ dev->epmaxpacketout[b] = ep->wMaxPacketSize; - dev->epmaxpacketin [b] = ep->wMaxPacketSize; + dev->epmaxpacketin[b] = ep->wMaxPacketSize; USB_PRINTF("##Control EP epmaxpacketout/in[%d] = %d\n", b, dev->epmaxpacketin[b]); } else { @@ -779,13 +780,13 @@ int usb_new_device(struct usb_device *dev) * invalid header while reading 8 bytes as device descriptor. */ dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */ dev->maxpacketsize = PACKET_SIZE_8; - dev->epmaxpacketin [0] = 8; + dev->epmaxpacketin[0] = 8; dev->epmaxpacketout[0] = 8; err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8); if (err < 8) { printf("\n USB device not responding, " \ - "giving up (status=%lX)\n",dev->status); + "giving up (status=%lX)\n", dev->status); return 1; } #else @@ -793,7 +794,8 @@ int usb_new_device(struct usb_device *dev) * reset of the device (Linux uses the same sequence) * Some equipment is said to work only with such init sequence; this * patch is based on the work by Alan Stern: - * http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398 + * http://sourceforge.net/mailarchive/forum.php? + * thread_id=5729457&forum_id=5398 */ struct usb_device_descriptor *desc; int port = -1; @@ -809,7 +811,7 @@ int usb_new_device(struct usb_device *dev) dev->descriptor.bMaxPacketSize0 = 64; /* Start off at 64 bytes */ /* Default to 64 byte max packet size */ dev->maxpacketsize = PACKET_SIZE_64; - dev->epmaxpacketin [0] = 64; + dev->epmaxpacketin[0] = 64; dev->epmaxpacketout[0] = 64; err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); @@ -844,13 +846,21 @@ int usb_new_device(struct usb_device *dev) } #endif - dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0; + dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0; dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0; switch (dev->descriptor.bMaxPacketSize0) { - case 8: dev->maxpacketsize = PACKET_SIZE_8; break; - case 16: dev->maxpacketsize = PACKET_SIZE_16; break; - case 32: dev->maxpacketsize = PACKET_SIZE_32; break; - case 64: dev->maxpacketsize = PACKET_SIZE_64; break; + case 8: + dev->maxpacketsize = PACKET_SIZE_8; + break; + case 16: + dev->maxpacketsize = PACKET_SIZE_16; + break; + case 32: + dev->maxpacketsize = PACKET_SIZE_32; + break; + case 64: + dev->maxpacketsize = PACKET_SIZE_64; + break; } dev->devnum = addr; @@ -947,7 +957,7 @@ void usb_scan_devices(void) #undef USB_HUB_DEBUG #ifdef USB_HUB_DEBUG -#define USB_HUB_PRINTF(fmt, args...) printf (fmt , ##args) +#define USB_HUB_PRINTF(fmt, args...) printf(fmt , ##args) #else #define USB_HUB_PRINTF(fmt, args...) #endif -- cgit v1.1 From bebfc6ef3ec994c8e18783269b1d8d41f8e38afd Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Wed, 26 Nov 2008 17:40:37 +0100 Subject: Remove obsolete command (apply afte USB style patch, 80 chars strict) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove USB obsolete commmand Signed-off-by: Michael Trimarchi Signed-off-by: Remy Böhmer --- common/cmd_usb.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'common') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 8a8dca9..8b19240 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -579,15 +579,6 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } #ifdef CONFIG_USB_STORAGE - if (strncmp(argv[1], "scan", 4) == 0) { - printf(" NOTE: this command is obsolete and will be" - " phased out\n"); - printf(" please use 'usb storage' for USB storage devices" - " information\n\n"); - usb_stor_info(); - return 0; - } - if (strncmp(argv[1], "stor", 4) == 0) return usb_stor_info(); -- cgit v1.1 From 5e46b1e54112f4b7fd5185665e571510132c12a7 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 27 Nov 2008 14:11:37 +0100 Subject: OneNAND: Add missing mtd info struct before calling onenand_erase() Without this patch "saveenv" crashes when MTD partitions are enabled (e.g. for use in UBI) via CONFIG_MTD_PARTITIONS. Signed-off-by: Stefan Roese Signed-off-by: Scott Wood --- common/env_onenand.c | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/env_onenand.c b/common/env_onenand.c index 3c65b3e..dbccc79 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -97,6 +97,7 @@ int saveenv(void) instr.len = CONFIG_ENV_SIZE; instr.addr = env_addr; + instr.mtd = &onenand_mtd; if (onenand_erase(&onenand_mtd, &instr)) { printf("OneNAND: erase failed at 0x%08lx\n", env_addr); return 1; -- cgit v1.1 From 2e4970d8109d690adcf615d9e3cac7b5b2e8eaed Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 2 Dec 2008 12:59:51 -0600 Subject: net: Fix download command parsing When CONFIG_SYS_HUSH_PARSER is defined network download commands with 1 argument in the format 'tftp "/path/file"' do not work as expected. The hush command parser strips the quotes from "/path/file" which causes the network commands to interpret "/path/file" as an address instead of the intended filename. The previous check for a leading quote in netboot_common() was replaced with a check which ensures only valid numbers are treated as addresses. Signed-off-by: Peter Tyser Signed-off-by: Ben Warren --- common/cmd_net.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/cmd_net.c b/common/cmd_net.c index af691a4..c053d7b 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -154,8 +154,10 @@ static int netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) { char *s; + char *end; int rcode = 0; int size; + ulong addr; /* pre-set load_addr */ if ((s = getenv("loadaddr")) != NULL) { @@ -166,15 +168,17 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) case 1: break; - case 2: /* only one arg - accept two forms: - * just load address, or just boot file name. - * The latter form must be written "filename" here. + case 2: /* + * Only one arg - accept two forms: + * Just load address, or just boot file name. The latter + * form must be written in a format which can not be + * mis-interpreted as a valid number. */ - if (argv[1][0] == '"') { /* just boot filename */ - copy_filename (BootFile, argv[1], sizeof(BootFile)); - } else { /* load address */ - load_addr = simple_strtoul(argv[1], NULL, 16); - } + addr = simple_strtoul(argv[1], &end, 16); + if (end == (argv[1] + strlen(argv[1]))) + load_addr = addr; + else + copy_filename(BootFile, argv[1], sizeof(BootFile)); break; case 3: load_addr = simple_strtoul(argv[1], NULL, 16); -- cgit v1.1 From c8aa7dfc18f7cc90d0aea6c7becbb67dfc5bba4b Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 31 Oct 2008 12:26:55 +0100 Subject: FPGA: move fpga drivers to drivers/fpga Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/ACEX1K.c | 362 ----------------------------- common/Makefile | 11 - common/altera.c | 283 ----------------------- common/cyclon2.c | 301 ------------------------ common/fpga.c | 335 --------------------------- common/spartan2.c | 663 ---------------------------------------------------- common/spartan3.c | 668 ----------------------------------------------------- common/stratixII.c | 231 ------------------ common/virtex2.c | 554 -------------------------------------------- common/xilinx.c | 307 ------------------------ 10 files changed, 3715 deletions(-) delete mode 100644 common/ACEX1K.c delete mode 100644 common/altera.c delete mode 100644 common/cyclon2.c delete mode 100644 common/fpga.c delete mode 100644 common/spartan2.c delete mode 100644 common/spartan3.c delete mode 100644 common/stratixII.c delete mode 100644 common/virtex2.c delete mode 100644 common/xilinx.c (limited to 'common') diff --git a/common/ACEX1K.c b/common/ACEX1K.c deleted file mode 100644 index 3f79677..0000000 --- a/common/ACEX1K.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * (C) Copyright 2003 - * Steven Scholz, imc Measurement & Control, steven.scholz@imc-berlin.de - * - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * - * 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 - * - */ - -#include /* core U-Boot definitions */ -#include /* ACEX device family */ - -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* Note: The assumption is that we cannot possibly run fast enough to - * overrun the device (the Slave Parallel mode can free run at 50MHz). - * If there is a need to operate slower, define CONFIG_FPGA_DELAY in - * the board config file to slow things down. - */ -#ifndef CONFIG_FPGA_DELAY -#define CONFIG_FPGA_DELAY() -#endif - -#ifndef CONFIG_SYS_FPGA_WAIT -#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/10 /* 100 ms */ -#endif - -static int ACEX1K_ps_load( Altera_desc *desc, void *buf, size_t bsize ); -static int ACEX1K_ps_dump( Altera_desc *desc, void *buf, size_t bsize ); -/* static int ACEX1K_ps_info( Altera_desc *desc ); */ -static int ACEX1K_ps_reloc( Altera_desc *desc, ulong reloc_offset ); - -/* ------------------------------------------------------------------------- */ -/* ACEX1K Generic Implementation */ -int ACEX1K_load (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - PRINTF ("%s: Launching Passive Serial Loader\n", __FUNCTION__); - ret_val = ACEX1K_ps_load (desc, buf, bsize); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int ACEX1K_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - PRINTF ("%s: Launching Passive Serial Dump\n", __FUNCTION__); - ret_val = ACEX1K_ps_dump (desc, buf, bsize); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int ACEX1K_info( Altera_desc *desc ) -{ - return FPGA_SUCCESS; -} - - -int ACEX1K_reloc (Altera_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (desc->family != Altera_ACEX1K) { - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - return FPGA_FAIL; - } else - switch (desc->iface) { - case passive_serial: - ret_val = ACEX1K_ps_reloc (desc, reloc_offset); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - - -/* ------------------------------------------------------------------------- */ -/* ACEX1K Passive Serial Generic Implementation */ - -static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Altera_ACEX1K_Passive_Serial_fns *fn = desc->iface_fns; - int i; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "config:\t0x%p\n" - "status:\t0x%p\n" - "clk:\t0x%p\n" - "data:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->config, fn->status, - fn->clk, fn->data, fn->done); -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...", cookie); -#endif - - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->config) (TRUE, TRUE, cookie); /* Assert nCONFIG */ - - udelay(2); /* T_cfg > 2us */ - - /* nSTATUS should be asserted now */ - (*fn->done) (cookie); - if ( !(*fn->status) (cookie) ) { - puts ("** nSTATUS is not asserted.\n"); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - - (*fn->config) (FALSE, TRUE, cookie); /* Deassert nCONFIG */ - udelay(2); /* T_cf2st1 < 4us */ - - /* Wait for nSTATUS to be released (i.e. deasserted) */ - ts = get_timer (0); /* get current time */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for STATUS to go high.\n"); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - (*fn->done) (cookie); - } while ((*fn->status) (cookie)); - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - - /* Load the data */ - while (bytecount < bsize) { - unsigned char val=0; -#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC - if (ctrlc ()) { - (*fn->abort) (cookie); - return FPGA_FAIL; - } -#endif - /* Altera detects an error if INIT goes low (active) - while DONE is low (inactive) */ -#if 0 /* not yet implemented */ - if ((*fn->done) (cookie) == 0 && (*fn->init) (cookie)) { - puts ("** CRC error during FPGA load.\n"); - (*fn->abort) (cookie); - return (FPGA_FAIL); - } -#endif - val = data [bytecount ++ ]; - i = 8; - do { - /* Deassert the clock */ - (*fn->clk) (FALSE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Write data */ - (*fn->data) ( (val & 0x01), TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Assert the clock */ - (*fn->clk) (TRUE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - val >>= 1; - i --; - } while (i > 0); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - CONFIG_FPGA_DELAY (); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc (' '); /* terminate the dotted line */ -#endif - - /* - * Checking FPGA's CONF_DONE signal - correctly booted ? - */ - - if ( ! (*fn->done) (cookie) ) { - puts ("** Booting failed! CONF_DONE is still deasserted.\n"); - (*fn->abort) (cookie); - return (FPGA_FAIL); - } - - /* - * "DCLK must be clocked an additional 10 times fpr ACEX 1K..." - */ - - for (i = 0; i < 12; i++) { - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - } - - ret_val = FPGA_SUCCESS; - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (ret_val == FPGA_SUCCESS) { - puts ("Done.\n"); - } - else { - puts ("Fail.\n"); - } -#endif - (*fn->post) (cookie); - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int ACEX1K_ps_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - /* Readback is only available through the Slave Parallel and */ - /* boundary-scan interfaces. */ - printf ("%s: Passive Serial Dumping is unavailable\n", - __FUNCTION__); - return FPGA_FAIL; -} - -static int ACEX1K_ps_reloc (Altera_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Altera_ACEX1K_Passive_Serial_fns *fn_r, *fn = - (Altera_ACEX1K_Passive_Serial_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Altera_ACEX1K_Passive_Serial_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Altera_ACEX1K_Passive_Serial_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Altera_pre_fn) addr; - - addr = (ulong) (fn->config) + reloc_offset; - fn_r->config = (Altera_config_fn) addr; - - addr = (ulong) (fn->status) + reloc_offset; - fn_r->status = (Altera_status_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Altera_done_fn) addr; - - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Altera_clk_fn) addr; - - addr = (ulong) (fn->data) + reloc_offset; - fn_r->data = (Altera_data_fn) addr; - - addr = (ulong) (fn->abort) + reloc_offset; - fn_r->abort = (Altera_abort_fn) addr; - - addr = (ulong) (fn->post) + reloc_offset; - fn_r->post = (Altera_post_fn) addr; - - fn_r->relocated = TRUE; - - } else { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; - -} diff --git a/common/Makefile b/common/Makefile index 9dec4ec..596fef3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -90,18 +90,7 @@ COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o COBJS-$(CONFIG_CMD_FDOS) += cmd_fdos.o COBJS-$(CONFIG_CMD_FLASH) += cmd_flash.o ifdef CONFIG_FPGA -COBJS-y += fpga.o COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o -COBJS-$(CONFIG_FPGA_SPARTAN2) += spartan2.o -COBJS-$(CONFIG_FPGA_SPARTAN3) += spartan3.o -COBJS-$(CONFIG_FPGA_VIRTEX2) += virtex2.o -COBJS-$(CONFIG_FPGA_XILINX) += xilinx.o -ifdef CONFIG_FPGA_ALTERA -COBJS-y += altera.o -COBJS-$(CONFIG_FPGA_ACEX1K) += ACEX1K.o -COBJS-$(CONFIG_FPGA_CYCLON2) += cyclon2.o -COBJS-$(CONFIG_FPGA_STRATIX_II) += stratixII.o -endif endif COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o diff --git a/common/altera.c b/common/altera.c deleted file mode 100644 index 09dc0b2..0000000 --- a/common/altera.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * (C) Copyright 2003 - * Steven Scholz, imc Measurement & Control, steven.scholz@imc-berlin.de - * - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * - * 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 - * - */ - -/* - * Altera FPGA support - */ -#include -#include -#include - -/* Define FPGA_DEBUG to get debug printf's */ -/* #define FPGA_DEBUG */ - -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* Local Static Functions */ -static int altera_validate (Altera_desc * desc, const char *fn); - -/* ------------------------------------------------------------------------- */ -int altera_load( Altera_desc *desc, void *buf, size_t bsize ) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!altera_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else { - switch (desc->family) { - case Altera_ACEX1K: - case Altera_CYC2: -#if defined(CONFIG_FPGA_ACEX1K) - PRINTF ("%s: Launching the ACEX1K Loader...\n", - __FUNCTION__); - ret_val = ACEX1K_load (desc, buf, bsize); -#elif defined(CONFIG_FPGA_CYCLON2) - PRINTF ("%s: Launching the CYCLON II Loader...\n", - __FUNCTION__); - ret_val = CYC2_load (desc, buf, bsize); -#else - printf ("%s: No support for ACEX1K devices.\n", - __FUNCTION__); -#endif - break; - -#if defined(CONFIG_FPGA_STRATIX_II) - case Altera_StratixII: - PRINTF ("%s: Launching the Stratix II Loader...\n", - __FUNCTION__); - ret_val = StratixII_load (desc, buf, bsize); - break; -#endif - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - } - - return ret_val; -} - -int altera_dump( Altera_desc *desc, void *buf, size_t bsize ) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!altera_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else { - switch (desc->family) { - case Altera_ACEX1K: -#if defined(CONFIG_FPGA_ACEX) - PRINTF ("%s: Launching the ACEX1K Reader...\n", - __FUNCTION__); - ret_val = ACEX1K_dump (desc, buf, bsize); -#else - printf ("%s: No support for ACEX1K devices.\n", - __FUNCTION__); -#endif - break; - -#if defined(CONFIG_FPGA_STRATIX_II) - case Altera_StratixII: - PRINTF ("%s: Launching the Stratix II Reader...\n", - __FUNCTION__); - ret_val = StratixII_dump (desc, buf, bsize); - break; -#endif - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - } - - return ret_val; -} - -int altera_info( Altera_desc *desc ) -{ - int ret_val = FPGA_FAIL; - - if (altera_validate (desc, (char *)__FUNCTION__)) { - printf ("Family: \t"); - switch (desc->family) { - case Altera_ACEX1K: - printf ("ACEX1K\n"); - break; - case Altera_CYC2: - printf ("CYCLON II\n"); - break; - case Altera_StratixII: - printf ("Stratix II\n"); - break; - /* Add new family types here */ - default: - printf ("Unknown family type, %d\n", desc->family); - } - - printf ("Interface type:\t"); - switch (desc->iface) { - case passive_serial: - printf ("Passive Serial (PS)\n"); - break; - case passive_parallel_synchronous: - printf ("Passive Parallel Synchronous (PPS)\n"); - break; - case passive_parallel_asynchronous: - printf ("Passive Parallel Asynchronous (PPA)\n"); - break; - case passive_serial_asynchronous: - printf ("Passive Serial Asynchronous (PSA)\n"); - break; - case altera_jtag_mode: /* Not used */ - printf ("JTAG Mode\n"); - break; - case fast_passive_parallel: - printf ("Fast Passive Parallel (FPP)\n"); - break; - case fast_passive_parallel_security: - printf - ("Fast Passive Parallel with Security (FPPS) \n"); - break; - /* Add new interface types here */ - default: - printf ("Unsupported interface type, %d\n", desc->iface); - } - - printf ("Device Size: \t%d bytes\n" - "Cookie: \t0x%x (%d)\n", - desc->size, desc->cookie, desc->cookie); - - if (desc->iface_fns) { - printf ("Device Function Table @ 0x%p\n", desc->iface_fns); - switch (desc->family) { - case Altera_ACEX1K: - case Altera_CYC2: -#if defined(CONFIG_FPGA_ACEX1K) - ACEX1K_info (desc); -#elif defined(CONFIG_FPGA_CYCLON2) - CYC2_info (desc); -#else - /* just in case */ - printf ("%s: No support for ACEX1K devices.\n", - __FUNCTION__); -#endif - break; -#if defined(CONFIG_FPGA_STRATIX_II) - case Altera_StratixII: - StratixII_info (desc); - break; -#endif - /* Add new family types here */ - default: - /* we don't need a message here - we give one up above */ - break; - } - } else { - printf ("No Device Function Table.\n"); - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } - - return ret_val; -} - -int altera_reloc( Altera_desc *desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!altera_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else { - switch (desc->family) { - case Altera_ACEX1K: -#if defined(CONFIG_FPGA_ACEX1K) - ret_val = ACEX1K_reloc (desc, reloc_offset); -#else - printf ("%s: No support for ACEX devices.\n", - __FUNCTION__); -#endif - break; -#if defined(CONFIG_FPGA_STRATIX_II) - case Altera_StratixII: - ret_val = StratixII_reloc (desc, reloc_offset); - break; -#endif - case Altera_CYC2: -#if defined(CONFIG_FPGA_CYCLON2) - ret_val = CYC2_reloc (desc, reloc_offset); -#else - printf ("%s: No support for CYCLON II devices.\n", - __FUNCTION__); -#endif - break; - /* Add new family types here */ - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - } - - return ret_val; -} - -/* ------------------------------------------------------------------------- */ - -static int altera_validate (Altera_desc * desc, const char *fn) -{ - int ret_val = FALSE; - - if (desc) { - if ((desc->family > min_altera_type) && - (desc->family < max_altera_type)) { - if ((desc->iface > min_altera_iface_type) && - (desc->iface < max_altera_iface_type)) { - if (desc->size) { - ret_val = TRUE; - } else { - printf ("%s: NULL part size\n", fn); - } - } else { - printf ("%s: Invalid Interface type, %d\n", - fn, desc->iface); - } - } else { - printf ("%s: Invalid family type, %d\n", fn, desc->family); - } - } else { - printf ("%s: NULL descriptor!\n", fn); - } - - return ret_val; -} - -/* ------------------------------------------------------------------------- */ diff --git a/common/cyclon2.c b/common/cyclon2.c deleted file mode 100644 index 3ed64b2..0000000 --- a/common/cyclon2.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * (C) Copyright 2006 - * Heiko Schocher, hs@denx.de - * Based on ACE1XK.c - * - * 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 - * - */ - -#include /* core U-Boot definitions */ -#include -#include /* ACEX device family */ - -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* Note: The assumption is that we cannot possibly run fast enough to - * overrun the device (the Slave Parallel mode can free run at 50MHz). - * If there is a need to operate slower, define CONFIG_FPGA_DELAY in - * the board config file to slow things down. - */ -#ifndef CONFIG_FPGA_DELAY -#define CONFIG_FPGA_DELAY() -#endif - -#ifndef CONFIG_SYS_FPGA_WAIT -#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/10 /* 100 ms */ -#endif - -static int CYC2_ps_load( Altera_desc *desc, void *buf, size_t bsize ); -static int CYC2_ps_dump( Altera_desc *desc, void *buf, size_t bsize ); -/* static int CYC2_ps_info( Altera_desc *desc ); */ -static int CYC2_ps_reloc( Altera_desc *desc, ulong reloc_offset ); - -/* ------------------------------------------------------------------------- */ -/* CYCLON2 Generic Implementation */ -int CYC2_load (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - PRINTF ("%s: Launching Passive Serial Loader\n", __FUNCTION__); - ret_val = CYC2_ps_load (desc, buf, bsize); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int CYC2_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - PRINTF ("%s: Launching Passive Serial Dump\n", __FUNCTION__); - ret_val = CYC2_ps_dump (desc, buf, bsize); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int CYC2_info( Altera_desc *desc ) -{ - return FPGA_SUCCESS; -} - -int CYC2_reloc (Altera_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (desc->family != Altera_CYC2) { - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - return FPGA_FAIL; - } else - switch (desc->iface) { - case passive_serial: - ret_val = CYC2_ps_reloc (desc, reloc_offset); - break; - - /* Add new interface types here */ - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -/* ------------------------------------------------------------------------- */ -/* CYCLON2 Passive Serial Generic Implementation */ -static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Altera_CYC2_Passive_Serial_fns *fn = desc->iface_fns; - int ret = 0; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "config:\t0x%p\n" - "status:\t0x%p\n" - "write:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->config, fn->status, - fn->write, fn->done); -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...", cookie); -#endif - - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->config) (TRUE, TRUE, cookie); /* Assert nCONFIG */ - - udelay(2); /* T_cfg > 2us */ - - /* Wait for nSTATUS to be asserted */ - ts = get_timer (0); /* get current time */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for STATUS to go high.\n"); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - } while (!(*fn->status) (cookie)); - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - - ret = (*fn->write) (buf, bsize, TRUE, cookie); - if (ret) { - puts ("** Write failed.\n"); - (*fn->abort) (cookie); - return FPGA_FAIL; - } -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts(" OK? ..."); -#endif - - CONFIG_FPGA_DELAY (); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc (' '); /* terminate the dotted line */ -#endif - - /* - * Checking FPGA's CONF_DONE signal - correctly booted ? - */ - - if ( ! (*fn->done) (cookie) ) { - puts ("** Booting failed! CONF_DONE is still deasserted.\n"); - (*fn->abort) (cookie); - return (FPGA_FAIL); - } -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts(" OK\n"); -#endif - - ret_val = FPGA_SUCCESS; - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (ret_val == FPGA_SUCCESS) { - puts ("Done.\n"); - } - else { - puts ("Fail.\n"); - } -#endif - (*fn->post) (cookie); - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int CYC2_ps_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - /* Readback is only available through the Slave Parallel and */ - /* boundary-scan interfaces. */ - printf ("%s: Passive Serial Dumping is unavailable\n", - __FUNCTION__); - return FPGA_FAIL; -} - -static int CYC2_ps_reloc (Altera_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Altera_CYC2_Passive_Serial_fns *fn_r, *fn = - (Altera_CYC2_Passive_Serial_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Altera_CYC2_Passive_Serial_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Altera_CYC2_Passive_Serial_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Altera_pre_fn) addr; - - addr = (ulong) (fn->config) + reloc_offset; - fn_r->config = (Altera_config_fn) addr; - - addr = (ulong) (fn->status) + reloc_offset; - fn_r->status = (Altera_status_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Altera_done_fn) addr; - - addr = (ulong) (fn->write) + reloc_offset; - fn_r->write = (Altera_write_fn) addr; - - addr = (ulong) (fn->abort) + reloc_offset; - fn_r->abort = (Altera_abort_fn) addr; - - addr = (ulong) (fn->post) + reloc_offset; - fn_r->post = (Altera_post_fn) addr; - - fn_r->relocated = TRUE; - - } else { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} diff --git a/common/fpga.c b/common/fpga.c deleted file mode 100644 index 67a6c30..0000000 --- a/common/fpga.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * - * 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 - * - */ - -/* - * Generic FPGA support - */ -#include /* core U-Boot definitions */ -#include /* xilinx specific definitions */ -#include /* altera specific definitions */ - -#if 0 -#define FPGA_DEBUG /* define FPGA_DEBUG to get debug messages */ -#endif - -/* Local definitions */ -#ifndef CONFIG_MAX_FPGA_DEVICES -#define CONFIG_MAX_FPGA_DEVICES 5 -#endif - -/* Enable/Disable debug console messages */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* Local static data */ -static ulong relocation_offset = 0; -static int next_desc = FPGA_INVALID_DEVICE; -static fpga_desc desc_table[CONFIG_MAX_FPGA_DEVICES]; - -/* Local static functions */ -static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_get_desc( int devnum ); -static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_validate( int devnum, void *buf, - size_t bsize, char *fn ); -static int fpga_dev_info( int devnum ); - - -/* ------------------------------------------------------------------------- */ - -/* fpga_no_sup - * 'no support' message function - */ -static void fpga_no_sup( char *fn, char *msg ) -{ - if ( fn && msg ) { - printf( "%s: No support for %s.\n", fn, msg); - } else if ( msg ) { - printf( "No support for %s.\n", msg); - } else { - printf( "No FPGA suport!\n"); - } -} - - -/* fpga_get_desc - * map a device number to a descriptor - */ -static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_get_desc( int devnum ) -{ - fpga_desc *desc = (fpga_desc * )NULL; - - if (( devnum >= 0 ) && (devnum < next_desc )) { - desc = &desc_table[devnum]; - PRINTF( "%s: found fpga descriptor #%d @ 0x%p\n", - __FUNCTION__, devnum, desc ); - } - - return desc; -} - - -/* fpga_validate - * generic parameter checking code - */ -static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_validate( int devnum, void *buf, - size_t bsize, char *fn ) -{ - fpga_desc * desc = fpga_get_desc( devnum ); - - if ( !desc ) { - printf( "%s: Invalid device number %d\n", fn, devnum ); - } - - if ( !buf ) { - printf( "%s: Null buffer.\n", fn ); - return (fpga_desc * const)NULL; - } - return desc; -} - - -/* fpga_dev_info - * generic multiplexing code - */ -static int fpga_dev_info( int devnum ) -{ - int ret_val = FPGA_FAIL; /* assume failure */ - const fpga_desc * const desc = fpga_get_desc( devnum ); - - if ( desc ) { - PRINTF( "%s: Device Descriptor @ 0x%p\n", - __FUNCTION__, desc->devdesc ); - - switch ( desc->devtype ) { - case fpga_xilinx: -#if defined(CONFIG_FPGA_XILINX) - printf( "Xilinx Device\nDescriptor @ 0x%p\n", desc ); - ret_val = xilinx_info( desc->devdesc ); -#else - fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); -#endif - break; - case fpga_altera: -#if defined(CONFIG_FPGA_ALTERA) - printf( "Altera Device\nDescriptor @ 0x%p\n", desc ); - ret_val = altera_info( desc->devdesc ); -#else - fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); -#endif - break; - default: - printf( "%s: Invalid or unsupported device type %d\n", - __FUNCTION__, desc->devtype ); - } - } else { - printf( "%s: Invalid device number %d\n", - __FUNCTION__, devnum ); - } - - return ret_val; -} - - -/* fpga_reloc - * generic multiplexing code - */ -int fpga_reloc( fpga_type devtype, void *desc, ulong reloc_off ) -{ - int ret_val = FPGA_FAIL; - - PRINTF( "%s: Relocating Device of type %d @ 0x%p with offset %lx\n", - __FUNCTION__, devtype, desc, reloc_off ); - - switch ( devtype ) { - case 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 defined(CONFIG_FPGA_ALTERA) - ret_val = altera_reloc( desc, reloc_off ); -#else - fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); -#endif - break; - default: - printf( "%s: Invalid or unsupported device type %d\n", - __FUNCTION__, devtype ); - } - - return ret_val; -} - -/* ------------------------------------------------------------------------- */ -/* fgpa_init is usually called from misc_init_r() and MUST be called - * before any of the other fpga functions are used. - */ -void fpga_init( ulong reloc_off ) -{ - relocation_offset = reloc_off; - next_desc = 0; - memset( desc_table, 0, sizeof(desc_table)); - - PRINTF( "%s: CONFIG_FPGA = 0x%x\n", __FUNCTION__, CONFIG_FPGA ); -} - -/* fpga_count - * Basic interface function to get the current number of devices available. - */ -int fpga_count( void ) -{ - return next_desc; -} - -/* fpga_add - * Attempts to relocate the device/board specific interface code - * to the proper RAM locations and adds the device descriptor to - * the device table. - */ -int fpga_add( fpga_type devtype, void *desc ) -{ - int devnum = FPGA_INVALID_DEVICE; - - if ( next_desc < 0 ) { - printf( "%s: FPGA support not initialized!\n", __FUNCTION__ ); - } else if (( devtype > fpga_min_type ) && ( devtype < fpga_undefined )) { - if ( desc ) { - if ( next_desc < CONFIG_MAX_FPGA_DEVICES ) { - if ( fpga_reloc( devtype, desc, relocation_offset ) - == FPGA_SUCCESS ) { - devnum = next_desc; - desc_table[next_desc].devtype = devtype; - desc_table[next_desc++].devdesc = desc; - } else { - printf( "%s: Unable to relocate device interface table!\n", - __FUNCTION__ ); - } - } else { - printf( "%s: Exceeded Max FPGA device count\n", __FUNCTION__ ); - } - } else { - printf( "%s: NULL device descriptor\n", __FUNCTION__ ); - } - } else { - printf( "%s: Unsupported FPGA type %d\n", __FUNCTION__, devtype ); - } - - return devnum; -} - -/* - * Generic multiplexing code - */ -int fpga_load( int devnum, void *buf, size_t bsize ) -{ - int ret_val = FPGA_FAIL; /* assume failure */ - fpga_desc * desc = fpga_validate( devnum, buf, bsize, (char *)__FUNCTION__ ); - - if ( desc ) { - switch ( desc->devtype ) { - case 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 defined(CONFIG_FPGA_ALTERA) - ret_val = altera_load( desc->devdesc, buf, bsize ); -#else - fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); -#endif - break; - default: - printf( "%s: Invalid or unsupported device type %d\n", - __FUNCTION__, desc->devtype ); - } - } - - return ret_val; -} - -/* fpga_dump - * generic multiplexing code - */ -int fpga_dump( int devnum, void *buf, size_t bsize ) -{ - int ret_val = FPGA_FAIL; /* assume failure */ - fpga_desc * desc = fpga_validate( devnum, buf, bsize, (char *)__FUNCTION__ ); - - if ( desc ) { - switch ( desc->devtype ) { - case 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 defined(CONFIG_FPGA_ALTERA) - ret_val = altera_dump( desc->devdesc, buf, bsize ); -#else - fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); -#endif - break; - default: - printf( "%s: Invalid or unsupported device type %d\n", - __FUNCTION__, desc->devtype ); - } - } - - return ret_val; -} - - -/* fpga_info - * front end to fpga_dev_info. If devnum is invalid, report on all - * available devices. - */ -int fpga_info( int devnum ) -{ - if ( devnum == FPGA_INVALID_DEVICE ) { - if ( next_desc > 0 ) { - int dev; - - for ( dev = 0; dev < next_desc; dev++ ) { - fpga_dev_info( dev ); - } - return FPGA_SUCCESS; - } else { - printf( "%s: No FPGA devices available.\n", __FUNCTION__ ); - return FPGA_FAIL; - } - } - else return fpga_dev_info( devnum ); -} - -/* ------------------------------------------------------------------------- */ diff --git a/common/spartan2.c b/common/spartan2.c deleted file mode 100644 index f5ba7fc..0000000 --- a/common/spartan2.c +++ /dev/null @@ -1,663 +0,0 @@ -/* - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * - * 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 - * - */ - -#include /* core U-Boot definitions */ -#include /* Spartan-II device family */ - -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -#undef CONFIG_SYS_FPGA_CHECK_BUSY -#undef CONFIG_SYS_FPGA_PROG_FEEDBACK - -/* Note: The assumption is that we cannot possibly run fast enough to - * overrun the device (the Slave Parallel mode can free run at 50MHz). - * If there is a need to operate slower, define CONFIG_FPGA_DELAY in - * the board config file to slow things down. - */ -#ifndef CONFIG_FPGA_DELAY -#define CONFIG_FPGA_DELAY() -#endif - -#ifndef CONFIG_SYS_FPGA_WAIT -#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/100 /* 10 ms */ -#endif - -static int Spartan2_sp_load( Xilinx_desc *desc, void *buf, size_t bsize ); -static int Spartan2_sp_dump( Xilinx_desc *desc, void *buf, size_t bsize ); -/* static int Spartan2_sp_info( Xilinx_desc *desc ); */ -static int Spartan2_sp_reloc( Xilinx_desc *desc, ulong reloc_offset ); - -static int Spartan2_ss_load( Xilinx_desc *desc, void *buf, size_t bsize ); -static int Spartan2_ss_dump( Xilinx_desc *desc, void *buf, size_t bsize ); -/* static int Spartan2_ss_info( Xilinx_desc *desc ); */ -static int Spartan2_ss_reloc( Xilinx_desc *desc, ulong reloc_offset ); - -/* ------------------------------------------------------------------------- */ -/* Spartan-II Generic Implementation */ -int Spartan2_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Load\n", __FUNCTION__); - ret_val = Spartan2_ss_load (desc, buf, bsize); - break; - - case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Load\n", __FUNCTION__); - ret_val = Spartan2_sp_load (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int Spartan2_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Dump\n", __FUNCTION__); - ret_val = Spartan2_ss_dump (desc, buf, bsize); - break; - - case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Dump\n", __FUNCTION__); - ret_val = Spartan2_sp_dump (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int Spartan2_info( Xilinx_desc *desc ) -{ - return FPGA_SUCCESS; -} - - -int Spartan2_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (desc->family != Xilinx_Spartan2) { - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - return FPGA_FAIL; - } else - switch (desc->iface) { - case slave_serial: - ret_val = Spartan2_ss_reloc (desc, reloc_offset); - break; - - case slave_parallel: - ret_val = Spartan2_sp_reloc (desc, reloc_offset); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - - -/* ------------------------------------------------------------------------- */ -/* Spartan-II Slave Parallel Generic Implementation */ - -static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan2_Slave_Parallel_fns *fn = desc->iface_fns; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pre: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "err:\t0x%p\n" - "clk:\t0x%p\n" - "cs:\t0x%p\n" - "wr:\t0x%p\n" - "read data:\t0x%p\n" - "write data:\t0x%p\n" - "busy:\t0x%p\n" - "abort:\t0x%p\n", - "post:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, - fn->abort, fn->post); - - /* - * This code is designed to emulate the "Express Style" - * Continuous Data Loading in Slave Parallel Mode for - * the Spartan-II Family. - */ -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...\n", cookie); -#endif - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */ - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */ - - ts = get_timer (0); /* get current time */ - /* Now wait for INIT and BUSY to go high */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - return FPGA_FAIL; - } - } while ((*fn->init) (cookie) && (*fn->busy) (cookie)); - - (*fn->wr) (TRUE, TRUE, cookie); /* Assert write, commit */ - (*fn->cs) (TRUE, TRUE, cookie); /* Assert chip select, commit */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - /* Load the data */ - while (bytecount < bsize) { - /* XXX - do we check for an Ctrl-C press in here ??? */ - /* XXX - Check the error bit? */ - - (*fn->wdata) (data[bytecount++], TRUE, cookie); /* write the data */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - -#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); /* get current time */ - while ((*fn->busy) (cookie)) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for BUSY to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - return FPGA_FAIL; - } - } -#endif - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - CONFIG_FPGA_DELAY (); - (*fn->cs) (FALSE, TRUE, cookie); /* Deassert the chip select */ - (*fn->wr) (FALSE, TRUE, cookie); /* Deassert the write pin */ - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - - /* now check for done signal */ - ts = get_timer (0); /* get current time */ - ret_val = FPGA_SUCCESS; - while ((*fn->done) (cookie) == FPGA_FAIL) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for DONE to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - ret_val = FPGA_FAIL; - break; - } - } - - if (ret_val == FPGA_SUCCESS) { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts ("Done.\n"); -#endif - } - /* - * Run the post configuration function if there is one. - */ - if (*fn->post) { - (*fn->post) (cookie); - } - - else { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts ("Fail.\n"); -#endif - } - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int Spartan2_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan2_Slave_Parallel_fns *fn = desc->iface_fns; - - if (fn) { - unsigned char *data = (unsigned char *) buf; - size_t bytecount = 0; - int cookie = desc->cookie; /* make a local copy */ - - printf ("Starting Dump of FPGA Device %d...\n", cookie); - - (*fn->cs) (TRUE, TRUE, cookie); /* Assert chip select, commit */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - /* dump the data */ - while (bytecount < bsize) { - /* XXX - do we check for an Ctrl-C press in here ??? */ - - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - (*fn->rdata) (&(data[bytecount++]), cookie); /* read the data */ -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - (*fn->cs) (FALSE, FALSE, cookie); /* Deassert the chip select */ - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - puts ("Done.\n"); - - /* XXX - checksum the data? */ - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - - -static int Spartan2_sp_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan2_Slave_Parallel_fns *fn_r, *fn = - (Xilinx_Spartan2_Slave_Parallel_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Xilinx_Spartan2_Slave_Parallel_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Xilinx_Spartan2_Slave_Parallel_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - 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; - - addr = (ulong) (fn->init) + reloc_offset; - fn_r->init = (Xilinx_init_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Xilinx_done_fn) addr; - - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Xilinx_clk_fn) addr; - - addr = (ulong) (fn->err) + reloc_offset; - fn_r->err = (Xilinx_err_fn) addr; - - addr = (ulong) (fn->cs) + reloc_offset; - fn_r->cs = (Xilinx_cs_fn) addr; - - addr = (ulong) (fn->wr) + reloc_offset; - fn_r->wr = (Xilinx_wr_fn) addr; - - addr = (ulong) (fn->rdata) + reloc_offset; - fn_r->rdata = (Xilinx_rdata_fn) addr; - - addr = (ulong) (fn->wdata) + reloc_offset; - fn_r->wdata = (Xilinx_wdata_fn) addr; - - addr = (ulong) (fn->busy) + reloc_offset; - fn_r->busy = (Xilinx_busy_fn) addr; - - addr = (ulong) (fn->abort) + reloc_offset; - fn_r->abort = (Xilinx_abort_fn) addr; - - addr = (ulong) (fn->post) + reloc_offset; - fn_r->post = (Xilinx_post_fn) addr; - - fn_r->relocated = TRUE; - - } else { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; - -} - -/* ------------------------------------------------------------------------- */ - -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; - unsigned char val; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "clk:\t0x%p\n" - "wr:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pgm, fn->init, - fn->clk, fn->wr, fn->done); -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...\n", cookie); -#endif - - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */ - - /* Wait for INIT state (init low) */ - ts = get_timer (0); /* get current time */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to start.\n"); - return FPGA_FAIL; - } - } while (!(*fn->init) (cookie)); - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */ - - ts = get_timer (0); /* get current time */ - /* Now wait for INIT to go high */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to clear.\n"); - return FPGA_FAIL; - } - } while ((*fn->init) (cookie)); - - /* Load the data */ - while (bytecount < bsize) { - - /* Xilinx detects an error if INIT goes low (active) - while DONE is low (inactive) */ - if ((*fn->done) (cookie) == 0 && (*fn->init) (cookie)) { - puts ("** CRC error during FPGA load.\n"); - return (FPGA_FAIL); - } - val = data [bytecount ++]; - i = 8; - do { - /* Deassert the clock */ - (*fn->clk) (FALSE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Write data */ - (*fn->wr) ((val & 0x80), TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Assert the clock */ - (*fn->clk) (TRUE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - val <<= 1; - i --; - } while (i > 0); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - CONFIG_FPGA_DELAY (); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - - /* now check for done signal */ - ts = get_timer (0); /* get current time */ - ret_val = FPGA_SUCCESS; - (*fn->wr) (TRUE, TRUE, cookie); - - while (! (*fn->done) (cookie)) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - putc ('*'); - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for DONE to clear.\n"); - ret_val = FPGA_FAIL; - break; - } - } - putc ('\n'); /* terminate the dotted line */ - - /* - * Run the post configuration function if there is one. - */ - if (*fn->post) { - (*fn->post) (cookie); - } - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (ret_val == FPGA_SUCCESS) { - puts ("Done.\n"); - } - else { - puts ("Fail.\n"); - } -#endif - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int Spartan2_ss_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - /* Readback is only available through the Slave Parallel and */ - /* boundary-scan interfaces. */ - printf ("%s: Slave Serial Dumping is unavailable\n", - __FUNCTION__); - return FPGA_FAIL; -} - -static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan2_Slave_Serial_fns *fn_r, *fn = - (Xilinx_Spartan2_Slave_Serial_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Xilinx_Spartan2_Slave_Serial_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Xilinx_Spartan2_Slave_Serial_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - 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; - - addr = (ulong) (fn->init) + reloc_offset; - fn_r->init = (Xilinx_init_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Xilinx_done_fn) addr; - - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Xilinx_clk_fn) addr; - - 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 { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; - -} diff --git a/common/spartan3.c b/common/spartan3.c deleted file mode 100644 index 9ce41f1..0000000 --- a/common/spartan3.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * - * 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 - * - */ - -/* - * Configuration support for Xilinx Spartan3 devices. Based - * on spartan2.c (Rich Ireland, rireland@enterasys.com). - */ - -#include /* core U-Boot definitions */ -#include /* Spartan-II device family */ - -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -#undef CONFIG_SYS_FPGA_CHECK_BUSY -#undef CONFIG_SYS_FPGA_PROG_FEEDBACK - -/* Note: The assumption is that we cannot possibly run fast enough to - * overrun the device (the Slave Parallel mode can free run at 50MHz). - * If there is a need to operate slower, define CONFIG_FPGA_DELAY in - * the board config file to slow things down. - */ -#ifndef CONFIG_FPGA_DELAY -#define CONFIG_FPGA_DELAY() -#endif - -#ifndef CONFIG_SYS_FPGA_WAIT -#define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/100 /* 10 ms */ -#endif - -static int Spartan3_sp_load( Xilinx_desc *desc, void *buf, size_t bsize ); -static int Spartan3_sp_dump( Xilinx_desc *desc, void *buf, size_t bsize ); -/* static int Spartan3_sp_info( Xilinx_desc *desc ); */ -static int Spartan3_sp_reloc( Xilinx_desc *desc, ulong reloc_offset ); - -static int Spartan3_ss_load( Xilinx_desc *desc, void *buf, size_t bsize ); -static int Spartan3_ss_dump( Xilinx_desc *desc, void *buf, size_t bsize ); -/* static int Spartan3_ss_info( Xilinx_desc *desc ); */ -static int Spartan3_ss_reloc( Xilinx_desc *desc, ulong reloc_offset ); - -/* ------------------------------------------------------------------------- */ -/* Spartan-II Generic Implementation */ -int Spartan3_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Load\n", __FUNCTION__); - ret_val = Spartan3_ss_load (desc, buf, bsize); - break; - - case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Load\n", __FUNCTION__); - ret_val = Spartan3_sp_load (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int Spartan3_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Dump\n", __FUNCTION__); - ret_val = Spartan3_ss_dump (desc, buf, bsize); - break; - - case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Dump\n", __FUNCTION__); - ret_val = Spartan3_sp_dump (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - -int Spartan3_info( Xilinx_desc *desc ) -{ - return FPGA_SUCCESS; -} - - -int Spartan3_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (desc->family != Xilinx_Spartan3) { - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - return FPGA_FAIL; - } else - switch (desc->iface) { - case slave_serial: - ret_val = Spartan3_ss_reloc (desc, reloc_offset); - break; - - case slave_parallel: - ret_val = Spartan3_sp_reloc (desc, reloc_offset); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - - return ret_val; -} - - -/* ------------------------------------------------------------------------- */ -/* Spartan-II Slave Parallel Generic Implementation */ - -static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pre: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "err:\t0x%p\n" - "clk:\t0x%p\n" - "cs:\t0x%p\n" - "wr:\t0x%p\n" - "read data:\t0x%p\n" - "write data:\t0x%p\n" - "busy:\t0x%p\n" - "abort:\t0x%p\n", - "post:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pre, fn->pgm, fn->init, fn->err, - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, fn->busy, - fn->abort, fn->post); - - /* - * This code is designed to emulate the "Express Style" - * Continuous Data Loading in Slave Parallel Mode for - * the Spartan-II Family. - */ -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...\n", cookie); -#endif - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */ - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */ - - ts = get_timer (0); /* get current time */ - /* Now wait for INIT and BUSY to go high */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - return FPGA_FAIL; - } - } while ((*fn->init) (cookie) && (*fn->busy) (cookie)); - - (*fn->wr) (TRUE, TRUE, cookie); /* Assert write, commit */ - (*fn->cs) (TRUE, TRUE, cookie); /* Assert chip select, commit */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - /* Load the data */ - while (bytecount < bsize) { - /* XXX - do we check for an Ctrl-C press in here ??? */ - /* XXX - Check the error bit? */ - - (*fn->wdata) (data[bytecount++], TRUE, cookie); /* write the data */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - -#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); /* get current time */ - while ((*fn->busy) (cookie)) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for BUSY to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - return FPGA_FAIL; - } - } -#endif - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - CONFIG_FPGA_DELAY (); - (*fn->cs) (FALSE, TRUE, cookie); /* Deassert the chip select */ - (*fn->wr) (FALSE, TRUE, cookie); /* Deassert the write pin */ - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - - /* now check for done signal */ - ts = get_timer (0); /* get current time */ - ret_val = FPGA_SUCCESS; - while ((*fn->done) (cookie) == FPGA_FAIL) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for DONE to clear.\n"); - (*fn->abort) (cookie); /* abort the burn */ - ret_val = FPGA_FAIL; - break; - } - } - - if (ret_val == FPGA_SUCCESS) { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts ("Done.\n"); -#endif - } - /* - * Run the post configuration function if there is one. - */ - if (*fn->post) { - (*fn->post) (cookie); - } - - else { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - puts ("Fail.\n"); -#endif - } - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int Spartan3_sp_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns; - - if (fn) { - unsigned char *data = (unsigned char *) buf; - size_t bytecount = 0; - int cookie = desc->cookie; /* make a local copy */ - - printf ("Starting Dump of FPGA Device %d...\n", cookie); - - (*fn->cs) (TRUE, TRUE, cookie); /* Assert chip select, commit */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - /* dump the data */ - while (bytecount < bsize) { - /* XXX - do we check for an Ctrl-C press in here ??? */ - - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - (*fn->rdata) (&(data[bytecount++]), cookie); /* read the data */ -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - (*fn->cs) (FALSE, FALSE, cookie); /* Deassert the chip select */ - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - puts ("Done.\n"); - - /* XXX - checksum the data? */ - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - - -static int Spartan3_sp_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan3_Slave_Parallel_fns *fn_r, *fn = - (Xilinx_Spartan3_Slave_Parallel_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Xilinx_Spartan3_Slave_Parallel_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Xilinx_Spartan3_Slave_Parallel_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - 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; - - addr = (ulong) (fn->init) + reloc_offset; - fn_r->init = (Xilinx_init_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Xilinx_done_fn) addr; - - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Xilinx_clk_fn) addr; - - addr = (ulong) (fn->err) + reloc_offset; - fn_r->err = (Xilinx_err_fn) addr; - - addr = (ulong) (fn->cs) + reloc_offset; - fn_r->cs = (Xilinx_cs_fn) addr; - - addr = (ulong) (fn->wr) + reloc_offset; - fn_r->wr = (Xilinx_wr_fn) addr; - - addr = (ulong) (fn->rdata) + reloc_offset; - fn_r->rdata = (Xilinx_rdata_fn) addr; - - addr = (ulong) (fn->wdata) + reloc_offset; - fn_r->wdata = (Xilinx_wdata_fn) addr; - - addr = (ulong) (fn->busy) + reloc_offset; - fn_r->busy = (Xilinx_busy_fn) addr; - - addr = (ulong) (fn->abort) + reloc_offset; - fn_r->abort = (Xilinx_abort_fn) addr; - - addr = (ulong) (fn->post) + reloc_offset; - fn_r->post = (Xilinx_post_fn) addr; - - fn_r->relocated = TRUE; - - } else { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; - -} - -/* ------------------------------------------------------------------------- */ - -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; - unsigned char val; - - PRINTF ("%s: start with interface functions @ 0x%p\n", - __FUNCTION__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; /* make a local copy */ - unsigned long ts; /* timestamp */ - - PRINTF ("%s: Function Table:\n" - "ptr:\t0x%p\n" - "struct: 0x%p\n" - "pgm:\t0x%p\n" - "init:\t0x%p\n" - "clk:\t0x%p\n" - "wr:\t0x%p\n" - "done:\t0x%p\n\n", - __FUNCTION__, &fn, fn, fn->pgm, fn->init, - fn->clk, fn->wr, fn->done); -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Loading FPGA Device %d...\n", cookie); -#endif - - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* Establish the initial state */ - (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */ - - /* Wait for INIT state (init low) */ - ts = get_timer (0); /* get current time */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to start.\n"); - return FPGA_FAIL; - } - } while (!(*fn->init) (cookie)); - - /* Get ready for the burn */ - CONFIG_FPGA_DELAY (); - (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */ - - ts = get_timer (0); /* get current time */ - /* Now wait for INIT to go high */ - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for INIT to clear.\n"); - return FPGA_FAIL; - } - } while ((*fn->init) (cookie)); - - /* Load the data */ - while (bytecount < bsize) { - - /* Xilinx detects an error if INIT goes low (active) - while DONE is low (inactive) */ - if ((*fn->done) (cookie) == 0 && (*fn->init) (cookie)) { - puts ("** CRC error during FPGA load.\n"); - return (FPGA_FAIL); - } - val = data [bytecount ++]; - i = 8; - do { - /* Deassert the clock */ - (*fn->clk) (FALSE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Write data */ - (*fn->wr) ((val & 0x80), TRUE, cookie); - CONFIG_FPGA_DELAY (); - /* Assert the clock */ - (*fn->clk) (TRUE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - val <<= 1; - i --; - } while (i > 0); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); /* let them know we are alive */ -#endif - } - - CONFIG_FPGA_DELAY (); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); /* terminate the dotted line */ -#endif - - /* now check for done signal */ - ts = get_timer (0); /* get current time */ - ret_val = FPGA_SUCCESS; - (*fn->wr) (TRUE, TRUE, cookie); - - while (! (*fn->done) (cookie)) { - /* XXX - we should have a check in here somewhere to - * make sure we aren't busy forever... */ - - CONFIG_FPGA_DELAY (); - (*fn->clk) (FALSE, TRUE, cookie); /* Deassert the clock pin */ - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */ - - putc ('*'); - - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ - puts ("** Timeout waiting for DONE to clear.\n"); - ret_val = FPGA_FAIL; - break; - } - } - putc ('\n'); /* terminate the dotted line */ - - /* - * Run the post configuration function if there is one. - */ - if (*fn->post) { - (*fn->post) (cookie); - } - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (ret_val == FPGA_SUCCESS) { - puts ("Done.\n"); - } - else { - puts ("Fail.\n"); - } -#endif - - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; -} - -static int Spartan3_ss_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - /* Readback is only available through the Slave Parallel and */ - /* boundary-scan interfaces. */ - printf ("%s: Slave Serial Dumping is unavailable\n", - __FUNCTION__); - return FPGA_FAIL; -} - -static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume the worst */ - Xilinx_Spartan3_Slave_Serial_fns *fn_r, *fn = - (Xilinx_Spartan3_Slave_Serial_fns *) (desc->iface_fns); - - if (fn) { - ulong addr; - - /* Get the relocated table address */ - addr = (ulong) fn + reloc_offset; - fn_r = (Xilinx_Spartan3_Slave_Serial_fns *) addr; - - if (!fn_r->relocated) { - - if (memcmp (fn_r, fn, - sizeof (Xilinx_Spartan3_Slave_Serial_fns)) - == 0) { - /* good copy of the table, fix the descriptor pointer */ - desc->iface_fns = fn_r; - } else { - PRINTF ("%s: Invalid function table at 0x%p\n", - __FUNCTION__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, - desc); - - 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; - - addr = (ulong) (fn->init) + reloc_offset; - fn_r->init = (Xilinx_init_fn) addr; - - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Xilinx_done_fn) addr; - - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Xilinx_clk_fn) addr; - - 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 { - /* this table has already been moved */ - /* XXX - should check to see if the descriptor is correct */ - desc->iface_fns = fn_r; - } - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - - return ret_val; - -} diff --git a/common/stratixII.c b/common/stratixII.c deleted file mode 100644 index 7556dbf..0000000 --- a/common/stratixII.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * (C) Copyright 2007 - * Eran Liberty, Extricom , eran.liberty@gmail.com - * - * 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 - * - */ - -#include /* core U-Boot definitions */ -#include - -int StratixII_ps_fpp_load (Altera_desc * desc, void *buf, size_t bsize, - int isSerial, int isSecure); -int StratixII_ps_fpp_dump (Altera_desc * desc, void *buf, size_t bsize); - -/****************************************************************/ -/* Stratix II Generic Implementation */ -int StratixII_load (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - ret_val = StratixII_ps_fpp_load (desc, buf, bsize, 1, 0); - break; - case fast_passive_parallel: - ret_val = StratixII_ps_fpp_load (desc, buf, bsize, 0, 0); - break; - case fast_passive_parallel_security: - ret_val = StratixII_ps_fpp_load (desc, buf, bsize, 0, 1); - break; - - /* Add new interface types here */ - default: - printf ("%s: Unsupported interface type, %d\n", __FUNCTION__, - desc->iface); - } - return ret_val; -} - -int StratixII_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case passive_serial: - case fast_passive_parallel: - case fast_passive_parallel_security: - ret_val = StratixII_ps_fpp_dump (desc, buf, bsize); - break; - /* Add new interface types here */ - default: - printf ("%s: Unsupported interface type, %d\n", __FUNCTION__, - desc->iface); - } - return ret_val; -} - -int StratixII_info (Altera_desc * desc) -{ - return FPGA_SUCCESS; -} - -int StratixII_reloc (Altera_desc * desc, ulong reloc_offset) -{ - int i; - uint32_t dest = (uint32_t) desc & 0xff000000; - - /* we assume a relocated code and non relocated code has different upper 8 bits */ - if (dest != ((uint32_t) desc->iface_fns & 0xff000000)) { - desc->iface_fns = - (void *)((uint32_t) (desc->iface_fns) + reloc_offset); - } - for (i = 0; i < sizeof (altera_board_specific_func) / sizeof (void *); - i++) { - if (dest != - ((uint32_t) (((void **)(desc->iface_fns))[i]) & 0xff000000)) - { - ((void **)(desc->iface_fns))[i] = - (void - *)(((uint32_t) (((void **)(desc->iface_fns))[i])) + - reloc_offset); - } - } - return FPGA_SUCCESS; -} - -int StratixII_ps_fpp_dump (Altera_desc * desc, void *buf, size_t bsize) -{ - printf ("Stratix II Fast Passive Parallel dump is not implemented\n"); - return FPGA_FAIL; -} - -int StratixII_ps_fpp_load (Altera_desc * desc, void *buf, size_t bsize, - int isSerial, int isSecure) -{ - altera_board_specific_func *fns; - int cookie; - int ret_val = FPGA_FAIL; - int bytecount; - char *buff = buf; - int i; - - if (!desc) { - printf ("%s(%d) Altera_desc missing\n", __FUNCTION__, __LINE__); - return FPGA_FAIL; - } - if (!buff) { - printf ("%s(%d) buffer is missing\n", __FUNCTION__, __LINE__); - return FPGA_FAIL; - } - if (!bsize) { - printf ("%s(%d) size is zero\n", __FUNCTION__, __LINE__); - return FPGA_FAIL; - } - if (!desc->iface_fns) { - printf - ("%s(%d) Altera_desc function interface table is missing\n", - __FUNCTION__, __LINE__); - return FPGA_FAIL; - } - fns = (altera_board_specific_func *) (desc->iface_fns); - cookie = desc->cookie; - - if (! - (fns->config && fns->status && fns->done && fns->data - && fns->abort)) { - printf - ("%s(%d) Missing some function in the function interface table\n", - __FUNCTION__, __LINE__); - return FPGA_FAIL; - } - - /* 1. give board specific a chance to do anything before we start */ - if (fns->pre) { - if ((ret_val = fns->pre (cookie)) < 0) { - return ret_val; - } - } - - /* from this point on we must fail gracfully by calling lower layer abort */ - - /* 2. Strat burn cycle by deasserting config for t_CFG and waiting t_CF2CK after reaserted */ - fns->config (0, 1, cookie); - udelay (5); /* nCONFIG low pulse width 2usec */ - fns->config (1, 1, cookie); - udelay (100); /* nCONFIG high to first rising edge on DCLK */ - - /* 3. Start the Data cycle with clk deasserted */ - bytecount = 0; - fns->clk (0, 1, cookie); - - printf ("loading to fpga "); - while (bytecount < bsize) { - /* 3.1 check stratix has not signaled us an error */ - if (fns->status (cookie) != 1) { - printf - ("\n%s(%d) Stratix failed (byte transfered till failure 0x%x)\n", - __FUNCTION__, __LINE__, bytecount); - fns->abort (cookie); - return FPGA_FAIL; - } - if (isSerial) { - int i; - uint8_t data = buff[bytecount++]; - for (i = 0; i < 8; i++) { - /* 3.2(ps) put data on the bus */ - fns->data ((data >> i) & 1, 1, cookie); - - /* 3.3(ps) clock once */ - fns->clk (1, 1, cookie); - fns->clk (0, 1, cookie); - } - } else { - /* 3.2(fpp) put data on the bus */ - fns->data (buff[bytecount++], 1, cookie); - - /* 3.3(fpp) clock once */ - fns->clk (1, 1, cookie); - fns->clk (0, 1, cookie); - - /* 3.4(fpp) for secure cycle push 3 more clocks */ - for (i = 0; isSecure && i < 3; i++) { - fns->clk (1, 1, cookie); - fns->clk (0, 1, cookie); - } - } - - /* 3.5 while clk is deasserted it is safe to print some progress indication */ - if ((bytecount % (bsize / 100)) == 0) { - printf ("\b\b\b%02d\%", bytecount * 100 / bsize); - } - } - - /* 4. Set one last clock and check conf done signal */ - fns->clk (1, 1, cookie); - udelay (100); - if (!fns->done (cookie)) { - printf (" error!.\n"); - fns->abort (cookie); - return FPGA_FAIL; - } else { - printf ("\b\b\b done.\n"); - } - - /* 5. call lower layer post configuration */ - if (fns->post) { - if ((ret_val = fns->post (cookie)) < 0) { - fns->abort (cookie); - return ret_val; - } - } - - return FPGA_SUCCESS; -} diff --git a/common/virtex2.c b/common/virtex2.c deleted file mode 100644 index 50d0921..0000000 --- a/common/virtex2.c +++ /dev/null @@ -1,554 +0,0 @@ -/* - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * Keith Outwater, keith_outwater@mvis.com - * - * 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 - * - */ - -/* - * Configuration support for Xilinx Virtex2 devices. Based - * on spartan2.c (Rich Ireland, rireland@enterasys.com). - */ - -#include -#include - -#if 0 -#define FPGA_DEBUG -#endif - -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* - * If the SelectMap interface can be overrun by the processor, define - * CONFIG_SYS_FPGA_CHECK_BUSY and/or CONFIG_FPGA_DELAY in the board configuration - * file and add board-specific support for checking BUSY status. By default, - * assume that the SelectMap interface cannot be overrun. - */ -#ifndef CONFIG_SYS_FPGA_CHECK_BUSY -#undef CONFIG_SYS_FPGA_CHECK_BUSY -#endif - -#ifndef CONFIG_FPGA_DELAY -#define CONFIG_FPGA_DELAY() -#endif - -#ifndef CONFIG_SYS_FPGA_PROG_FEEDBACK -#define CONFIG_SYS_FPGA_PROG_FEEDBACK -#endif - -/* - * Don't allow config cycle to be interrupted - */ -#ifndef CONFIG_SYS_FPGA_CHECK_CTRLC -#undef CONFIG_SYS_FPGA_CHECK_CTRLC -#endif - -/* - * Check for errors during configuration by default - */ -#ifndef CONFIG_SYS_FPGA_CHECK_ERROR -#define CONFIG_SYS_FPGA_CHECK_ERROR -#endif - -/* - * The default timeout in mS for INIT_B to deassert after PROG_B has - * been deasserted. Per the latest Virtex II Handbook (page 347), the - * max time from PORG_B deassertion to INIT_B deassertion is 4uS per - * data frame for the XC2V8000. The XC2V8000 has 2860 data frames - * which yields 11.44 mS. So let's make it bigger in order to handle - * an XC2V1000, if anyone can ever get ahold of one. - */ -#ifndef CONFIG_SYS_FPGA_WAIT_INIT -#define CONFIG_SYS_FPGA_WAIT_INIT CONFIG_SYS_HZ/2 /* 500 ms */ -#endif - -/* - * The default timeout for waiting for BUSY to deassert during configuration. - * This is normally not necessary since for most reasonable configuration - * clock frequencies (i.e. 66 MHz or less), BUSY monitoring is unnecessary. - */ -#ifndef CONFIG_SYS_FPGA_WAIT_BUSY -#define CONFIG_SYS_FPGA_WAIT_BUSY CONFIG_SYS_HZ/200 /* 5 ms*/ -#endif - -/* Default timeout for waiting for FPGA to enter operational mode after - * configuration data has been written. - */ -#ifndef CONFIG_SYS_FPGA_WAIT_CONFIG -#define CONFIG_SYS_FPGA_WAIT_CONFIG CONFIG_SYS_HZ/5 /* 200 ms */ -#endif - -static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize); -static int Virtex2_ssm_dump (Xilinx_desc * desc, void *buf, size_t bsize); -static int Virtex2_ssm_reloc (Xilinx_desc * desc, ulong reloc_offset); - -static int Virtex2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize); -static int Virtex2_ss_dump (Xilinx_desc * desc, void *buf, size_t bsize); -static int Virtex2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset); - -int Virtex2_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Load\n", __FUNCTION__); - ret_val = Virtex2_ss_load (desc, buf, bsize); - break; - - case slave_selectmap: - PRINTF ("%s: Launching Slave Parallel Load\n", __FUNCTION__); - ret_val = Virtex2_ssm_load (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - return ret_val; -} - -int Virtex2_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - - switch (desc->iface) { - case slave_serial: - PRINTF ("%s: Launching Slave Serial Dump\n", __FUNCTION__); - ret_val = Virtex2_ss_dump (desc, buf, bsize); - break; - - case slave_parallel: - PRINTF ("%s: Launching Slave Parallel Dump\n", __FUNCTION__); - ret_val = Virtex2_ssm_dump (desc, buf, bsize); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - return ret_val; -} - -int Virtex2_info (Xilinx_desc * desc) -{ - return FPGA_SUCCESS; -} - -int Virtex2_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; - - if (desc->family != Xilinx_Virtex2) { - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - return FPGA_FAIL; - } else - switch (desc->iface) { - case slave_serial: - ret_val = Virtex2_ss_reloc (desc, reloc_offset); - break; - - case slave_selectmap: - ret_val = Virtex2_ssm_reloc (desc, reloc_offset); - break; - - default: - printf ("%s: Unsupported interface type, %d\n", - __FUNCTION__, desc->iface); - } - return ret_val; -} - -/* - * Virtex-II Slave SelectMap configuration loader. Configuration via - * SelectMap is as follows: - * 1. Set the FPGA's PROG_B line low. - * 2. Set the FPGA's PROG_B line high. Wait for INIT_B to go high. - * 3. Write data to the SelectMap port. If INIT_B goes low at any time - * this process, a configuration error (most likely CRC failure) has - * ocurred. At this point a status word may be read from the - * SelectMap interface to determine the source of the problem (You - * could, for instance, put this in your 'abort' function handler). - * 4. After all data has been written, test the state of the FPGA - * INIT_B and DONE lines. If both are high, configuration has - * succeeded. Congratulations! - */ -static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - Xilinx_Virtex2_Slave_SelectMap_fns *fn = desc->iface_fns; - - PRINTF ("%s:%d: Start with interface functions @ 0x%p\n", - __FUNCTION__, __LINE__, fn); - - if (fn) { - size_t bytecount = 0; - unsigned char *data = (unsigned char *) buf; - int cookie = desc->cookie; - unsigned long ts; - - /* Gotta split this one up (so the stack won't blow??) */ - PRINTF ("%s:%d: Function Table:\n" - " base 0x%p\n" - " struct 0x%p\n" - " pre 0x%p\n" - " prog 0x%p\n" - " init 0x%p\n" - " error 0x%p\n", - __FUNCTION__, __LINE__, - &fn, fn, fn->pre, fn->pgm, fn->init, fn->err); - PRINTF (" clock 0x%p\n" - " cs 0x%p\n" - " write 0x%p\n" - " rdata 0x%p\n" - " wdata 0x%p\n" - " busy 0x%p\n" - " abort 0x%p\n" - " post 0x%p\n\n", - fn->clk, fn->cs, fn->wr, fn->rdata, fn->wdata, - fn->busy, fn->abort, fn->post); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Initializing FPGA Device %d...\n", cookie); -#endif - /* - * Run the pre configuration function if there is one. - */ - if (*fn->pre) { - (*fn->pre) (cookie); - } - - /* - * Assert the program line. The minimum pulse width for - * Virtex II devices is 300 nS (Tprogram parameter in datasheet). - * There is no maximum value for the pulse width. Check to make - * sure that INIT_B goes low after assertion of PROG_B - */ - (*fn->pgm) (TRUE, TRUE, cookie); - udelay (10); - ts = get_timer (0); - do { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { - printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" - " to assert.\n", __FUNCTION__, __LINE__, - CONFIG_SYS_FPGA_WAIT_INIT); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - } while (!(*fn->init) (cookie)); - - (*fn->pgm) (FALSE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); - - /* - * Start a timer and wait for INIT_B to go high - */ - ts = get_timer (0); - do { - CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { - printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" - " to deassert.\n", __FUNCTION__, __LINE__, - CONFIG_SYS_FPGA_WAIT_INIT); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - } while ((*fn->init) (cookie) && (*fn->busy) (cookie)); - - (*fn->wr) (TRUE, TRUE, cookie); - (*fn->cs) (TRUE, TRUE, cookie); - - udelay (10000); - - /* - * Load the data byte by byte - */ - while (bytecount < bsize) { -#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC - if (ctrlc ()) { - (*fn->abort) (cookie); - return FPGA_FAIL; - } -#endif - - if ((*fn->done) (cookie) == FPGA_SUCCESS) { - PRINTF ("%s:%d:done went active early, bytecount = %d\n", - __FUNCTION__, __LINE__, bytecount); - break; - } - -#ifdef CONFIG_SYS_FPGA_CHECK_ERROR - if ((*fn->init) (cookie)) { - printf ("\n%s:%d: ** Error: INIT asserted during" - " configuration\n", __FUNCTION__, __LINE__); - printf ("%d = buffer offset, %d = buffer size\n", - bytecount, bsize); - (*fn->abort) (cookie); - return FPGA_FAIL; - } -#endif - - (*fn->wdata) (data[bytecount++], TRUE, cookie); - CONFIG_FPGA_DELAY (); - - /* - * Cycle the clock pin - */ - (*fn->clk) (FALSE, TRUE, cookie); - CONFIG_FPGA_DELAY (); - (*fn->clk) (TRUE, TRUE, cookie); - -#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); - while ((*fn->busy) (cookie)) { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_BUSY) { - printf ("%s:%d: ** Timeout after %d ticks waiting for" - " BUSY to deassert\n", - __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_BUSY); - (*fn->abort) (cookie); - return FPGA_FAIL; - } - } -#endif - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); -#endif - } - - /* - * Finished writing the data; deassert FPGA CS_B and WRITE_B signals. - */ - CONFIG_FPGA_DELAY (); - (*fn->cs) (FALSE, TRUE, cookie); - (*fn->wr) (FALSE, TRUE, cookie); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); -#endif - - /* - * Check for successful configuration. FPGA INIT_B and DONE should - * both be high upon successful configuration. - */ - ts = get_timer (0); - ret_val = FPGA_SUCCESS; - while (((*fn->done) (cookie) == FPGA_FAIL) || (*fn->init) (cookie)) { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_CONFIG) { - printf ("%s:%d: ** Timeout after %d ticks waiting for DONE to" - "assert and INIT to deassert\n", - __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_CONFIG); - (*fn->abort) (cookie); - ret_val = FPGA_FAIL; - break; - } - } - - if (ret_val == FPGA_SUCCESS) { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("Initialization of FPGA device %d complete\n", cookie); -#endif - /* - * Run the post configuration function if there is one. - */ - if (*fn->post) { - (*fn->post) (cookie); - } - } else { -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - printf ("** Initialization of FPGA device %d FAILED\n", - cookie); -#endif - } - } else { - printf ("%s:%d: NULL Interface function table!\n", - __FUNCTION__, __LINE__); - } - return ret_val; -} - -/* - * Read the FPGA configuration data - */ -static int Virtex2_ssm_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; - Xilinx_Virtex2_Slave_SelectMap_fns *fn = desc->iface_fns; - - if (fn) { - unsigned char *data = (unsigned char *) buf; - size_t bytecount = 0; - int cookie = desc->cookie; - - printf ("Starting Dump of FPGA Device %d...\n", cookie); - - (*fn->cs) (TRUE, TRUE, cookie); - (*fn->clk) (TRUE, TRUE, cookie); - - while (bytecount < bsize) { -#ifdef CONFIG_SYS_FPGA_CHECK_CTRLC - if (ctrlc ()) { - (*fn->abort) (cookie); - return FPGA_FAIL; - } -#endif - /* - * Cycle the clock and read the data - */ - (*fn->clk) (FALSE, TRUE, cookie); - (*fn->clk) (TRUE, TRUE, cookie); - (*fn->rdata) (&(data[bytecount++]), cookie); -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - if (bytecount % (bsize / 40) == 0) - putc ('.'); -#endif - } - - /* - * Deassert CS_B and cycle the clock to deselect the device. - */ - (*fn->cs) (FALSE, FALSE, cookie); - (*fn->clk) (FALSE, TRUE, cookie); - (*fn->clk) (TRUE, TRUE, cookie); - -#ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK - putc ('\n'); -#endif - puts ("Done.\n"); - } else { - printf ("%s:%d: NULL Interface function table!\n", - __FUNCTION__, __LINE__); - } - return ret_val; -} - -/* - * Relocate the addresses in the function table from FLASH (or ROM, - * or whatever) to RAM. - */ -static int Virtex2_ssm_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - ulong addr; - int ret_val = FPGA_FAIL; - Xilinx_Virtex2_Slave_SelectMap_fns *fn_r, *fn = - (Xilinx_Virtex2_Slave_SelectMap_fns *) (desc->iface_fns); - - if (fn) { - /* - * Get the relocated table address - */ - addr = (ulong) fn + reloc_offset; - fn_r = (Xilinx_Virtex2_Slave_SelectMap_fns *) addr; - - /* - * Check to see if the table has already been relocated. If not, do - * a sanity check to make sure there is a faithful copy of the - * FLASH based function table in RAM, then adjust the table. - */ - if (!fn_r->relocated) { - if (memcmp - (fn_r, fn, sizeof (Xilinx_Virtex2_Slave_SelectMap_fns)) - == 0) { - desc->iface_fns = fn_r; - } else { - PRINTF ("%s:%d: Invalid function table at 0x%p\n", - __FUNCTION__, __LINE__, fn_r); - return FPGA_FAIL; - } - - PRINTF ("%s:%d: Relocating descriptor at 0x%p\n", - __FUNCTION__, __LINE__, desc); - - 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; - addr = (ulong) (fn->init) + reloc_offset; - fn_r->init = (Xilinx_init_fn) addr; - addr = (ulong) (fn->done) + reloc_offset; - fn_r->done = (Xilinx_done_fn) addr; - addr = (ulong) (fn->err) + reloc_offset; - fn_r->err = (Xilinx_err_fn) addr; - addr = (ulong) (fn->clk) + reloc_offset; - fn_r->clk = (Xilinx_clk_fn) addr; - addr = (ulong) (fn->cs) + reloc_offset; - fn_r->cs = (Xilinx_cs_fn) addr; - addr = (ulong) (fn->wr) + reloc_offset; - fn_r->wr = (Xilinx_wr_fn) addr; - addr = (ulong) (fn->rdata) + reloc_offset; - fn_r->rdata = (Xilinx_rdata_fn) addr; - addr = (ulong) (fn->wdata) + reloc_offset; - fn_r->wdata = (Xilinx_wdata_fn) addr; - addr = (ulong) (fn->busy) + reloc_offset; - fn_r->busy = (Xilinx_busy_fn) addr; - addr = (ulong) (fn->abort) + reloc_offset; - fn_r->abort = (Xilinx_abort_fn) addr; - addr = (ulong) (fn->post) + reloc_offset; - fn_r->post = (Xilinx_post_fn) addr; - fn_r->relocated = TRUE; - } else { - printf ("%s:%d: Function table @0x%p has already been relocated\n", __FUNCTION__, __LINE__, fn_r); - desc->iface_fns = fn_r; - } - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: NULL Interface function table!\n", __FUNCTION__); - } - return ret_val; -} - -static int Virtex2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - printf ("%s: Slave Serial Loading is unsupported\n", __FUNCTION__); - return FPGA_FAIL; -} - -static int Virtex2_ss_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - printf ("%s: Slave Serial Dumping is unsupported\n", __FUNCTION__); - return FPGA_FAIL; -} - -static int Virtex2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; - Xilinx_Virtex2_Slave_Serial_fns *fn = - (Xilinx_Virtex2_Slave_Serial_fns *) (desc->iface_fns); - - if (fn) { - printf ("%s:%d: Slave Serial Loading is unsupported\n", - __FUNCTION__, __LINE__); - } else { - printf ("%s:%d: NULL Interface function table!\n", - __FUNCTION__, __LINE__); - } - return ret_val; -} - -/* vim: set ts=4 tw=78: */ diff --git a/common/xilinx.c b/common/xilinx.c deleted file mode 100644 index 7b5e8c5..0000000 --- a/common/xilinx.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * (C) Copyright 2002 - * Rich Ireland, Enterasys Networks, rireland@enterasys.com. - * Keith Outwater, keith_outwater@mvis.com - * - * 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 - * - */ - -/* - * Xilinx FPGA support - */ - -#include -#include -#include -#include - -#if 0 -#define FPGA_DEBUG -#endif - -/* Define FPGA_DEBUG to get debug printf's */ -#ifdef FPGA_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -/* Local Static Functions */ -static int xilinx_validate (Xilinx_desc * desc, char *fn); - -/* ------------------------------------------------------------------------- */ - -int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!xilinx_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else - switch (desc->family) { - case Xilinx_Spartan2: -#if defined(CONFIG_FPGA_SPARTAN2) - PRINTF ("%s: Launching the Spartan-II Loader...\n", - __FUNCTION__); - ret_val = Spartan2_load (desc, buf, bsize); -#else - printf ("%s: No support for Spartan-II devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Spartan3: -#if defined(CONFIG_FPGA_SPARTAN3) - PRINTF ("%s: Launching the Spartan-III Loader...\n", - __FUNCTION__); - ret_val = Spartan3_load (desc, buf, bsize); -#else - printf ("%s: No support for Spartan-III devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Virtex2: -#if defined(CONFIG_FPGA_VIRTEX2) - PRINTF ("%s: Launching the Virtex-II Loader...\n", - __FUNCTION__); - ret_val = Virtex2_load (desc, buf, bsize); -#else - printf ("%s: No support for Virtex-II devices.\n", - __FUNCTION__); -#endif - break; - - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - - return ret_val; -} - -int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!xilinx_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else - switch (desc->family) { - case Xilinx_Spartan2: -#if defined(CONFIG_FPGA_SPARTAN2) - PRINTF ("%s: Launching the Spartan-II Reader...\n", - __FUNCTION__); - ret_val = Spartan2_dump (desc, buf, bsize); -#else - printf ("%s: No support for Spartan-II devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Spartan3: -#if defined(CONFIG_FPGA_SPARTAN3) - PRINTF ("%s: Launching the Spartan-III Reader...\n", - __FUNCTION__); - ret_val = Spartan3_dump (desc, buf, bsize); -#else - printf ("%s: No support for Spartan-III devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Virtex2: -#if defined( CONFIG_FPGA_VIRTEX2) - PRINTF ("%s: Launching the Virtex-II Reader...\n", - __FUNCTION__); - ret_val = Virtex2_dump (desc, buf, bsize); -#else - printf ("%s: No support for Virtex-II devices.\n", - __FUNCTION__); -#endif - break; - - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - - return ret_val; -} - -int xilinx_info (Xilinx_desc * desc) -{ - int ret_val = FPGA_FAIL; - - if (xilinx_validate (desc, (char *)__FUNCTION__)) { - printf ("Family: \t"); - switch (desc->family) { - case Xilinx_Spartan2: - printf ("Spartan-II\n"); - break; - case Xilinx_Spartan3: - printf ("Spartan-III\n"); - break; - case Xilinx_Virtex2: - printf ("Virtex-II\n"); - break; - /* Add new family types here */ - default: - printf ("Unknown family type, %d\n", desc->family); - } - - printf ("Interface type:\t"); - switch (desc->iface) { - case slave_serial: - printf ("Slave Serial\n"); - break; - case master_serial: /* Not used */ - printf ("Master Serial\n"); - break; - case slave_parallel: - printf ("Slave Parallel\n"); - break; - case jtag_mode: /* Not used */ - printf ("JTAG Mode\n"); - break; - case slave_selectmap: - printf ("Slave SelectMap Mode\n"); - break; - case master_selectmap: - printf ("Master SelectMap Mode\n"); - break; - /* Add new interface types here */ - default: - printf ("Unsupported interface type, %d\n", desc->iface); - } - - printf ("Device Size: \t%d bytes\n" - "Cookie: \t0x%x (%d)\n", - desc->size, desc->cookie, desc->cookie); - - if (desc->iface_fns) { - printf ("Device Function Table @ 0x%p\n", desc->iface_fns); - switch (desc->family) { - case Xilinx_Spartan2: -#if defined(CONFIG_FPGA_SPARTAN2) - Spartan2_info (desc); -#else - /* just in case */ - printf ("%s: No support for Spartan-II devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Spartan3: -#if defined(CONFIG_FPGA_SPARTAN3) - Spartan3_info (desc); -#else - /* just in case */ - printf ("%s: No support for Spartan-III devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Virtex2: -#if defined(CONFIG_FPGA_VIRTEX2) - Virtex2_info (desc); -#else - /* just in case */ - printf ("%s: No support for Virtex-II devices.\n", - __FUNCTION__); -#endif - break; - /* Add new family types here */ - default: - /* we don't need a message here - we give one up above */ - ; - } - } else - printf ("No Device Function Table.\n"); - - ret_val = FPGA_SUCCESS; - } else { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } - - return ret_val; -} - -int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) -{ - int ret_val = FPGA_FAIL; /* assume a failure */ - - if (!xilinx_validate (desc, (char *)__FUNCTION__)) { - printf ("%s: Invalid device descriptor\n", __FUNCTION__); - } else - switch (desc->family) { - case Xilinx_Spartan2: -#if defined(CONFIG_FPGA_SPARTAN2) - ret_val = Spartan2_reloc (desc, reloc_offset); -#else - printf ("%s: No support for Spartan-II devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Spartan3: -#if defined(CONFIG_FPGA_SPARTAN3) - ret_val = Spartan3_reloc (desc, reloc_offset); -#else - printf ("%s: No support for Spartan-III devices.\n", - __FUNCTION__); -#endif - break; - case Xilinx_Virtex2: -#if defined(CONFIG_FPGA_VIRTEX2) - ret_val = Virtex2_reloc (desc, reloc_offset); -#else - printf ("%s: No support for Virtex-II devices.\n", - __FUNCTION__); -#endif - break; - /* Add new family types here */ - default: - printf ("%s: Unsupported family type, %d\n", - __FUNCTION__, desc->family); - } - - return ret_val; -} - - -/* ------------------------------------------------------------------------- */ - -static int xilinx_validate (Xilinx_desc * desc, char *fn) -{ - int ret_val = FALSE; - - if (desc) { - if ((desc->family > min_xilinx_type) && - (desc->family < max_xilinx_type)) { - if ((desc->iface > min_xilinx_iface_type) && - (desc->iface < max_xilinx_iface_type)) { - if (desc->size) { - ret_val = TRUE; - } else - printf ("%s: NULL part size\n", fn); - } else - printf ("%s: Invalid Interface type, %d\n", - fn, desc->iface); - } else - printf ("%s: Invalid family type, %d\n", fn, desc->family); - } else - printf ("%s: NULL descriptor!\n", fn); - - return ret_val; -} -- cgit v1.1 From ace514837cac656e29c37a19569cb8ea83071126 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Fri, 31 Oct 2008 11:12:38 -0500 Subject: lcd: Let the board code show board-specific info cleanup remove unneeded version.h from lcd.c Signed-off-by: Peter Tyser Signed-off-by: Wolfgang Denk --- common/lcd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'common') diff --git a/common/lcd.c b/common/lcd.c index 31bb190..ae79051 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include -- cgit v1.1 From 29a4c24de99d8cb4ac32991c04cab87ed94ca1f9 Mon Sep 17 00:00:00 2001 From: Niklaus Giger Date: Mon, 3 Nov 2008 22:15:34 +0100 Subject: cmd_elf.c: Cleanup bootvx and handle new CONFIG_SYS_VXWORKS parameters - fix size too small by one in sprintf - changed old (pre 2004) device name ibmEmac to emac - boot device may be overriden in board config - servername may be defined in board config - additional parameters may be defined in board config - fixed some line wrappings - replaced redundant MAX define by max Signed-off-by: Niklaus Giger --- common/cmd_elf.c | 77 ++++++++++++++++++++++---------------------------------- 1 file changed, 30 insertions(+), 47 deletions(-) (limited to 'common') diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 4d8e1d2..27a4b73 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -18,6 +18,7 @@ #include #include #include +#include #if defined(CONFIG_WALNUT) || defined(CONFIG_SYS_VXWORKS_MAC_PTR) DECLARE_GLOBAL_DATA_PTR; @@ -98,13 +99,10 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) unsigned long bootaddr; /* Address to put the bootline */ char *bootline; /* Text of the bootline */ char *tmp; /* Temporary char pointer */ + char build_buf[128]; /* Buffer for building the bootline */ -#if defined(CONFIG_4xx) || defined(CONFIG_IOP480) - char build_buf[80]; /* Buffer for building the bootline */ -#endif - /* -------------------------------------------------- */ - - /* + /* --------------------------------------------------- + * * Check the loadaddr variable. * If we don't know where the image is then we're done. */ @@ -120,7 +118,8 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if ((argc == 2) && (strcmp (argv[1], "tftp") == 0)) { if (NetLoop (TFTP) <= 0) return 1; - printf ("Automatic boot of VxWorks image at address 0x%08lx ... \n", addr); + printf ("Automatic boot of VxWorks image at address 0x%08lx ... \n", + addr); } #endif @@ -148,7 +147,7 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) */ if ((tmp = getenv ("bootaddr")) == NULL) - bootaddr = 0x4200; + bootaddr = CONFIG_SYS_VXWORKS_BOOT_ADDR; else bootaddr = simple_strtoul (tmp, NULL, 16); @@ -159,54 +158,40 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) */ if ((bootline = getenv ("bootargs")) != NULL) { - memcpy ((void *) bootaddr, bootline, MAX(strlen(bootline), 255)); - flush_cache (bootaddr, MAX(strlen(bootline), 255)); + memcpy ((void *) bootaddr, bootline, + max (strlen (bootline), 255)); + flush_cache (bootaddr, max (strlen (bootline), 255)); } else { -#if defined(CONFIG_4xx) - sprintf (build_buf, "ibmEmac(0,0)"); - if ((tmp = getenv ("hostname")) != NULL) { - sprintf (&build_buf[strlen (build_buf - 1)], - "host:%s ", tmp); + + sprintf (build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE); + if ((tmp = getenv ("bootfile")) != NULL) { + sprintf (&build_buf[strlen (build_buf)], + "%s:%s ", CONFIG_SYS_VXWORKS_SERVERNAME, tmp); } else { - sprintf (&build_buf[strlen (build_buf - 1)], - ": "); + sprintf (&build_buf[strlen (build_buf)], + "%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME); } if ((tmp = getenv ("ipaddr")) != NULL) { - sprintf (&build_buf[strlen (build_buf - 1)], - "e=%s ", tmp); + sprintf (&build_buf[strlen (build_buf)], "e=%s ", tmp); } - memcpy ((void *)bootaddr, build_buf, MAX(strlen(build_buf), 255)); - flush_cache (bootaddr, MAX(strlen(build_buf), 255)); -#elif defined(CONFIG_IOP480) - sprintf (build_buf, "dc(0,0)"); - if ((tmp = getenv ("hostname")) != NULL) { - sprintf (&build_buf[strlen (build_buf - 1)], - "host:%s ", tmp); - } else { - sprintf (&build_buf[strlen (build_buf - 1)], - ": "); + if ((tmp = getenv ("serverip")) != NULL) { + sprintf (&build_buf[strlen (build_buf)], "h=%s ", tmp); } - if ((tmp = getenv ("ipaddr")) != NULL) { - sprintf (&build_buf[strlen (build_buf - 1)], - "e=%s ", tmp); + if ((tmp = getenv ("hostname")) != NULL) { + sprintf (&build_buf[strlen (build_buf)], "tn=%s ", tmp); } - memcpy ((void *) bootaddr, build_buf, MAX(strlen(build_buf), 255)); - flush_cache (bootaddr, MAX(strlen(build_buf), 255)); -#else - - /* - * I'm not sure what the device should be for other - * PPC flavors, the hostname and ipaddr should be ok - * to just copy - */ - - puts ("No bootargs defined\n"); - return 1; +#ifdef CONFIG_SYS_VXWORKS_ADD_PARAMS + sprintf (&build_buf[strlen (build_buf)], + CONFIG_SYS_VXWORKS_ADD_PARAMS); #endif + + memcpy ((void *) bootaddr, build_buf, + max (strlen (build_buf), 255)); + flush_cache (bootaddr, max (strlen (build_buf), 255)); } /* @@ -251,8 +236,7 @@ int valid_elf_image (unsigned long addr) } if (ehdr->e_type != ET_EXEC) { - printf ("## Not a 32-bit elf image at address 0x%08lx\n", - addr); + printf ("## Not a 32-bit elf image at address 0x%08lx\n", addr); return 0; } @@ -267,7 +251,6 @@ int valid_elf_image (unsigned long addr) return 1; } - /* ====================================================================== * A very simple elf loader, assumes the image is valid, returns the * entry point address. -- cgit v1.1 From 774ce72026f74ac9641bcbbc588b20f2e13f7ab8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 4 Nov 2008 16:03:46 -0500 Subject: strings: use puts() rather than printf() When running `strings` on really long strings, the stack tends to get smashed due to printf(). Switch to puts() instead since we're only passing the data through. Signed-off-by: Mike Frysinger --- common/cmd_strings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_strings.c b/common/cmd_strings.c index db54f29..7d05cf8 100644 --- a/common/cmd_strings.c +++ b/common/cmd_strings.c @@ -29,7 +29,8 @@ int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) char *addr = start_addr; do { - printf("%s\n", addr); + puts(addr); + puts("\n"); addr += strlen(addr) + 1; } while (addr[0] && addr < last_addr); -- cgit v1.1 From 16a28ef219c27423a1ef502f19070c4d375079b8 Mon Sep 17 00:00:00 2001 From: Gary Jennejohn Date: Thu, 6 Nov 2008 15:04:23 +0100 Subject: IOMUX: Add console multiplexing support. Modifications to support console multiplexing. This is controlled using CONFIG_SYS_CONSOLE_MUX in the board configuration file. This allows a user to specify multiple console devices in the environment with a command like this: setenv stdin serial,nc. As a result, the user can enter text on both the serial and netconsole interfaces. All devices - stdin, stdout and stderr - can be set in this manner. 1) common/iomux.c and include/iomux.h contain the environment setting implementation. 2) doc/README.iomux contains a somewhat more detailed description. 3) The implementation in (1) is called from common/cmd_nvedit.c to handle setenv and from common/console.c to handle initialization of input/output devices at boot time. 4) common/console.c also contains the code needed to poll multiple console devices for input and send output to all devices registered for output. 5) include/common.h includes iomux.h and common/Makefile generates iomux.o when CONFIG_SYS_CONSOLE_MUX is set. Signed-off-by: Gary Jennejohn --- common/Makefile | 1 + common/cmd_nvedit.c | 6 ++ common/console.c | 156 +++++++++++++++++++++++++++++++++++++++++++++- common/iomux.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 common/iomux.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 596fef3..93e3963 100644 --- a/common/Makefile +++ b/common/Makefile @@ -142,6 +142,7 @@ COBJS-$(CONFIG_VFD) += cmd_vfd.o # others COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o COBJS-$(CONFIG_CMD_DOC) += docecc.o +COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-y += kgdb.o COBJS-$(CONFIG_LCD) += lcd.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index d280cb0..85025da 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -213,6 +213,11 @@ int _do_setenv (int flag, int argc, char *argv[]) return 1; } +#ifdef CONFIG_CONSOLE_MUX + i = iomux_doenv(console, argv[2]); + if (i) + return i; +#else /* Try assigning specified device */ if (console_assign (console, argv[2]) < 0) return 1; @@ -221,6 +226,7 @@ int _do_setenv (int flag, int argc, char *argv[]) if (serial_assign (argv[2]) < 0) return 1; #endif +#endif /* CONFIG_CONSOLE_MUX */ } /* diff --git a/common/console.c b/common/console.c index 6f0846f..89aeab6 100644 --- a/common/console.c +++ b/common/console.c @@ -93,6 +93,76 @@ static int console_setfile (int file, device_t * dev) return error; } +#if defined(CONFIG_CONSOLE_MUX) +/** Console I/O multiplexing *******************************************/ + +static device_t *tstcdev; +device_t **console_devices[MAX_FILES]; +int cd_count[MAX_FILES]; + +/* + * This depends on tstc() always being called before getc(). + * This is guaranteed to be true because this routine is called + * only from fgetc() which assures it. + * No attempt is made to demultiplex multiple input sources. + */ +static int iomux_getc(void) +{ + unsigned char ret; + + /* This is never called with testcdev == NULL */ + ret = tstcdev->getc(); + tstcdev = NULL; + return ret; +} + +static int iomux_tstc(int file) +{ + int i, ret; + device_t *dev; + + disable_ctrlc(1); + for (i = 0; i < cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev->tstc != NULL) { + ret = dev->tstc(); + if (ret > 0) { + tstcdev = dev; + disable_ctrlc(0); + return ret; + } + } + } + disable_ctrlc(0); + + return 0; +} + +static void iomux_putc(int file, const char c) +{ + int i; + device_t *dev; + + for (i = 0; i < cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev->putc != NULL) + dev->putc(c); + } +} + +static void iomux_puts(int file, const char *s) +{ + int i; + device_t *dev; + + for (i = 0; i < cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev->puts != NULL) + dev->puts(s); + } +} +#endif /* defined(CONFIG_CONSOLE_MUX) */ + /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/ void serial_printf (const char *fmt, ...) @@ -114,8 +184,31 @@ void serial_printf (const char *fmt, ...) int fgetc (int file) { - if (file < MAX_FILES) + if (file < MAX_FILES) { +#if defined(CONFIG_CONSOLE_MUX) + /* + * Effectively poll for input wherever it may be available. + */ + for (;;) { + /* + * Upper layer may have already called tstc() so + * check for that first. + */ + if (tstcdev != NULL) + return iomux_getc(); + iomux_tstc(file); +#ifdef CONFIG_WATCHDOG + /* + * If the watchdog must be rate-limited then it should + * already be handled in board-specific code. + */ + udelay(1); +#endif + } +#else return stdio_devices[file]->getc (); +#endif + } return -1; } @@ -123,7 +216,11 @@ int fgetc (int file) int ftstc (int file) { if (file < MAX_FILES) +#if defined(CONFIG_CONSOLE_MUX) + return iomux_tstc(file); +#else return stdio_devices[file]->tstc (); +#endif return -1; } @@ -131,13 +228,21 @@ int ftstc (int file) void fputc (int file, const char c) { if (file < MAX_FILES) +#if defined(CONFIG_CONSOLE_MUX) + iomux_putc(file, c); +#else stdio_devices[file]->putc (c); +#endif } void fputs (int file, const char *s) { if (file < MAX_FILES) +#if defined(CONFIG_CONSOLE_MUX) + iomux_puts(file, s); +#else stdio_devices[file]->puts (s); +#endif } void fprintf (int file, const char *fmt, ...) @@ -407,6 +512,9 @@ int console_init_r (void) #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ +#ifdef CONFIG_CONSOLE_MUX + int iomux_err = 0; +#endif /* set default handlers at first */ gd->jt[XF_getc] = serial_getc; @@ -425,6 +533,14 @@ int console_init_r (void) inputdev = search_device (DEV_FLAGS_INPUT, stdinname); outputdev = search_device (DEV_FLAGS_OUTPUT, stdoutname); errdev = search_device (DEV_FLAGS_OUTPUT, stderrname); +#ifdef CONFIG_CONSOLE_MUX + iomux_err = iomux_doenv(stdin, stdinname); + iomux_err += iomux_doenv(stdout, stdoutname); + iomux_err += iomux_doenv(stderr, stderrname); + if (!iomux_err) + /* Successful, so skip all the code below. */ + goto done; +#endif } /* if the devices are overwritten or not found, use default device */ if (inputdev == NULL) { @@ -438,15 +554,34 @@ int console_init_r (void) } /* Initializes output console first */ if (outputdev != NULL) { +#ifdef CONFIG_CONSOLE_MUX + /* need to set a console if not done above. */ + iomux_doenv(stdout, outputdev->name); +#else console_setfile (stdout, outputdev); +#endif } if (errdev != NULL) { +#ifdef CONFIG_CONSOLE_MUX + /* need to set a console if not done above. */ + iomux_doenv(stderr, errdev->name); +#else console_setfile (stderr, errdev); +#endif } if (inputdev != NULL) { +#ifdef CONFIG_CONSOLE_MUX + /* need to set a console if not done above. */ + iomux_doenv(stdin, inputdev->name); +#else console_setfile (stdin, inputdev); +#endif } +#ifdef CONFIG_CONSOLE_MUX +done: +#endif + gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET @@ -455,21 +590,33 @@ int console_init_r (void) if (stdio_devices[stdin] == NULL) { puts ("No input devices available!\n"); } else { +#ifdef CONFIG_CONSOLE_MUX + iomux_printdevs(stdin); +#else printf ("%s\n", stdio_devices[stdin]->name); +#endif } puts ("Out: "); if (stdio_devices[stdout] == NULL) { puts ("No output devices available!\n"); } else { +#ifdef CONFIG_CONSOLE_MUX + iomux_printdevs(stdout); +#else printf ("%s\n", stdio_devices[stdout]->name); +#endif } puts ("Err: "); if (stdio_devices[stderr] == NULL) { puts ("No error devices available!\n"); } else { +#ifdef CONFIG_CONSOLE_MUX + iomux_printdevs(stderr); +#else printf ("%s\n", stdio_devices[stderr]->name); +#endif } #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ @@ -524,11 +671,18 @@ int console_init_r (void) if (outputdev != NULL) { console_setfile (stdout, outputdev); console_setfile (stderr, outputdev); +#ifdef CONFIG_CONSOLE_MUX + console_devices[stdout][0] = outputdev; + console_devices[stderr][0] = outputdev; +#endif } /* Initializes input console */ if (inputdev != NULL) { console_setfile (stdin, inputdev); +#ifdef CONFIG_CONSOLE_MUX + console_devices[stdin][0] = inputdev; +#endif } gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ diff --git a/common/iomux.c b/common/iomux.c new file mode 100644 index 0000000..bdcc853 --- /dev/null +++ b/common/iomux.c @@ -0,0 +1,175 @@ +/* + * (C) Copyright 2008 + * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de. + * + * 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 + */ + +#include +#include +#include + +#ifdef CONFIG_CONSOLE_MUX +void iomux_printdevs(const int console) +{ + int i; + device_t *dev; + + for (i = 0; i < cd_count[console]; i++) { + dev = console_devices[console][i]; + printf("%s ", dev->name); + } + printf("\n"); +} + +/* This tries to preserve the old list if an error occurs. */ +int iomux_doenv(const int console, const char *arg) +{ + char *console_args, *temp, **start; + int i, j, k, io_flag, cs_idx, repeat; + device_t *dev; + device_t **cons_set; + + console_args = strdup(arg); + if (console_args == NULL) + return 1; + /* + * Check whether a comma separated list of devices was + * entered and count how many devices were entered. + * The array start[] has pointers to the beginning of + * each device name (up to MAX_CONSARGS devices). + * + * Have to do this twice - once to count the number of + * commas and then again to populate start. + */ + i = 0; + temp = console_args; + for (;;) { + temp = strchr(temp, ','); + if (temp != NULL) { + i++; + temp++; + continue; + } + /* There's always one entry more than the number of commas. */ + i++; + break; + } + start = (char **)malloc(i * sizeof(char *)); + if (start == NULL) { + free(console_args); + return 1; + } + i = 0; + start[0] = console_args; + for (;;) { + temp = strchr(start[i++], ','); + if (temp == NULL) + break; + *temp = '\0'; + start[i] = temp + 1; + } + cons_set = (device_t **)calloc(i, sizeof(device_t *)); + if (cons_set == NULL) { + free(start); + free(console_args); + return 1; + } + + switch (console) { + case stdin: + io_flag = DEV_FLAGS_INPUT; + break; + case stdout: + case stderr: + io_flag = DEV_FLAGS_OUTPUT; + break; + default: + free(start); + free(console_args); + free(cons_set); + return 1; + } + + cs_idx = 0; + for (j = 0; j < i; j++) { + /* + * Check whether the device exists and is valid. + * console_assign() also calls search_device(), + * but I need the pointer to the device. + */ + dev = search_device(io_flag, start[j]); + if (dev == NULL) + continue; + /* + * Prevent multiple entries for a device. + */ + repeat = 0; + for (k = 0; k < cs_idx; k++) { + if (dev == cons_set[k]) { + repeat++; + break; + } + } + if (repeat) + continue; + /* + * Try assigning the specified device. + * This could screw up the console settings for apps. + */ + if (console_assign(console, start[j]) < 0) + continue; +#ifdef CONFIG_SERIAL_MULTI + /* + * This was taken from common/cmd_nvedit.c. + * This will never work because serial_assign() returns + * 1 upon error, not -1. + * This would almost always return an error anyway because + * serial_assign() expects the name of a serial device, like + * serial_smc, but the user generally only wants to set serial. + */ + if (serial_assign(start[j]) < 0) + continue; +#endif + cons_set[cs_idx++] = dev; + } + free(console_args); + free(start); + /* failed to set any console */ + if (cs_idx == 0) { + free(cons_set); + return 1; + } else { + /* Works even if console_devices[console] is NULL. */ + console_devices[console] = + (device_t **)realloc(console_devices[console], + cs_idx * sizeof(device_t *)); + if (console_devices[console] == NULL) { + free(cons_set); + return 1; + } + memcpy(console_devices[console], cons_set, cs_idx * + sizeof(device_t *)); + + cd_count[console] = cs_idx; + } + free(cons_set); + return 0; +} +#endif /* CONFIG_CONSOLE_MUX */ -- cgit v1.1 From bcdf1d2cf6b24fb905fd7da80da4b3c65a7995b5 Mon Sep 17 00:00:00 2001 From: Richard Retanubun Date: Thu, 6 Nov 2008 14:01:51 -0500 Subject: common/cmd_ide.c: Corrected endian order printing for compact flash serial number. Corrected endian order printing for compact flash serial number. Signed-off-by: Richard Retanubun --- common/cmd_ide.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 2564c2b..db05f76 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -1166,15 +1166,16 @@ static void ide_ident (block_dev_desc_t *dev_desc) ident_cpy ((unsigned char*)dev_desc->product, iop->serial_no, sizeof(dev_desc->product)); #ifdef __LITTLE_ENDIAN /* - * firmware revision and model number have Big Endian Byte - * order in Word. Convert both to little endian. + * firmware revision, model, and serial number have Big Endian Byte + * order in Word. Convert all three to little endian. * * See CF+ and CompactFlash Specification Revision 2.0: - * 6.2.1.6: Identfy Drive, Table 39 for more details + * 6.2.1.6: Identify Drive, Table 39 for more details */ strswab (dev_desc->revision); strswab (dev_desc->vendor); + strswab (dev_desc->product); #endif /* __LITTLE_ENDIAN */ if ((iop->config & 0x0080)==0x0080) -- cgit v1.1 From 4b530018764934ad5689196e9aa5714a6f4d1a6c Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 12 Nov 2008 09:50:45 +0100 Subject: jffs2: rename devices_init () in common/jffs2.c rename devices_init () in common/jffs2.c to jffs2_devices_init (), because there is also a devices_init () in common/devices.c. Signed-off-by: Heiko Schocher --- common/cmd_jffs2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index 791a572..c2caade 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -1056,7 +1056,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_ * * @return 0 on success, 1 otherwise */ -static int devices_init(void) +static int jffs2_devices_init(void) { last_parts[0] = '\0'; current_dev = NULL; @@ -1471,12 +1471,12 @@ static int parse_mtdparts(const char *const mtdparts) DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p); /* delete all devices and partitions */ - if (devices_init() != 0) { + if (jffs2_devices_init() != 0) { printf("could not initialise device list\n"); return err; } - /* re-read 'mtdparts' variable, devices_init may be updating env */ + /* re-read 'mtdparts' variable, jffs2_devices_init may be updating env */ p = getenv("mtdparts"); if (strncmp(p, "mtdparts=", 9) != 0) { @@ -1698,7 +1698,7 @@ int mtdparts_init(void) ids_changed = 1; if (parse_mtdids(ids) != 0) { - devices_init(); + jffs2_devices_init(); return 1; } @@ -1731,7 +1731,7 @@ int mtdparts_init(void) /* mtdparts variable was reset to NULL, delete all devices/partitions */ if (!parts && (last_parts[0] != '\0')) - return devices_init(); + return jffs2_devices_init(); /* do not process current partition if mtdparts variable is null */ if (!parts) @@ -2105,8 +2105,8 @@ int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) setenv("mtdparts", NULL); - /* devices_init() calls current_save() */ - return devices_init(); + /* jffs2_devices_init() calls current_save() */ + return jffs2_devices_init(); } } -- cgit v1.1 From 2ee951ba2ac9874d2a93d52e7a187d3184be937e Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 27 Nov 2008 14:07:09 +0100 Subject: UBI: Enable re-initializing of the "ubi part" command With this patch now, the user can call "ubi part" multiple times to re-connect the UBI device to another MTD partition. Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 8446765..495d71e 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -31,6 +31,7 @@ /* Private own data */ static struct ubi_device *ubi; static char buffer[80]; +static int ubi_initialized; struct selected_dev { char dev_name[32]; /* NAND/OneNAND etc */ @@ -428,6 +429,8 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev) return err; } + ubi_initialized = 1; + return 0; } @@ -464,6 +467,14 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ubi_dev.nr = 0; /* + * Call ubi_exit() before re-initializing the UBI subsystem + */ + if (ubi_initialized) { + ubi_exit(); + del_mtd_partitions(ubi_dev.mtd_info); + } + + /* * Check for nand|onenand selection */ #if defined(CONFIG_CMD_NAND) -- cgit v1.1 From 2d2e05727fe4013f807ffa814dff0e75259a1db4 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 2 Dec 2008 10:53:47 +0100 Subject: UBI: Fix size parsing in "ubi create" Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 495d71e..fd33a67 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -546,7 +546,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } /* E.g., create volume size */ if (argc == 4) { - addr = simple_strtoul(argv[3], NULL, 16); + size = simple_strtoul(argv[3], NULL, 16); argc--; } /* Use maximum available size */ -- cgit v1.1 From e0b5532579eda8b4629f1b4f6e49c3cc60f52237 Mon Sep 17 00:00:00 2001 From: Ilya Yanok Date: Thu, 13 Nov 2008 19:49:32 +0300 Subject: jffs2: add sector_size field to part_info structure This patch adds sector_size field to part_info structure (used by new JFFS2 code). Signed-off-by: Ilya Yanok --- common/cmd_jffs2.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index c2caade..7866c80 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -339,11 +339,15 @@ static int part_validate_nor(struct mtdids *id, struct part_info *part) extern flash_info_t flash_info[]; flash_info_t *flash; int offset_aligned; - u32 end_offset; + u32 end_offset, sector_size = 0; int i; flash = &flash_info[id->num]; + /* size of last sector */ + part->sector_size = flash->size - + (flash->start[flash->sector_count-1] - flash->start[0]); + offset_aligned = 0; for (i = 0; i < flash->sector_count; i++) { if ((flash->start[i] - flash->start[0]) == part->offset) { @@ -358,12 +362,18 @@ static int part_validate_nor(struct mtdids *id, struct part_info *part) } end_offset = part->offset + part->size; + offset_aligned = 0; for (i = 0; i < flash->sector_count; i++) { + if (i) { + sector_size = flash->start[i] - flash->start[i-1]; + if (part->sector_size < sector_size) + part->sector_size = sector_size; + } if ((flash->start[i] - flash->start[0]) == end_offset) - return 0; + offset_aligned = 1; } - if (flash->size == end_offset) + if (offset_aligned || flash->size == end_offset) return 0; printf("%s%d: partition (%s) size alignment incorrect\n", @@ -389,6 +399,8 @@ static int part_validate_nand(struct mtdids *id, struct part_info *part) nand = &nand_info[id->num]; + part->sector_size = nand->erasesize; + if ((unsigned long)(part->offset) % nand->erasesize) { printf("%s%d: partition (%s) start offset alignment incorrect\n", MTD_DEV_TYPE(id->type), id->num, part->name); @@ -424,6 +436,8 @@ static int part_validate_onenand(struct mtdids *id, struct part_info *part) mtd = &onenand_mtd; + part->sector_size = mtd->erasesize; + if ((unsigned long)(part->offset) % mtd->erasesize) { printf("%s%d: partition (%s) start offset" "alignment incorrect\n", -- cgit v1.1 From 3b089e4f889a2902449d55e081c886ae607cae89 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 10 Dec 2008 10:32:59 +0100 Subject: UBI: Set ubi_dev.type back to DEV_TYPE_NONE upon failing initialization With this patch we set the type back to NONE upon failing UBI partition initialization. Otherwise further calls to the UBI subsystem would try to really access the non-existing UBI partition. Thanks to Michael Lawnick for pointing this out. Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index fd33a67..4c35892 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -508,6 +508,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) err = ubi_dev_scan(ubi_dev.mtd_info, ubi_dev.part_name); if (err) { printf("UBI init error %d\n", err); + ubi_dev.type = DEV_TYPE_NONE; return err; } -- cgit v1.1 From cd6734510a9ff0f41c4a73567d4080ea0033d2c1 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 24 Nov 2008 13:33:51 +0100 Subject: Fix FIT and FDT support to have CONFIG_OF_LIBFDT and CONFIG_FIT independent FDT support is used for both FIT style images and for architectures that can pass a fdt blob to an OS (ppc, m68k, sparc). For other architectures and boards which do not pass a fdt blob to an OS but want to use the new uImage format, we just need FIT support. Now we can have the 4 following configurations : 1) FIT only CONFIG_FIT 2) fdt blob only CONFIG_OF_LIBFDT 3) both CONFIG_OF_LIBFDT & CONFIG_FIT 4) none none Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/image.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') diff --git a/common/image.c b/common/image.c index 866edf6..daa68bc 100644 --- a/common/image.c +++ b/common/image.c @@ -1071,6 +1071,7 @@ int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len, error: return -1; } +#endif /* defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) */ #ifdef CONFIG_OF_LIBFDT static void fdt_error (const char *msg) @@ -1575,6 +1576,7 @@ error: } #endif /* CONFIG_OF_LIBFDT */ +#if defined(CONFIG_PPC) || defined(CONFIG_M68K) /** * boot_get_cmdline - allocate and initialize kernel cmdline * @lmb: pointer to lmb handle, will be used for memory mgmt -- cgit v1.1 From d16da93430520d3e46c1ab52eedacf36ab7a2311 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 24 Nov 2008 11:54:47 -0600 Subject: cmd_mem: Remove unused variable Signed-off-by: Peter Tyser --- common/cmd_mem.c | 1 - 1 file changed, 1 deletion(-) (limited to 'common') diff --git a/common/cmd_mem.c b/common/cmd_mem.c index d7666c2..400cfd7 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -1175,7 +1175,6 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { unsigned long src, dst; unsigned long src_len = ~0UL, dst_len = ~0UL; - int err; switch (argc) { case 4: -- cgit v1.1 From 5b3375ac8c36c29c87abb132fede0509eb21e5c9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Dec 2008 06:23:37 -0500 Subject: env_sf: support embedded environments If both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE are defined, and the sect size is larger than the env size, then it means the env is embedded in a block. So we have to save/restore the part of the sector which is not the environment. Previously, saving the environment in SPI flash in this setup would probably brick the board as the rest of the sector tends to contain actual U-Boot data/code. Signed-off-by: Mike Frysinger Acked-by: Haavard Skinnemoen --- common/env_sf.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/env_sf.c b/common/env_sf.c index 1bbf93f..2f52e25 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -27,6 +27,7 @@ */ #include #include +#include #include #ifndef CONFIG_ENV_SPI_BUS @@ -60,13 +61,30 @@ uchar env_get_char_spec(int index) int saveenv(void) { + u32 saved_size, saved_offset; + char *saved_buffer = NULL; u32 sector = 1; + int ret; if (!env_flash) { puts("Environment SPI flash not initialized\n"); return 1; } + /* Is the sector larger than the env (i.e. embedded) */ + if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) { + saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE; + saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE; + saved_buffer = malloc(saved_size); + if (!saved_buffer) { + ret = 1; + goto done; + } + ret = spi_flash_read(env_flash, saved_offset, saved_size, saved_buffer); + if (ret) + goto done; + } + if (CONFIG_ENV_SIZE > CONFIG_ENV_SECT_SIZE) { sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE; if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE) @@ -74,15 +92,28 @@ int saveenv(void) } puts("Erasing SPI flash..."); - if (spi_flash_erase(env_flash, CONFIG_ENV_OFFSET, sector * CONFIG_ENV_SECT_SIZE)) - return 1; + ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET, sector * CONFIG_ENV_SECT_SIZE); + if (ret) + goto done; puts("Writing to SPI flash..."); - if (spi_flash_write(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr)) - return 1; + ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr); + if (ret) + goto done; + + if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) { + ret = spi_flash_write(env_flash, saved_offset, saved_size, saved_buffer); + if (ret) + goto done; + } + ret = 0; puts("done\n"); - return 0; + + done: + if (saved_buffer) + free(saved_buffer); + return ret; } void env_relocate_spec(void) -- cgit v1.1 From 455ae7e87f67c44e6aea68865c83acadd3fcd36c Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 16 Dec 2008 01:02:17 +0100 Subject: Coding style cleanup, update CHANGELOG. Signed-off-by: Wolfgang Denk --- common/cmd_ubi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 4c35892..5c31f7b 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -601,7 +601,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD(ubi, 6, 1, do_ubi, "ubi - ubi commands\n", - "part [nand|nor|onenand] [part]" + "part [nand|nor|onenand] [part]" " - Show or set current partition\n" "ubi info [l[ayout]]" " - Display volume and ubi layout information\n" -- cgit v1.1