summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/ACEX1K.c4
-rw-r--r--common/Makefile131
-rw-r--r--common/altera.c18
-rw-r--r--common/cmd_bdinfo.c2
-rw-r--r--common/cmd_bedbug.c3
-rw-r--r--common/cmd_bmp.c4
-rw-r--r--common/cmd_bootm.c2
-rw-r--r--common/cmd_console.c4
-rw-r--r--common/cmd_date.c4
-rw-r--r--common/cmd_dcr.c4
-rw-r--r--common/cmd_diag.c4
-rw-r--r--common/cmd_display.c4
-rw-r--r--common/cmd_doc.c5
-rw-r--r--common/cmd_dtt.c4
-rw-r--r--common/cmd_elf.c4
-rw-r--r--common/cmd_ext2.c4
-rw-r--r--common/cmd_fat.c7
-rw-r--r--common/cmd_fdos.c4
-rw-r--r--common/cmd_fdt.c111
-rw-r--r--common/cmd_flash.c4
-rw-r--r--common/cmd_fpga.c42
-rw-r--r--common/cmd_i2c.c5
-rw-r--r--common/cmd_ide.c24
-rw-r--r--common/cmd_immap.c5
-rw-r--r--common/cmd_itest.c3
-rw-r--r--common/cmd_jffs2.c14
-rw-r--r--common/cmd_log.c4
-rw-r--r--common/cmd_mfsl.c4
-rw-r--r--common/cmd_mii.c12
-rw-r--r--common/cmd_misc.c4
-rw-r--r--common/cmd_mmc.c5
-rw-r--r--common/cmd_nand.c8
-rw-r--r--common/cmd_net.c4
-rw-r--r--common/cmd_pci.c9
-rw-r--r--common/cmd_portio.c4
-rw-r--r--common/cmd_reginfo.c5
-rw-r--r--common/cmd_reiser.c4
-rw-r--r--common/cmd_scsi.c13
-rw-r--r--common/cmd_spi.c4
-rw-r--r--common/cmd_terminal.c102
-rw-r--r--common/cmd_universe.c4
-rw-r--r--common/cmd_usb.c10
-rw-r--r--common/cyclon2.c4
-rw-r--r--common/env_onenand.c4
-rw-r--r--common/fdt_support.c378
-rw-r--r--common/fpga.c30
-rw-r--r--common/main.c26
-rw-r--r--common/miiphyutil.c282
-rw-r--r--common/serial.c10
-rw-r--r--common/spartan2.c24
-rw-r--r--common/spartan3.c24
-rw-r--r--common/usb.c2
-rw-r--r--common/usb_storage.c2
-rw-r--r--common/virtex2.c2
-rw-r--r--common/xilinx.c28
55 files changed, 898 insertions, 534 deletions
diff --git a/common/ACEX1K.c b/common/ACEX1K.c
index 2a421e2..76dc166 100644
--- a/common/ACEX1K.c
+++ b/common/ACEX1K.c
@@ -28,7 +28,7 @@
#include <common.h> /* core U-Boot definitions */
#include <ACEX1K.h> /* ACEX device family */
-#if (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K))
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_ACEX1K)
/* Define FPGA_DEBUG to get debug printf's */
#ifdef FPGA_DEBUG
@@ -363,4 +363,4 @@ static int ACEX1K_ps_reloc (Altera_desc * desc, ulong reloc_offset)
}
-#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K)) */
+#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_ACEX1K */
diff --git a/common/Makefile b/common/Makefile
index fde5ad9..fbfa536 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -27,32 +27,113 @@ LIB = $(obj)libcommon.a
AOBJS =
-COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o cmd_autoscript.o \
- cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o \
- cmd_cache.o cmd_console.o \
- cmd_date.o cmd_dcr.o cmd_diag.o cmd_display.o cmd_doc.o cmd_dtt.o \
- cmd_eeprom.o cmd_elf.o cmd_ext2.o \
- cmd_fat.o cmd_fdc.o cmd_fdt.o cmd_fdos.o cmd_flash.o cmd_fpga.o \
- cmd_i2c.o cmd_ide.o cmd_immap.o cmd_itest.o cmd_jffs2.o \
- cmd_load.o cmd_log.o \
- cmd_mem.o cmd_mii.o cmd_misc.o cmd_mmc.o \
- cmd_nand.o cmd_net.o cmd_nvedit.o \
- cmd_onenand.o \
- cmd_pci.o cmd_pcmcia.o cmd_portio.o \
- cmd_reginfo.o cmd_reiser.o cmd_sata.o cmd_scsi.o cmd_spi.o \
- cmd_universe.o cmd_usb.o cmd_vfd.o \
- command.o console.o cyclon2.o devices.o dlmalloc.o docecc.o \
- environment.o env_common.o \
- env_nand.o env_dataflash.o env_flash.o env_eeprom.o \
- env_onenand.o env_nvram.o env_nowhere.o \
- exports.o \
- fdt_support.o flash.o fpga.o ft_build.o \
- hush.o kgdb.o lcd.o lists.o lynxkdi.o \
- memsize.o miiphybb.o miiphyutil.o \
- s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \
- usb.o usb_kbd.o usb_storage.o \
- virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o cmd_mfsl.o
+COBJS-y += main.o
+COBJS-y += ACEX1K.o
+COBJS-y += altera.o
+COBJS-y += bedbug.o
+COBJS-y += circbuf.o
+COBJS-y += cmd_autoscript.o
+COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o
+COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
+COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
+COBJS-y += cmd_boot.o
+COBJS-y += cmd_bootm.o
+COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
+COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
+COBJS-$(CONFIG_CMD_DATE) += cmd_date.o
+ifdef CONFIG_4xx
+COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
+endif
+ifdef CONFIG_POST
+COBJS-$(CONFIG_CMD_DIAG) += cmd_diag.o
+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_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_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-$(CONFIG_CMD_FPGA) += cmd_fpga.o
+endif
+COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
+COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o
+COBJS-$(CONFIG_CMD_IMMAP) += cmd_immap.o
+COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
+COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
+COBJS-y += cmd_load.o
+COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
+COBJS-y += cmd_mem.o
+COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
+COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
+COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
+COBJS-y += cmd_nand.o
+COBJS-$(CONFIG_CMD_NET) += cmd_net.o
+COBJS-y += cmd_nvedit.o
+COBJS-y += cmd_onenand.o
+ifdef CONFIG_PCI
+COBJS-$(CONFIG_CMD_PCI) += cmd_pci.o
+endif
+COBJS-y += cmd_pcmcia.o
+COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o
+COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
+COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o
+COBJS-y += cmd_sata.o
+COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o
+COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
+COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
+COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
+COBJS-$(CONFIG_CMD_USB) += cmd_usb.o
+COBJS-y += cmd_vfd.o
+COBJS-y += command.o
+COBJS-y += console.o
+COBJS-y += cyclon2.o
+COBJS-y += devices.o
+COBJS-y += dlmalloc.o
+COBJS-y += docecc.o
+COBJS-y += environment.o
+COBJS-y += env_common.o
+COBJS-y += env_nand.o
+COBJS-y += env_dataflash.o
+COBJS-y += env_flash.o
+COBJS-y += env_eeprom.o
+COBJS-y += env_onenand.o
+COBJS-y += env_nvram.o
+COBJS-y += env_nowhere.o
+COBJS-y += exports.o
+COBJS-y += flash.o
+COBJS-y += fpga.o
+COBJS-y += ft_build.o
+COBJS-y += hush.o
+COBJS-y += kgdb.o
+COBJS-y += lcd.o
+COBJS-y += lists.o
+COBJS-y += lynxkdi.o
+COBJS-y += memsize.o
+COBJS-y += miiphybb.o
+COBJS-y += miiphyutil.o
+COBJS-y += s_record.o
+COBJS-y += serial.o
+COBJS-y += soft_i2c.o
+COBJS-y += soft_spi.o
+COBJS-y += spartan2.o
+COBJS-y += spartan3.o
+COBJS-y += usb.o
+COBJS-y += usb_kbd.o
+COBJS-y += usb_storage.o
+COBJS-y += virtex2.o
+COBJS-y += xilinx.o
+COBJS-y += crc16.o
+COBJS-y += xyzModem.o
+COBJS-y += cmd_mac.o
+COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
+COBJS := $(COBJS-y)
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
diff --git a/common/altera.c b/common/altera.c
index 06e8a95..0df7bae 100644
--- a/common/altera.c
+++ b/common/altera.c
@@ -40,7 +40,7 @@
#define PRINTF(fmt,args...)
#endif
-#if (CONFIG_FPGA & CFG_FPGA_ALTERA)
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA)
/* Local Static Functions */
static int altera_validate (Altera_desc * desc, char *fn);
@@ -56,11 +56,11 @@ int altera_load( Altera_desc *desc, void *buf, size_t bsize )
switch (desc->family) {
case Altera_ACEX1K:
case Altera_CYC2:
-#if (CONFIG_FPGA & CFG_ACEX1K)
+#if defined(CONFIG_FPGA_ACEX1K)
PRINTF ("%s: Launching the ACEX1K Loader...\n",
__FUNCTION__);
ret_val = ACEX1K_load (desc, buf, bsize);
-#elif (CONFIG_FPGA & CFG_CYCLON2)
+#elif defined CONFIG_FPGA_CYCLON2
PRINTF ("%s: Launching the CYCLON II Loader...\n",
__FUNCTION__);
ret_val = CYC2_load (desc, buf, bsize);
@@ -88,7 +88,7 @@ int altera_dump( Altera_desc *desc, void *buf, size_t bsize )
} else {
switch (desc->family) {
case Altera_ACEX1K:
-#if (CONFIG_FPGA & CFG_ACEX)
+#if defined(CONFIG_FPGA_ACEX)
PRINTF ("%s: Launching the ACEX1K Reader...\n",
__FUNCTION__);
ret_val = ACEX1K_dump (desc, buf, bsize);
@@ -156,9 +156,9 @@ int altera_info( Altera_desc *desc )
switch (desc->family) {
case Altera_ACEX1K:
case Altera_CYC2:
-#if (CONFIG_FPGA & CFG_ACEX1K)
+#if defined(CONFIG_FPGA_ACEX1K)
ACEX1K_info (desc);
-#elif (CONFIG_FPGA & CFG_CYCLON2)
+#elif defined(CONFIG_FPGA_CYCLON2)
CYC2_info (desc);
#else
/* just in case */
@@ -192,7 +192,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset)
} else {
switch (desc->family) {
case Altera_ACEX1K:
-#if (CONFIG_FPGA & CFG_ACEX1K)
+#if defined(CONFIG_FPGA_ACEX1K)
ret_val = ACEX1K_reloc (desc, reloc_offset);
#else
printf ("%s: No support for ACEX devices.\n",
@@ -200,7 +200,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset)
#endif
break;
case Altera_CYC2:
-#if (CONFIG_FPGA & CFG_CYCLON2)
+#if defined(CONFIG_FPGA_CYCLON2)
ret_val = CYC2_reloc (desc, reloc_offset);
#else
printf ("%s: No support for CYCLON II devices.\n",
@@ -249,4 +249,4 @@ static int altera_validate (Altera_desc * desc, char *fn)
/* ------------------------------------------------------------------------- */
-#endif /* CONFIG_FPGA & CFG_FPGA_ALTERA */
+#endif /* CONFIG_FPGA & CONFIG_FPGA_ALTERA */
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index ef15a00..d059983 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -30,7 +30,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#if defined(CONFIG_CMD_BDI)
static void print_num(const char *, ulong);
#ifndef CONFIG_ARM /* PowerPC and other */
@@ -350,4 +349,3 @@ U_BOOT_CMD(
"bdinfo - print Board Info structure\n",
NULL
);
-#endif
diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c
index 1c3547a..94f7e08 100644
--- a/common/cmd_bedbug.c
+++ b/common/cmd_bedbug.c
@@ -13,8 +13,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#if defined(CONFIG_CMD_BEDBUG)
-
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
@@ -413,7 +411,6 @@ int do_bedbug_rdump (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
U_BOOT_CMD (rdump, 1, 1, do_bedbug_rdump,
"rdump - Show registers.\n", " - Show registers.\n");
/* ====================================================================== */
-#endif
/*
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index 241aa83..907f9a2 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -31,8 +31,6 @@
#include <asm/byteorder.h>
#include <malloc.h>
-#if defined(CONFIG_CMD_BMP)
-
static int bmp_info (ulong addr);
static int bmp_display (ulong addr, int x, int y);
@@ -187,5 +185,3 @@ static int bmp_display(ulong addr, int x, int y)
# error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
#endif
}
-
-#endif /* defined(CONFIG_CMD_BMP) */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d816349..9546729 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -260,6 +260,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (hdr->ih_arch != IH_CPU_NIOS2)
#elif defined(__PPC__)
if (hdr->ih_arch != IH_CPU_PPC)
+#elif defined(__sh__)
+ if (hdr->ih_arch != IH_CPU_SH)
#else
# error Unknown CPU type
#endif
diff --git a/common/cmd_console.c b/common/cmd_console.c
index 5e0f990..50ddb01 100644
--- a/common/cmd_console.c
+++ b/common/cmd_console.c
@@ -28,8 +28,6 @@
#include <command.h>
#include <devices.h>
-#if defined(CONFIG_CMD_CONSOLE)
-
extern void _do_coninfo (void);
int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
@@ -67,5 +65,3 @@ U_BOOT_CMD(
"coninfo - print console devices and information\n",
""
);
-
-#endif
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 4a42534..7511598 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -31,8 +31,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#if defined(CONFIG_CMD_DATE)
-
const char *weekdays[] = {
"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
};
@@ -210,5 +208,3 @@ U_BOOT_CMD(
" - with numeric argument: set the system date & time\n"
" - with 'reset' argument: reset the RTC\n"
);
-
-#endif
diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c
index 12fa9db..a053343 100644
--- a/common/cmd_dcr.c
+++ b/common/cmd_dcr.c
@@ -29,8 +29,6 @@
#include <config.h>
#include <command.h>
-#if defined(CONFIG_4xx) && defined(CONFIG_CMD_SETGETDCR)
-
unsigned long get_dcr (unsigned short);
unsigned long set_dcr (unsigned short, unsigned long);
@@ -245,5 +243,3 @@ U_BOOT_CMD(
"setidcr - Set a register value via indirect DCR addressing\n",
"adr_dcrn[.dat_dcrn] offset value - write offset to adr_dcrn, write value to dat_dcrn.\n"
);
-
-#endif
diff --git a/common/cmd_diag.c b/common/cmd_diag.c
index cb99b77..82d5ad3 100644
--- a/common/cmd_diag.c
+++ b/common/cmd_diag.c
@@ -28,8 +28,6 @@
#include <command.h>
#include <post.h>
-#if defined(CONFIG_CMD_DIAG) && defined(CONFIG_POST)
-
int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
unsigned int i;
@@ -76,5 +74,3 @@ U_BOOT_CMD(
"diag run [test1 [test2]]\n"
" - run specified tests\n"
);
-
-#endif
diff --git a/common/cmd_display.c b/common/cmd_display.c
index d19f412..a29345c 100644
--- a/common/cmd_display.c
+++ b/common/cmd_display.c
@@ -24,8 +24,6 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_DISPLAY)
-
#undef DEBUG_DISP
#define DISP_SIZE 8
@@ -78,5 +76,3 @@ U_BOOT_CMD(
" - with <string> argument: display <string> on dot matrix display\n"
" - without arguments: clear dot matrix display\n"
);
-
-#endif
diff --git a/common/cmd_doc.c b/common/cmd_doc.c
index d6d3aff..3d717c0 100644
--- a/common/cmd_doc.c
+++ b/common/cmd_doc.c
@@ -11,9 +11,6 @@
#include <command.h>
#include <malloc.h>
#include <asm/io.h>
-
-#if defined(CONFIG_CMD_DOC)
-
#include <linux/mtd/nftl.h>
#include <linux/mtd/doc2000.h>
@@ -1607,5 +1604,3 @@ void doc_probe(unsigned long physadr)
puts ("No DiskOnChip found\n");
}
}
-
-#endif
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index 804d467..956dc69 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -25,8 +25,6 @@
#include <config.h>
#include <command.h>
-#if defined(CONFIG_CMD_DTT)
-
#include <dtt.h>
#include <i2c.h>
@@ -60,5 +58,3 @@ U_BOOT_CMD(
"dtt - Digital Thermometer and Thermostat\n",
" - Read temperature from digital thermometer and thermostat.\n"
);
-
-#endif
diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 63a5593..2eb7453 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -23,8 +23,6 @@
DECLARE_GLOBAL_DATA_PTR;
#endif
-#if defined(CONFIG_CMD_ELF)
-
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
@@ -323,5 +321,3 @@ U_BOOT_CMD(
"bootvx - Boot vxWorks from an ELF image\n",
" [address] - load address of vxWorks ELF image.\n"
);
-
-#endif
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index 8bd2b47..f569406 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -34,8 +34,6 @@
*/
#include <common.h>
#include <part.h>
-
-#if defined(CONFIG_CMD_EXT2)
#include <config.h>
#include <command.h>
#include <image.h>
@@ -259,5 +257,3 @@ U_BOOT_CMD(
" - load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from ext2 filesystem\n"
);
-
-#endif
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index 54f0f9f..9576cdf 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -30,11 +30,6 @@
#include <net.h>
#include <ata.h>
#include <part.h>
-
-#if defined(CONFIG_CMD_FAT)
-
-#undef DEBUG
-
#include <fat.h>
@@ -323,5 +318,3 @@ void hexdump (int cnt, unsigned char *data)
}
}
#endif /* NOT_IMPLEMENTED_YET */
-
-#endif
diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c
index f9da98d..b3dbd19 100644
--- a/common/cmd_fdos.c
+++ b/common/cmd_fdos.c
@@ -31,8 +31,6 @@
#include <command.h>
#include <fdc.h>
-#if defined(CONFIG_CMD_FDOS)
-
/*-----------------------------------------------------------------------------
* do_fdosboot --
*-----------------------------------------------------------------------------
@@ -153,5 +151,3 @@ U_BOOT_CMD(
"fdosls - list files in a directory\n",
"[directory]\n"
);
-
-#endif
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 571b8f1..9cd22ee 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -28,9 +28,6 @@
#include <command.h>
#include <linux/ctype.h>
#include <linux/types.h>
-
-#ifdef CONFIG_OF_LIBFDT
-
#include <asm/global_data.h>
#include <fdt.h>
#include <libfdt.h>
@@ -47,7 +44,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int fdt_valid(void);
static int fdt_parse_prop(char *pathp, char *prop, char *newval,
char *data, int *len);
-static int fdt_print(char *pathp, char *prop, int depth);
+static int fdt_print(const char *pathp, char *prop, int depth);
/*
* Flattened Device Tree command, see the help for parameter definitions.
@@ -78,7 +75,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
/*
* Optional new length
*/
- len = simple_strtoul(argv[3], NULL, 16);
+ len = simple_strtoul(argv[3], NULL, 16);
if (len < fdt_totalsize(fdt)) {
printf ("New length %d < existing length %d, "
"ignoring.\n",
@@ -165,12 +162,12 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
pathp = argv[2];
nodep = argv[3];
- nodeoffset = fdt_find_node_by_path (fdt, pathp);
+ nodeoffset = fdt_path_offset (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
- printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ printf ("libfdt fdt_path_offset() returned %s\n",
fdt_strerror(nodeoffset));
return 1;
}
@@ -187,36 +184,38 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
} else if (argv[1][0] == 's') {
char *pathp; /* path */
char *prop; /* property */
- char *newval; /* value from the user (as a string) */
int nodeoffset; /* node offset from libfdt */
static char data[SCRATCHPAD]; /* storage for the property */
int len; /* new length of the property */
int ret; /* return value */
/*
- * Parameters: Node path, property, value.
+ * Parameters: Node path, property, optional value.
*/
- if (argc < 5) {
+ if (argc < 4) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
pathp = argv[2];
prop = argv[3];
- newval = argv[4];
+ if (argc == 4) {
+ len = 0;
+ } else {
+ ret = fdt_parse_prop(pathp, prop, argv[4], data, &len);
+ if (ret != 0)
+ return ret;
+ }
- nodeoffset = fdt_find_node_by_path (fdt, pathp);
+ nodeoffset = fdt_path_offset (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
- printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ printf ("libfdt fdt_path_offset() returned %s\n",
fdt_strerror(nodeoffset));
return 1;
}
- ret = fdt_parse_prop(pathp, prop, newval, data, &len);
- if (ret != 0)
- return ret;
ret = fdt_setprop(fdt, nodeoffset, prop, data, len);
if (ret < 0) {
@@ -232,6 +231,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
char *pathp; /* path */
char *prop; /* property */
int ret; /* return value */
+ static char root[2] = "/";
/*
* list is an alias for print, but limited to 1 level
@@ -244,7 +244,10 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
* Get the starting path. The root node is an oddball,
* the offset is zero and has no name.
*/
- pathp = argv[2];
+ if (argc == 2)
+ pathp = root;
+ else
+ pathp = argv[2];
if (argc > 3)
prop = argv[3];
else
@@ -265,12 +268,12 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
* Get the path. The root node is an oddball, the offset
* is zero and has no name.
*/
- nodeoffset = fdt_find_node_by_path (fdt, argv[2]);
+ nodeoffset = fdt_path_offset (fdt, argv[2]);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
- printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ printf ("libfdt fdt_path_offset() returned %s\n",
fdt_strerror(nodeoffset));
return 1;
}
@@ -521,21 +524,21 @@ static void print_data(const void *data, int len)
switch (len) {
case 1: /* byte */
- printf("<%02x>", (*(u8 *) data) & 0xff);
+ printf("<0x%02x>", (*(u8 *) data) & 0xff);
break;
case 2: /* half-word */
- printf("<%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
+ printf("<0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
break;
case 4: /* word */
- printf("<%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
+ printf("<0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
break;
case 8: /* double-word */
#if __WORDSIZE == 64
- printf("<%016llx>", be64_to_cpu(*(uint64_t *) data));
+ printf("<0x%016llx>", be64_to_cpu(*(uint64_t *) data));
#else
- printf("<%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
+ printf("<0x%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
data += 4;
- printf("%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
+ printf("0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
#endif
break;
default: /* anything else... hexdump */
@@ -554,25 +557,25 @@ static void print_data(const void *data, int len)
* Recursively print (a portion of) the fdt. The depth parameter
* determines how deeply nested the fdt is printed.
*/
-static int fdt_print(char *pathp, char *prop, int depth)
+static int fdt_print(const char *pathp, char *prop, int depth)
{
- static int offstack[MAX_LEVEL];
static char tabs[MAX_LEVEL+1] =
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
- void *nodep; /* property node pointer */
+ const void *nodep; /* property node pointer */
int nodeoffset; /* node offset from libfdt */
int nextoffset; /* next node offset from libfdt */
uint32_t tag; /* tag */
int len; /* length of the property */
int level = 0; /* keep track of nesting level */
+ const struct fdt_property *fdt_prop;
- nodeoffset = fdt_find_node_by_path (fdt, pathp);
+ nodeoffset = fdt_path_offset (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
- printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ printf ("libfdt fdt_path_offset() returned %s\n",
fdt_strerror(nodeoffset));
return 1;
}
@@ -587,7 +590,7 @@ static int fdt_print(char *pathp, char *prop, int depth)
printf("%s %s\n", pathp, prop);
return 0;
} else if (len > 0) {
- printf("%s=", prop);
+ printf("%s = ", prop);
print_data (nodep, len);
printf("\n");
return 0;
@@ -602,46 +605,53 @@ static int fdt_print(char *pathp, char *prop, int depth)
* The user passed in a node path and no property,
* print the node and all subnodes.
*/
- offstack[0] = nodeoffset;
-
while(level >= 0) {
- tag = fdt_next_tag(fdt, nodeoffset, &nextoffset, &pathp);
+ tag = fdt_next_tag(fdt, nodeoffset, &nextoffset);
switch(tag) {
case FDT_BEGIN_NODE:
- if(level <= depth)
+ pathp = fdt_get_name(fdt, nodeoffset, NULL);
+ if (level <= depth) {
+ if (pathp == NULL)
+ pathp = "/* NULL pointer error */";
+ if (*pathp == '\0')
+ pathp = "/"; /* root is nameless */
printf("%s%s {\n",
&tabs[MAX_LEVEL - level], pathp);
+ }
level++;
- offstack[level] = nodeoffset;
if (level >= MAX_LEVEL) {
- printf("Aaaiii <splat> nested too deep. "
- "Aborting.\n");
+ printf("Nested too deep, aborting.\n");
return 1;
}
break;
case FDT_END_NODE:
level--;
- if(level <= depth)
+ if (level <= depth)
printf("%s};\n", &tabs[MAX_LEVEL - level]);
if (level == 0) {
level = -1; /* exit the loop */
}
break;
case FDT_PROP:
- nodep = fdt_getprop (fdt, offstack[level], pathp, &len);
+ fdt_prop = fdt_offset_ptr(fdt, nodeoffset,
+ sizeof(*fdt_prop));
+ pathp = fdt_string(fdt,
+ fdt32_to_cpu(fdt_prop->nameoff));
+ len = fdt32_to_cpu(fdt_prop->len);
+ nodep = fdt_prop->data;
if (len < 0) {
printf ("libfdt fdt_getprop(): %s\n",
fdt_strerror(len));
return 1;
} else if (len == 0) {
/* the property has no value */
- if(level <= depth)
+ if (level <= depth)
printf("%s%s;\n",
&tabs[MAX_LEVEL - level],
pathp);
} else {
- if(level <= depth) {
- printf("%s%s=",
+ if (level <= depth) {
+ printf("%s%s = ",
&tabs[MAX_LEVEL - level],
pathp);
print_data (nodep, len);
@@ -650,11 +660,12 @@ static int fdt_print(char *pathp, char *prop, int depth)
}
break;
case FDT_NOP:
+ printf("/* NOP */\n", &tabs[MAX_LEVEL - level]);
break;
case FDT_END:
return 1;
default:
- if(level <= depth)
+ if (level <= depth)
printf("Unknown tag 0x%08X\n", tag);
return 1;
}
@@ -672,7 +683,7 @@ U_BOOT_CMD(
#ifdef CONFIG_OF_BOARD_SETUP
"fdt boardsetup - Do board-specific set up\n"
#endif
- "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr>\n"
+ "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n"
"fdt print <path> [<prop>] - Recursive print starting at <path>\n"
"fdt list <path> [<prop>] - Print one level starting at <path>\n"
"fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n"
@@ -685,12 +696,6 @@ U_BOOT_CMD(
#ifdef CONFIG_OF_HAS_BD_T
"fdt bd_t - Add/replace the /bd_t branch in the tree\n"
#endif
- "Hints:\n"
- " If the property you are setting/printing has a '#' character or spaces,\n"
- " you MUST escape it with a \\ character or quote it with \".\n"
- "Examples: fdt print / # print the whole tree\n"
- " fdt print /cpus \"#address-cells\"\n"
- " fdt set /cpus \"#address-cells\" \"[00 00 00 01]\"\n"
+ "NOTE: If the path or property you are setting/printing has a '#' character\n"
+ " or spaces, you MUST escape it with a \\ character or quote it with \".\n"
);
-
-#endif /* CONFIG_OF_LIBFDT */
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index 11c8857..f56443e 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -31,8 +31,6 @@
#include <dataflash.h>
#endif
-#if defined(CONFIG_CMD_FLASH)
-
#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
#include <jffs2/jffs2.h>
@@ -731,5 +729,3 @@ U_BOOT_CMD(
#undef TMP_ERASE
#undef TMP_PROT_ON
#undef TMP_PROT_OFF
-
-#endif
diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c
index cce23ad..f55447a 100644
--- a/common/cmd_fpga.c
+++ b/common/cmd_fpga.c
@@ -43,8 +43,6 @@
#define PRINTF(fmt,args...)
#endif
-#if defined (CONFIG_FPGA) && defined(CONFIG_CMD_FPGA)
-
/* Local functions */
static void fpga_usage (cmd_tbl_t * cmdtp);
static int fpga_get_op (char *opstr);
@@ -60,14 +58,11 @@ static int fpga_get_op (char *opstr);
/* Convert bitstream data and load into the fpga */
int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size)
{
-#if (CONFIG_FPGA & CFG_FPGA_XILINX)
+#if defined(CONFIG_FPGA_XILINX)
unsigned int length;
- unsigned char* swapdata;
unsigned int swapsize;
char buffer[80];
- unsigned char *ptr;
unsigned char *dataptr;
- unsigned char data;
unsigned int i;
int rc;
@@ -145,39 +140,7 @@ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size)
dataptr+=4;
printf(" bytes in bitstream = %d\n", swapsize);
- /* check consistency of length obtained */
- if (swapsize >= size) {
- printf("%s: Could not find right length of data in bitstream\n",
- __FUNCTION__);
- return FPGA_FAIL;
- }
-
- /* allocate memory */
- swapdata = (unsigned char *)malloc(swapsize);
- if (swapdata == NULL) {
- printf("%s: Could not allocate %d bytes memory !\n",
- __FUNCTION__, swapsize);
- return FPGA_FAIL;
- }
-
- /* read data into memory and swap bits */
- ptr = swapdata;
- for (i = 0; i < swapsize; i++) {
- data = 0x00;
- data |= (*dataptr & 0x01) << 7;
- data |= (*dataptr & 0x02) << 5;
- data |= (*dataptr & 0x04) << 3;
- data |= (*dataptr & 0x08) << 1;
- data |= (*dataptr & 0x10) >> 1;
- data |= (*dataptr & 0x20) >> 3;
- data |= (*dataptr & 0x40) >> 5;
- data |= (*dataptr & 0x80) >> 7;
- *ptr++ = data;
- dataptr++;
- }
-
- rc = fpga_load(dev, swapdata, swapsize);
- free(swapdata);
+ rc = fpga_load(dev, dataptr, swapsize);
return rc;
#else
printf("Bitstream support only for Xilinx devices\n");
@@ -321,4 +284,3 @@ U_BOOT_CMD (fpga, 6, 1, do_fpga,
"\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n"
"\tloadmk\tLoad device generated with mkimage\n"
"\tdump\tLoad device to memory buffer\n");
-#endif
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index a684a58..10cab46 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -86,9 +86,6 @@
#include <i2c.h>
#include <asm/byteorder.h>
-#if defined(CONFIG_CMD_I2C)
-
-
/* Display values from last command.
* Memory modify remembered values are different from display memory.
*/
@@ -1024,5 +1021,3 @@ U_BOOT_CMD(
" (valid chip values 50..57)\n"
);
#endif
-
-#endif
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index bb064ea..c38be4f 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -54,10 +54,6 @@
#ifndef __PPC__
#include <asm/io.h>
-#ifdef __MIPS__
-/* Macros depend on this variable */
-unsigned long mips_io_port_base = 0;
-#endif
#endif
#ifdef CONFIG_IDE_8xx_DIRECT
@@ -72,8 +68,6 @@ DECLARE_GLOBAL_DATA_PTR;
# define SYNC /* nothing */
#endif
-#if defined(CONFIG_CMD_IDE)
-
#ifdef CONFIG_IDE_8xx_DIRECT
/* Timings for IDE Interface
*
@@ -892,7 +886,7 @@ input_swap_data(int dev, ulong *sect_buf, int words)
#endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
static void
output_data(int dev, ulong *sect_buf, int words)
{
@@ -944,7 +938,7 @@ output_data(int dev, ulong *sect_buf, int words)
}
#endif /* __PPC__ */
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
static void
input_data(int dev, ulong *sect_buf, int words)
{
@@ -1136,9 +1130,9 @@ static void ide_ident (block_dev_desc_t *dev_desc)
input_swap_data (device, iobuf, ATA_SECTORWORDS);
- ident_cpy (dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision));
- ident_cpy (dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));
- ident_cpy (dev_desc->product, iop->serial_no, sizeof(dev_desc->product));
+ ident_cpy ((unsigned char*)dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision));
+ ident_cpy ((unsigned char*)dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));
+ 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
@@ -1953,9 +1947,9 @@ static void atapi_inquiry(block_dev_desc_t * dev_desc)
return;
/* copy device ident strings */
- ident_cpy(dev_desc->vendor,&iobuf[8],8);
- ident_cpy(dev_desc->product,&iobuf[16],16);
- ident_cpy(dev_desc->revision,&iobuf[32],5);
+ ident_cpy((unsigned char*)dev_desc->vendor,&iobuf[8],8);
+ ident_cpy((unsigned char*)dev_desc->product,&iobuf[16],16);
+ ident_cpy((unsigned char*)dev_desc->revision,&iobuf[32],5);
dev_desc->lun=0;
dev_desc->lba=0;
@@ -2085,5 +2079,3 @@ U_BOOT_CMD(
"diskboot- boot from IDE device\n",
"loadAddr dev:part\n"
);
-
-#endif
diff --git a/common/cmd_immap.c b/common/cmd_immap.c
index ae95758..d758269 100644
--- a/common/cmd_immap.c
+++ b/common/cmd_immap.c
@@ -28,8 +28,7 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_IMMAP) && \
- (defined(CONFIG_8xx) || defined(CONFIG_8260))
+#if defined(CONFIG_8xx) || defined(CONFIG_8260)
#if defined(CONFIG_8xx)
#include <asm/8xx_immap.h>
@@ -41,9 +40,7 @@
#include <asm/iopin_8260.h>
#endif
-#if defined(CONFIG_8xx) || defined(CONFIG_8260)
DECLARE_GLOBAL_DATA_PTR;
-#endif
static void
unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 8e20517..ce98872 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -32,8 +32,6 @@
#include <config.h>
#include <command.h>
-#if defined(CONFIG_CMD_ITEST)
-
#define EQ 0
#define NE 1
#define LT 2
@@ -197,4 +195,3 @@ U_BOOT_CMD(
"itest\t- return true/false on integer compare\n",
"[.b, .w, .l, .s] [*]value1 <op> [*]value2\n"
);
-#endif
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index 513a226..1b67e73 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -93,9 +93,6 @@
#include <jffs2/jffs2.h>
#include <linux/list.h>
#include <linux/ctype.h>
-
-#if defined(CONFIG_CMD_JFFS2)
-
#include <cramfs/cramfs_fs.h>
#if defined(CONFIG_CMD_NAND)
@@ -170,10 +167,19 @@ struct list_head devices;
static struct mtd_device *current_dev = NULL;
static u8 current_partnum = 0;
+#if defined(CONFIG_CMD_CRAMFS)
extern int cramfs_check (struct part_info *info);
extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename);
extern int cramfs_ls (struct part_info *info, char *filename);
extern int cramfs_info (struct part_info *info);
+#else
+/* defining empty macros for function names is ugly but avoids ifdef clutter
+ * all over the code */
+#define cramfs_check(x) (0)
+#define cramfs_load(x,y,z) (-1)
+#define cramfs_ls(x,y) (0)
+#define cramfs_info(x) (0)
+#endif
static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num);
@@ -2191,5 +2197,3 @@ U_BOOT_CMD(
#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
/***************************************************/
-
-#endif
diff --git a/common/cmd_log.c b/common/cmd_log.c
index fba8bd8..e593dbe 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -48,8 +48,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#if defined(CONFIG_LOGBUFFER)
-
/* Local prototypes */
static void logbuff_putc (const char c);
static void logbuff_puts (const char *s);
@@ -287,5 +285,3 @@ static int logbuff_printk(const char *line)
}
return i;
}
-
-#endif /* (CONFIG_LOGBUFFER) */
diff --git a/common/cmd_mfsl.c b/common/cmd_mfsl.c
index 9d1d875..5982b76 100644
--- a/common/cmd_mfsl.c
+++ b/common/cmd_mfsl.c
@@ -29,8 +29,6 @@
#include <common.h>
#include <config.h>
#include <command.h>
-
-#if defined(CONFIG_CMD_MFSL)
#include <asm/asm.h>
int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
@@ -413,5 +411,3 @@ U_BOOT_CMD (rspr, 3, 1, do_rspr,
" 1 - MSR - Machine status register\n"
" 3 - EAR - Exception address register\n"
" 5 - ESR - Exception status register\n");
-
-#endif
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index 72e11d5..f530a38 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -27,8 +27,6 @@
#include <common.h>
#include <command.h>
-
-#if defined(CONFIG_CMD_MII)
#include <miiphy.h>
#ifdef CONFIG_TERSE_MII
@@ -112,9 +110,11 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
"OUI = 0x%04X, "
"Model = 0x%02X, "
"Rev = 0x%02X, "
- "%3dbaseT, %s\n",
+ "%3dbase%s, %s\n",
j, oui, model, rev,
miiphy_speed (devname, j),
+ miiphy_is_1000base_x (devname, j)
+ ? "X" : "T",
(miiphy_duplex (devname, j) == FULL)
? "FDX" : "HDX");
}
@@ -496,9 +496,11 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
"OUI = 0x%04X, "
"Model = 0x%02X, "
"Rev = 0x%02X, "
- "%3dbaseT, %s\n",
+ "%3dbase%s, %s\n",
j, oui, model, rev,
miiphy_speed (devname, j),
+ miiphy_is_1000base_x (devname, j)
+ ? "X" : "T",
(miiphy_duplex (devname, j) == FULL)
? "FDX" : "HDX");
}
@@ -594,5 +596,3 @@ U_BOOT_CMD(
);
#endif /* CONFIG_TERSE_MII */
-
-#endif
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index c0c6b8f..126b538 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -27,8 +27,6 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_MISC)
-
int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong start = get_timer(0);
@@ -68,5 +66,3 @@ U_BOOT_CMD(
"N\n"
" - delay execution for N seconds (N is _decimal_ !!!)\n"
);
-
-#endif
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 069c6d0..25c9702 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -23,9 +23,6 @@
#include <common.h>
#include <command.h>
-
-#if defined(CONFIG_CMD_MMC)
-
#include <mmc.h>
int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -42,5 +39,3 @@ U_BOOT_CMD(
"mmcinit - init mmc card\n",
NULL
);
-
-#endif
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 1fdd7a6..b248a2c 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -347,6 +347,14 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
opts.quiet = quiet;
ret = nand_write_opts(nand, &opts);
}
+ } else if (s != NULL && !strcmp(s, ".oob")) {
+ /* read out-of-band data */
+ if (read)
+ ret = nand->read_oob(nand, off, size, &size,
+ (u_char *) addr);
+ else
+ ret = nand->write_oob(nand, off, size, &size,
+ (u_char *) addr);
} else {
if (read)
ret = nand_read(nand, off, &size, (u_char *)addr);
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 0715fbc..21682c0 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -28,8 +28,6 @@
#include <command.h>
#include <net.h>
-#if defined(CONFIG_CMD_NET)
-
extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
@@ -343,5 +341,3 @@ U_BOOT_CMD(
"[NTP server IP]\n"
);
#endif
-
-#endif
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index 8be6da9..82d9717 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -30,16 +30,11 @@
*/
#include <common.h>
-
-#ifdef CONFIG_PCI
-
#include <command.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <pci.h>
-#if defined(CONFIG_CMD_PCI)
-
extern int cmd_get_data_size(char* arg, int default_size);
unsigned char ShortPCIListing = 1;
@@ -564,7 +559,3 @@ U_BOOT_CMD(
"pci write[.b, .w, .l] b.d.f address value\n"
" - write to CFG address\n"
);
-
-#endif
-
-#endif /* CONFIG_PCI */
diff --git a/common/cmd_portio.c b/common/cmd_portio.c
index bfe33e3..a06cac0 100644
--- a/common/cmd_portio.c
+++ b/common/cmd_portio.c
@@ -30,8 +30,6 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_PORTIO)
-
extern int cmd_get_data_size (char *arg, int default_size);
/* Display values from last command.
@@ -165,5 +163,3 @@ U_BOOT_CMD(
"[.b, .w, .l] port\n"
" - read datum from IO port\n"
);
-
-#endif
diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c
index 17e9cd9..bb6aa30 100644
--- a/common/cmd_reginfo.c
+++ b/common/cmd_reginfo.c
@@ -33,8 +33,6 @@
#include <mpc5xxx.h>
#endif
-#if defined(CONFIG_CMD_REGINFO)
-
int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
#if defined(CONFIG_8xx)
@@ -335,9 +333,6 @@ int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#endif
-
-
/**************************************************/
#if ( defined(CONFIG_8xx) || defined(CONFIG_405GP) || \
diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c
index 1ba3929..b7395d7 100644
--- a/common/cmd_reiser.c
+++ b/common/cmd_reiser.c
@@ -27,8 +27,6 @@
* Reiserfs support
*/
#include <common.h>
-
-#if defined(CONFIG_CMD_REISER)
#include <config.h>
#include <command.h>
#include <image.h>
@@ -239,5 +237,3 @@ U_BOOT_CMD(
" - load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from dos filesystem\n"
);
-
-#endif
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index f563931..1cdec15 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -34,8 +34,6 @@
#include <image.h>
#include <pci.h>
-#if defined(CONFIG_CMD_SCSI)
-
#ifdef CONFIG_SCSI_SYM53C8XX
#define SCSI_VEND_ID 0x1000
#ifndef CONFIG_SCSI_DEV_ID
@@ -129,9 +127,12 @@ void scsi_scan(int mode)
if((modi&0x80)==0x80) /* drive is removable */
scsi_dev_desc[scsi_max_devs].removable=TRUE;
/* get info for this device */
- scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].vendor[0],&tempbuff[8],8);
- scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].product[0],&tempbuff[16],16);
- scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].revision[0],&tempbuff[32],4);
+ scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].vendor[0],
+ &tempbuff[8], 8);
+ scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].product[0],
+ &tempbuff[16], 16);
+ scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].revision[0],
+ &tempbuff[32], 4);
scsi_dev_desc[scsi_max_devs].target=pccb->target;
scsi_dev_desc[scsi_max_devs].lun=pccb->lun;
@@ -608,5 +609,3 @@ U_BOOT_CMD(
"scsiboot- boot from SCSI device\n",
"loadAddr dev:part\n"
);
-
-#endif
diff --git a/common/cmd_spi.c b/common/cmd_spi.c
index 3118d27..7604422 100644
--- a/common/cmd_spi.c
+++ b/common/cmd_spi.c
@@ -29,8 +29,6 @@
#include <command.h>
#include <spi.h>
-#if defined(CONFIG_CMD_SPI)
-
/*-----------------------------------------------------------------------
* Definitions
*/
@@ -139,5 +137,3 @@ U_BOOT_CMD(
"<bit_len> - Number of bits to send (base 10)\n"
"<dout> - Hexadecimal string that gets sent\n"
);
-
-#endif
diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c
new file mode 100644
index 0000000..8871607
--- /dev/null
+++ b/common/cmd_terminal.c
@@ -0,0 +1,102 @@
+/*
+ * (C) Copyright 2007 OpenMoko, Inc.
+ * Written by Harald Welte <laforge@openmoko.org>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Boot support
+ */
+#include <common.h>
+#include <command.h>
+#include <devices.h>
+
+#if defined(CONFIG_CMD_TERMINAL)
+
+int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
+{
+ int i, l;
+ int last_tilde = 0;
+ device_t *dev = NULL;
+
+ if (argc < 1)
+ return -1;
+
+ /* Scan for selected output/input device */
+ for (i = 1; i <= ListNumItems (devlist); i++) {
+ device_t *tmp = ListGetPtrToItem (devlist, i);
+ if (!strcmp(tmp->name, argv[1])) {
+ dev = tmp;
+ break;
+ }
+ }
+ if (!dev)
+ return -1;
+
+ serial_reinit_all();
+ printf("Entering terminal mode for port %s\n", dev->name);
+ puts("Use '~.' to leave the terminal and get back to u-boot\n");
+
+ while (1) {
+ int c;
+
+ /* read from console and display on serial port */
+ if (stdio_devices[0]->tstc()) {
+ c = stdio_devices[0]->getc();
+ if (last_tilde == 1) {
+ if (c == '.') {
+ putc(c);
+ putc('\n');
+ break;
+ } else {
+ last_tilde = 0;
+ /* write the delayed tilde */
+ dev->putc('~');
+ /* fall-through to print current
+ * character */
+ }
+ }
+ if (c == '~') {
+ last_tilde = 1;
+ puts("[u-boot]");
+ putc(c);
+ }
+ dev->putc(c);
+ }
+
+ /* read from serial port and display on console */
+ if (dev->tstc()) {
+ c = dev->getc();
+ putc(c);
+ }
+ }
+ return 0;
+}
+
+
+/***************************************************/
+
+U_BOOT_CMD(
+ terminal, 3, 1, do_terminal,
+ "terminal - start terminal emulator\n",
+ ""
+);
+
+#endif /* CONFIG_CMD_TERMINAL */
diff --git a/common/cmd_universe.c b/common/cmd_universe.c
index 8bf0b1f..ea97782 100644
--- a/common/cmd_universe.c
+++ b/common/cmd_universe.c
@@ -28,8 +28,6 @@
#include <universe.h>
-#if defined(CONFIG_CMD_UNIVERSE)
-
#define PCI_VENDOR PCI_VENDOR_ID_TUNDRA
#define PCI_DEVICE PCI_DEVICE_ID_TUNDRA_CA91C042
@@ -386,5 +384,3 @@ U_BOOT_CMD(
" 02 -> D16 Data Width\n"
" 03 -> D32 Data Width\n"
);
-
-#endif
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 45e07f1..c6b17c2 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -29,9 +29,6 @@
#include <command.h>
#include <asm/byteorder.h>
#include <part.h>
-
-#if defined(CONFIG_CMD_USB)
-
#include <usb.h>
#ifdef CONFIG_USB_STORAGE
@@ -608,12 +605,6 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
-
-#endif
-
-
-#if defined(CONFIG_CMD_USB)
-
#ifdef CONFIG_USB_STORAGE
U_BOOT_CMD(
usb, 5, 1, do_usb,
@@ -645,4 +636,3 @@ U_BOOT_CMD(
"usb info [dev] - show available USB devices\n"
);
#endif
-#endif
diff --git a/common/cyclon2.c b/common/cyclon2.c
index dce13b5..06f5e8a 100644
--- a/common/cyclon2.c
+++ b/common/cyclon2.c
@@ -27,7 +27,7 @@
#include <altera.h>
#include <ACEX1K.h> /* ACEX device family */
-#if (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2))
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_CYCLON2)
/* Define FPGA_DEBUG to get debug printf's */
#ifdef FPGA_DEBUG
@@ -302,4 +302,4 @@ static int CYC2_ps_reloc (Altera_desc * desc, ulong reloc_offset)
return ret_val;
}
-#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2)) */
+#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_CYCLON2 */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 66107f9..5888f75 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -64,7 +64,7 @@ void env_relocate_spec(void)
DECLARE_GLOBAL_DATA_PTR;
unsigned long env_addr;
int use_default = 0;
- int retlen;
+ size_t retlen;
env_addr = CFG_ENV_ADDR;
env_addr -= (unsigned long)onenand_chip.base;
@@ -96,7 +96,7 @@ int saveenv(void)
{
unsigned long env_addr = CFG_ENV_ADDR;
struct erase_info instr;
- int retlen;
+ size_t retlen;
instr.len = CFG_ENV_SIZE;
instr.addr = env_addr;
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 175d59e..92f1c7f 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -24,13 +24,11 @@
#include <common.h>
#include <linux/ctype.h>
#include <linux/types.h>
-
-#ifdef CONFIG_OF_LIBFDT
-
#include <asm/global_data.h>
#include <fdt.h>
#include <libfdt.h>
#include <fdt_support.h>
+#include <exports.h>
/*
* Global data (for the gd->bd)
@@ -44,12 +42,76 @@ struct fdt_header *fdt;
/********************************************************************/
+/**
+ * fdt_find_and_setprop: Find a node and set it's property
+ *
+ * @fdt: ptr to device tree
+ * @node: path of node
+ * @prop: property name
+ * @val: ptr to new value
+ * @len: length of new property value
+ * @create: flag to create the property if it doesn't exist
+ *
+ * Convenience function to directly set a property given the path to the node.
+ */
+int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
+ const void *val, int len, int create)
+{
+ int nodeoff = fdt_path_offset(fdt, node);
+
+ if (nodeoff < 0)
+ return nodeoff;
+
+ if ((!create) && (fdt_get_property(fdt, nodeoff, prop, 0) == NULL))
+ return 0; /* create flag not set; so exit quietly */
+
+ return fdt_setprop(fdt, nodeoff, prop, val, len);
+}
+
+#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
+static int fdt_fixup_stdout(void *fdt, int choosenoff)
+{
+ int err = 0;
+#ifdef CONFIG_CONS_INDEX
+ int node;
+ char sername[9] = { 0 };
+ const char *path;
+
+ sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
+
+ err = node = fdt_path_offset(fdt, "/aliases");
+ if (node >= 0) {
+ int len;
+ path = fdt_getprop(fdt, node, sername, &len);
+ if (path) {
+ char *p = malloc(len);
+ err = -FDT_ERR_NOSPACE;
+ if (p) {
+ memcpy(p, path, len);
+ err = fdt_setprop(fdt, choosenoff,
+ "linux,stdout-path", p, len);
+ free(p);
+ }
+ } else {
+ err = len;
+ }
+ }
+#endif
+ if (err < 0)
+ printf("WARNING: could not set linux,stdout-path %s.\n",
+ fdt_strerror(err));
+
+ return err;
+}
+#endif
+
int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
{
int nodeoffset;
int err;
u32 tmp; /* used to set 32 bit integer properties */
char *str; /* used to set string properties */
+ const char *path;
err = fdt_check_header(fdt);
if (err < 0) {
@@ -58,34 +120,23 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
}
if (initrd_start && initrd_end) {
- struct fdt_reserve_entry re;
- int used;
- int total;
+ uint64_t addr, size;
+ int total = fdt_num_mem_rsv(fdt);
int j;
- err = fdt_num_reservemap(fdt, &used, &total);
- if (err < 0) {
- printf("fdt_chosen: %s\n", fdt_strerror(err));
- return err;
- }
- if (used >= total) {
- printf("WARNING: "
- "no room in the reserved map (%d of %d)\n",
- used, total);
- return -1;
- }
/*
* Look for an existing entry and update it. If we don't find
* the entry, we will j be the next available slot.
*/
- for (j = 0; j < used; j++) {
- err = fdt_get_reservemap(fdt, j, &re);
- if (re.address == initrd_start) {
+ for (j = 0; j < total; j++) {
+ err = fdt_get_mem_rsv(fdt, j, &addr, &size);
+ if (addr == initrd_start) {
+ fdt_del_mem_rsv(fdt, j);
break;
}
}
- err = fdt_replace_reservemap_entry(fdt, j,
- initrd_start, initrd_end - initrd_start + 1);
+
+ err = fdt_add_mem_rsv(fdt, initrd_start, initrd_end - initrd_start + 1);
if (err < 0) {
printf("fdt_chosen: %s\n", fdt_strerror(err));
return err;
@@ -95,17 +146,10 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
/*
* Find the "chosen" node.
*/
- nodeoffset = fdt_find_node_by_path (fdt, "/chosen");
-
- /*
- * If we have a "chosen" node already the "force the writing"
- * is not set, our job is done.
- */
- if ((nodeoffset >= 0) && !force)
- return 0;
+ nodeoffset = fdt_path_offset (fdt, "/chosen");
/*
- * No "chosen" node in the blob: create it.
+ * If there is no "chosen" node in the blob, create it.
*/
if (nodeoffset < 0) {
/*
@@ -120,37 +164,55 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
}
/*
- * Update pre-existing properties, create them if non-existant.
+ * Create /chosen properites that don't exist in the fdt.
+ * If the property exists, update it only if the "force" parameter
+ * is true.
*/
str = getenv("bootargs");
if (str != NULL) {
- err = fdt_setprop(fdt, nodeoffset,
- "bootargs", str, strlen(str)+1);
- if (err < 0)
- printf("WARNING: could not set bootargs %s.\n",
- fdt_strerror(err));
+ path = fdt_getprop(fdt, nodeoffset, "bootargs", NULL);
+ if ((path == NULL) || force) {
+ err = fdt_setprop(fdt, nodeoffset,
+ "bootargs", str, strlen(str)+1);
+ if (err < 0)
+ printf("WARNING: could not set bootargs %s.\n",
+ fdt_strerror(err));
+ }
}
if (initrd_start && initrd_end) {
- tmp = __cpu_to_be32(initrd_start);
- err = fdt_setprop(fdt, nodeoffset,
- "linux,initrd-start", &tmp, sizeof(tmp));
- if (err < 0)
- printf("WARNING: "
- "could not set linux,initrd-start %s.\n",
- fdt_strerror(err));
- tmp = __cpu_to_be32(initrd_end);
+ path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL);
+ if ((path == NULL) || force) {
+ tmp = __cpu_to_be32(initrd_start);
+ err = fdt_setprop(fdt, nodeoffset,
+ "linux,initrd-start", &tmp, sizeof(tmp));
+ if (err < 0)
+ printf("WARNING: "
+ "could not set linux,initrd-start %s.\n",
+ fdt_strerror(err));
+ tmp = __cpu_to_be32(initrd_end);
+ err = fdt_setprop(fdt, nodeoffset,
+ "linux,initrd-end", &tmp, sizeof(tmp));
+ if (err < 0)
+ printf("WARNING: could not set linux,initrd-end %s.\n",
+ fdt_strerror(err));
+ }
+ }
+
+#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
+ path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL);
+ if ((path == NULL) || force)
+ err = fdt_fixup_stdout(fdt, nodeoffset);
+#endif
+
+#ifdef OF_STDOUT_PATH
+ path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL);
+ if ((path == NULL) || force) {
err = fdt_setprop(fdt, nodeoffset,
- "linux,initrd-end", &tmp, sizeof(tmp));
+ "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
if (err < 0)
- printf("WARNING: could not set linux,initrd-end %s.\n",
+ printf("WARNING: could not set linux,stdout-path %s.\n",
fdt_strerror(err));
}
-#ifdef OF_STDOUT_PATH
- err = fdt_setprop(fdt, nodeoffset,
- "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
- if (err < 0)
- printf("WARNING: could not set linux,stdout-path %s.\n",
- fdt_strerror(err));
#endif
return err;
@@ -182,7 +244,7 @@ int fdt_env(void *fdt)
* See if we already have a "u-boot-env" node, delete it if so.
* Then create a new empty node.
*/
- nodeoffset = fdt_find_node_by_path (fdt, "/u-boot-env");
+ nodeoffset = fdt_path_offset (fdt, "/u-boot-env");
if (nodeoffset >= 0) {
err = fdt_del_node(fdt, nodeoffset);
if (err < 0) {
@@ -304,7 +366,7 @@ int fdt_bd_t(void *fdt)
* See if we already have a "bd_t" node, delete it if so.
* Then create a new empty node.
*/
- nodeoffset = fdt_find_node_by_path (fdt, "/bd_t");
+ nodeoffset = fdt_path_offset (fdt, "/bd_t");
if (nodeoffset >= 0) {
err = fdt_del_node(fdt, nodeoffset);
if (err < 0) {
@@ -348,4 +410,208 @@ int fdt_bd_t(void *fdt)
}
#endif /* ifdef CONFIG_OF_HAS_BD_T */
-#endif /* CONFIG_OF_LIBFDT */
+void do_fixup_by_path(void *fdt, const char *path, const char *prop,
+ const void *val, int len, int create)
+{
+#if defined(DEBUG)
+ int i;
+ debug("Updating property '%s/%s' = ", node, prop);
+ for (i = 0; i < len; i++)
+ debug(" %.2x", *(u8*)(val+i));
+ debug("\n");
+#endif
+ int rc = fdt_find_and_setprop(fdt, path, prop, val, len, create);
+ if (rc)
+ printf("Unable to update property %s:%s, err=%s\n",
+ path, prop, fdt_strerror(rc));
+}
+
+void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
+ u32 val, int create)
+{
+ val = cpu_to_fdt32(val);
+ do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
+}
+
+void do_fixup_by_prop(void *fdt,
+ const char *pname, const void *pval, int plen,
+ const char *prop, const void *val, int len,
+ int create)
+{
+ int off;
+#if defined(DEBUG)
+ int i;
+ debug("Updating property '%s/%s' = ", node, prop);
+ for (i = 0; i < len; i++)
+ debug(" %.2x", *(u8*)(val+i));
+ debug("\n");
+#endif
+ off = fdt_node_offset_by_prop_value(fdt, -1, pname, pval, plen);
+ while (off != -FDT_ERR_NOTFOUND) {
+ if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+ fdt_setprop(fdt, off, prop, val, len);
+ off = fdt_node_offset_by_prop_value(fdt, off, pname, pval, plen);
+ }
+}
+
+void do_fixup_by_prop_u32(void *fdt,
+ const char *pname, const void *pval, int plen,
+ const char *prop, u32 val, int create)
+{
+ val = cpu_to_fdt32(val);
+ do_fixup_by_prop(fdt, pname, pval, plen, prop, &val, 4, create);
+}
+
+void do_fixup_by_compat(void *fdt, const char *compat,
+ const char *prop, const void *val, int len, int create)
+{
+ int off = -1;
+#if defined(DEBUG)
+ int i;
+ debug("Updating property '%s/%s' = ", node, prop);
+ for (i = 0; i < len; i++)
+ debug(" %.2x", *(u8*)(val+i));
+ debug("\n");
+#endif
+ off = fdt_node_offset_by_compatible(fdt, -1, compat);
+ while (off != -FDT_ERR_NOTFOUND) {
+ if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+ fdt_setprop(fdt, off, prop, val, len);
+ off = fdt_node_offset_by_compatible(fdt, off, compat);
+ }
+}
+
+void do_fixup_by_compat_u32(void *fdt, const char *compat,
+ const char *prop, u32 val, int create)
+{
+ val = cpu_to_fdt32(val);
+ do_fixup_by_compat(fdt, compat, prop, &val, 4, create);
+}
+
+int fdt_fixup_memory(void *blob, u64 start, u64 size)
+{
+ int err, nodeoffset, len = 0;
+ u8 tmp[16];
+ const u32 *addrcell, *sizecell;
+
+ err = fdt_check_header(blob);
+ if (err < 0) {
+ printf("%s: %s\n", __FUNCTION__, fdt_strerror(err));
+ return err;
+ }
+
+ /* update, or add and update /memory node */
+ nodeoffset = fdt_path_offset(blob, "/memory");
+ if (nodeoffset < 0) {
+ nodeoffset = fdt_add_subnode(blob, 0, "memory");
+ if (nodeoffset < 0)
+ printf("WARNING: could not create /memory: %s.\n",
+ fdt_strerror(nodeoffset));
+ return nodeoffset;
+ }
+ err = fdt_setprop(blob, nodeoffset, "device_type", "memory",
+ sizeof("memory"));
+ if (err < 0) {
+ printf("WARNING: could not set %s %s.\n", "device_type",
+ fdt_strerror(err));
+ return err;
+ }
+
+ addrcell = fdt_getprop(blob, 0, "#address-cells", NULL);
+ /* use shifts and mask to ensure endianness */
+ if ((addrcell) && (*addrcell == 2)) {
+ tmp[0] = (start >> 56) & 0xff;
+ tmp[1] = (start >> 48) & 0xff;
+ tmp[2] = (start >> 40) & 0xff;
+ tmp[3] = (start >> 32) & 0xff;
+ tmp[4] = (start >> 24) & 0xff;
+ tmp[5] = (start >> 16) & 0xff;
+ tmp[6] = (start >> 8) & 0xff;
+ tmp[7] = (start ) & 0xff;
+ len = 8;
+ } else {
+ tmp[0] = (start >> 24) & 0xff;
+ tmp[1] = (start >> 16) & 0xff;
+ tmp[2] = (start >> 8) & 0xff;
+ tmp[3] = (start ) & 0xff;
+ len = 4;
+ }
+
+ sizecell = fdt_getprop(blob, 0, "#size-cells", NULL);
+ /* use shifts and mask to ensure endianness */
+ if ((sizecell) && (*sizecell == 2)) {
+ tmp[0+len] = (size >> 56) & 0xff;
+ tmp[1+len] = (size >> 48) & 0xff;
+ tmp[2+len] = (size >> 40) & 0xff;
+ tmp[3+len] = (size >> 32) & 0xff;
+ tmp[4+len] = (size >> 24) & 0xff;
+ tmp[5+len] = (size >> 16) & 0xff;
+ tmp[6+len] = (size >> 8) & 0xff;
+ tmp[7+len] = (size ) & 0xff;
+ len += 8;
+ } else {
+ tmp[0+len] = (size >> 24) & 0xff;
+ tmp[1+len] = (size >> 16) & 0xff;
+ tmp[2+len] = (size >> 8) & 0xff;
+ tmp[3+len] = (size ) & 0xff;
+ len += 4;
+ }
+
+ err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
+ if (err < 0) {
+ printf("WARNING: could not set %s %s.\n",
+ "reg", fdt_strerror(err));
+ return err;
+ }
+ return 0;
+}
+
+#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
+ defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
+
+void fdt_fixup_ethernet(void *fdt, bd_t *bd)
+{
+ int node;
+ const char *path;
+
+ node = fdt_path_offset(fdt, "/aliases");
+ if (node >= 0) {
+#if defined(CONFIG_HAS_ETH0)
+ path = fdt_getprop(fdt, node, "ethernet0", NULL);
+ if (path) {
+ do_fixup_by_path(fdt, path, "mac-address",
+ bd->bi_enetaddr, 6, 0);
+ do_fixup_by_path(fdt, path, "local-mac-address",
+ bd->bi_enetaddr, 6, 1);
+ }
+#endif
+#if defined(CONFIG_HAS_ETH1)
+ path = fdt_getprop(fdt, node, "ethernet1", NULL);
+ if (path) {
+ do_fixup_by_path(fdt, path, "mac-address",
+ bd->bi_enet1addr, 6, 0);
+ do_fixup_by_path(fdt, path, "local-mac-address",
+ bd->bi_enet1addr, 6, 1);
+ }
+#endif
+#if defined(CONFIG_HAS_ETH2)
+ path = fdt_getprop(fdt, node, "ethernet2", NULL);
+ if (path) {
+ do_fixup_by_path(fdt, path, "mac-address",
+ bd->bi_enet2addr, 6, 0);
+ do_fixup_by_path(fdt, path, "local-mac-address",
+ bd->bi_enet2addr, 6, 1);
+ }
+#endif
+#if defined(CONFIG_HAS_ETH3)
+ path = fdt_getprop(fdt, node, "ethernet3", NULL);
+ if (path) {
+ do_fixup_by_path(fdt, path, "mac-address",
+ bd->bi_enet3addr, 6, 0);
+ do_fixup_by_path(fdt, path, "local-mac-address",
+ bd->bi_enet3addr, 6, 1);
+ }
+#endif
+ }
+}
+#endif
diff --git a/common/fpga.c b/common/fpga.c
index 2eff239..d8b6ae3 100644
--- a/common/fpga.c
+++ b/common/fpga.c
@@ -67,14 +67,11 @@ static int fpga_dev_info( int devnum );
static void fpga_no_sup( char *fn, char *msg )
{
if ( fn && msg ) {
- printf( "%s: No support for %s. CONFIG_FPGA defined as 0x%x.\n",
- fn, msg, CONFIG_FPGA );
+ printf( "%s: No support for %s.\n", fn, msg);
} else if ( msg ) {
- printf( "No support for %s. CONFIG_FPGA defined as 0x%x.\n",
- msg, CONFIG_FPGA );
+ printf( "No support for %s.\n", msg);
} else {
- printf( "No FPGA suport! CONFIG_FPGA defined as 0x%x.\n",
- CONFIG_FPGA );
+ printf( "No FPGA suport!\n");
}
}
@@ -112,11 +109,6 @@ static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_va
printf( "%s: Null buffer.\n", fn );
return (fpga_desc * const)NULL;
}
- if ( !bsize ) {
- printf( "%s: Null buffer size.\n", fn );
- return (fpga_desc * const)NULL;
- }
-
return desc;
}
@@ -135,7 +127,7 @@ static int fpga_dev_info( int devnum )
switch ( desc->devtype ) {
case fpga_xilinx:
-#if CONFIG_FPGA & CFG_FPGA_XILINX
+#if defined(CONFIG_FPGA_XILINX)
printf( "Xilinx Device\nDescriptor @ 0x%p\n", desc );
ret_val = xilinx_info( desc->devdesc );
#else
@@ -143,7 +135,7 @@ static int fpga_dev_info( int devnum )
#endif
break;
case fpga_altera:
-#if CONFIG_FPGA & CFG_FPGA_ALTERA
+#if defined(CONFIG_FPGA_ALTERA)
printf( "Altera Device\nDescriptor @ 0x%p\n", desc );
ret_val = altera_info( desc->devdesc );
#else
@@ -175,14 +167,14 @@ int fpga_reloc( fpga_type devtype, void *desc, ulong reloc_off )
switch ( devtype ) {
case fpga_xilinx:
-#if CONFIG_FPGA & CFG_FPGA_XILINX
+#if defined(CONFIG_FPGA_XILINX)
ret_val = xilinx_reloc( desc, reloc_off );
#else
fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" );
#endif
break;
case fpga_altera:
-#if CONFIG_FPGA & CFG_FPGA_ALTERA
+#if defined(CONFIG_FPGA_ALTERA)
ret_val = altera_reloc( desc, reloc_off );
#else
fpga_no_sup( (char *)__FUNCTION__, "Altera devices" );
@@ -268,14 +260,14 @@ int fpga_load( int devnum, void *buf, size_t bsize )
if ( desc ) {
switch ( desc->devtype ) {
case fpga_xilinx:
-#if CONFIG_FPGA & CFG_FPGA_XILINX
+#if defined(CONFIG_FPGA_XILINX)
ret_val = xilinx_load( desc->devdesc, buf, bsize );
#else
fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" );
#endif
break;
case fpga_altera:
-#if CONFIG_FPGA & CFG_FPGA_ALTERA
+#if defined(CONFIG_FPGA_ALTERA)
ret_val = altera_load( desc->devdesc, buf, bsize );
#else
fpga_no_sup( (char *)__FUNCTION__, "Altera devices" );
@@ -301,14 +293,14 @@ int fpga_dump( int devnum, void *buf, size_t bsize )
if ( desc ) {
switch ( desc->devtype ) {
case fpga_xilinx:
-#if CONFIG_FPGA & CFG_FPGA_XILINX
+#if defined(CONFIG_FPGA_XILINX)
ret_val = xilinx_dump( desc->devdesc, buf, bsize );
#else
fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" );
#endif
break;
case fpga_altera:
-#if CONFIG_FPGA & CFG_FPGA_ALTERA
+#if defined(CONFIG_FPGA_ALTERA)
ret_val = altera_dump( desc->devdesc, buf, bsize );
#else
fpga_no_sup( (char *)__FUNCTION__, "Altera devices" );
diff --git a/common/main.c b/common/main.c
index 379695c..4253eac 100644
--- a/common/main.c
+++ b/common/main.c
@@ -696,7 +696,7 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num
}
}
-static int cread_line(char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len)
{
unsigned long num = 0;
unsigned long eol_num = 0;
@@ -818,6 +818,7 @@ static int cread_line(char *buf, unsigned int *len)
insert = !insert;
break;
case CTL_CH('x'):
+ case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
@@ -867,6 +868,27 @@ static int cread_line(char *buf, unsigned int *len)
REFRESH_TO_EOL();
continue;
}
+#ifdef CONFIG_AUTO_COMPLETE
+ case '\t': {
+ int num2, col;
+
+ /* do not autocomplete when in the middle */
+ if (num < eol_num) {
+ getcmd_cbeep();
+ break;
+ }
+
+ buf[num] = '\0';
+ col = strlen(prompt) + eol_num;
+ num2 = num;
+ if (cmd_auto_complete(prompt, buf, &num2, &col)) {
+ col = num2 - num;
+ num += col;
+ eol_num += col;
+ }
+ break;
+ }
+#endif
default:
cread_add_char(ichar, insert, &num, &eol_num, buf, *len);
break;
@@ -909,7 +931,7 @@ int readline (const char *const prompt)
puts (prompt);
- rc = cread_line(p, &len);
+ rc = cread_line(prompt, p, &len);
return rc < 0 ? rc : len;
#else
char *p = console_buffer;
diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index c69501f..281f0b2 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -49,10 +49,10 @@
struct mii_dev {
struct list_head link;
char *name;
- int (* read)(char *devname, unsigned char addr,
- unsigned char reg, unsigned short *value);
- int (* write)(char *devname, unsigned char addr,
- unsigned char reg, unsigned short value);
+ int (*read) (char *devname, unsigned char addr,
+ unsigned char reg, unsigned short *value);
+ int (*write) (char *devname, unsigned char addr,
+ unsigned char reg, unsigned short value);
};
static struct list_head mii_devs;
@@ -62,21 +62,21 @@ static struct mii_dev *current_mii;
*
* Initialize global data. Need to be called before any other miiphy routine.
*/
-void miiphy_init()
+void miiphy_init ()
{
- INIT_LIST_HEAD(&mii_devs);
- current_mii = NULL;
+ INIT_LIST_HEAD (&mii_devs);
+ current_mii = NULL;
}
/*****************************************************************************
*
* Register read and write MII access routines for the device <name>.
*/
-void miiphy_register(char *name,
- int (* read)(char *devname, unsigned char addr,
- unsigned char reg, unsigned short *value),
- int (* write)(char *devname, unsigned char addr,
- unsigned char reg, unsigned short value))
+void miiphy_register (char *name,
+ int (*read) (char *devname, unsigned char addr,
+ unsigned char reg, unsigned short *value),
+ int (*write) (char *devname, unsigned char addr,
+ unsigned char reg, unsigned short value))
{
struct list_head *entry;
struct mii_dev *new_dev;
@@ -84,63 +84,64 @@ void miiphy_register(char *name,
unsigned int name_len;
/* check if we have unique name */
- list_for_each(entry, &mii_devs) {
- miidev = list_entry(entry, struct mii_dev, link);
- if (strcmp(miidev->name, name) == 0) {
- printf("miiphy_register: non unique device name '%s'\n",
- name);
+ list_for_each (entry, &mii_devs) {
+ miidev = list_entry (entry, struct mii_dev, link);
+ if (strcmp (miidev->name, name) == 0) {
+ printf ("miiphy_register: non unique device name "
+ "'%s'\n", name);
return;
}
}
/* allocate memory */
- name_len = strlen(name);
- new_dev = (struct mii_dev *)malloc(sizeof(struct mii_dev) + name_len + 1);
+ name_len = strlen (name);
+ new_dev =
+ (struct mii_dev *)malloc (sizeof (struct mii_dev) + name_len + 1);
- if(new_dev == NULL) {
- printf("miiphy_register: cannot allocate memory for '%s'\n",
- name);
+ if (new_dev == NULL) {
+ printf ("miiphy_register: cannot allocate memory for '%s'\n",
+ name);
return;
}
- memset(new_dev, 0, sizeof(struct mii_dev) + name_len);
+ memset (new_dev, 0, sizeof (struct mii_dev) + name_len);
/* initalize mii_dev struct fields */
- INIT_LIST_HEAD(&new_dev->link);
+ INIT_LIST_HEAD (&new_dev->link);
new_dev->read = read;
new_dev->write = write;
new_dev->name = (char *)(new_dev + 1);
- strncpy(new_dev->name, name, name_len);
+ strncpy (new_dev->name, name, name_len);
new_dev->name[name_len] = '\0';
- debug("miiphy_register: added '%s', read=0x%08lx, write=0x%08lx\n",
- new_dev->name, new_dev->read, new_dev->write);
+ debug ("miiphy_register: added '%s', read=0x%08lx, write=0x%08lx\n",
+ new_dev->name, new_dev->read, new_dev->write);
/* add it to the list */
- list_add_tail(&new_dev->link, &mii_devs);
+ list_add_tail (&new_dev->link, &mii_devs);
if (!current_mii)
current_mii = new_dev;
}
-int miiphy_set_current_dev(char *devname)
+int miiphy_set_current_dev (char *devname)
{
struct list_head *entry;
struct mii_dev *dev;
- list_for_each(entry, &mii_devs) {
- dev = list_entry(entry, struct mii_dev, link);
+ list_for_each (entry, &mii_devs) {
+ dev = list_entry (entry, struct mii_dev, link);
- if (strcmp(devname, dev->name) == 0) {
+ if (strcmp (devname, dev->name) == 0) {
current_mii = dev;
return 0;
}
}
- printf("No such device: %s\n", devname);
+ printf ("No such device: %s\n", devname);
return 1;
}
-char *miiphy_get_current_dev()
+char *miiphy_get_current_dev ()
{
if (current_mii)
return current_mii->name;
@@ -156,8 +157,8 @@ char *miiphy_get_current_dev()
* Returns:
* 0 on success
*/
-int miiphy_read(char *devname, unsigned char addr, unsigned char reg,
- unsigned short *value)
+int miiphy_read (char *devname, unsigned char addr, unsigned char reg,
+ unsigned short *value)
{
struct list_head *entry;
struct mii_dev *dev;
@@ -165,22 +166,22 @@ int miiphy_read(char *devname, unsigned char addr, unsigned char reg,
int read_ret = 0;
if (!devname) {
- printf("NULL device name!\n");
+ printf ("NULL device name!\n");
return 1;
}
- list_for_each(entry, &mii_devs) {
- dev = list_entry(entry, struct mii_dev, link);
+ list_for_each (entry, &mii_devs) {
+ dev = list_entry (entry, struct mii_dev, link);
- if (strcmp(devname, dev->name) == 0) {
+ if (strcmp (devname, dev->name) == 0) {
found_dev = 1;
- read_ret = dev->read(devname, addr, reg, value);
+ read_ret = dev->read (devname, addr, reg, value);
break;
}
}
if (found_dev == 0)
- printf("No such device: %s\n", devname);
+ printf ("No such device: %s\n", devname);
return ((found_dev) ? read_ret : 1);
}
@@ -193,8 +194,8 @@ int miiphy_read(char *devname, unsigned char addr, unsigned char reg,
* Returns:
* 0 on success
*/
-int miiphy_write(char *devname, unsigned char addr, unsigned char reg,
- unsigned short value)
+int miiphy_write (char *devname, unsigned char addr, unsigned char reg,
+ unsigned short value)
{
struct list_head *entry;
struct mii_dev *dev;
@@ -202,22 +203,22 @@ int miiphy_write(char *devname, unsigned char addr, unsigned char reg,
int write_ret = 0;
if (!devname) {
- printf("NULL device name!\n");
+ printf ("NULL device name!\n");
return 1;
}
- list_for_each(entry, &mii_devs) {
- dev = list_entry(entry, struct mii_dev, link);
+ list_for_each (entry, &mii_devs) {
+ dev = list_entry (entry, struct mii_dev, link);
- if (strcmp(devname, dev->name) == 0) {
+ if (strcmp (devname, dev->name) == 0) {
found_dev = 1;
- write_ret = dev->write(devname, addr, reg, value);
+ write_ret = dev->write (devname, addr, reg, value);
break;
}
}
if (found_dev == 0)
- printf("No such device: %s\n", devname);
+ printf ("No such device: %s\n", devname);
return ((found_dev) ? write_ret : 1);
}
@@ -226,23 +227,22 @@ int miiphy_write(char *devname, unsigned char addr, unsigned char reg,
*
* Print out list of registered MII capable devices.
*/
-void miiphy_listdev(void)
+void miiphy_listdev (void)
{
struct list_head *entry;
struct mii_dev *dev;
- puts("MII devices: ");
- list_for_each(entry, &mii_devs) {
- dev = list_entry(entry, struct mii_dev, link);
- printf("'%s' ", dev->name);
+ puts ("MII devices: ");
+ list_for_each (entry, &mii_devs) {
+ dev = list_entry (entry, struct mii_dev, link);
+ printf ("'%s' ", dev->name);
}
- puts("\n");
+ puts ("\n");
if (current_mii)
- printf("Current device: '%s'\n", current_mii->name);
+ printf ("Current device: '%s'\n", current_mii->name);
}
-
/*****************************************************************************
*
* Read the OUI, manufacture's model number, and revision number.
@@ -254,9 +254,7 @@ void miiphy_listdev(void)
* Returns:
* 0 on success
*/
-int miiphy_info (char *devname,
- unsigned char addr,
- unsigned int *oui,
+int miiphy_info (char *devname, unsigned char addr, unsigned int *oui,
unsigned char *model, unsigned char *rev)
{
unsigned int reg = 0;
@@ -288,13 +286,12 @@ int miiphy_info (char *devname,
#ifdef DEBUG
printf ("PHY_PHYIDR[1,2] @ 0x%x = 0x%08x\n", addr, reg);
#endif
- *oui = ( reg >> 10);
- *model = (unsigned char) ((reg >> 4) & 0x0000003F);
- *rev = (unsigned char) ( reg & 0x0000000F);
+ *oui = (reg >> 10);
+ *model = (unsigned char)((reg >> 4) & 0x0000003F);
+ *rev = (unsigned char)(reg & 0x0000000F);
return (0);
}
-
/*****************************************************************************
*
* Reset the PHY.
@@ -345,104 +342,138 @@ int miiphy_reset (char *devname, unsigned char addr)
return (0);
}
-
/*****************************************************************************
*
- * Determine the ethernet speed (10/100).
+ * Determine the ethernet speed (10/100/1000). Return 10 on error.
*/
int miiphy_speed (char *devname, unsigned char addr)
{
- unsigned short reg;
+ u16 bmcr, anlpar;
#if defined(CONFIG_PHY_GIGE)
- if (miiphy_read (devname, addr, PHY_1000BTSR, &reg)) {
- printf ("PHY 1000BT Status read failed\n");
- } else {
- if (reg != 0xFFFF) {
- if ((reg & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) !=0) {
- return (_1000BASET);
- }
- }
+ u16 btsr;
+
+ /*
+ * Check for 1000BASE-X. If it is supported, then assume that the speed
+ * is 1000.
+ */
+ if (miiphy_is_1000base_x (devname, addr)) {
+ return _1000BASET;
+ }
+ /*
+ * No 1000BASE-X, so assume 1000BASE-T/100BASE-TX/10BASE-T register set.
+ */
+ /* Check for 1000BASE-T. */
+ if (miiphy_read (devname, addr, PHY_1000BTSR, &btsr)) {
+ printf ("PHY 1000BT status");
+ goto miiphy_read_failed;
+ }
+ if (btsr != 0xFFFF &&
+ (btsr & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD))) {
+ return _1000BASET;
}
#endif /* CONFIG_PHY_GIGE */
/* Check Basic Management Control Register first. */
- if (miiphy_read (devname, addr, PHY_BMCR, &reg)) {
- puts ("PHY speed read failed, assuming 10bT\n");
- return (_10BASET);
+ if (miiphy_read (devname, addr, PHY_BMCR, &bmcr)) {
+ printf ("PHY speed");
+ goto miiphy_read_failed;
}
/* Check if auto-negotiation is on. */
- if ((reg & PHY_BMCR_AUTON) != 0) {
+ if (bmcr & PHY_BMCR_AUTON) {
/* Get auto-negotiation results. */
- if (miiphy_read (devname, addr, PHY_ANLPAR, &reg)) {
- puts ("PHY AN speed read failed, assuming 10bT\n");
- return (_10BASET);
- }
- if ((reg & PHY_ANLPAR_100) != 0) {
- return (_100BASET);
- } else {
- return (_10BASET);
+ if (miiphy_read (devname, addr, PHY_ANLPAR, &anlpar)) {
+ printf ("PHY AN speed");
+ goto miiphy_read_failed;
}
+ return (anlpar & PHY_ANLPAR_100) ? _100BASET : _10BASET;
}
/* Get speed from basic control settings. */
- else if (reg & PHY_BMCR_100MB) {
- return (_100BASET);
- } else {
- return (_10BASET);
- }
+ return (bmcr & PHY_BMCR_100MB) ? _100BASET : _10BASET;
+ miiphy_read_failed:
+ printf (" read failed, assuming 10BASE-T\n");
+ return _10BASET;
}
-
/*****************************************************************************
*
- * Determine full/half duplex.
+ * Determine full/half duplex. Return half on error.
*/
int miiphy_duplex (char *devname, unsigned char addr)
{
- unsigned short reg;
+ u16 bmcr, anlpar;
#if defined(CONFIG_PHY_GIGE)
- if (miiphy_read (devname, addr, PHY_1000BTSR, &reg)) {
- printf ("PHY 1000BT Status read failed\n");
- } else {
- if ( (reg != 0xFFFF) &&
- (reg & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) ) {
- if ((reg & PHY_1000BTSR_1000FD) !=0) {
- return (FULL);
- } else {
- return (HALF);
- }
+ u16 btsr;
+
+ /* Check for 1000BASE-X. */
+ if (miiphy_is_1000base_x (devname, addr)) {
+ /* 1000BASE-X */
+ if (miiphy_read (devname, addr, PHY_ANLPAR, &anlpar)) {
+ printf ("1000BASE-X PHY AN duplex");
+ goto miiphy_read_failed;
+ }
+ }
+ /*
+ * No 1000BASE-X, so assume 1000BASE-T/100BASE-TX/10BASE-T register set.
+ */
+ /* Check for 1000BASE-T. */
+ if (miiphy_read (devname, addr, PHY_1000BTSR, &btsr)) {
+ printf ("PHY 1000BT status");
+ goto miiphy_read_failed;
+ }
+ if (btsr != 0xFFFF) {
+ if (btsr & PHY_1000BTSR_1000FD) {
+ return FULL;
+ } else if (btsr & PHY_1000BTSR_1000HD) {
+ return HALF;
}
}
#endif /* CONFIG_PHY_GIGE */
/* Check Basic Management Control Register first. */
- if (miiphy_read (devname, addr, PHY_BMCR, &reg)) {
- puts ("PHY duplex read failed, assuming half duplex\n");
- return (HALF);
+ if (miiphy_read (devname, addr, PHY_BMCR, &bmcr)) {
+ puts ("PHY duplex");
+ goto miiphy_read_failed;
}
/* Check if auto-negotiation is on. */
- if ((reg & PHY_BMCR_AUTON) != 0) {
+ if (bmcr & PHY_BMCR_AUTON) {
/* Get auto-negotiation results. */
- if (miiphy_read (devname, addr, PHY_ANLPAR, &reg)) {
- puts ("PHY AN duplex read failed, assuming half duplex\n");
- return (HALF);
- }
-
- if ((reg & (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD)) != 0) {
- return (FULL);
- } else {
- return (HALF);
+ if (miiphy_read (devname, addr, PHY_ANLPAR, &anlpar)) {
+ puts ("PHY AN duplex");
+ goto miiphy_read_failed;
}
+ return (anlpar & (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD)) ?
+ FULL : HALF;
}
/* Get speed from basic control settings. */
- else if (reg & PHY_BMCR_DPLX) {
- return (FULL);
- } else {
- return (HALF);
- }
+ return (bmcr & PHY_BMCR_DPLX) ? FULL : HALF;
+
+ miiphy_read_failed:
+ printf (" read failed, assuming half duplex\n");
+ return HALF;
+}
+/*****************************************************************************
+ *
+ * Return 1 if PHY supports 1000BASE-X, 0 if PHY supports 10BASE-T/100BASE-TX/
+ * 1000BASE-T, or on error.
+ */
+int miiphy_is_1000base_x (char *devname, unsigned char addr)
+{
+#if defined(CONFIG_PHY_GIGE)
+ u16 exsr;
+
+ if (miiphy_read (devname, addr, PHY_EXSR, &exsr)) {
+ printf ("PHY extended status read failed, assuming no "
+ "1000BASE-X\n");
+ return 0;
+ }
+ return 0 != (exsr & (PHY_EXSR_1000XF | PHY_EXSR_1000XH));
+#else
+ return 0;
+#endif
}
#ifdef CFG_FAULT_ECHO_LINK_DOWN
@@ -455,7 +486,7 @@ int miiphy_link (char *devname, unsigned char addr)
unsigned short reg;
/* dummy read; needed to latch some phys */
- (void)miiphy_read(devname, addr, PHY_BMSR, &reg);
+ (void)miiphy_read (devname, addr, PHY_BMSR, &reg);
if (miiphy_read (devname, addr, PHY_BMSR, &reg)) {
puts ("PHY_BMSR read failed, assuming no link\n");
return (0);
@@ -469,5 +500,4 @@ int miiphy_link (char *devname, unsigned char addr)
}
}
#endif
-
#endif /* CONFIG_MII */
diff --git a/common/serial.c b/common/serial.c
index dee1cc0..5601080 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -33,7 +33,7 @@ static struct serial_device *serial_devices = NULL;
static struct serial_device *serial_current = NULL;
#if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA27X)
-struct serial_device *default_serial_console (void)
+struct serial_device *__default_serial_console (void)
{
#if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2)
return &serial_smc_device;
@@ -41,7 +41,8 @@ struct serial_device *default_serial_console (void)
|| defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
return &serial_scc_device;
#elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
- || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx)
+ || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \
+ || defined(CONFIG_MPC5xxx)
#if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL)
#if (CONFIG_CONS_INDEX==1)
return &eserial1_device;
@@ -63,6 +64,8 @@ struct serial_device *default_serial_console (void)
#error No default console
#endif
}
+
+struct serial_device *default_serial_console(void) __attribute__((weak, alias("__default_serial_console")));
#endif
int serial_register (struct serial_device *dev)
@@ -91,7 +94,8 @@ void serial_initialize (void)
#endif
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
- || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx)
+ || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \
+ || defined(CONFIG_MPC5xxx)
serial_register(&serial0_device);
serial_register(&serial1_device);
#endif
diff --git a/common/spartan2.c b/common/spartan2.c
index 0fb23b6..2f1ea2c 100644
--- a/common/spartan2.c
+++ b/common/spartan2.c
@@ -25,7 +25,7 @@
#include <common.h> /* core U-Boot definitions */
#include <spartan2.h> /* Spartan-II device family */
-#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN2))
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN2)
/* Define FPGA_DEBUG to get debug printf's */
#ifdef FPGA_DEBUG
@@ -441,7 +441,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
int ret_val = FPGA_FAIL; /* assume the worst */
Xilinx_Spartan2_Slave_Serial_fns *fn = desc->iface_fns;
int i;
- char val;
+ unsigned char val;
PRINTF ("%s: start with interface functions @ 0x%p\n",
__FUNCTION__, fn);
@@ -516,7 +516,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
(*fn->clk) (FALSE, TRUE, cookie);
CONFIG_FPGA_DELAY ();
/* Write data */
- (*fn->wr) ((val < 0), TRUE, cookie);
+ (*fn->wr) ((val & 0x80), TRUE, cookie);
CONFIG_FPGA_DELAY ();
/* Assert the clock */
(*fn->clk) (TRUE, TRUE, cookie);
@@ -561,6 +561,13 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
}
putc ('\n'); /* terminate the dotted line */
+ /*
+ * Run the post configuration function if there is one.
+ */
+ if (*fn->post) {
+ (*fn->post) (cookie);
+ }
+
#ifdef CFG_FPGA_PROG_FEEDBACK
if (ret_val == FPGA_SUCCESS) {
puts ("Done.\n");
@@ -615,8 +622,10 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset)
PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__,
desc);
- addr = (ulong) (fn->pre) + reloc_offset;
- fn_r->pre = (Xilinx_pre_fn) addr;
+ if (fn->pre) {
+ addr = (ulong) (fn->pre) + reloc_offset;
+ fn_r->pre = (Xilinx_pre_fn) addr;
+ }
addr = (ulong) (fn->pgm) + reloc_offset;
fn_r->pgm = (Xilinx_pgm_fn) addr;
@@ -633,6 +642,11 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset)
addr = (ulong) (fn->wr) + reloc_offset;
fn_r->wr = (Xilinx_wr_fn) addr;
+ if (fn->post) {
+ addr = (ulong) (fn->post) + reloc_offset;
+ fn_r->post = (Xilinx_post_fn) addr;
+ }
+
fn_r->relocated = TRUE;
} else {
diff --git a/common/spartan3.c b/common/spartan3.c
index c0f2b05..d329e70 100644
--- a/common/spartan3.c
+++ b/common/spartan3.c
@@ -30,7 +30,7 @@
#include <common.h> /* core U-Boot definitions */
#include <spartan3.h> /* Spartan-II device family */
-#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN3))
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN3)
/* Define FPGA_DEBUG to get debug printf's */
#ifdef FPGA_DEBUG
@@ -446,7 +446,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
int ret_val = FPGA_FAIL; /* assume the worst */
Xilinx_Spartan3_Slave_Serial_fns *fn = desc->iface_fns;
int i;
- char val;
+ unsigned char val;
PRINTF ("%s: start with interface functions @ 0x%p\n",
__FUNCTION__, fn);
@@ -521,7 +521,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
(*fn->clk) (FALSE, TRUE, cookie);
CONFIG_FPGA_DELAY ();
/* Write data */
- (*fn->wr) ((val < 0), TRUE, cookie);
+ (*fn->wr) ((val & 0x80), TRUE, cookie);
CONFIG_FPGA_DELAY ();
/* Assert the clock */
(*fn->clk) (TRUE, TRUE, cookie);
@@ -566,6 +566,13 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
}
putc ('\n'); /* terminate the dotted line */
+ /*
+ * Run the post configuration function if there is one.
+ */
+ if (*fn->post) {
+ (*fn->post) (cookie);
+ }
+
#ifdef CFG_FPGA_PROG_FEEDBACK
if (ret_val == FPGA_SUCCESS) {
puts ("Done.\n");
@@ -620,8 +627,10 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset)
PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__,
desc);
- addr = (ulong) (fn->pre) + reloc_offset;
- fn_r->pre = (Xilinx_pre_fn) addr;
+ if (fn->pre) {
+ addr = (ulong) (fn->pre) + reloc_offset;
+ fn_r->pre = (Xilinx_pre_fn) addr;
+ }
addr = (ulong) (fn->pgm) + reloc_offset;
fn_r->pgm = (Xilinx_pgm_fn) addr;
@@ -638,6 +647,11 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset)
addr = (ulong) (fn->wr) + reloc_offset;
fn_r->wr = (Xilinx_wr_fn) addr;
+ if (fn->post) {
+ addr = (ulong) (fn->post) + reloc_offset;
+ fn_r->post = (Xilinx_post_fn) addr;
+ }
+
fn_r->relocated = TRUE;
} else {
diff --git a/common/usb.c b/common/usb.c
index 933afa9..4df01ea 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -53,7 +53,7 @@
#include <usb.h>
#ifdef CONFIG_4xx
-#include <405gp_pci.h>
+#include <asm/4xx_pci.h>
#endif
#undef USB_DEBUG
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 0f79f36..443d785 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1195,7 +1195,7 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
dev_desc->product[16] = 0;
dev_desc->revision[4] = 0;
#ifdef CONFIG_USB_BIN_FIXUP
- usb_bin_fixup(dev->descriptor, dev_desc->vendor, dev_desc->product);
+ usb_bin_fixup(dev->descriptor, (uchar *)dev_desc->vendor, (uchar *)dev_desc->product);
#endif /* CONFIG_USB_BIN_FIXUP */
USB_STOR_PRINTF("ISO Vers %X, Response Data %X\n",usb_stor_buf[2],usb_stor_buf[3]);
if(usb_test_unit_ready(pccb,ss)) {
diff --git a/common/virtex2.c b/common/virtex2.c
index b5dc366..1283ff6 100644
--- a/common/virtex2.c
+++ b/common/virtex2.c
@@ -31,7 +31,7 @@
#include <common.h>
#include <virtex2.h>
-#if (CONFIG_FPGA & (CFG_XILINX | CFG_VIRTEX2))
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_VIRTEX2)
#if 0
#define FPGA_DEBUG
diff --git a/common/xilinx.c b/common/xilinx.c
index e03e78c..c898238 100644
--- a/common/xilinx.c
+++ b/common/xilinx.c
@@ -32,7 +32,7 @@
#include <spartan2.h>
#include <spartan3.h>
-#if (CONFIG_FPGA & CFG_FPGA_XILINX)
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
#if 0
#define FPGA_DEBUG
@@ -59,7 +59,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize)
} else
switch (desc->family) {
case Xilinx_Spartan2:
-#if (CONFIG_FPGA & CFG_SPARTAN2)
+#if defined(CONFIG_FPGA_SPARTAN2)
PRINTF ("%s: Launching the Spartan-II Loader...\n",
__FUNCTION__);
ret_val = Spartan2_load (desc, buf, bsize);
@@ -69,7 +69,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize)
#endif
break;
case Xilinx_Spartan3:
-#if (CONFIG_FPGA & CFG_SPARTAN3)
+#if defined(CONFIG_FPGA_SPARTAN3)
PRINTF ("%s: Launching the Spartan-III Loader...\n",
__FUNCTION__);
ret_val = Spartan3_load (desc, buf, bsize);
@@ -79,7 +79,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize)
#endif
break;
case Xilinx_Virtex2:
-#if (CONFIG_FPGA & CFG_VIRTEX2)
+#if defined(CONFIG_FPGA_VIRTEX2)
PRINTF ("%s: Launching the Virtex-II Loader...\n",
__FUNCTION__);
ret_val = Virtex2_load (desc, buf, bsize);
@@ -106,7 +106,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize)
} else
switch (desc->family) {
case Xilinx_Spartan2:
-#if (CONFIG_FPGA & CFG_SPARTAN2)
+#if defined(CONFIG_FPGA_SPARTAN2)
PRINTF ("%s: Launching the Spartan-II Reader...\n",
__FUNCTION__);
ret_val = Spartan2_dump (desc, buf, bsize);
@@ -116,7 +116,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize)
#endif
break;
case Xilinx_Spartan3:
-#if (CONFIG_FPGA & CFG_SPARTAN3)
+#if defined(CONFIG_FPGA_SPARTAN3)
PRINTF ("%s: Launching the Spartan-III Reader...\n",
__FUNCTION__);
ret_val = Spartan3_dump (desc, buf, bsize);
@@ -126,7 +126,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize)
#endif
break;
case Xilinx_Virtex2:
-#if (CONFIG_FPGA & CFG_VIRTEX2)
+#if defined( CONFIG_FPGA_VIRTEX2)
PRINTF ("%s: Launching the Virtex-II Reader...\n",
__FUNCTION__);
ret_val = Virtex2_dump (desc, buf, bsize);
@@ -198,7 +198,7 @@ int xilinx_info (Xilinx_desc * desc)
printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
switch (desc->family) {
case Xilinx_Spartan2:
-#if (CONFIG_FPGA & CFG_SPARTAN2)
+#if defined(CONFIG_FPGA_SPARTAN2)
Spartan2_info (desc);
#else
/* just in case */
@@ -207,7 +207,7 @@ int xilinx_info (Xilinx_desc * desc)
#endif
break;
case Xilinx_Spartan3:
-#if (CONFIG_FPGA & CFG_SPARTAN3)
+#if defined(CONFIG_FPGA_SPARTAN3)
Spartan3_info (desc);
#else
/* just in case */
@@ -216,7 +216,7 @@ int xilinx_info (Xilinx_desc * desc)
#endif
break;
case Xilinx_Virtex2:
-#if (CONFIG_FPGA & CFG_VIRTEX2)
+#if defined(CONFIG_FPGA_VIRTEX2)
Virtex2_info (desc);
#else
/* just in case */
@@ -249,7 +249,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset)
} else
switch (desc->family) {
case Xilinx_Spartan2:
-#if (CONFIG_FPGA & CFG_SPARTAN2)
+#if defined(CONFIG_FPGA_SPARTAN2)
ret_val = Spartan2_reloc (desc, reloc_offset);
#else
printf ("%s: No support for Spartan-II devices.\n",
@@ -257,7 +257,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset)
#endif
break;
case Xilinx_Spartan3:
-#if (CONFIG_FPGA & CFG_SPARTAN3)
+#if defined(CONFIG_FPGA_SPARTAN3)
ret_val = Spartan3_reloc (desc, reloc_offset);
#else
printf ("%s: No support for Spartan-III devices.\n",
@@ -265,7 +265,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset)
#endif
break;
case Xilinx_Virtex2:
-#if (CONFIG_FPGA & CFG_VIRTEX2)
+#if defined(CONFIG_FPGA_VIRTEX2)
ret_val = Virtex2_reloc (desc, reloc_offset);
#else
printf ("%s: No support for Virtex-II devices.\n",
@@ -308,4 +308,4 @@ static int xilinx_validate (Xilinx_desc * desc, char *fn)
return ret_val;
}
-#endif /* CONFIG_FPGA & CFG_FPGA_XILINX */
+#endif /* CONFIG_FPGA && CONFIG_FPGA_XILINX */