summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-12-17 16:53:07 +0100
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-12-17 16:53:07 +0100
commitcb5473205206c7f14cbb1e747f28ec75b48826e2 (patch)
tree8f4808d60917100b18a10b05230f7638a0a9bbcc /common
parentbaf449fc5ff96f071bb0e3789fd3265f6d4fd9a0 (diff)
parent92c78a3bbcb2ce508b4bf1c4a1e0940406a024bb (diff)
downloadu-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.zip
u-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.tar.gz
u-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.tar.bz2
Merge branch 'fixes' into cleanups
Conflicts: board/atmel/atngw100/atngw100.c board/atmel/atstk1000/atstk1000.c cpu/at32ap/at32ap700x/gpio.c include/asm-avr32/arch-at32ap700x/clk.h include/configs/atngw100.h include/configs/atstk1002.h include/configs/atstk1003.h include/configs/atstk1004.h include/configs/atstk1006.h include/configs/favr-32-ezkit.h include/configs/hammerhead.h include/configs/mimc200.h
Diffstat (limited to 'common')
-rw-r--r--common/ACEX1K.c362
-rw-r--r--common/Makefile69
-rw-r--r--common/altera.c283
-rw-r--r--common/cmd_autoscript.c10
-rw-r--r--common/cmd_bdinfo.c46
-rw-r--r--common/cmd_bedbug.c6
-rw-r--r--common/cmd_bmp.c10
-rw-r--r--common/cmd_boot.c2
-rw-r--r--common/cmd_bootm.c416
-rw-r--r--common/cmd_date.c30
-rw-r--r--common/cmd_diag.c2
-rw-r--r--common/cmd_display.c8
-rw-r--r--common/cmd_doc.c30
-rw-r--r--common/cmd_dtt.c2
-rw-r--r--common/cmd_eeprom.c92
-rw-r--r--common/cmd_elf.c89
-rw-r--r--common/cmd_ext2.c6
-rw-r--r--common/cmd_fat.c2
-rw-r--r--common/cmd_fdc.c44
-rw-r--r--common/cmd_fdos.c4
-rw-r--r--common/cmd_fdt.c7
-rw-r--r--common/cmd_flash.c177
-rw-r--r--common/cmd_i2c.c309
-rw-r--r--common/cmd_ide.c163
-rw-r--r--common/cmd_immap.c12
-rw-r--r--common/cmd_itest.c2
-rw-r--r--common/cmd_jffs2.c113
-rw-r--r--common/cmd_load.c50
-rw-r--r--common/cmd_log.c2
-rw-r--r--common/cmd_mac.c3
-rw-r--r--common/cmd_mem.c54
-rw-r--r--common/cmd_misc.c2
-rw-r--r--common/cmd_mp.c2
-rw-r--r--common/cmd_nand.c40
-rw-r--r--common/cmd_net.c20
-rw-r--r--common/cmd_nvedit.c56
-rw-r--r--common/cmd_pci.c4
-rw-r--r--common/cmd_pcmcia.c4
-rw-r--r--common/cmd_portio.c2
-rw-r--r--common/cmd_reginfo.c6
-rw-r--r--common/cmd_reiser.c2
-rw-r--r--common/cmd_sata.c14
-rw-r--r--common/cmd_scsi.c20
-rw-r--r--common/cmd_spi.c3
-rw-r--r--common/cmd_strings.c7
-rw-r--r--common/cmd_ubi.c620
-rw-r--r--common/cmd_usb.c598
-rw-r--r--common/cmd_vfd.c2
-rw-r--r--common/command.c66
-rw-r--r--common/console.c216
-rw-r--r--common/cyclon2.c301
-rw-r--r--common/devices.c38
-rw-r--r--common/env_common.c20
-rw-r--r--common/env_dataflash.c19
-rw-r--r--common/env_eeprom.c27
-rw-r--r--common/env_embedded.c (renamed from common/environment.c)20
-rw-r--r--common/env_flash.c89
-rw-r--r--common/env_nand.c85
-rw-r--r--common/env_nowhere.c5
-rw-r--r--common/env_nvram.c43
-rw-r--r--common/env_onenand.c12
-rw-r--r--common/env_sf.c76
-rw-r--r--common/fdt_support.c107
-rw-r--r--common/flash.c14
-rw-r--r--common/fpga.c335
-rw-r--r--common/hush.c74
-rw-r--r--common/image.c119
-rw-r--r--common/iomux.c175
-rw-r--r--common/kgdb.c2
-rw-r--r--common/lcd.c113
-rw-r--r--common/main.c55
-rw-r--r--common/miiphyutil.c2
-rw-r--r--common/serial.c14
-rw-r--r--common/spartan2.c663
-rw-r--r--common/spartan3.c668
-rw-r--r--common/stratixII.c231
-rw-r--r--common/update.c315
-rw-r--r--common/usb.c720
-rw-r--r--common/usb_kbd.c8
-rw-r--r--common/virtex2.c554
-rw-r--r--common/xilinx.c307
81 files changed, 3842 insertions, 5458 deletions
diff --git a/common/ACEX1K.c b/common/ACEX1K.c
deleted file mode 100644
index 53677b8..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 <common.h> /* core U-Boot definitions */
-#include <ACEX1K.h> /* 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 CFG_FPGA_WAIT
-#define CFG_FPGA_WAIT CFG_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 CFG_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) > CFG_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 CFG_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 CFG_FPGA_PROG_FEEDBACK
- if (bytecount % (bsize / 40) == 0)
- putc ('.'); /* let them know we are alive */
-#endif
- }
-
- CONFIG_FPGA_DELAY ();
-
-#ifdef CFG_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 CFG_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 0fe9c8b..93e3963 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -42,27 +42,31 @@ 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
-COBJS-y += env_dataflash.o
-COBJS-y += env_eeprom.o
-COBJS-y += env_flash.o
-COBJS-y += env_nand.o
-COBJS-y += env_nvram.o
-COBJS-y += env_onenand.o
-COBJS-y += env_sf.o
-COBJS-y += env_nowhere.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-$(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
+COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
+COBJS-$(CONFIG_ENV_IS_NOWHERE) += 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
-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
@@ -76,27 +80,17 @@ 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
-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
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
@@ -107,17 +101,17 @@ 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-y += cmd_mem.o
+COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o
+COBJS-$(CONFIG_CMD_MEMORY) += 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
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
@@ -134,6 +128,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
@@ -142,17 +137,21 @@ 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
+
+# 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
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-y += $(COBJS-yy)
-COBJS := $(COBJS-y)
+
+COBJS := $(sort $(COBJS-y))
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
@@ -163,10 +162,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/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 <common.h>
-#include <ACEX1K.h>
-#include <stratixII.h>
-
-/* 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/cmd_autoscript.c b/common/cmd_autoscript.c
index c2e7e66..4517ac8 100644
--- a/common/cmd_autoscript.c
+++ b/common/cmd_autoscript.c
@@ -43,7 +43,7 @@
#if defined(CONFIG_8xx)
#include <mpc8xx.h>
#endif
-#ifdef CFG_HUSH_PARSER
+#ifdef CONFIG_SYS_HUSH_PARSER
#include <hush.h>
#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
{
@@ -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);
@@ -209,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 24ff9b9..6675241 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
@@ -164,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
@@ -193,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
@@ -223,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("CFG_ENV_ADDR ", CFG_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);
+ print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
+ print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
+ 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 =");
@@ -262,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..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[];
@@ -218,7 +214,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 0db7b75..a8f85e9 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -34,13 +34,14 @@
#include <bzlib.h>
#include <environment.h>
#include <lmb.h>
+#include <linux/ctype.h>
#include <asm/byteorder.h>
#if defined(CONFIG_CMD_USB)
#include <usb.h>
#endif
-#ifdef CFG_HUSH_PARSER
+#ifdef CONFIG_SYS_HUSH_PARSER
#include <hush.h>
#endif
@@ -50,11 +51,18 @@
#include <fdt_support.h>
#endif
+#ifdef CONFIG_LZMA
+#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */
+#include <lzma/LzmaTypes.h>
+#include <lzma/LzmaDecode.h>
+#include <lzma/LzmaTools.h>
+#endif /* CONFIG_LZMA */
+
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
@@ -95,24 +103,56 @@ 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;
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;
+#if defined(CONFIG_INTEGRITY)
+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,
+#endif
+#ifdef CONFIG_INTEGRITY
+ [IH_OS_INTEGRITY] = 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)
@@ -121,6 +161,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__)
@@ -166,6 +212,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 */
@@ -246,11 +293,12 @@ 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;
}
#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,10 +309,11 @@ 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;
- images.valid = 1;
+ images.state = BOOTM_STATE_START;
return 0;
}
@@ -280,7 +329,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);
@@ -320,7 +369,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);
@@ -332,18 +381,34 @@ 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_len);
+ 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;
}
puts ("OK\n");
- debug (" kernel loaded at 0x%08lx, end = 0x%08lx\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%lx\n", load, load_end);
+ debug ("images.os.load = 0x%lx, load_end = 0x%lx\n", load, *load_end);
return BOOTM_ERR_OVERLAP;
}
@@ -351,17 +416,160 @@ 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 */
/*******************************************************************/
+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;
+ }
+
+ /* 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);
+ }
- 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
@@ -421,45 +629,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_ARTOS
- case IH_OS_ARTOS:
- do_bootm_artos (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
@@ -736,7 +912,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"
@@ -756,6 +932,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"
);
/*******************************************************************/
@@ -766,7 +957,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
@@ -853,6 +1044,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:
@@ -864,7 +1061,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"
@@ -885,7 +1082,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;
@@ -980,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)
{
@@ -989,6 +1187,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");
@@ -1062,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[],
@@ -1069,6 +1271,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");
@@ -1082,11 +1287,15 @@ 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)
{
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");
@@ -1109,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[],
@@ -1116,6 +1326,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");
@@ -1136,6 +1349,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");
@@ -1152,92 +1368,34 @@ static int do_bootm_qnxelf(int flag, int argc, char *argv[],
}
#endif
-#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
-static int do_bootm_artos (int flag, int argc, char *argv[],
+#ifdef CONFIG_INTEGRITY
+static int do_bootm_integrity (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);
+ 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 ("ARTOS");
+ fit_unsupported_reset ("INTEGRITY");
return 1;
}
#endif
- /*
- * Booting an ARTOS kernel image + application
- */
+ entry_point = (void (*)(void))images->ep;
- /* 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 */
+ printf ("## Transferring control to INTEGRITY (at address %08lx) ...\n",
+ (ulong)entry_point);
+
+ show_boot_progress (15);
- entry = (void (*)(bd_t *, char *, char **, ulong))images->ep;
- (*entry) (kbd, cmdline, fwenv, top);
+ /*
+ * INTEGRITY Parameters:
+ * None
+ */
+ (*entry_point)();
return 1;
}
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 7511598..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 */
@@ -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,
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",
"[<string>]\n"
" - with <string> argument: display <string> 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; ++i) {
+ for (i=0; i<CONFIG_SYS_MAX_DOC_DEVICE; ++i) {
if(doc_dev_desc[i].ChipID == DOC_ChipID_UNKNOWN)
continue; /* list only known devices */
printf ("Device %d: ", i);
@@ -113,7 +113,7 @@ int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
} else if (strcmp(argv[1],"device") == 0) {
- if ((curr_device < 0) || (curr_device >= 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<CFG_MAX_DOC_DEVICE; i++) {
+ for (i=0; i<CONFIG_SYS_MAX_DOC_DEVICE; i++) {
if (doc_dev_desc[i].ChipID == DOC_ChipID_UNKNOWN) {
this = doc_dev_desc + i;
break;
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index 956dc69..c5b1d4d 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -36,7 +36,7 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
/* switch to correct I2C bus */
old_bus = I2C_GET_BUS();
- I2C_SET_BUS(CFG_DTT_BUS_NUM);
+ I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
/*
* Loop through sensors, read
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index e5000e9..2451bef 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -32,8 +32,8 @@
* Use the following configuration options to ensure no unneeded performance
* degradation (typical for EEPROM) is incured for FRAM memory:
*
- * #define CFG_I2C_FRAM
- * #undef CFG_EEPROM_PAGE_WRITE_DELAY_MS
+ * #define CONFIG_SYS_I2C_FRAM
+ * #undef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
*
*/
@@ -42,20 +42,17 @@
#include <command.h>
#include <i2c.h>
-#if defined(CFG_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);
extern int eeprom_write (unsigned dev_addr, unsigned offset,
uchar *buffer, unsigned cnt);
-#if defined(CFG_EEPROM_WREN)
+#if defined(CONFIG_SYS_EEPROM_WREN)
extern int eeprom_write_enable (unsigned dev_addr, int state);
#endif
-#endif
-#if defined(CFG_EEPROM_X40430)
+#if defined(CONFIG_SYS_EEPROM_X40430)
/* Maximum number of times to poll for acknowledge after write */
#define MAX_ACKNOWLEDGE_POLLS 10
#endif
@@ -68,7 +65,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
const char *const fmt =
"\nEEPROM @0x%lX %s: addr %08lx off %04lx count %ld ... ";
-#if defined(CFG_I2C_MULTI_EEPROMS)
+#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
if (argc == 6) {
ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
ulong addr = simple_strtoul (argv[3], NULL, 16);
@@ -76,11 +73,11 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
ulong cnt = simple_strtoul (argv[5], NULL, 16);
#else
if (argc == 5) {
- ulong dev_addr = CFG_DEF_EEPROM_ADDR;
+ ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
ulong addr = simple_strtoul (argv[2], NULL, 16);
ulong off = simple_strtoul (argv[3], NULL, 16);
ulong cnt = simple_strtoul (argv[4], NULL, 16);
-#endif /* CFG_I2C_MULTI_EEPROMS */
+#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
# ifndef CONFIG_SPI
eeprom_init ();
@@ -114,18 +111,16 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
/*-----------------------------------------------------------------------
*
- * 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.
*/
-#if defined(CFG_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
+#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
@@ -141,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 */
@@ -162,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 */
@@ -173,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;
@@ -196,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.
*/
@@ -209,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];
@@ -217,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.
@@ -227,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 */
@@ -248,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 */
@@ -259,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);
@@ -280,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.
@@ -289,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) {
@@ -339,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) {
@@ -369,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;
@@ -387,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 */
@@ -402,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)
@@ -417,18 +412,17 @@ 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
}
/*-----------------------------------------------------------------------
*/
-#endif
/***************************************************/
#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",
@@ -444,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..27a4b73 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -18,15 +18,12 @@
#include <linux/ctype.h>
#include <net.h>
#include <elf.h>
+#include <vxworks.h>
-#if defined(CONFIG_WALNUT) || defined(CFG_VXWORKS_MAC_PTR)
+#if defined(CONFIG_WALNUT) || defined(CONFIG_SYS_VXWORKS_MAC_PTR)
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);
@@ -102,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.
*/
@@ -124,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
@@ -135,10 +130,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");
@@ -152,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);
@@ -163,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));
}
/*
@@ -255,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;
}
@@ -271,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.
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index f569406..9c43792 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -44,8 +44,8 @@
#include <usb.h>
#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 */
@@ -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 8493def..d995ff2 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -50,8 +50,6 @@
/*#include <rtc.h> */
/*#endif */
-#if defined(CONFIG_CMD_FDC) || defined(CONFIG_CMD_FDOS)
-
typedef struct {
int flags; /* connected drives ect */
unsigned long blnr; /* Logical block nr */
@@ -172,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
@@ -215,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];
}
@@ -226,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;
}
@@ -654,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 */
@@ -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)
@@ -792,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);
@@ -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",
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 0593bad..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
@@ -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/cmd_flash.c b/common/cmd_flash.c
index 18d2250..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;
@@ -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 < 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 */
+ 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;
@@ -205,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;
@@ -276,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
@@ -288,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; ++bank) {
+ for (bank=0; bank <CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
printf ("\nBank # %ld: ", bank+1);
flash_print_info (&flash_info[bank]);
@@ -299,20 +308,20 @@ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
bank = simple_strtoul(argv[1], 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 ("\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;
@@ -329,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);
@@ -381,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);
@@ -406,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;
@@ -428,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;
@@ -450,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)
@@ -503,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;
@@ -514,17 +523,17 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
p ? "" : "Un-", bank);
for (i=0; i<info->sector_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;
}
@@ -538,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;
}
@@ -588,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",
@@ -602,18 +611,18 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
for (i=0; i<info->sector_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;
}
@@ -628,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;
@@ -651,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;
}
@@ -662,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);
@@ -685,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 91bf25b..448f2fe 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...
@@ -83,7 +83,9 @@
#include <common.h>
#include <command.h>
+#include <environment.h>
#include <i2c.h>
+#include <malloc.h>
#include <asm/byteorder.h>
/* Display values from last command.
@@ -103,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))
@@ -125,9 +127,16 @@ 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 = CONFIG_SYS_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[]);
-extern int cmd_get_data_size(char* arg, int default_size);
/*
* Syntax:
@@ -240,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);
@@ -314,7 +322,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
@@ -330,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:
@@ -400,7 +407,6 @@ int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-
/* Modify memory.
*
* Syntax:
@@ -520,8 +526,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;
@@ -543,14 +549,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)) {
@@ -566,7 +572,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))
@@ -578,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}]
@@ -649,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.
@@ -1183,6 +1187,43 @@ 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 (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+ 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[])
{
@@ -1221,12 +1262,16 @@ 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)
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))
@@ -1239,6 +1284,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)
@@ -1257,16 +1304,20 @@ 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)
- "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"
"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"
@@ -1327,3 +1378,221 @@ 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(CONFIG_SYS_I2C_IVM_BUS)
+ i2c_mux_ident_muxstring_f ((uchar *)CONFIG_SYS_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 */
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 2fcaff8..db05f76 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; ++i) {
+ for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i) {
if (ide_dev_desc[i].type==DEV_TYPE_UNKNOWN)
continue; /* list only known devices */
printf ("IDE device %d: ", i);
@@ -214,7 +214,7 @@ int do_ide (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_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; ++dev) {
+ for (ok=0, dev=0; dev<CONFIG_SYS_IDE_MAXDEVICE; ++dev) {
if (ide_dev_desc[dev].part_type!=PART_TYPE_UNKNOWN) {
++ok;
if (dev)
@@ -245,7 +245,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf ("\nIDE device %d: ", dev);
- if (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; bus<CFG_IDE_MAXBUS; ++bus) {
- int dev = bus * (CFG_IDE_MAXDEVICE / CFG_IDE_MAXBUS);
+ for (bus=0; bus<CONFIG_SYS_IDE_MAXBUS; ++bus) {
+ int dev = bus * (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS);
#else
s = getenv("ide_maxbus");
if (s)
max_bus_scan = simple_strtol(s, NULL, 10);
else
- max_bus_scan = CFG_IDE_MAXBUS;
+ max_bus_scan = CONFIG_SYS_IDE_MAXBUS;
for (bus=0; bus<max_bus_scan; ++bus) {
- int dev = bus * (CFG_IDE_MAXDEVICE / max_bus_scan);
+ int dev = bus * (CONFIG_SYS_IDE_MAXDEVICE / max_bus_scan);
#endif
#ifdef CONFIG_IDE_8xx_PCCARD
@@ -722,7 +722,7 @@ void ide_init (void)
ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
curr_device = -1;
- for (i=0; i<CFG_IDE_MAXDEVICE; ++i) {
+ for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i) {
#ifdef CONFIG_IDE_LED
int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
#endif
@@ -753,7 +753,7 @@ void ide_init (void)
block_dev_desc_t * ide_get_dev(int dev)
{
- return (dev < CFG_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
+ return (dev < CONFIG_SYS_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
}
@@ -762,7 +762,7 @@ block_dev_desc_t * ide_get_dev(int dev)
static void
set_pcmcia_timing (int pmode)
{
- volatile immap_t *immr = (immap_t *)CFG_IMMR;
+ volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
volatile pcmconf8xx_t *pcmp = &(immr->im_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;
@@ -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)
@@ -1359,7 +1360,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 +1398,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 +1455,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 +1488,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 +1568,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; i<CFG_IDE_MAXBUS; ++i)
+ for (i=0; i<CONFIG_SYS_IDE_MAXBUS; ++i)
ide_bus_ok[i] = 0;
- for (i=0; i<CFG_IDE_MAXDEVICE; ++i)
+ for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i)
ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
ide_set_reset (1); /* assert reset */
@@ -1585,11 +1586,11 @@ static void ide_reset (void)
WATCHDOG_RESET();
-#ifdef CFG_PB_12V_ENABLE
- immr->im_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 +1598,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 +1627,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_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_jffs2.c b/common/cmd_jffs2.c
index c031d80..7866c80 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -51,7 +51,7 @@
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
- * <dev-id> := 'nand'|'nor'<dev-num>
+ * <dev-id> := 'nand'|'nor'|'onenand'<dev-num>
* <dev-num> := mtd device number, 0...
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
*
@@ -103,6 +103,13 @@
#include <nand.h>
#endif /* !CONFIG_NAND_LEGACY */
#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/onenand.h>
+#include <onenand_uboot.h>
+#endif
+
/* enable/disable debugging messages */
#define DEBUG_JFFS
#undef DEBUG_JFFS
@@ -332,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) {
@@ -351,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",
@@ -382,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);
@@ -401,6 +420,45 @@ 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;
+
+ part->sector_size = mtd->erasesize;
+
+ 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 +494,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");
@@ -726,7 +786,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;
@@ -734,28 +794,36 @@ 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
- }
+ } 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;
}
@@ -1002,7 +1070,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;
@@ -1065,8 +1133,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 <dev-id> := 'nand'|'nor'<dev-num>, return device
- * type and number.
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * 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 +1153,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;
@@ -1414,12 +1485,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) {
@@ -1489,7 +1560,7 @@ static int parse_mtdids(const char *const ids)
while(p && (*p != '\0')) {
ret = 1;
- /* parse 'nor'|'nand'<dev-num> */
+ /* parse 'nor'|'nand'|'onenand'<dev-num> */
if (id_parse(p, &p, &type, &num) != 0)
break;
@@ -1641,7 +1712,7 @@ int mtdparts_init(void)
ids_changed = 1;
if (parse_mtdids(ids) != 0) {
- devices_init();
+ jffs2_devices_init();
return 1;
}
@@ -1674,7 +1745,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)
@@ -2048,8 +2119,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();
}
}
@@ -2181,7 +2252,7 @@ U_BOOT_CMD(
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
"mtdids=<idmap>[,<idmap>,...]\n\n"
"<idmap> := <dev-id>=<mtd-id>\n"
- "<dev-id> := 'nand'|'nor'<dev-num>\n"
+ "<dev-id> := 'nand'|'nor'|'onenand'<dev-num>\n"
"<dev-num> := mtd device number, 0...\n"
"<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
"'mtdparts' - partition list\n\n"
diff --git a/common/cmd_load.c b/common/cmd_load.c
index f2b73bd..65a4d69 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,12 +53,12 @@ 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;
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,9 +70,9 @@ 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_strtoul(argv[1], NULL, 16);
+ offset = simple_strtol(argv[1], NULL, 16);
}
if (argc == 3) {
load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
@@ -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_strtoul(argv[1], NULL, 16);
+ 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);
@@ -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 */
@@ -167,7 +167,7 @@ load_serial (ulong 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_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 <common.h>
#include <command.h>
-#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 */
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4766c24..400cfd7 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -37,37 +37,6 @@
#endif
#include <watchdog.h>
-#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
#define PRINTF(fmt,args...) printf (fmt ,##args)
#else
@@ -414,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
@@ -494,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
){
@@ -694,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[])
@@ -704,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;
@@ -712,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
@@ -738,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) {
@@ -753,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);
@@ -1206,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:
@@ -1227,7 +1195,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",
@@ -1336,6 +1303,3 @@ U_BOOT_CMD(
"srcaddr dstaddr [dstsize]\n"
);
#endif /* CONFIG_CMD_UNZIP */
-
-#endif
-#endif
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",
"<num> reset - Reset cpu <num>\n"
"cpu <num> status - Status of cpu <num>\n"
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index b94a2bf..0a366d3 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;
@@ -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"
@@ -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_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);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 7089706..85025da 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -52,15 +52,15 @@
DECLARE_GLOBAL_DATA_PTR;
-#if !defined(CFG_ENV_IS_IN_NVRAM) && \
- !defined(CFG_ENV_IS_IN_EEPROM) && \
- !defined(CFG_ENV_IS_IN_FLASH) && \
- !defined(CFG_ENV_IS_IN_DATAFLASH) && \
- !defined(CFG_ENV_IS_IN_NAND) && \
- !defined(CFG_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}
+#if !defined(CONFIG_ENV_IS_IN_NVRAM) && \
+ !defined(CONFIG_ENV_IS_IN_EEPROM) && \
+ !defined(CONFIG_ENV_IS_IN_FLASH) && \
+ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
+ !defined(CONFIG_ENV_IS_IN_NAND) && \
+ !defined(CONFIG_ENV_IS_IN_ONENAND) && \
+ !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
+ !defined(CONFIG_ENV_IS_NOWHERE)
+# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}
#endif
#define XMK_STR(x) #x
@@ -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]))
@@ -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 */
}
/*
@@ -416,9 +422,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 +470,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;
@@ -503,7 +509,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 +529,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);
}
}
@@ -540,11 +546,11 @@ 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(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \
|| (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \
|| (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \
|| (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \
- && !defined(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;
@@ -580,7 +586,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 +594,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"
@@ -596,11 +602,11 @@ U_BOOT_CMD(
" - delete environment variable 'name'\n"
);
-#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_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))) \
- && !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",
@@ -612,7 +618,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 +635,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 8968701..67ff2fb 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -35,8 +35,6 @@
#include <asm/io.h>
#include <pci.h>
-extern int cmd_get_data_size(char* arg, int default_size);
-
unsigned char ShortPCIListing = 1;
/*
@@ -50,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_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 <common.h>
#include <command.h>
-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/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 <sata.h>
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;i<CFG_SCSI_MAX_DEVICE;i++) {
+ for(i=0;i<CONFIG_SYS_SCSI_MAX_DEVICE;i++) {
scsi_dev_desc[i].target=0xff;
scsi_dev_desc[i].lun=0xff;
scsi_dev_desc[i].lba=0;
@@ -104,9 +104,9 @@ void scsi_scan(int mode)
scsi_dev_desc[i].block_read=scsi_read;
}
scsi_max_devs=0;
- for(i=0;i<CFG_SCSI_MAX_SCSI_ID;i++) {
+ for(i=0;i<CONFIG_SYS_SCSI_MAX_SCSI_ID;i++) {
pccb->target=i;
- for(lun=0;lun<CFG_SCSI_MAX_LUN;lun++) {
+ for(lun=0;lun<CONFIG_SYS_SCSI_MAX_LUN;lun++) {
pccb->lun=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; ++i) {
+ for (i=0; i<CONFIG_SYS_SCSI_MAX_DEVICE; ++i) {
if(scsi_dev_desc[i].type==DEV_TYPE_UNKNOWN)
continue; /* list only known devices */
printf ("SCSI dev. %d: ", i);
@@ -365,7 +365,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
if (strncmp(argv[1],"dev",3) == 0) {
- if ((scsi_curr_dev < 0) || (scsi_curr_dev >= 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; ++dev) {
+ for (ok=0, dev=0; dev<CONFIG_SYS_SCSI_MAX_DEVICE; ++dev) {
if (scsi_dev_desc[dev].type!=DEV_TYPE_UNKNOWN) {
ok++;
if (dev)
@@ -398,7 +398,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strncmp(argv[1],"dev",3) == 0) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf ("\nSCSI device %d: ", dev);
- if (dev >= CFG_SCSI_MAX_DEVICE) {
+ if (dev >= CONFIG_SYS_SCSI_MAX_DEVICE) {
printf("unknown device\n");
return 1;
}
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");
}
diff --git a/common/cmd_strings.c b/common/cmd_strings.c
index bbf56a0..7d05cf8 100644
--- a/common/cmd_strings.c
+++ b/common/cmd_strings.c
@@ -10,8 +10,6 @@
#include <common.h>
#include <command.h>
-#ifdef CONFIG_CFG_STRINGS
-
static char *start_addr, *last_addr;
int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -31,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);
@@ -45,5 +44,3 @@ U_BOOT_CMD(strings, 3, 1, do_strings,
"strings - display strings\n",
"<addr> [byte count]\n"
" - display strings at <addr> for at least [byte count] or first double NUL\n");
-
-#endif
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
new file mode 100644
index 0000000..5c31f7b
--- /dev/null
+++ b/common/cmd_ubi.c
@@ -0,0 +1,620 @@
+/*
+ * Unsorted Block Image commands
+ *
+ * Copyright (C) 2008 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * Copyright 2008 Stefan Roese <sr@denx.de>, 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 <common.h>
+#include <command.h>
+#include <exports.h>
+
+#include <nand.h>
+#include <onenand_uboot.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <ubi_uboot.h>
+#include <asm/errno.h>
+#include <jffs2/load_kernel.h>
+
+#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;
+static char buffer[80];
+static int ubi_initialized;
+
+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 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;
+ 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;
+
+ memcpy(buf, tbuf, len);
+
+ 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;
+ 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;
+ }
+
+ ubi_initialized = 1;
+
+ 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;
+
+ /*
+ * 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)
+ 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_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");
+ 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);
+ ubi_dev.type = DEV_TYPE_NONE;
+ 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) {
+ size = simple_strtoul(argv[3], NULL, 16);
+ 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);
+ size = simple_strtoul(argv[4], NULL, 16);
+
+ 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) {
+ size = simple_strtoul(argv[4], NULL, 16);
+ 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|nor|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"
+);
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index c62ca97..8b19240 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("%s",usb_get_class_desc(dclass));
+ 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");
+ 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;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];
+ 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;i<dev->maxchild;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;i<dev->parent->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++<dev->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;i<dev->maxchild;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;
@@ -321,96 +354,99 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
switch (argc) {
case 1:
- addr = CFG_LOAD_ADDR;
- boot_device = getenv ("bootdevice");
+ addr = CONFIG_SYS_LOAD_ADDR;
+ 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;d<USB_MAX_DEVICE;d++) {
- dev=usb_get_dev_index(d);
- if (dev==NULL)
+ if (argc == 2) {
+ for (d = 0; d < USB_MAX_DEVICE; d++) {
+ dev = usb_get_dev_index(d);
+ if (dev == NULL)
break;
usb_display_desc(dev);
usb_display_config(dev);
}
return 0;
- }
- else {
+ } else {
int d;
- i=simple_strtoul(argv[2], NULL, 16);
- printf("config for device %d\n",i);
- for(d=0;d<USB_MAX_DEVICE;d++) {
- dev=usb_get_dev_index(d);
- if (dev==NULL)
+ i = simple_strtoul(argv[2], NULL, 16);
+ printf("config for device %d\n", i);
+ for (d = 0; d < USB_MAX_DEVICE; d++) {
+ dev = usb_get_dev_index(d);
+ if (dev == NULL)
break;
- if (dev->devnum==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);
}
@@ -542,37 +579,28 @@ 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) {
+ 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; devno<USB_MAX_STOR_DEV; ++devno) {
- stor_dev=usb_stor_get_dev(devno);
- if (stor_dev->type!=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 +610,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 +635,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 +673,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/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 */
diff --git a/common/command.c b/common/command.c
index 861796d..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,26 +325,26 @@ 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
*/
-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[])
@@ -564,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;
@@ -577,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);
@@ -625,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;
}
@@ -654,3 +660,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
diff --git a/common/console.c b/common/console.c
index cfcaeb8..89aeab6 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)
{
@@ -93,13 +93,83 @@ 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, ...)
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, 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,20 +228,28 @@ 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, ...)
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, fmt);
@@ -162,6 +267,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 +283,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 +304,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 +325,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);
@@ -218,7 +343,7 @@ void printf (const char *fmt, ...)
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, fmt);
@@ -235,7 +360,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.
@@ -294,7 +419,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));
@@ -378,15 +503,18 @@ 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 */
+#ifdef CONFIG_CONSOLE_MUX
+ int iomux_err = 0;
+#endif
/* set default handlers at first */
gd->jt[XF_getc] = serial_getc;
@@ -405,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) {
@@ -418,47 +554,78 @@ 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 CFG_CONSOLE_INFO_QUIET
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
/* Print information */
puts ("In: ");
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 /* 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 */
@@ -468,7 +635,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)
@@ -504,16 +671,23 @@ 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 */
-#ifndef CFG_CONSOLE_INFO_QUIET
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
/* Print information */
puts ("In: ");
if (stdio_devices[stdin] == NULL) {
@@ -535,7 +709,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++) {
@@ -551,4 +725,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
deleted file mode 100644
index 479bebb..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 <common.h> /* core U-Boot definitions */
-#include <altera.h>
-#include <ACEX1K.h> /* 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 CFG_FPGA_WAIT
-#define CFG_FPGA_WAIT CFG_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 CFG_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) > CFG_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 CFG_FPGA_PROG_FEEDBACK
- puts(" OK? ...");
-#endif
-
- CONFIG_FPGA_DELAY ();
-
-#ifdef CFG_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 CFG_FPGA_PROG_FEEDBACK
- puts(" OK\n");
-#endif
-
- ret_val = FPGA_SUCCESS;
-
-#ifdef CFG_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/devices.c b/common/devices.c
index 2977436..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");
@@ -130,17 +130,39 @@ 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_tail(&(_dev->list), &(devs.list));
return 0;
}
/* 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;
@@ -175,7 +197,7 @@ int device_deregister(char *devname)
}
return 0;
}
-#endif /* CFG_DEVICE_DEREGISTER */
+#endif /* CONFIG_SYS_DEVICE_DEREGISTER */
int devices_init (void)
{
@@ -194,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 d51c211..6be3bb0 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -91,14 +91,20 @@ 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
#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"
@@ -133,8 +139,8 @@ uchar default_environment[] = {
"\0"
};
-#if defined(CFG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \
- || defined(CFG_ENV_IS_IN_SPI_FLASH)
+#if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \
+ || defined(CONFIG_ENV_IS_IN_SPI_FLASH)
int default_environment_size = sizeof(default_environment);
#endif
@@ -214,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 ();
@@ -241,12 +247,12 @@ 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
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_dataflash.c b/common/env_dataflash.c
index 2945364..fed919e 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -18,9 +18,6 @@
*
*/
#include <common.h>
-
-#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -44,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);
}
/************************************************************************
@@ -77,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;
@@ -100,5 +97,3 @@ int env_init(void)
return (0);
}
-
-#endif /* CFG_ENV_IS_IN_DATAFLASH */
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 9e1a201..1578d61 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -25,9 +25,6 @@
*/
#include <common.h>
-
-#if defined(CFG_ENV_IS_IN_EEPROM) /* Environment is in EEPROM */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -42,8 +39,8 @@ uchar env_get_char_spec (int index)
{
uchar c;
- eeprom_read (CFG_DEF_EEPROM_ADDR,
- CFG_ENV_OFFSET+index+offsetof(env_t,data),
+ eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR,
+ CONFIG_ENV_OFFSET+index+offsetof(env_t,data),
&c, 1);
return (c);
@@ -51,18 +48,18 @@ uchar env_get_char_spec (int index)
void env_relocate_spec (void)
{
- eeprom_read (CFG_DEF_EEPROM_ADDR,
- CFG_ENV_OFFSET,
+ eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR,
+ 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,
+ return eeprom_write (CONFIG_SYS_DEF_EEPROM_ADDR,
+ CONFIG_ENV_OFFSET,
(uchar *)env_ptr,
- CFG_ENV_SIZE);
+ CONFIG_ENV_SIZE);
}
/************************************************************************
@@ -80,8 +77,8 @@ int env_init(void)
eeprom_init (); /* prepare for EEPROM read/write */
/* read old CRC */
- eeprom_read (CFG_DEF_EEPROM_ADDR,
- CFG_ENV_OFFSET+offsetof(env_t,crc),
+ eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR,
+ CONFIG_ENV_OFFSET+offsetof(env_t,crc),
(uchar *)&crc, sizeof(ulong));
new = 0;
@@ -90,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 (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n);
new = crc32 (new, buf, n);
len -= n;
off += n;
@@ -106,5 +103,3 @@ int env_init(void)
return (0);
}
-
-#endif /* CFG_ENV_IS_IN_EEPROM */
diff --git a/common/environment.c b/common/env_embedded.c
index 3b9914f..ae6cac4 100644
--- a/common/environment.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
{
@@ -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
@@ -144,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"
@@ -180,7 +186,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 +194,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 +209,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 a92160d..75ee8dd 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -27,9 +27,6 @@
/* #define DEBUG */
#include <common.h>
-
-#if defined(CFG_ENV_IS_IN_FLASH) /* Environment is in Flash */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -39,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
@@ -62,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;
@@ -94,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)
{
@@ -145,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
@@ -163,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) {
@@ -173,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
@@ -209,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;
@@ -245,7 +242,7 @@ Done:
}
#endif /* CMD_SAVEENV */
-#else /* ! CFG_ENV_ADDR_REDUND */
+#else /* ! CONFIG_ENV_ADDR_REDUND */
int env_init(void)
{
@@ -267,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;
@@ -332,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;
@@ -377,11 +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 */
}
-
-#endif /* CFG_ENV_IS_IN_FLASH */
diff --git a/common/env_nand.c b/common/env_nand.c
index a8f0de7..8af9e74 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -33,9 +33,6 @@
/* #define DEBUG */
#include <common.h>
-
-#if defined(CFG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -44,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,
@@ -110,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);
@@ -157,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 {
@@ -178,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;
@@ -191,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");
@@ -226,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;
}
@@ -255,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 {
@@ -280,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)
@@ -294,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);
@@ -339,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.
@@ -349,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();
@@ -357,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()
@@ -366,5 +363,3 @@ static void use_default()
set_default_env();
}
#endif
-
-#endif /* CFG_ENV_IS_IN_NAND */
diff --git a/common/env_nowhere.c b/common/env_nowhere.c
index 17ecc77..78e8f8e 100644
--- a/common/env_nowhere.c
+++ b/common/env_nowhere.c
@@ -25,9 +25,6 @@
*/
#include <common.h>
-
-#if defined(CFG_ENV_IS_NOWHERE) /* Environment is nowhere */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -61,5 +58,3 @@ int env_init(void)
return (0);
}
-
-#endif /* CFG_ENV_IS_NOWHERE) */
diff --git a/common/env_nvram.c b/common/env_nvram.c
index fa77719..562edd0 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -35,27 +35,24 @@
* 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.
*/
#include <common.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#ifdef CFG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
-#ifdef CFG_NVRAM_ACCESS_ROUTINE
+DECLARE_GLOBAL_DATA_PTR;
+
+#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;
#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,10 +63,10 @@ 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, CFG_ENV_ADDR+index, 1);
+ nvram_read(&c, CONFIG_ENV_ADDR+index, 1);
return c;
#else
@@ -83,10 +80,10 @@ 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, CFG_ENV_ADDR+index, 1);
+ nvram_read(&c, CONFIG_ENV_ADDR+index, 1);
return c;
#else
@@ -97,10 +94,10 @@ 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);
+#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
+ 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
}
@@ -110,10 +107,10 @@ int saveenv (void)
#ifdef CONFIG_AMIGAONEG3SE
enable_nvram();
#endif
-#ifdef CFG_NVRAM_ACCESS_ROUTINE
- nvram_write(CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE);
+#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
+ 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,14 +131,14 @@ 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, 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);
@@ -156,5 +153,3 @@ int env_init (void)
#endif
return (0);
}
-
-#endif /* CFG_ENV_IS_IN_NVRAM */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index d5c907c..dbccc79 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -22,9 +22,6 @@
*/
#include <common.h>
-
-#if defined(CFG_ENV_IS_IN_ONENAND) /* Environment is in OneNAND */
-
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
@@ -65,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)
@@ -92,14 +89,15 @@ 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;
+ instr.mtd = &onenand_mtd;
if (onenand_erase(&onenand_mtd, &instr)) {
printf("OneNAND: erase failed at 0x%08lx\n", env_addr);
return 1;
@@ -126,5 +124,3 @@ int env_init(void)
return 0;
}
-
-#endif /* CFG_ENV_IS_IN_ONENAND */
diff --git a/common/env_sf.c b/common/env_sf.c
index 9077d78..2f52e25 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -26,23 +26,21 @@
* MA 02111-1307 USA
*/
#include <common.h>
-
-#ifdef CFG_ENV_IS_IN_SPI_FLASH
-
#include <environment.h>
+#include <malloc.h>
#include <spi_flash.h>
-#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;
@@ -63,41 +61,71 @@ 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;
}
- if (CFG_ENV_SIZE > CFG_ENV_SECT_SIZE) {
- sector = CFG_ENV_SIZE / CFG_ENV_SECT_SIZE;
- if (CFG_ENV_SIZE % CFG_ENV_SECT_SIZE)
+ /* 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)
sector++;
}
puts("Erasing SPI flash...");
- if (spi_flash_erase(env_flash, CFG_ENV_OFFSET, sector * CFG_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, CFG_ENV_OFFSET, CFG_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)
{
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;
@@ -115,7 +143,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;
@@ -135,5 +163,3 @@ int env_init(void)
return 0;
}
-
-#endif /* CFG_ENV_IS_IN_SPI_FLASH */
diff --git a/common/fdt_support.c b/common/fdt_support.c
index a7773ab..5a83bca 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
@@ -165,7 +192,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 +242,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)
@@ -577,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);
@@ -595,3 +623,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
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 <common.h>
#include <flash.h>
-#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]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
+ for (i=0, info = &flash_info[0]; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {
if (info->flash_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/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 <common.h> /* core U-Boot definitions */
-#include <xilinx.h> /* xilinx specific definitions */
-#include <altera.h> /* 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/hush.c b/common/hush.c
index 093c428..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 <ctype.h> /* isalpha, isdigit */
#include <unistd.h> /* getpid */
@@ -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
@@ -1023,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
@@ -1037,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) {
@@ -1079,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);
@@ -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;
}
-#endif /* CFG_HUSH_PARSER */
+#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, CONFIG_SYS_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 /* CONFIG_SYS_HUSH_PARSER */
/****************************************************************************/
diff --git a/common/image.c b/common/image.c
index 55c4cce..daa68bc 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", },
@@ -119,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", },
@@ -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, "", "", },
};
@@ -425,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
@@ -439,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);
@@ -662,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 ();
@@ -749,7 +750,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 +937,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)
@@ -1069,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)
@@ -1152,8 +1155,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
/**
@@ -1188,7 +1191,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;
@@ -1200,8 +1203,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 */
@@ -1211,9 +1214,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");
@@ -1238,7 +1241,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);
@@ -1516,7 +1519,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;
}
@@ -1562,7 +1565,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;
@@ -1573,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
@@ -1596,8 +1600,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;
@@ -1633,7 +1637,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;
@@ -1850,7 +1854,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
@@ -1909,14 +1916,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)
@@ -2644,27 +2654,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 ("+ ");
@@ -2681,6 +2693,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
@@ -2791,7 +2852,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
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 <common.h>
+#include <serial.h>
+#include <malloc.h>
+
+#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 */
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..ae79051 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -32,7 +32,6 @@
#include <config.h>
#include <common.h>
#include <command.h>
-#include <version.h>
#include <stdarg.h>
#include <linux/types.h>
#include <devices.h>
@@ -52,7 +51,6 @@
#if defined(CONFIG_ATMEL_LCD)
#include <atmel_lcdc.h>
-#include <nand.h>
#endif
/************************************************************************/
@@ -225,6 +223,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 */
/************************************************************************/
@@ -386,13 +398,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();
@@ -426,6 +438,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 ();
@@ -436,7 +449,6 @@ static int lcd_init (void *lcdbase)
#else
console_row = 1; /* leave 1 blank line below logo */
#endif
- lcd_is_enabled = 1;
return 0;
}
@@ -531,7 +543,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 +583,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 +639,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 +693,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;
@@ -748,15 +760,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;
@@ -786,75 +789,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 < CFG_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));
diff --git a/common/main.c b/common/main.c
index 187ef8a..a999a5d 100644
--- a/common/main.c
+++ b/common/main.c
@@ -34,7 +34,7 @@
#include <malloc.h> /* for free() prototype */
#endif
-#ifdef CFG_HUSH_PARSER
+#ifdef CONFIG_SYS_HUSH_PARSER
#include <hush.h>
#endif
@@ -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
@@ -65,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 */
@@ -269,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;
@@ -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++;
@@ -330,10 +337,14 @@ void main_loop (void)
}
#endif /* CONFIG_VERSION_VARIABLE */
-#ifdef CFG_HUSH_PARSER
+#ifdef CONFIG_SYS_HUSH_PARSER
u_boot_hush_start ();
#endif
+#if defined(CONFIG_HUSH_INIT_VAR)
+ hush_init_var ();
+#endif
+
#ifdef CONFIG_AUTO_COMPLETE
install_auto_complete();
#endif
@@ -344,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 |
@@ -390,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 |
@@ -406,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 |
@@ -427,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 (;;);
@@ -441,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)
@@ -472,7 +483,7 @@ void main_loop (void)
lastcommand[0] = 0;
}
}
-#endif /*CFG_HUSH_PARSER*/
+#endif /*CONFIG_SYS_HUSH_PARSER*/
}
#ifdef CONFIG_BOOT_RETRY_TIME
@@ -1031,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 */
@@ -1100,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')) {
@@ -1133,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);
@@ -1148,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 '{' */
@@ -1208,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 */
@@ -1259,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:
@@ -1273,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;
@@ -1295,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;
}
@@ -1414,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
deleted file mode 100644
index ebac388..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 <common.h> /* core U-Boot definitions */
-#include <spartan2.h> /* 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 CFG_FPGA_CHECK_BUSY
-#undef CFG_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 CFG_FPGA_WAIT
-#define CFG_FPGA_WAIT CFG_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 CFG_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) > CFG_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 CFG_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) > CFG_FPGA_WAIT) { /* check the time */
- puts ("** Timeout waiting for BUSY to clear.\n");
- (*fn->abort) (cookie); /* abort the burn */
- return FPGA_FAIL;
- }
- }
-#endif
-
-#ifdef CFG_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 CFG_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) > CFG_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 CFG_FPGA_PROG_FEEDBACK
- puts ("Done.\n");
-#endif
- }
- /*
- * Run the post configuration function if there is one.
- */
- if (*fn->post) {
- (*fn->post) (cookie);
- }
-
- else {
-#ifdef CFG_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 CFG_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 CFG_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 CFG_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) > CFG_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) > CFG_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 CFG_FPGA_PROG_FEEDBACK
- if (bytecount % (bsize / 40) == 0)
- putc ('.'); /* let them know we are alive */
-#endif
- }
-
- CONFIG_FPGA_DELAY ();
-
-#ifdef CFG_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) > CFG_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 CFG_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 8f1ab80..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 <common.h> /* core U-Boot definitions */
-#include <spartan3.h> /* 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 CFG_FPGA_CHECK_BUSY
-#undef CFG_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 CFG_FPGA_WAIT
-#define CFG_FPGA_WAIT CFG_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 CFG_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) > CFG_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 CFG_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) > CFG_FPGA_WAIT) { /* check the time */
- puts ("** Timeout waiting for BUSY to clear.\n");
- (*fn->abort) (cookie); /* abort the burn */
- return FPGA_FAIL;
- }
- }
-#endif
-
-#ifdef CFG_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 CFG_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) > CFG_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 CFG_FPGA_PROG_FEEDBACK
- puts ("Done.\n");
-#endif
- }
- /*
- * Run the post configuration function if there is one.
- */
- if (*fn->post) {
- (*fn->post) (cookie);
- }
-
- else {
-#ifdef CFG_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 CFG_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 CFG_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 CFG_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) > CFG_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) > CFG_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 CFG_FPGA_PROG_FEEDBACK
- if (bytecount % (bsize / 40) == 0)
- putc ('.'); /* let them know we are alive */
-#endif
- }
-
- CONFIG_FPGA_DELAY ();
-
-#ifdef CFG_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) > CFG_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 CFG_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 <common.h> /* core U-Boot definitions */
-#include <altera.h>
-
-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/update.c b/common/update.c
new file mode 100644
index 0000000..7528474
--- /dev/null
+++ b/common/update.c
@@ -0,0 +1,315 @@
+/*
+ * (C) Copyright 2008 Semihalf
+ *
+ * Written by: Rafal Czubak <rcz@semihalf.com>
+ * Bartlomiej Sieka <tur@semihalf.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 <common.h>
+
+#if !(defined(CONFIG_FIT) && defined(CONFIG_OF_LIBFDT))
+#error "CONFIG_FIT and CONFIG_OF_LIBFDT are required for auto-update feature"
+#endif
+
+#if defined(CONFIG_SYS_NO_FLASH)
+#error "CONFIG_SYS_NO_FLASH defined, but FLASH is required for auto-update feature"
+#endif
+
+#include <command.h>
+#include <flash.h>
+#include <net.h>
+#include <malloc.h>
+
+/* 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(CONFIG_SYS_MAX_FLASH_BANKS * CONFIG_SYS_MAX_FLASH_SECT, 1);
+ if (!saved_prot_info)
+ return 1;
+ }
+
+ for (bank = 0; bank < CONFIG_SYS_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 * CONFIG_SYS_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(CONFIG_SYS_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;
+}
diff --git a/common/usb.c b/common/usb.c
index 9502f39..ee18152 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
@@ -80,17 +80,19 @@ 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
*/
-void __inline__ wait_ms(unsigned long ms)
+inline void wait_ms(unsigned long ms)
{
- while(ms-->0)
+ while (ms-- > 0)
udelay(1000);
}
+
/***************************************************************************
* Init USB Device
*/
@@ -99,22 +101,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;
@@ -126,10 +128,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;
}
/*
@@ -138,7 +145,7 @@ int usb_stop(void)
*/
void usb_disable_asynch(int disable)
{
- asynch_allowed=!disable;
+ asynch_allowed = !disable;
}
@@ -151,9 +158,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);
}
/*
@@ -170,8 +177,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;
@@ -179,24 +188,25 @@ 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))
- 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;
}
/*-------------------------------------------------------------------
@@ -209,15 +219,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;
@@ -232,12 +242,54 @@ 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 */
- return(dev->epmaxpacketout[((pipe>>15) & 0xf)]);
+ /* 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)]);
+ 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 */
}
/*
@@ -245,35 +297,13 @@ int usb_maxpacket(struct usb_device *dev,unsigned long pipe)
*/
int usb_set_maxpacket(struct usb_device *dev)
{
- int i,ii,b;
- struct usb_endpoint_descriptor *ep;
+ int i, ii;
- for(i=0; i<dev->config.bNumInterfaces;i++) {
- for(ii=0; ii<dev->config.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;
}
@@ -294,8 +324,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]);
@@ -303,45 +334,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];
@@ -360,7 +398,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)
@@ -382,7 +421,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),
@@ -395,32 +435,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];
- result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8);
- if (result < 8) {
+ config = (struct usb_config_descriptor *)&buffer[0];
+ 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);
+ 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", 9, 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;
}
@@ -432,11 +476,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;
}
@@ -460,16 +504,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;
@@ -481,18 +528,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;
}
@@ -519,11 +565,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);
}
/********************************************************************
@@ -540,7 +588,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;
@@ -631,17 +680,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);
}
}
@@ -673,9 +724,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];
@@ -685,21 +736,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;i<USB_MAXCHILDREN;i++)
- usb_dev[dev_index].children[i]=NULL;
- usb_dev[dev_index].parent=NULL;
+ /* default Address is 0, real addresses start with 1 */
+ usb_dev[dev_index].devnum = dev_index + 1;
+ usb_dev[dev_index].maxchild = 0;
+ for (i = 0; i < USB_MAXCHILDREN; i++)
+ usb_dev[dev_index].children[i] = NULL;
+ usb_dev[dev_index].parent = NULL;
dev_index++;
- return &usb_dev[dev_index-1];
+ return &usb_dev[dev_index - 1];
}
@@ -716,23 +768,35 @@ 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
- /* 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:
- * http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398
+#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 = PACKET_SIZE_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);
+ return 1;
+ }
+#else
+ /* 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;
@@ -741,21 +805,26 @@ 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;
- 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;
- }
+ 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->epmaxpacketout[0] = 64;
+
+ 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) {
@@ -764,7 +833,7 @@ int usb_new_device(struct usb_device *dev)
}
}
if (port < 0) {
- printf("usb_new_device: cannot locate device's port..\n");
+ printf("usb_new_device:cannot locate device's port.\n");
return 1;
}
@@ -775,29 +844,31 @@ 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;
+ 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;
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;
}
@@ -805,12 +876,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 */
@@ -819,30 +893,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;
}
@@ -853,15 +932,15 @@ void usb_scan_devices(void)
struct usb_device *dev;
/* first make all devices unknown */
- for(i=0;i<USB_MAX_DEVICE;i++) {
- memset(&usb_dev[i],0,sizeof(struct usb_device));
+ for (i = 0; i < USB_MAX_DEVICE; i++) {
+ memset(&usb_dev[i], 0, sizeof(struct usb_device));
usb_dev[i].devnum = -1;
}
- dev_index=0;
+ dev_index = 0;
/* device 0 is always present (root hub, so let it analyze) */
- dev=usb_alloc_new_device();
+ dev = usb_alloc_new_device();
usb_new_device(dev);
- printf("%d USB Device(s) found\n",dev_index);
+ printf("%d USB Device(s) found\n", dev_index);
/* insert "driver" if possible */
#ifdef CONFIG_USB_KEYBOARD
drv_usb_kbd_init();
@@ -878,9 +957,9 @@ 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...)
+#define USB_HUB_PRINTF(fmt, args...)
#endif
@@ -898,19 +977,22 @@ int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size)
int usb_clear_hub_feature(struct usb_device *dev, int feature)
{
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, USB_CNTL_TIMEOUT);
+ USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature,
+ 0, NULL, 0, USB_CNTL_TIMEOUT);
}
int usb_clear_port_feature(struct usb_device *dev, int port, int feature)
{
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port, NULL, 0, USB_CNTL_TIMEOUT);
+ USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature,
+ port, NULL, 0, USB_CNTL_TIMEOUT);
}
int usb_set_port_feature(struct usb_device *dev, int port, int feature)
{
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port, NULL, 0, USB_CNTL_TIMEOUT);
+ USB_REQ_SET_FEATURE, USB_RT_PORT, feature,
+ port, NULL, 0, USB_CNTL_TIMEOUT);
}
int usb_get_hub_status(struct usb_device *dev, void *data)
@@ -933,27 +1015,27 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
int i;
struct usb_device *dev;
- dev=hub->pusb_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_index<USB_MAX_HUB) {
+ if (usb_hub_index < USB_MAX_HUB)
return &hub_dev[usb_hub_index++];
- }
- printf("ERROR: USB_MAX_HUB (%d) reached\n",USB_MAX_HUB);
+
+ printf("ERROR: USB_MAX_HUB (%d) reached\n", USB_MAX_HUB);
return NULL;
}
@@ -966,39 +1048,42 @@ static int hub_port_reset(struct usb_device *dev, int port,
struct usb_port_status portsts;
unsigned short portstatus, portchange;
-
USB_HUB_PRINTF("hub_port_reset: resetting port %d...\n", port);
- for(tries=0;tries<MAX_TRIES;tries++) {
+ for (tries = 0; tries < MAX_TRIES; tries++) {
usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET);
wait_ms(200);
- if (usb_get_port_status(dev, port + 1, &portsts)<0) {
- USB_HUB_PRINTF("get_port_status failed status %lX\n",dev->status);
+ 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<<USB_PORT_FEAT_LOWSPEED) ? "Low Speed" : "High Speed");
- USB_HUB_PRINTF("STAT_C_CONNECTION = %d STAT_CONNECTION = %d USB_PORT_STAT_ENABLE %d\n",
+ USB_HUB_PRINTF("portstatus %x, change %x, %s\n",
+ portstatus, portchange,
+ portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? \
+ "Low Speed" : "High Speed");
+ USB_HUB_PRINTF("STAT_C_CONNECTION = %d STAT_CONNECTION = %d" \
+ " USB_PORT_STAT_ENABLE %d\n",
(portchange & USB_PORT_STAT_C_CONNECTION) ? 1 : 0,
(portstatus & USB_PORT_STAT_CONNECTION) ? 1 : 0,
(portstatus & USB_PORT_STAT_ENABLE) ? 1 : 0);
+
if ((portchange & USB_PORT_STAT_C_CONNECTION) ||
!(portstatus & USB_PORT_STAT_CONNECTION))
return -1;
- if (portstatus & USB_PORT_STAT_ENABLE) {
-
+ if (portstatus & USB_PORT_STAT_ENABLE)
break;
- }
wait_ms(200);
}
- if (tries==MAX_TRIES) {
- USB_HUB_PRINTF("Cannot enable port %i after %i retries, disabling port.\n", port+1, MAX_TRIES);
+ if (tries == MAX_TRIES) {
+ USB_HUB_PRINTF("Cannot enable port %i after %i retries, " \
+ "disabling port.\n", port + 1, MAX_TRIES);
USB_HUB_PRINTF("Maybe the USB cable is bad?\n");
return -1;
}
@@ -1006,7 +1091,6 @@ static int hub_port_reset(struct usb_device *dev, int port,
usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_RESET);
*portstat = portstatus;
return 0;
-
}
@@ -1017,22 +1101,24 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
unsigned short portstatus, portchange;
/* Check status */
- if (usb_get_port_status(dev, port + 1, &portsts)<0) {
+ if (usb_get_port_status(dev, port + 1, &portsts) < 0) {
USB_HUB_PRINTF("get_port_status failed\n");
return;
}
portstatus = le16_to_cpu(portsts.wPortStatus);
portchange = le16_to_cpu(portsts.wPortChange);
- USB_HUB_PRINTF("portstatus %x, change %x, %s\n", portstatus, portchange,
- portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? "Low Speed" : "High Speed");
+ USB_HUB_PRINTF("portstatus %x, change %x, %s\n",
+ portstatus, portchange,
+ portstatus&(1 << USB_PORT_FEAT_LOWSPEED) ? \
+ "Low Speed" : "High Speed");
/* Clear the connection change status */
usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_CONNECTION);
/* Disconnect any existing devices under this port */
if (((!(portstatus & USB_PORT_STAT_CONNECTION)) &&
- (!(portstatus & USB_PORT_STAT_ENABLE)))|| (dev->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))
@@ -1049,11 +1135,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 */
@@ -1072,13 +1158,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;
@@ -1086,43 +1173,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)
@@ -1131,40 +1223,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;
@@ -1173,41 +1277,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 */
@@ -1241,7 +1355,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;
}
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 108bd60..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
}
@@ -162,6 +162,8 @@ int drv_usb_kbd_init(void)
/* scan all USB Devices */
for(i=0;i<USB_MAX_DEVICE;i++) {
dev=usb_get_dev_index(i); /* get device */
+ if(dev == NULL)
+ return -1;
if(dev->devnum!=-1) {
if(usb_kbd_probe(dev,0)==1) { /* Ok, we found a keyboard */
/* check, if it is already registered */
diff --git a/common/virtex2.c b/common/virtex2.c
deleted file mode 100644
index 52da1b2..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 <common.h>
-#include <virtex2.h>
-
-#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
- * CFG_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
-#endif
-
-#ifndef CONFIG_FPGA_DELAY
-#define CONFIG_FPGA_DELAY()
-#endif
-
-#ifndef CFG_FPGA_PROG_FEEDBACK
-#define CFG_FPGA_PROG_FEEDBACK
-#endif
-
-/*
- * Don't allow config cycle to be interrupted
- */
-#ifndef CFG_FPGA_CHECK_CTRLC
-#undef CFG_FPGA_CHECK_CTRLC
-#endif
-
-/*
- * Check for errors during configuration by default
- */
-#ifndef CFG_FPGA_CHECK_ERROR
-#define CFG_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 CFG_FPGA_WAIT_INIT
-#define CFG_FPGA_WAIT_INIT CFG_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 CFG_FPGA_WAIT_BUSY
-#define CFG_FPGA_WAIT_BUSY CFG_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 */
-#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 CFG_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) > CFG_FPGA_WAIT_INIT) {
- printf ("%s:%d: ** Timeout after %d ticks waiting for INIT"
- " to assert.\n", __FUNCTION__, __LINE__,
- CFG_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) > CFG_FPGA_WAIT_INIT) {
- printf ("%s:%d: ** Timeout after %d ticks waiting for INIT"
- " to deassert.\n", __FUNCTION__, __LINE__,
- CFG_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 CFG_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 CFG_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 CFG_FPGA_CHECK_BUSY
- ts = get_timer (0);
- while ((*fn->busy) (cookie)) {
- if (get_timer (ts) > CFG_FPGA_WAIT_BUSY) {
- printf ("%s:%d: ** Timeout after %d ticks waiting for"
- " BUSY to deassert\n",
- __FUNCTION__, __LINE__, CFG_FPGA_WAIT_BUSY);
- (*fn->abort) (cookie);
- return FPGA_FAIL;
- }
- }
-#endif
-
-#ifdef CFG_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 CFG_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) > CFG_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);
- (*fn->abort) (cookie);
- ret_val = FPGA_FAIL;
- break;
- }
- }
-
- if (ret_val == FPGA_SUCCESS) {
-#ifdef CFG_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 CFG_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 CFG_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 CFG_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 CFG_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 <common.h>
-#include <virtex2.h>
-#include <spartan2.h>
-#include <spartan3.h>
-
-#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;
-}