summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.mailmap27
-rw-r--r--Makefile9
-rw-r--r--README16
-rw-r--r--arch/blackfin/cpu/jtag-console.c10
-rw-r--r--arch/m68k/include/asm/posix_types.h2
-rw-r--r--arch/powerpc/cpu/mpc512x/serial.c10
-rw-r--r--arch/powerpc/cpu/mpc8xx/video.c6
-rw-r--r--arch/sandbox/cpu/cpu.c4
-rw-r--r--arch/sandbox/cpu/start.c8
-rw-r--r--arch/sandbox/include/asm/config.h1
-rw-r--r--arch/sh/cpu/sh2/u-boot.lds76
-rw-r--r--arch/sh/cpu/sh4/u-boot.lds80
-rw-r--r--arch/sh/cpu/u-boot.lds (renamed from arch/sh/cpu/sh3/u-boot.lds)8
-rw-r--r--arch/sparc/cpu/u-boot.lds (renamed from board/gaisler/grsim/u-boot.lds)6
-rw-r--r--arch/x86/lib/video.c8
-rw-r--r--board/bf527-ezkit/video.c10
-rw-r--r--board/bf548-ezkit/video.c10
-rw-r--r--board/cm-bf548/video.c10
-rw-r--r--board/esd/common/cmd_loadpci.c8
-rw-r--r--board/freescale/m5253demo/flash.c10
-rw-r--r--board/gaisler/gr_cpci_ax2000/u-boot.lds143
-rw-r--r--board/gaisler/gr_ep2s60/u-boot.lds143
-rw-r--r--board/gaisler/gr_xc3s_1500/u-boot.lds145
-rw-r--r--board/gaisler/grsim_leon2/u-boot.lds142
-rw-r--r--board/mpl/common/kbd.c6
-rw-r--r--board/mpl/common/kbd.h6
-rw-r--r--board/mpl/pati/pati.c8
-rw-r--r--board/nokia/rx51/rx51.c6
-rw-r--r--board/raspberrypi/rpi_b/rpi_b.c4
-rw-r--r--boards.cfg18
-rw-r--r--common/autoboot.c1
-rw-r--r--common/board_f.c57
-rw-r--r--common/board_r.c34
-rw-r--r--common/bootm_os.c3
-rw-r--r--common/cmd_bdinfo.c3
-rw-r--r--common/cmd_cache.c4
-rw-r--r--common/cmd_eeprom.c6
-rw-r--r--common/cmd_ext2.c10
-rw-r--r--common/cmd_fat.c2
-rw-r--r--common/cmd_fs.c10
-rw-r--r--common/cmd_i2c.c6
-rw-r--r--common/cmd_ide.c135
-rw-r--r--common/cmd_log.c11
-rw-r--r--common/cmd_mii.c8
-rw-r--r--common/cmd_nvedit.c19
-rw-r--r--common/cmd_part.c6
-rw-r--r--common/cmd_pxe.c4
-rw-r--r--common/cmd_source.c3
-rw-r--r--common/cmd_ubi.c2
-rw-r--r--common/cmd_ubifs.c12
-rw-r--r--common/console.c24
-rw-r--r--common/dlmalloc.c85
-rw-r--r--common/env_common.c10
-rw-r--r--common/lcd.c14
-rw-r--r--common/main.c3
-rw-r--r--common/spl/spl_nand.c6
-rw-r--r--common/splash.c6
-rw-r--r--common/stdio.c66
-rw-r--r--common/usb_kbd.c6
-rw-r--r--disk/part.c8
-rw-r--r--doc/driver-model/README.txt216
-rw-r--r--drivers/block/ahci.c2
-rw-r--r--drivers/core/device.c169
-rw-r--r--drivers/core/lists.c23
-rw-r--r--drivers/core/root.c79
-rw-r--r--drivers/core/uclass.c135
-rw-r--r--drivers/demo/demo-uclass.c1
-rw-r--r--drivers/gpio/Makefile2
-rw-r--r--drivers/i2c/fsl_i2c.c22
-rw-r--r--drivers/i2c/omap24xx_i2c.c57
-rw-r--r--drivers/input/cros_ec_keyb.c6
-rw-r--r--drivers/input/i8042.c4
-rw-r--r--drivers/input/keyboard.c6
-rw-r--r--drivers/input/tegra-kbc.c6
-rw-r--r--drivers/misc/cbmem_console.c6
-rw-r--r--drivers/mmc/mmc.c26
-rw-r--r--drivers/mmc/omap_hsmmc.c2
-rw-r--r--drivers/mtd/cfi_flash.c2
-rw-r--r--drivers/net/netconsole.c10
-rw-r--r--drivers/serial/serial.c55
-rw-r--r--drivers/serial/serial_ns16550.c18
-rw-r--r--drivers/serial/usbtty.c8
-rw-r--r--drivers/usb/host/xhci.h6
-rw-r--r--drivers/video/cfb_console.c8
-rw-r--r--fs/fs.c5
-rw-r--r--fs/yaffs2/yaffs_guts.c32
-rw-r--r--fs/yaffs2/yaffs_verify.c4
-rw-r--r--fs/yaffs2/yaffsfs.c8
-rw-r--r--include/altera.h2
-rw-r--r--include/asm-generic/global_data.h9
-rw-r--r--include/common.h5
-rw-r--r--include/compiler.h1
-rw-r--r--include/configs/ELPPC.h4
-rw-r--r--include/configs/MHPC.h4
-rw-r--r--include/configs/am335x_evm.h2
-rw-r--r--include/configs/h2200.h1
-rw-r--r--include/configs/jadecpu.h4
-rw-r--r--include/configs/nokia_rx51.h5
-rw-r--r--include/configs/omap3_beagle.h2
-rw-r--r--include/configs/rpi_b.h2
-rw-r--r--include/configs/sandbox.h4
-rw-r--r--include/dm/device-internal.h6
-rw-r--r--include/dm/device.h120
-rw-r--r--include/dm/lists.h2
-rw-r--r--include/dm/platdata.h10
-rw-r--r--include/dm/root.h61
-rw-r--r--include/dm/test.h22
-rw-r--r--include/dm/uclass-id.h3
-rw-r--r--include/dm/uclass-internal.h23
-rw-r--r--include/dm/uclass.h49
-rw-r--r--include/env_callback.h2
-rw-r--r--include/fdtdec.h29
-rw-r--r--include/i8042.h6
-rw-r--r--include/ide.h4
-rw-r--r--include/linux/compat.h19
-rw-r--r--include/mmc.h4
-rw-r--r--include/search.h3
-rw-r--r--include/status_led.h22
-rw-r--r--include/stdio_dev.h17
-rw-r--r--include/video.h8
-rw-r--r--lib/asm-offsets.c3
-rw-r--r--lib/div64.c1
-rw-r--r--lib/fdtdec.c61
-rw-r--r--lib/hashtable.c17
-rw-r--r--lib/lmb.c6
-rw-r--r--lib/sha1.c2
-rw-r--r--lib/time.c18
-rw-r--r--lib/vsprintf.c22
-rw-r--r--net/bootp.c5
-rw-r--r--net/eth.c29
-rwxr-xr-xscripts/mailmapper160
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/bus.c242
-rw-r--r--test/dm/cmd_dm.c35
-rw-r--r--test/dm/core.c64
-rw-r--r--test/dm/test-driver.c11
-rw-r--r--test/dm/test-fdt.c164
-rw-r--r--test/dm/test-main.c4
-rw-r--r--test/dm/test.dts42
-rw-r--r--tools/buildman/builder.py27
-rwxr-xr-xtools/buildman/buildman.py3
-rw-r--r--tools/buildman/control.py1
143 files changed, 2388 insertions, 1411 deletions
diff --git a/.gitignore b/.gitignore
index 2ddf57f..0ace33b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,11 +44,7 @@
#
# Generated files
#
-
/LOG
-/errlog
-/reloc_off
-
/spl/
/tpl/
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..e1c6663
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,27 @@
+#
+# This list is used by git-shortlog to fix a few botched name translations
+# in the git archive, either because the author's full name was messed up
+# and/or not always written the same way, making contributions from the
+# same person appearing not to be so or badly displayed.
+#
+# This file can be modified by hand or updated by the following command:
+# scripts/mailmapper > tmp; mv tmp .mailmap
+#
+
+Allen Martin <amartin@nvidia.com>
+Andreas Bießmann <andreas.devel@googlemail.com>
+Aneesh V <aneesh@ti.com>
+Dirk Behme <dirk.behme@googlemail.com>
+Fabio Estevam <fabio.estevam@freescale.com>
+Jagannadha Sutradharudu Teki <402jagan@gmail.com>
+Markus Klotzbuecher <mk@denx.de>
+Prabhakar Kushwaha <prabhakar@freescale.com>
+Rajeshwari Shinde <rajeshwari.s@samsung.com>
+Sandeep Paulraj <s-paulraj@ti.com>
+Shaohui Xie <Shaohui.Xie@freescale.com>
+Stefan Roese <stroese>
+Stefano Babic <sbabic@denx.de>
+TsiChung Liew <Tsi-Chung.Liew@freescale.com>
+Wolfgang Denk <wdenk>
+York Sun <yorksun@freescale.com>
+Łukasz Majewski <l.majewski@samsung.com>
diff --git a/Makefile b/Makefile
index 5277781..ca212b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1137,7 +1137,7 @@ spl/sunxi-spl.bin: spl/u-boot-spl
tpl/u-boot-tpl.bin: tools prepare
$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all CONFIG_TPL_BUILD=y
-TAG_SUBDIRS := $(u-boot-dirs) include
+TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
FIND := find
FINDFLAGS := -L
@@ -1147,7 +1147,7 @@ tags ctags:
-name '*.[chS]' -print`
etags:
- etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
+ etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
-name '*.[chS]' -print`
cscope:
$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
@@ -1222,7 +1222,7 @@ CLOBBER_FILES += u-boot* MLO* SPL System.map
MRPROPER_DIRS += include/config include/generated \
.tmp_objdiff
MRPROPER_FILES += .config .config.old \
- tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
+ ctags etags cscope* GPATH GTAGS GRTAGS GSYMS \
include/config.h include/config.mk
# clean - Delete most, but leave enough to build external modules
@@ -1311,7 +1311,8 @@ help:
@echo ' dir/file.[oisS] - Build specified target only'
@echo ' dir/file.lst - Build specified mixed source/assembly target only'
@echo ' (requires a recent binutils and recent build (System.map))'
- @echo ' tags/TAGS - Generate tags file for editors'
+ @echo ' tags/ctags - Generate ctags file for editors'
+ @echo ' etags - Generate etags file for editors'
@echo ' cscope - Generate cscope index'
@echo ' ubootrelease - Output the release version string'
@echo ' ubootversion - Output the version stored in Makefile'
diff --git a/README b/README
index 4ac7399..f704eb3 100644
--- a/README
+++ b/README
@@ -3736,6 +3736,22 @@ Configuration Settings:
- CONFIG_SYS_MALLOC_LEN:
Size of DRAM reserved for malloc() use.
+- CONFIG_SYS_MALLOC_F_LEN
+ Size of the malloc() pool for use before relocation. If
+ this is defined, then a very simple malloc() implementation
+ will become available before relocation. The address is just
+ below the global data, and the stack is moved down to make
+ space.
+
+ This feature allocates regions with increasing addresses
+ within the region. calloc() is supported, but realloc()
+ is not available. free() is supported but does nothing.
+ The memory will be freed (or in fact just forgotton) when
+ U-Boot relocates itself.
+
+ Pre-relocation malloc() is only supported on sandbox
+ at present but is fairly easy to enable for other archs.
+
- CONFIG_SYS_BOOTM_LEN:
Normally compressed uImages are limited to an
uncompressed size of 8 MBytes. If this is not enough,
diff --git a/arch/blackfin/cpu/jtag-console.c b/arch/blackfin/cpu/jtag-console.c
index 7cddb85..b8be318 100644
--- a/arch/blackfin/cpu/jtag-console.c
+++ b/arch/blackfin/cpu/jtag-console.c
@@ -112,11 +112,11 @@ static void jtag_send(const char *raw_str, uint32_t len)
if (cooked_str != raw_str)
free((char *)cooked_str);
}
-static void jtag_putc(const char c)
+static void jtag_putc(struct stdio_dev *dev, const char c)
{
jtag_send(&c, 1);
}
-static void jtag_puts(const char *s)
+static void jtag_puts(struct stdio_dev *dev, const char *s)
{
jtag_send(s, strlen(s));
}
@@ -133,7 +133,7 @@ static int jtag_tstc_dbg(void)
}
/* Higher layers want to know when any data is available */
-static int jtag_tstc(void)
+static int jtag_tstc(struct stdio_dev *dev)
{
return jtag_tstc_dbg() || leftovers_len;
}
@@ -142,7 +142,7 @@ static int jtag_tstc(void)
* [32bit length][actual data]
*/
static uint32_t leftovers;
-static int jtag_getc(void)
+static int jtag_getc(struct stdio_dev *dev)
{
int ret;
uint32_t emudat;
@@ -173,7 +173,7 @@ static int jtag_getc(void)
leftovers = emudat;
}
- return jtag_getc();
+ return jtag_getc(dev);
}
int drv_jtag_console_init(void)
diff --git a/arch/m68k/include/asm/posix_types.h b/arch/m68k/include/asm/posix_types.h
index b97d267..4fbc040 100644
--- a/arch/m68k/include/asm/posix_types.h
+++ b/arch/m68k/include/asm/posix_types.h
@@ -15,7 +15,7 @@ typedef long __kernel_off_t;
typedef int __kernel_pid_t;
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
-typedef unsigned long __kernel_size_t;
+typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef long __kernel_ptrdiff_t;
typedef long __kernel_time_t;
diff --git a/arch/powerpc/cpu/mpc512x/serial.c b/arch/powerpc/cpu/mpc512x/serial.c
index 42e0dc9..4105a28 100644
--- a/arch/powerpc/cpu/mpc512x/serial.c
+++ b/arch/powerpc/cpu/mpc512x/serial.c
@@ -384,7 +384,7 @@ struct stdio_dev *open_port(int num, int baudrate)
sprintf(env_val, "%d", baudrate);
setenv(env_var, env_val);
- if (port->start())
+ if (port->start(port))
return NULL;
set_bit(num, &initialized);
@@ -407,7 +407,7 @@ int close_port(int num)
if (!port)
return -1;
- ret = port->stop();
+ ret = port->stop(port);
clear_bit(num, &initialized);
return ret;
@@ -418,7 +418,7 @@ int write_port(struct stdio_dev *port, char *buf)
if (!port || !buf)
return -1;
- port->puts(buf);
+ port->puts(port, buf);
return 0;
}
@@ -433,8 +433,8 @@ int read_port(struct stdio_dev *port, char *buf, int size)
if (!size)
return 0;
- while (port->tstc()) {
- buf[cnt++] = port->getc();
+ while (port->tstc(port)) {
+ buf[cnt++] = port->getc(port);
if (cnt > size)
break;
}
diff --git a/arch/powerpc/cpu/mpc8xx/video.c b/arch/powerpc/cpu/mpc8xx/video.c
index 2fd5b11..9590bfd 100644
--- a/arch/powerpc/cpu/mpc8xx/video.c
+++ b/arch/powerpc/cpu/mpc8xx/video.c
@@ -948,7 +948,7 @@ static inline void console_newline (void)
}
}
-void video_putc (const char c)
+void video_putc(struct stdio_dev *dev, const char c)
{
if (!video_enable) {
serial_putc (c);
@@ -985,7 +985,7 @@ void video_putc (const char c)
}
}
-void video_puts (const char *s)
+void video_puts(struct stdio_dev *dev, const char *s)
{
int count = strlen (s);
@@ -994,7 +994,7 @@ void video_puts (const char *s)
serial_putc (*s++);
else
while (count--)
- video_putc (*s++);
+ video_putc(dev, *s++);
}
/************************************************************************/
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 3f4005b..1aa397c 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -4,6 +4,7 @@
*/
#include <common.h>
+#include <dm/root.h>
#include <os.h>
#include <asm/state.h>
@@ -14,6 +15,9 @@ void reset_cpu(ulong ignored)
if (state_uninit())
os_exit(2);
+ if (dm_uninit())
+ os_exit(2);
+
/* This is considered normal termination for now */
os_exit(0);
}
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index aad3b8b..b3d7051 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <os.h>
#include <asm/getopt.h>
+#include <asm/io.h>
#include <asm/sections.h>
#include <asm/state.h>
@@ -218,6 +219,7 @@ SANDBOX_CMDLINE_OPT_SHORT(terminal, 't', 1,
int main(int argc, char *argv[])
{
struct sandbox_state *state;
+ gd_t data;
int ret;
ret = state_init();
@@ -236,6 +238,12 @@ int main(int argc, char *argv[])
if (state->ram_buf_rm && state->ram_buf_fname)
os_unlink(state->ram_buf_fname);
+ memset(&data, '\0', sizeof(data));
+ gd = &data;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
+
/* Do pre- and post-relocation init */
board_init_f(0);
diff --git a/arch/sandbox/include/asm/config.h b/arch/sandbox/include/asm/config.h
index 6c1bff9..ec7729e 100644
--- a/arch/sandbox/include/asm/config.h
+++ b/arch/sandbox/include/asm/config.h
@@ -7,7 +7,6 @@
#ifndef _ASM_CONFIG_H_
#define _ASM_CONFIG_H_
-#define CONFIG_SYS_GENERIC_GLOBAL_DATA
#define CONFIG_SANDBOX_ARCH
/* Used by drivers/spi/sandbox_spi.c and arch/sandbox/include/asm/state.h */
diff --git a/arch/sh/cpu/sh2/u-boot.lds b/arch/sh/cpu/sh2/u-boot.lds
deleted file mode 100644
index 254d9f2..0000000
--- a/arch/sh/cpu/sh2/u-boot.lds
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2008 Nobuhiro Iwamatsu
- * Copyright (C) 2008 Renesas Solutions Corp.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sh-linux", "elf32-sh-linux", "elf32-sh-linux")
-OUTPUT_ARCH(sh)
-ENTRY(_start)
-
-SECTIONS
-{
- /*
- * entry and reloct_dst will be provided via ldflags
- */
- . = .;
-
- PROVIDE (_ftext = .);
- PROVIDE (_fcode = .);
- PROVIDE (_start = .);
-
- .text :
- {
- KEEP(arch/sh/cpu/sh2/start.o (.text))
- . = ALIGN(8192);
- common/env_embedded.o (.ppcenv)
- . = ALIGN(8192);
- common/env_embedded.o (.ppcenvr)
- . = ALIGN(8192);
- *(.text)
- . = ALIGN(4);
- } =0xFF
- PROVIDE (_ecode = .);
- .rodata :
- {
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- . = ALIGN(4);
- }
- PROVIDE (_etext = .);
-
-
- PROVIDE (_fdata = .);
- .data :
- {
- *(.data)
- . = ALIGN(4);
- }
- PROVIDE (_edata = .);
-
- PROVIDE (_fgot = .);
- .got :
- {
- *(.got)
- . = ALIGN(4);
- }
- PROVIDE (_egot = .);
-
-
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- PROVIDE (reloc_dst_end = .);
-
- PROVIDE (bss_start = .);
- PROVIDE (__bss_start = .);
- .bss :
- {
- *(.bss)
- . = ALIGN(4);
- }
- PROVIDE (bss_end = .);
-
- PROVIDE (__bss_end = .);
-}
diff --git a/arch/sh/cpu/sh4/u-boot.lds b/arch/sh/cpu/sh4/u-boot.lds
deleted file mode 100644
index 57544ce..0000000
--- a/arch/sh/cpu/sh4/u-boot.lds
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007
- * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
- *
- * Copyright (C) 2008-2009
- * Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sh-linux", "elf32-sh-linux", "elf32-sh-linux")
-OUTPUT_ARCH(sh)
-ENTRY(_start)
-
-SECTIONS
-{
- /*
- * entry and reloct_dst will be provided via ldflags
- */
- . = .;
-
- PROVIDE (_ftext = .);
- PROVIDE (_fcode = .);
- PROVIDE (_start = .);
-
- .text :
- {
- KEEP(arch/sh/cpu/sh4/start.o (.text))
- . = ALIGN(8192);
- common/env_embedded.o (.ppcenv)
- . = ALIGN(8192);
- common/env_embedded.o (.ppcenvr)
- . = ALIGN(8192);
- *(.text)
- . = ALIGN(4);
- } =0xFF
- PROVIDE (_ecode = .);
- .rodata :
- {
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- . = ALIGN(4);
- }
- PROVIDE (_etext = .);
-
-
- PROVIDE (_fdata = .);
- .data :
- {
- *(.data)
- . = ALIGN(4);
- }
- PROVIDE (_edata = .);
-
- PROVIDE (_fgot = .);
- .got :
- {
- *(.got)
- . = ALIGN(4);
- }
- PROVIDE (_egot = .);
-
-
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- PROVIDE (reloc_dst_end = .);
- /* _reloc_dst_end = .; */
-
- PROVIDE (bss_start = .);
- PROVIDE (__bss_start = .);
- .bss (NOLOAD) :
- {
- *(.bss)
- . = ALIGN(4);
- }
- PROVIDE (bss_end = .);
-
- PROVIDE (__bss_end = .);
-}
diff --git a/arch/sh/cpu/sh3/u-boot.lds b/arch/sh/cpu/u-boot.lds
index 26de086..30c7a9d 100644
--- a/arch/sh/cpu/sh3/u-boot.lds
+++ b/arch/sh/cpu/u-boot.lds
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2007
- * Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
- *
- * Copyright (C) 2007
* Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
*
+ * Copyright (C) 2008-2009
+ * Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
+ *
* Copyright (C) 2008
* Mark Jonas <mark.jonas@de.bosch.com>
*
@@ -28,7 +28,7 @@ SECTIONS
.text :
{
- KEEP(arch/sh/cpu/sh3/start.o (.text))
+ KEEP(*/start.o (.text))
. = ALIGN(8192);
common/env_embedded.o (.ppcenv)
. = ALIGN(8192);
diff --git a/board/gaisler/grsim/u-boot.lds b/arch/sparc/cpu/u-boot.lds
index cdc8394..1ade3b3 100644
--- a/board/gaisler/grsim/u-boot.lds
+++ b/arch/sparc/cpu/u-boot.lds
@@ -1,7 +1,5 @@
/*
- * Linker script for Gaisler Research AB's GRSIM LEON3 simulator.
- *
- * (C) Copyright 2007
+ * (C) Copyright 2007-2008
* Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
*
* SPDX-License-Identifier: GPL-2.0+
@@ -43,7 +41,7 @@ SECTIONS
_text = .;
*(.start)
- arch/sparc/cpu/leon3/start.o (.text)
+ */start.o (.text)
/* 8k is the same as the PROM offset from end of main memory, (CONFIG_SYS_PROM_SIZE) */
. = ALIGN(8192);
/* PROM CODE, Will be relocated to the end of memory,
diff --git a/arch/x86/lib/video.c b/arch/x86/lib/video.c
index dfd2a84..975949d 100644
--- a/arch/x86/lib/video.c
+++ b/arch/x86/lib/video.c
@@ -104,7 +104,7 @@ static void __video_putc(const char c, int *x, int *y)
}
}
-static void video_putc(const char c)
+static void video_putc(struct stdio_dev *dev, const char c)
{
int x, y, pos;
@@ -123,7 +123,7 @@ static void video_putc(const char c)
outb_p(0xff & (pos >> 1), vidport+1);
}
-static void video_puts(const char *s)
+static void video_puts(struct stdio_dev *dev, const char *s)
{
int x, y, pos;
char c;
@@ -178,8 +178,6 @@ int video_init(void)
vga_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
vga_dev.putc = video_putc; /* 'putc' function */
vga_dev.puts = video_puts; /* 'puts' function */
- vga_dev.tstc = NULL; /* 'tstc' function */
- vga_dev.getc = NULL; /* 'getc' function */
if (stdio_register(&vga_dev) == 0)
return 1;
@@ -191,8 +189,6 @@ int video_init(void)
strcpy(kbd_dev.name, "kbd");
kbd_dev.ext = 0;
kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- kbd_dev.putc = NULL; /* 'putc' function */
- kbd_dev.puts = NULL; /* 'puts' function */
kbd_dev.tstc = i8042_tstc; /* 'tstc' function */
kbd_dev.getc = i8042_getc; /* 'getc' function */
diff --git a/board/bf527-ezkit/video.c b/board/bf527-ezkit/video.c
index 5d8a091..c2bf145 100644
--- a/board/bf527-ezkit/video.c
+++ b/board/bf527-ezkit/video.c
@@ -391,14 +391,6 @@ void video_stop(void)
#endif
}
-void video_putc(const char c)
-{
-}
-
-void video_puts(const char *s)
-{
-}
-
int drv_video_init(void)
{
int error, devices = 1;
@@ -448,8 +440,6 @@ int drv_video_init(void)
strcpy(videodev.name, "video");
videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
videodev.flags = DEV_FLAGS_SYSTEM; /* No Output */
- videodev.putc = video_putc; /* 'putc' function */
- videodev.puts = video_puts; /* 'puts' function */
error = stdio_register(&videodev);
diff --git a/board/bf548-ezkit/video.c b/board/bf548-ezkit/video.c
index 6737ac1..47e68c6 100644
--- a/board/bf548-ezkit/video.c
+++ b/board/bf548-ezkit/video.c
@@ -281,14 +281,6 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y)
}
-void video_putc(const char c)
-{
-}
-
-void video_puts(const char *s)
-{
-}
-
int drv_video_init(void)
{
int error, devices = 1;
@@ -338,8 +330,6 @@ int drv_video_init(void)
strcpy(videodev.name, "video");
videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
videodev.flags = DEV_FLAGS_SYSTEM; /* No Output */
- videodev.putc = video_putc; /* 'putc' function */
- videodev.puts = video_puts; /* 'puts' function */
error = stdio_register(&videodev);
diff --git a/board/cm-bf548/video.c b/board/cm-bf548/video.c
index c35d285..b098615 100644
--- a/board/cm-bf548/video.c
+++ b/board/cm-bf548/video.c
@@ -283,14 +283,6 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y)
}
-void video_putc(const char c)
-{
-}
-
-void video_puts(const char *s)
-{
-}
-
int drv_video_init(void)
{
int error, devices = 1;
@@ -342,8 +334,6 @@ int drv_video_init(void)
strcpy(videodev.name, "video");
videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
videodev.flags = DEV_FLAGS_SYSTEM; /* No Output */
- videodev.putc = video_putc; /* 'putc' function */
- videodev.puts = video_puts; /* 'puts' function */
error = stdio_register(&videodev);
diff --git a/board/esd/common/cmd_loadpci.c b/board/esd/common/cmd_loadpci.c
index 803179a..95d1891 100644
--- a/board/esd/common/cmd_loadpci.c
+++ b/board/esd/common/cmd_loadpci.c
@@ -12,9 +12,6 @@
#endif
#if defined(CONFIG_CMD_BSP)
-
-extern int do_source (cmd_tbl_t *, int, int, char *[]);
-
#define ADDRMASK 0xfffff000
/*
@@ -27,7 +24,6 @@ int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int count2 = 0;
char addr[16];
char str[] = "\\|/-";
- char *local_args[2];
u32 la, ptm1la;
#if defined(CONFIG_440)
@@ -84,9 +80,7 @@ int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* Boot image via "source" command
*/
printf("executing script at addr 0x%s ...\n", addr);
- local_args[0] = addr;
- local_args[1] = NULL;
- do_source(cmdtp, 0, 1, local_args);
+ source(la, NULL);
break;
case 2:
diff --git a/board/freescale/m5253demo/flash.c b/board/freescale/m5253demo/flash.c
index 16bba59..071701d 100644
--- a/board/freescale/m5253demo/flash.c
+++ b/board/freescale/m5253demo/flash.c
@@ -56,14 +56,16 @@ ulong flash_init(void)
int flash_get_offsets(ulong base, flash_info_t * info)
{
- int j, k;
+ int i;
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
info->start[0] = base;
- for (k = 0, j = 0; j < CONFIG_SYS_SST_SECT; j++, k++) {
- info->start[k + 1] = info->start[k] + CONFIG_SYS_SST_SECTSZ;
- info->protect[k] = 0;
+ info->protect[0] = 0;
+ for (i = 1; i < CONFIG_SYS_SST_SECT; i++) {
+ info->start[i] = info->start[i - 1]
+ + CONFIG_SYS_SST_SECTSZ;
+ info->protect[i] = 0;
}
}
diff --git a/board/gaisler/gr_cpci_ax2000/u-boot.lds b/board/gaisler/gr_cpci_ax2000/u-boot.lds
deleted file mode 100644
index 6d9c90c..0000000
--- a/board/gaisler/gr_cpci_ax2000/u-boot.lds
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Linker script for Gaisler Research AB's GR-CPCI-AX2000 board
- * with template design.
- *
- * (C) Copyright 2008
- * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sparc", "elf32-sparc", "elf32-sparc")
-OUTPUT_ARCH(sparc)
-ENTRY(_start)
-SECTIONS
-{
-
-/* Read-only sections, merged into text segment: */
- . = + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .rel.text : { *(.rel.text) }
- .rela.text : { *(.rela.text) }
- .rel.data : { *(.rel.data) }
- .rela.data : { *(.rela.data) }
- .rel.rodata : { *(.rel.rodata) }
- .rela.rodata : { *(.rela.rodata) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) }
- .plt : { *(.plt) }
-
- .text : {
- _load_addr = .;
- _text = .;
-
- *(.start)
- arch/sparc/cpu/leon3/start.o (.text)
-/* 8k is the same as the PROM offset from end of main memory, (CONFIG_SYS_PROM_SIZE) */
- . = ALIGN(8192);
-/* PROM CODE, Will be relocated to the end of memory,
- * no global data accesses please.
- */
- __prom_start = .;
- *(.prom.pgt)
- *(.prom.data)
- *(.prom.text)
- . = ALIGN(16);
- __prom_end = .;
- *(.text)
- *(.fixup)
- *(.gnu.warning)
-/* *(.got1)*/
- . = ALIGN(16);
- *(.eh_frame)
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- }
- . = ALIGN(4);
- _etext = .;
-
- /* CMD Table */
-
-
- . = ALIGN(4);
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- .data :
- {
- *(.data)
- *(.data1)
- *(.data.rel)
- *(.data.rel.*)
- *(.sdata)
- *(.sdata2)
- *(.dynamic)
- CONSTRUCTORS
- }
- _edata = .;
- PROVIDE (edata = .);
-
- . = ALIGN(4);
- __got_start = .;
- .got : {
- *(.got)
-/* *(.data.rel)
- *(.data.rel.local)*/
- . = ALIGN(16);
- }
- __got_end = .;
-
-/* .data.rel : { } */
-
- . = ALIGN(4096);
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(4096);
- __init_end = .;
-
- __bss_start = .;
- .bss :
- {
- *(.sbss) *(.scommon)
- *(.dynbss)
- *(.bss)
- *(COMMON)
- . = ALIGN(16); /* to speed clearing of bss up */
- }
- __bss_end = . ;
- __bss_end = . ;
- PROVIDE (end = .);
-
-/* Relocated into main memory */
-
- /* Start of main memory */
- /*. = 0x40000000;*/
-
- .stack (NOLOAD) : { *(.stack) }
-
- /* PROM CODE */
-
- /* global data in RAM passed to kernel after booting */
-
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
-
-}
diff --git a/board/gaisler/gr_ep2s60/u-boot.lds b/board/gaisler/gr_ep2s60/u-boot.lds
deleted file mode 100644
index 973603c..0000000
--- a/board/gaisler/gr_ep2s60/u-boot.lds
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Linker script for Gaisler Research AB's Template design
- * for Altera NIOS Development board Stratix II Edition, EP2S60 FPGA.
- *
- * (C) Copyright 2008
- * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sparc", "elf32-sparc", "elf32-sparc")
-OUTPUT_ARCH(sparc)
-ENTRY(_start)
-SECTIONS
-{
-
-/* Read-only sections, merged into text segment: */
- . = + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .rel.text : { *(.rel.text) }
- .rela.text : { *(.rela.text) }
- .rel.data : { *(.rel.data) }
- .rela.data : { *(.rela.data) }
- .rel.rodata : { *(.rel.rodata) }
- .rela.rodata : { *(.rela.rodata) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) }
- .plt : { *(.plt) }
-
- .text : {
- _load_addr = .;
- _text = .;
-
- *(.start)
- arch/sparc/cpu/leon3/start.o (.text)
-/* 8k is the same as the PROM offset from end of main memory, (CONFIG_SYS_PROM_SIZE) */
- . = ALIGN(8192);
-/* PROM CODE, Will be relocated to the end of memory,
- * no global data accesses please.
- */
- __prom_start = .;
- *(.prom.pgt)
- *(.prom.data)
- *(.prom.text)
- . = ALIGN(16);
- __prom_end = .;
- *(.text)
- *(.fixup)
- *(.gnu.warning)
-/* *(.got1)*/
- . = ALIGN(16);
- *(.eh_frame)
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- }
- . = ALIGN(4);
- _etext = .;
-
- /* CMD Table */
-
-
- . = ALIGN(4);
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- .data :
- {
- *(.data)
- *(.data1)
- *(.data.rel)
- *(.data.rel.*)
- *(.sdata)
- *(.sdata2)
- *(.dynamic)
- CONSTRUCTORS
- }
- _edata = .;
- PROVIDE (edata = .);
-
- . = ALIGN(4);
- __got_start = .;
- .got : {
- *(.got)
-/* *(.data.rel)
- *(.data.rel.local)*/
- . = ALIGN(16);
- }
- __got_end = .;
-
-/* .data.rel : { } */
-
- . = ALIGN(4096);
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(4096);
- __init_end = .;
-
- __bss_start = .;
- .bss :
- {
- *(.sbss) *(.scommon)
- *(.dynbss)
- *(.bss)
- *(COMMON)
- . = ALIGN(16); /* to speed clearing of bss up */
- }
- __bss_end = . ;
- __bss_end = . ;
- PROVIDE (end = .);
-
-/* Relocated into main memory */
-
- /* Start of main memory */
- /*. = 0x40000000;*/
-
- .stack (NOLOAD) : { *(.stack) }
-
- /* PROM CODE */
-
- /* global data in RAM passed to kernel after booting */
-
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
-
-}
diff --git a/board/gaisler/gr_xc3s_1500/u-boot.lds b/board/gaisler/gr_xc3s_1500/u-boot.lds
deleted file mode 100644
index 1ed71f2..0000000
--- a/board/gaisler/gr_xc3s_1500/u-boot.lds
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Linker script for Gaisler Research AB's GR-XC3S-1500 board
- * with template design.
- *
- * (C) Copyright 2007
- * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sparc", "elf32-sparc", "elf32-sparc")
-OUTPUT_ARCH(sparc)
-ENTRY(_start)
-SECTIONS
-{
-
-/* Read-only sections, merged into text segment: */
- . = + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .rel.text : { *(.rel.text) }
- .rela.text : { *(.rela.text) }
- .rel.data : { *(.rel.data) }
- .rela.data : { *(.rela.data) }
- .rel.rodata : { *(.rel.rodata) }
- .rela.rodata : { *(.rela.rodata) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) }
- .plt : { *(.plt) }
-
- .text : {
- _load_addr = .;
- _text = .;
-
- *(.start)
- arch/sparc/cpu/leon3/start.o (.text)
-/* 8k is the same as the PROM offset from end of main memory, (CONFIG_SYS_PROM_SIZE) */
- . = ALIGN(8192);
-/* PROM CODE, Will be relocated to the end of memory,
- * no global data accesses please.
- */
- __prom_start = .;
- *(.prom.pgt)
- *(.prom.data)
- *(.prom.text)
- . = ALIGN(16);
- __prom_end = .;
- *(.text)
- *(.fixup)
- *(.gnu.warning)
-/* *(.got1)*/
- . = ALIGN(16);
- *(.eh_frame)
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- }
- . = ALIGN(4);
- _etext = .;
-
- /* CMD Table */
-
-
- . = ALIGN(4);
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- .data :
- {
- *(.data)
- *(.data1)
- *(.data.rel)
- *(.data.rel.*)
- *(.sdata)
- *(.sdata2)
- *(.dynamic)
- CONSTRUCTORS
- }
- _edata = .;
- PROVIDE (edata = .);
-
- . = ALIGN(4);
- __got_start = .;
- .got : {
- *(.got)
-/* *(.data.rel)
- *(.data.rel.local)*/
- . = ALIGN(16);
- }
- __got_end = .;
-
-/* .data.rel : { } */
-
-
- . = ALIGN(4096);
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(4096);
- __init_end = .;
-
- __bss_start = .;
- .bss :
- {
- *(.sbss) *(.scommon)
- *(.dynbss)
- *(.bss)
- *(COMMON)
- . = ALIGN(16); /* to speed clearing of bss up */
- }
- __bss_end = . ;
- __bss_end = . ;
- PROVIDE (end = .);
-
-/* Relocated into main memory */
-
- /* Start of main memory */
- /*. = 0x40000000;*/
-
- .stack (NOLOAD) : { *(.stack) }
-
- /* PROM CODE */
-
- /* global data in RAM passed to kernel after booting */
-
-
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
-
-}
diff --git a/board/gaisler/grsim_leon2/u-boot.lds b/board/gaisler/grsim_leon2/u-boot.lds
deleted file mode 100644
index 1f038bc..0000000
--- a/board/gaisler/grsim_leon2/u-boot.lds
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Linker script for Gaisler Research AB's GRSIM LEON2 simulator.
- *
- * (C) Copyright 2007
- * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-sparc", "elf32-sparc", "elf32-sparc")
-OUTPUT_ARCH(sparc)
-ENTRY(_start)
-SECTIONS
-{
-
-/* Read-only sections, merged into text segment: */
- . = + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .rel.text : { *(.rel.text) }
- .rela.text : { *(.rela.text) }
- .rel.data : { *(.rel.data) }
- .rela.data : { *(.rela.data) }
- .rel.rodata : { *(.rel.rodata) }
- .rela.rodata : { *(.rela.rodata) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) }
- .plt : { *(.plt) }
-
- .text : {
- _load_addr = .;
- _text = .;
-
- *(.start)
- arch/sparc/cpu/leon2/start.o (.text)
-/* 8k is the same as the PROM offset from end of main memory, (CONFIG_SYS_PROM_SIZE) */
- . = ALIGN(8192);
-/* PROM CODE, Will be relocated to the end of memory,
- * no global data accesses please.
- */
- __prom_start = .;
- *(.prom.pgt)
- *(.prom.data)
- *(.prom.text)
- . = ALIGN(16);
- __prom_end = .;
- *(.text)
- *(.fixup)
- *(.gnu.warning)
-/* *(.got1)*/
- . = ALIGN(16);
- *(.eh_frame)
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- }
- . = ALIGN(4);
- _etext = .;
-
- /* CMD Table */
-
-
- . = ALIGN(4);
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- .data :
- {
- *(.data)
- *(.data1)
- *(.data.rel)
- *(.data.rel.*)
- *(.sdata)
- *(.sdata2)
- *(.dynamic)
- CONSTRUCTORS
- }
- _edata = .;
- PROVIDE (edata = .);
-
- . = ALIGN(4);
- __got_start = .;
- .got : {
- *(.got)
-/* *(.data.rel)
- *(.data.rel.local)*/
- . = ALIGN(16);
- }
- __got_end = .;
-
-/* .data.rel : { } */
-
- . = ALIGN(4096);
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(4096);
- __init_end = .;
-
- __bss_start = .;
- .bss :
- {
- *(.sbss) *(.scommon)
- *(.dynbss)
- *(.bss)
- *(COMMON)
- . = ALIGN(16); /* to speed clearing of bss up */
- }
- __bss_end = . ;
- __bss_end = . ;
- PROVIDE (end = .);
-
-/* Relocated into main memory */
-
- /* Start of main memory */
- /*. = 0x40000000;*/
-
- .stack (NOLOAD) : { *(.stack) }
-
- /* PROM CODE */
-
- /* global data in RAM passed to kernel after booting */
-
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
-
-}
diff --git a/board/mpl/common/kbd.c b/board/mpl/common/kbd.c
index 1b5487b..99de2ca 100644
--- a/board/mpl/common/kbd.c
+++ b/board/mpl/common/kbd.c
@@ -204,8 +204,6 @@ int drv_isa_kbd_init (void)
memset (&kbddev, 0, sizeof(kbddev));
strcpy(kbddev.name, DEVNAME);
kbddev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- kbddev.putc = NULL ;
- kbddev.puts = NULL ;
kbddev.getc = kbd_getc ;
kbddev.tstc = kbd_testc ;
@@ -250,7 +248,7 @@ void kbd_put_queue(char data)
}
/* test if a character is in the queue */
-int kbd_testc(void)
+int kbd_testc(struct stdio_dev *dev)
{
if(in_pointer==out_pointer)
return(0); /* no data */
@@ -258,7 +256,7 @@ int kbd_testc(void)
return(1);
}
/* gets the character from the queue */
-int kbd_getc(void)
+int kbd_getc(struct stdio_dev *dev)
{
char c;
while(in_pointer==out_pointer);
diff --git a/board/mpl/common/kbd.h b/board/mpl/common/kbd.h
index 7b19b37..b549e20 100644
--- a/board/mpl/common/kbd.h
+++ b/board/mpl/common/kbd.h
@@ -8,8 +8,10 @@
#ifndef _KBD_H_
#define _KBD_H_
-extern int kbd_testc(void);
-extern int kbd_getc(void);
+struct stdio_dev;
+
+int kbd_testc(struct stdio_dev *sdev);
+int kbd_getc(struct stdio_dev *sdev);
extern void kbd_interrupt(void);
extern char *kbd_initialize(void);
diff --git a/board/mpl/pati/pati.c b/board/mpl/pati/pati.c
index 8ca9bb3..5d701a7 100644
--- a/board/mpl/pati/pati.c
+++ b/board/mpl/pati/pati.c
@@ -445,7 +445,7 @@ void pci_con_put_it(const char c)
PCICON_SET_REG(PCICON_DBELL_REG,PCIMSG_CON_DATA);
}
-void pci_con_putc(const char c)
+void pci_con_putc(struct stdio_dev *dev, const char c)
{
pci_con_put_it(c);
if(c == '\n')
@@ -453,7 +453,7 @@ void pci_con_putc(const char c)
}
-int pci_con_getc(void)
+int pci_con_getc(struct stdio_dev *dev)
{
int res;
int diff;
@@ -473,14 +473,14 @@ int pci_con_getc(void)
return res;
}
-int pci_con_tstc(void)
+int pci_con_tstc(struct stdio_dev *dev)
{
if(r_ptr==(volatile int)w_ptr)
return 0;
return 1;
}
-void pci_con_puts (const char *s)
+void pci_con_puts(struct stdio_dev *dev, const char *s)
{
while (*s) {
pci_con_putc(*s);
diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
index 3e419ef..c2e07db 100644
--- a/board/nokia/rx51/rx51.c
+++ b/board/nokia/rx51/rx51.c
@@ -585,7 +585,7 @@ static void rx51_kp_fill(u8 k, u8 mods)
* Routine: rx51_kp_tstc
* Description: Test if key was pressed (from buffer).
*/
-int rx51_kp_tstc(void)
+int rx51_kp_tstc(struct stdio_dev *sdev)
{
u8 c, r, dk, i;
u8 intr;
@@ -641,10 +641,10 @@ int rx51_kp_tstc(void)
* Routine: rx51_kp_getc
* Description: Get last pressed key (from buffer).
*/
-int rx51_kp_getc(void)
+int rx51_kp_getc(struct stdio_dev *sdev)
{
keybuf_head %= KEYBUF_SIZE;
- while (!rx51_kp_tstc())
+ while (!rx51_kp_tstc(sdev))
WATCHDOG_RESET();
return keybuf[keybuf_head++];
}
diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c
index f33fae9..220bb90 100644
--- a/board/raspberrypi/rpi_b/rpi_b.c
+++ b/board/raspberrypi/rpi_b/rpi_b.c
@@ -16,7 +16,9 @@
#include <common.h>
#include <config.h>
+#include <fdt_support.h>
#include <lcd.h>
+#include <mmc.h>
#include <asm/arch/mbox.h>
#include <asm/arch/sdhci.h>
#include <asm/global_data.h>
@@ -91,7 +93,7 @@ int board_init(void)
return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
}
-int board_mmc_init(void)
+int board_mmc_init(bd_t *bis)
{
ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
int ret;
diff --git a/boards.cfg b/boards.cfg
index 1ba2081..4b2bc19 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -1007,19 +1007,19 @@ Active powerpc mpc8xx - tqc tqm8xx
Active powerpc mpc8xx - tqc tqm8xx TK885D - -
Active powerpc mpc8xx - tqc tqm8xx TQM823L - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx TQM823L_LCD TQM823L:LCD,NEC_NL6448BC20 Wolfgang Denk <wd@denx.de>
-Active powerpc mpc8xx - tqc tqm8xx TQM823M - -
+Active powerpc mpc8xx - tqc tqm8xx TQM823M - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx TQM850L - Wolfgang Denk <wd@denx.de>
-Active powerpc mpc8xx - tqc tqm8xx TQM850M - -
+Active powerpc mpc8xx - tqc tqm8xx TQM850M - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx TQM855L - Wolfgang Denk <wd@denx.de>
-Active powerpc mpc8xx - tqc tqm8xx TQM855M - -
+Active powerpc mpc8xx - tqc tqm8xx TQM855M - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx TQM860L - Wolfgang Denk <wd@denx.de>
-Active powerpc mpc8xx - tqc tqm8xx TQM860M - -
-Active powerpc mpc8xx - tqc tqm8xx TQM862L - -
-Active powerpc mpc8xx - tqc tqm8xx TQM862M - -
-Active powerpc mpc8xx - tqc tqm8xx TQM866M - -
-Active powerpc mpc8xx - tqc tqm8xx TQM885D - -
+Active powerpc mpc8xx - tqc tqm8xx TQM860M - Wolfgang Denk <wd@denx.de>
+Active powerpc mpc8xx - tqc tqm8xx TQM862L - Wolfgang Denk <wd@denx.de>
+Active powerpc mpc8xx - tqc tqm8xx TQM862M - Wolfgang Denk <wd@denx.de>
+Active powerpc mpc8xx - tqc tqm8xx TQM866M - Wolfgang Denk <wd@denx.de>
+Active powerpc mpc8xx - tqc tqm8xx TQM885D - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx TTTech TQM823L:LCD,SHARP_LQ104V7DS01 Wolfgang Denk <wd@denx.de>
-Active powerpc mpc8xx - tqc tqm8xx virtlab2 - -
+Active powerpc mpc8xx - tqc tqm8xx virtlab2 - Wolfgang Denk <wd@denx.de>
Active powerpc mpc8xx - tqc tqm8xx wtk TQM823L:LCD,SHARP_LQ065T9DR51U Wolfgang Denk <wd@denx.de>
Active powerpc ppc4xx - - csb272 csb272 - Tolunay Orkun <torkun@nextio.com>
Active powerpc ppc4xx - - csb472 csb472 - Tolunay Orkun <torkun@nextio.com>
diff --git a/common/autoboot.c b/common/autoboot.c
index 30102a4..c27cc2c 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -6,6 +6,7 @@
*/
#include <common.h>
+#include <autoboot.h>
#include <bootretry.h>
#include <cli.h>
#include <fdtdec.h>
diff --git a/common/board_f.c b/common/board_f.c
index 4ea4cb2..6203d85 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <version.h>
#include <environment.h>
+#include <dm.h>
#include <fdtdec.h>
#include <fs.h>
#if defined(CONFIG_CMD_IDE)
@@ -37,6 +38,7 @@
#include <os.h>
#include <post.h>
#include <spi.h>
+#include <status_led.h>
#include <trace.h>
#include <watchdog.h>
#include <asm/errno.h>
@@ -52,6 +54,7 @@
#ifdef CONFIG_SANDBOX
#include <asm/state.h>
#endif
+#include <dm/root.h>
#include <linux/compiler.h>
/*
@@ -78,25 +81,15 @@ DECLARE_GLOBAL_DATA_PTR;
************************************************************************
* May be supplied by boards if desired
*/
-inline void __coloured_LED_init(void) {}
-void coloured_LED_init(void)
- __attribute__((weak, alias("__coloured_LED_init")));
-inline void __red_led_on(void) {}
-void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
-inline void __red_led_off(void) {}
-void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
-inline void __green_led_on(void) {}
-void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
-inline void __green_led_off(void) {}
-void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
-inline void __yellow_led_on(void) {}
-void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
-inline void __yellow_led_off(void) {}
-void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
-inline void __blue_led_on(void) {}
-void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
-inline void __blue_led_off(void) {}
-void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
+__weak void coloured_LED_init(void) {}
+__weak void red_led_on(void) {}
+__weak void red_led_off(void) {}
+__weak void green_led_on(void) {}
+__weak void green_led_off(void) {}
+__weak void yellow_led_on(void) {}
+__weak void yellow_led_off(void) {}
+__weak void blue_led_on(void) {}
+__weak void blue_led_off(void) {}
/*
* Why is gd allocated a register? Prior to reloc it might be better to
@@ -776,6 +769,30 @@ static int mark_bootstage(void)
return 0;
}
+static int initf_malloc(void)
+{
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ assert(gd->malloc_base); /* Set up by crt0.S */
+ gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
+ gd->malloc_ptr = 0;
+#endif
+
+ return 0;
+}
+
+static int initf_dm(void)
+{
+#if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
+ int ret;
+
+ ret = dm_init_and_scan(true);
+ if (ret)
+ return ret;
+#endif
+
+ return 0;
+}
+
static init_fnc_t init_sequence_f[] = {
#ifdef CONFIG_SANDBOX
setup_ram_buf,
@@ -833,6 +850,8 @@ static init_fnc_t init_sequence_f[] = {
sdram_adjust_866,
init_timebase,
#endif
+ initf_malloc,
+ initf_dm,
init_baud_rate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
diff --git a/common/board_r.c b/common/board_r.c
index 602a239..8e7a3ac 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -259,6 +259,10 @@ static int initr_malloc(void)
{
ulong malloc_start;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
+ gd->malloc_ptr / 1024);
+#endif
/* The malloc area is immediately below the monitor copy in DRAM */
malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
@@ -269,27 +273,10 @@ static int initr_malloc(void)
#ifdef CONFIG_DM
static int initr_dm(void)
{
- int ret;
-
- ret = dm_init();
- if (ret) {
- debug("dm_init() failed: %d\n", ret);
- return ret;
- }
- ret = dm_scan_platdata();
- if (ret) {
- debug("dm_scan_platdata() failed: %d\n", ret);
- return ret;
- }
-#ifdef CONFIG_OF_CONTROL
- ret = dm_scan_fdt(gd->fdt_blob);
- if (ret) {
- debug("dm_scan_fdt() failed: %d\n", ret);
- return ret;
- }
-#endif
-
- return 0;
+ /* Save the pre-reloc driver model and start a new one */
+ gd->dm_root_f = gd->dm_root;
+ gd->dm_root = NULL;
+ return dm_init_and_scan(false);
}
#endif
@@ -588,15 +575,12 @@ static int initr_status_led(void)
#if defined(CONFIG_CMD_SCSI)
static int initr_scsi(void)
{
- /* Not supported properly on ARM yet */
-#ifndef CONFIG_ARM
puts("SCSI: ");
scsi_init();
-#endif
return 0;
}
-#endif /* CONFIG_CMD_NET */
+#endif
#if defined(CONFIG_CMD_DOC)
static int initr_doc(void)
diff --git a/common/bootm_os.c b/common/bootm_os.c
index f7769ac..5be4467 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -437,11 +437,10 @@ static boot_os_fn *boot_os[] = {
};
/* Allow for arch specific config before we boot */
-static void __arch_preboot_os(void)
+__weak void arch_preboot_os(void)
{
/* please define platform specific arch_preboot_os() */
}
-void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
int boot_selected_os(int argc, char * const argv[], int state,
bootm_headers_t *images, boot_os_fn *boot_fn)
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index f283a16..3d37a86 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -351,7 +351,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#elif defined(CONFIG_ARM)
-int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int i;
bd_t *bd = gd->bd;
diff --git a/common/cmd_cache.c b/common/cmd_cache.c
index 602feca..37ab345 100644
--- a/common/cmd_cache.c
+++ b/common/cmd_cache.c
@@ -20,7 +20,7 @@ void __weak invalidate_icache_all(void)
puts("No arch specific invalidate_icache_all available!\n");
}
-int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
switch (argc) {
case 2: /* on / off */
@@ -52,7 +52,7 @@ void __weak flush_dcache_all(void)
/* please define arch specific flush_dcache_all */
}
-int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
switch (argc) {
case 2: /* on / off */
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index fad462f..a02f0cb 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -43,7 +43,7 @@ extern int eeprom_write_enable (unsigned dev_addr, int state);
/* ------------------------------------------------------------------------- */
#if defined(CONFIG_CMD_EEPROM)
-int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
const char *const fmt =
"\nEEPROM @0x%lX %s: addr %08lx off %04lx count %ld ... ";
@@ -413,7 +413,7 @@ U_BOOT_CMD(
"read devaddr addr off cnt\n"
"eeprom write devaddr addr off cnt\n"
" - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
-);
+)
#else /* One EEPROM */
U_BOOT_CMD(
eeprom, 5, 1, do_eeprom,
@@ -421,7 +421,7 @@ U_BOOT_CMD(
"read addr off cnt\n"
"eeprom write addr off cnt\n"
" - read/write `cnt' bytes at EEPROM offset `off'"
-);
+)
#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
#endif
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index 5a4bcc1..6657ef5 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -22,7 +22,7 @@
*/
#include <fs.h>
-int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ext2ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT);
}
@@ -30,7 +30,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/******************************************************************************
* Ext2fs boot command intepreter. Derived from diskboot
*/
-int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_ext2load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT);
}
@@ -40,12 +40,12 @@ U_BOOT_CMD(
"list files in a directory (default /)",
"<interface> <dev[:part]> [directory]\n"
" - list files from 'dev' on 'interface' in a 'directory'"
-);
+)
U_BOOT_CMD(
ext2load, 6, 0, do_ext2load,
"load binary file from a Ext2 filesystem",
- "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
+ "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n"
" - load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from ext2 filesystem."
-);
+)
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index fbe3346..a478017 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -27,7 +27,7 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
fatload, 7, 0, do_fat_fsload,
"load binary file from a dos filesystem",
- "<interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]\n"
+ "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
" - Load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from dos filesystem.\n"
" 'pos' gives the file position to start loading from.\n"
diff --git a/common/cmd_fs.c b/common/cmd_fs.c
index 91a205a..78590d2 100644
--- a/common/cmd_fs.c
+++ b/common/cmd_fs.c
@@ -20,7 +20,8 @@
#include <command.h>
#include <fs.h>
-int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
}
@@ -35,9 +36,10 @@ U_BOOT_CMD(
" If 'bytes' is 0 or omitted, the file is read until the end.\n"
" 'pos' gives the file byte position to start reading from.\n"
" If 'pos' is 0 or omitted, the file is read from the start."
-);
+)
-int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
}
@@ -48,4 +50,4 @@ U_BOOT_CMD(
"<interface> [<dev[:part]> [directory]]\n"
" - List files in directory 'directory' of partition 'part' on\n"
" device type 'interface' instance 'dev'."
-);
+)
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index d714658..3a75f94 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1366,7 +1366,8 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
* Returns zero always.
*/
#if defined(CONFIG_SYS_I2C)
-int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int i;
#ifndef CONFIG_SYS_I2C_DIRECT_BUS
@@ -1425,7 +1426,8 @@ int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* on error.
*/
#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
-int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int ret = 0;
unsigned int bus_no;
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index c375ef2..04a6d9b 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -253,7 +253,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* ------------------------------------------------------------------------- */
-void __ide_led(uchar led, uchar status)
+__weak void ide_led(uchar led, uchar status)
{
#if defined(CONFIG_IDE_LED) && defined(PER8_BASE) /* required by LED_PORT */
static uchar led_buffer; /* Buffer for current LED status */
@@ -269,9 +269,6 @@ void __ide_led(uchar led, uchar status)
#endif
}
-void ide_led(uchar led, uchar status)
- __attribute__ ((weak, alias("__ide_led")));
-
#ifndef CONFIG_IDE_LED /* define LED macros, they are not used anyways */
# define DEVICE_LED(x) 0
# define LED_IDE1 1
@@ -280,7 +277,7 @@ void ide_led(uchar led, uchar status)
/* ------------------------------------------------------------------------- */
-inline void __ide_outb(int dev, int port, unsigned char val)
+__weak void 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,
@@ -299,10 +296,7 @@ inline void __ide_outb(int dev, int port, unsigned char val)
#endif
}
-void ide_outb(int dev, int port, unsigned char val)
- __attribute__ ((weak, alias("__ide_outb")));
-
-inline unsigned char __ide_inb(int dev, int port)
+__weak unsigned char ide_inb(int dev, int port)
{
uchar val;
@@ -318,19 +312,6 @@ inline unsigned char __ide_inb(int dev, int port)
return val;
}
-unsigned char ide_inb(int dev, int port)
- __attribute__ ((weak, alias("__ide_inb")));
-
-#ifdef CONFIG_TUNE_PIO
-inline int __ide_set_piomode(int pio_mode)
-{
- return 0;
-}
-
-inline int ide_set_piomode(int pio_mode)
- __attribute__ ((weak, alias("__ide_set_piomode")));
-#endif
-
void ide_init(void)
{
unsigned char c;
@@ -471,23 +452,14 @@ block_dev_desc_t *ide_get_dev(int dev)
/* ------------------------------------------------------------------------- */
-void ide_input_swap_data(int dev, ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_input_swap_data")));
-
-void ide_input_data(int dev, ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_input_data")));
-
-void ide_output_data(int dev, const ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_output_data")));
-
/* We only need to swap data if we are running on a big endian cpu. */
#if defined(__LITTLE_ENDIAN)
-void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words)
{
ide_input_data(dev, sect_buf, words);
}
#else
-void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words)
{
volatile ushort *pbuf =
(ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
@@ -510,7 +482,7 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
#if defined(CONFIG_IDE_SWAP_IO)
-void __ide_output_data(int dev, const ulong *sect_buf, int words)
+__weak void ide_output_data(int dev, const ulong *sect_buf, int words)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -525,7 +497,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
}
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_output_data(int dev, const ulong *sect_buf, int words)
+__weak void ide_output_data(int dev, const ulong *sect_buf, int words)
{
#if defined(CONFIG_IDE_AHB)
ide_write_data(dev, sect_buf, words);
@@ -536,7 +508,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
#endif /* CONFIG_IDE_SWAP_IO */
#if defined(CONFIG_IDE_SWAP_IO)
-void __ide_input_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_data(int dev, ulong *sect_buf, int words)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -554,7 +526,7 @@ void __ide_input_data(int dev, ulong *sect_buf, int words)
}
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_input_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_data(int dev, ulong *sect_buf, int words)
{
#if defined(CONFIG_IDE_AHB)
ide_read_data(dev, sect_buf, words);
@@ -575,14 +547,6 @@ static void ide_ident(block_dev_desc_t *dev_desc)
#ifdef CONFIG_ATAPI
int retries = 0;
#endif
-
-#ifdef CONFIG_TUNE_PIO
- int pio_mode;
-#endif
-
-#if 0
- int mode, cycle_time;
-#endif
int device;
device = dev_desc->dev;
@@ -691,72 +655,6 @@ static void ide_ident(block_dev_desc_t *dev_desc)
else
dev_desc->removable = 0;
-#ifdef CONFIG_TUNE_PIO
- /* Mode 0 - 2 only, are directly determined by word 51. */
- pio_mode = iop.tPIO;
- if (pio_mode > 2) {
- printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode);
- /* Force it to dead slow, and hope for the best... */
- pio_mode = 0;
- }
-
- /* Any CompactFlash Storage Card that supports PIO mode 3 or above
- * shall set bit 1 of word 53 to one and support the fields contained
- * in words 64 through 70.
- */
- if (iop.field_valid & 0x02) {
- /*
- * Mode 3 and above are possible. Check in order from slow
- * to fast, so we wind up with the highest mode allowed.
- */
- if (iop.eide_pio_modes & 0x01)
- pio_mode = 3;
- if (iop.eide_pio_modes & 0x02)
- pio_mode = 4;
- if (ata_id_is_cfa((u16 *)&iop)) {
- if ((iop.cf_advanced_caps & 0x07) == 0x01)
- pio_mode = 5;
- if ((iop.cf_advanced_caps & 0x07) == 0x02)
- pio_mode = 6;
- }
- }
-
- /* System-specific, depends on bus speeds, etc. */
- ide_set_piomode(pio_mode);
-#endif /* CONFIG_TUNE_PIO */
-
-#if 0
- /*
- * Drive PIO mode autoselection
- */
- mode = iop.tPIO;
-
- printf("tPIO = 0x%02x = %d\n", mode, mode);
- if (mode > 2) { /* 2 is maximum allowed tPIO value */
- mode = 2;
- debug("Override tPIO -> 2\n");
- }
- if (iop.field_valid & 2) { /* drive implements ATA2? */
- debug("Drive implements ATA2\n");
- if (iop.capability & 8) { /* drive supports use_iordy? */
- cycle_time = iop.eide_pio_iordy;
- } else {
- cycle_time = iop.eide_pio;
- }
- debug("cycle time = %d\n", cycle_time);
- mode = 4;
- if (cycle_time > 120)
- mode = 3; /* 120 ns for PIO mode 4 */
- if (cycle_time > 180)
- mode = 2; /* 180 ns for PIO mode 3 */
- if (cycle_time > 240)
- mode = 1; /* 240 ns for PIO mode 4 */
- if (cycle_time > 383)
- mode = 0; /* 383 ns for PIO mode 4 */
- }
- printf("PIO mode to use: PIO %d\n", mode);
-#endif /* 0 */
-
#ifdef CONFIG_ATAPI
if (dev_desc->if_type == IF_TYPE_ATAPI) {
atapi_inquiry(dev_desc);
@@ -1122,17 +1020,10 @@ int ide_device_present(int dev)
* ATAPI Support
*/
-void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
- __attribute__ ((weak, alias("__ide_input_data_shorts")));
-
-void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
- __attribute__ ((weak, alias("__ide_output_data_shorts")));
-
-
#if defined(CONFIG_IDE_SWAP_IO)
/* since ATAPI may use commands with not 4 bytes alligned length
* we have our own transfer functions, 2 bytes alligned */
-void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -1149,7 +1040,7 @@ void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
}
}
-void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -1167,12 +1058,12 @@ void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
{
outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
}
-void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
{
insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
}
diff --git a/common/cmd_log.c b/common/cmd_log.c
index 38d0f5e..873ee40 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -33,8 +33,8 @@
DECLARE_GLOBAL_DATA_PTR;
/* Local prototypes */
-static void logbuff_putc(const char c);
-static void logbuff_puts(const char *s);
+static void logbuff_putc(struct stdio_dev *dev, const char c);
+static void logbuff_puts(struct stdio_dev *dev, const char *s);
static int logbuff_printk(const char *line);
static char buf[1024];
@@ -143,7 +143,7 @@ int drv_logbuff_init(void)
return (rc == 0) ? 1 : rc;
}
-static void logbuff_putc(const char c)
+static void logbuff_putc(struct stdio_dev *dev, const char c)
{
char buf[2];
buf[0] = c;
@@ -151,7 +151,7 @@ static void logbuff_putc(const char c)
logbuff_printk(buf);
}
-static void logbuff_puts(const char *s)
+static void logbuff_puts(struct stdio_dev *dev, const char *s)
{
logbuff_printk (s);
}
@@ -181,6 +181,7 @@ void logbuff_log(char *msg)
*/
int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
+ struct stdio_dev *sdev = NULL;
char *s;
unsigned long i, start, size;
@@ -188,7 +189,7 @@ int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Log concatenation of all arguments separated by spaces */
for (i = 2; i < argc; i++) {
logbuff_printk(argv[i]);
- logbuff_putc((i < argc - 1) ? ' ' : '\n');
+ logbuff_putc(sdev, (i < argc - 1) ? ' ' : '\n');
}
return 0;
}
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index b82a7ce..7c4a57a 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -160,10 +160,10 @@ static void dump_reg(
mask_in_place = pdesc->mask << pdesc->lo;
- printf(" (%04hx:%04hx) %u.",
- mask_in_place,
- regval & mask_in_place,
- prd->regno);
+ printf(" (%04hx:%04x) %u.",
+ mask_in_place,
+ regval & mask_in_place,
+ prd->regno);
if (special_field(prd->regno, pdesc, regval)) {
}
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e6c3395..855808c 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -950,11 +950,15 @@ sep_err:
#ifdef CONFIG_CMD_IMPORTENV
/*
- * env import [-d] [-t | -b | -c] addr [size]
+ * env import [-d] [-t [-r] | -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitions
* -t: assume text format; either "size" must be given or the
* text data must be '\0' terminated
+ * -r: handle CRLF like LF, that means exported variables with
+ * a content which ends with \r won't get imported. Used
+ * to import text files created with editors which are using CRLF
+ * for line endings. Only effective in addition to -t.
* -b: assume binary format ('\0' separated, "\0\0" terminated)
* -c: assume checksum protected environment format
* addr: memory address to read from
@@ -970,6 +974,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
int chk = 0;
int fmt = 0;
int del = 0;
+ int crlf_is_lf = 0;
size_t size;
cmd = *argv;
@@ -994,6 +999,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
goto sep_err;
sep = '\n';
break;
+ case 'r': /* handle CRLF like LF */
+ crlf_is_lf = 1;
+ break;
case 'd':
del = 1;
break;
@@ -1009,6 +1017,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
if (!fmt)
printf("## Warning: defaulting to text format\n");
+ if (sep != '\n' && crlf_is_lf )
+ crlf_is_lf = 0;
+
addr = simple_strtoul(argv[0], NULL, 16);
ptr = map_sysmem(addr, 0);
@@ -1050,8 +1061,8 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
ptr = (char *)ep->data;
}
- if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR, 0,
- NULL) == 0) {
+ if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
+ crlf_is_lf, 0, NULL) == 0) {
error("Environment import failed: errno = %d\n", errno);
return 1;
}
@@ -1180,7 +1191,7 @@ static char env_help_text[] =
#endif
#endif
#if defined(CONFIG_CMD_IMPORTENV)
- "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
+ "env import [-d] [-t [-r] | -b | -c] addr [size] - import environment\n"
#endif
"env print [-a | name ...] - print environment\n"
#if defined(CONFIG_CMD_RUN)
diff --git a/common/cmd_part.c b/common/cmd_part.c
index c84bc27..39e8666 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -26,7 +26,7 @@
#error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled
#endif
-int do_part_uuid(int argc, char * const argv[])
+static int do_part_uuid(int argc, char * const argv[])
{
int part;
block_dev_desc_t *dev_desc;
@@ -49,7 +49,7 @@ int do_part_uuid(int argc, char * const argv[])
return 0;
}
-int do_part_list(int argc, char * const argv[])
+static int do_part_list(int argc, char * const argv[])
{
int ret;
block_dev_desc_t *desc;
@@ -66,7 +66,7 @@ int do_part_list(int argc, char * const argv[])
return 0;
}
-int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 3483328..ba48692 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -1562,7 +1562,7 @@ static cmd_tbl_t cmd_pxe_sub[] = {
U_BOOT_CMD_MKENT(boot, 2, 1, do_pxe_boot, "", "")
};
-int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *cp;
@@ -1596,7 +1596,7 @@ U_BOOT_CMD(
*
* Returns 0 on success, 1 on error.
*/
-int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
unsigned long pxefile_addr_r;
struct pxe_menu *cfg;
diff --git a/common/cmd_source.c b/common/cmd_source.c
index f3e9e60..6881bc9 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -142,8 +142,7 @@ source (ulong addr, const char *fit_uname)
/**************************************************/
#if defined(CONFIG_CMD_SOURCE)
-int
-do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_source(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr;
int rcode;
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7c4d950..3c37c93 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -287,7 +287,7 @@ out_err:
return err;
}
-int ubi_volume_continue_write(char *volume, void *buf, size_t size)
+static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
{
int err = 1;
struct ubi_volume *vol;
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index fdc8bfe..19c8a43 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -21,7 +21,8 @@
static int ubifs_initialized;
static int ubifs_mounted;
-int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *vol_name;
int ret;
@@ -65,7 +66,8 @@ void cmd_ubifs_umount(void)
ubifs_initialized = 0;
}
-int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
if (argc != 1)
return CMD_RET_USAGE;
@@ -80,7 +82,8 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 0;
}
-int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *filename = "/";
int ret;
@@ -103,7 +106,8 @@ int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return ret;
}
-int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *filename;
char *endp;
diff --git a/common/console.c b/common/console.c
index 5453726..898da39 100644
--- a/common/console.c
+++ b/common/console.c
@@ -109,7 +109,7 @@ static int console_setfile(int file, struct stdio_dev * dev)
case stderr:
/* Start new device */
if (dev->start) {
- error = dev->start();
+ error = dev->start(dev);
/* If it's not started dont use it */
if (error < 0)
break;
@@ -159,7 +159,7 @@ static int console_getc(int file)
unsigned char ret;
/* This is never called with testcdev == NULL */
- ret = tstcdev->getc();
+ ret = tstcdev->getc(tstcdev);
tstcdev = NULL;
return ret;
}
@@ -173,7 +173,7 @@ static int console_tstc(int file)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->tstc != NULL) {
- ret = dev->tstc();
+ ret = dev->tstc(dev);
if (ret > 0) {
tstcdev = dev;
disable_ctrlc(0);
@@ -194,7 +194,7 @@ static void console_putc(int file, const char c)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->putc != NULL)
- dev->putc(c);
+ dev->putc(dev, c);
}
}
@@ -206,7 +206,7 @@ static void console_puts(int file, const char *s)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->puts != NULL)
- dev->puts(s);
+ dev->puts(dev, s);
}
}
@@ -222,22 +222,22 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
#else
static inline int console_getc(int file)
{
- return stdio_devices[file]->getc();
+ return stdio_devices[file]->getc(stdio_devices[file]);
}
static inline int console_tstc(int file)
{
- return stdio_devices[file]->tstc();
+ return stdio_devices[file]->tstc(stdio_devices[file]);
}
static inline void console_putc(int file, const char c)
{
- stdio_devices[file]->putc(c);
+ stdio_devices[file]->putc(stdio_devices[file], c);
}
static inline void console_puts(int file, const char *s)
{
- stdio_devices[file]->puts(s);
+ stdio_devices[file]->puts(stdio_devices[file], s);
}
static inline void console_printdevs(int file)
@@ -417,7 +417,7 @@ static inline void print_pre_console_buffer(void) {}
void putc(const char c)
{
#ifdef CONFIG_SANDBOX
- if (!gd) {
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
os_putc(c);
return;
}
@@ -447,7 +447,7 @@ void putc(const char c)
void puts(const char *s)
{
#ifdef CONFIG_SANDBOX
- if (!gd) {
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
os_puts(s);
return;
}
@@ -504,7 +504,7 @@ int vprintf(const char *fmt, va_list args)
uint i;
char printbuffer[CONFIG_SYS_PBSIZE];
-#ifndef CONFIG_PRE_CONSOLE_BUFFER
+#if defined(CONFIG_PRE_CONSOLE_BUFFER) && !defined(CONFIG_SANDBOX)
if (!gd->have_console)
return 0;
#endif
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 3c70d5d..f987339 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1,5 +1,9 @@
#include <common.h>
+#ifdef CONFIG_SANDBOX
+#define DEBUG
+#endif
+
#if 0 /* Moved to malloc.h */
/* ---------- To make a malloc.h, start cutting here ------------ */
@@ -220,7 +224,7 @@
*/
-
+
/* Preliminaries */
@@ -930,6 +934,8 @@ struct mallinfo mALLINFo();
#endif /* 0 */ /* Moved to malloc.h */
#include <malloc.h>
+#include <asm/io.h>
+
#ifdef DEBUG
#if __STD_C
static void malloc_update_mallinfo (void);
@@ -1132,7 +1138,7 @@ gAllocatedSize))
#endif
-
+
/*
Type declarations
@@ -1272,7 +1278,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
serviced via calls to mmap, and then later released via munmap.
*/
-
+
/* sizes, alignments */
#define SIZE_SZ (sizeof(INTERNAL_SIZE_T))
@@ -1297,7 +1303,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define aligned_OK(m) (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0)
-
+
/*
Physical chunk operations
@@ -1332,7 +1338,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
-
+
/*
Dealing with use bits
@@ -1371,7 +1377,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE))
-
+
/*
Dealing with size fields
@@ -1394,7 +1400,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s))
-
+
/*
@@ -1566,7 +1572,7 @@ void mem_malloc_init(ulong start, ulong size)
#define is_small_request(nb) (nb < MAX_SMALLBIN_SIZE - SMALLBIN_WIDTH)
-
+
/*
To help compensate for the large number of bins, a one-level index
@@ -1590,7 +1596,7 @@ void mem_malloc_init(ulong start, ulong size)
#define clear_binblock(ii) (binblocks_w = (mbinptr)(binblocks_r & ~(idx2binblock(ii))))
-
+
/* Other static bookkeeping data */
@@ -1628,7 +1634,7 @@ static unsigned int max_n_mmaps = 0;
static unsigned long max_mmapped_mem = 0;
#endif
-
+
/*
Debugging support
@@ -1769,7 +1775,7 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
#define check_malloced_chunk(P,N)
#endif
-
+
/*
Macro-based internal utilities
@@ -1841,7 +1847,7 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
(last_remainder->fd = last_remainder->bk = last_remainder)
-
+
/* Routines dealing with mmap(). */
@@ -1972,7 +1978,7 @@ static mchunkptr mremap_chunk(p, new_size) mchunkptr p; size_t new_size;
#endif /* HAVE_MMAP */
-
+
/*
Extend the top-most chunk by obtaining memory from system.
@@ -2089,7 +2095,7 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
}
-
+
/* Main public routines */
@@ -2174,6 +2180,20 @@ Void_t* mALLOc(bytes) size_t bytes;
INTERNAL_SIZE_T nb;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ ulong new_ptr;
+ void *ptr;
+
+ new_ptr = gd->malloc_ptr + bytes;
+ if (new_ptr > gd->malloc_limit)
+ panic("Out of pre-reloc memory");
+ ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
+ gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
+ return ptr;
+ }
+#endif
+
/* check if mem_malloc_init() was run */
if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
/* not initialized yet */
@@ -2396,7 +2416,7 @@ Void_t* mALLOc(bytes) size_t bytes;
}
-
+
/*
@@ -2437,6 +2457,12 @@ void fREe(mem) Void_t* mem;
mchunkptr fwd; /* misc temp for linking */
int islr; /* track whether merging with last_remainder */
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ /* free() is a no-op - all the memory will be freed on relocation */
+ if (!(gd->flags & GD_FLG_RELOC))
+ return;
+#endif
+
if (mem == NULL) /* free(0) has no effect */
return;
@@ -2513,7 +2539,7 @@ void fREe(mem) Void_t* mem;
}
-
+
/*
@@ -2588,6 +2614,13 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
/* realloc of null is supposed to be same as malloc */
if (oldmem == NULL) return mALLOc(bytes);
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ /* This is harder to support and should not be needed */
+ panic("pre-reloc realloc() is not supported");
+ }
+#endif
+
newp = oldp = mem2chunk(oldmem);
newsize = oldsize = chunksize(oldp);
@@ -2750,7 +2783,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
}
-
+
/*
@@ -2868,7 +2901,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
}
-
+
/*
@@ -2933,6 +2966,12 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
return NULL;
else
{
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ MALLOC_ZERO(mem, sz);
+ return mem;
+ }
+#endif
p = mem2chunk(mem);
/* Two optional cases in which clearing not necessary */
@@ -2975,7 +3014,7 @@ void cfree(mem) Void_t *mem;
}
#endif
-
+
/*
@@ -3056,7 +3095,7 @@ int malloc_trim(pad) size_t pad;
}
}
-
+
/*
malloc_usable_size:
@@ -3092,7 +3131,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
}
-
+
/* Utility to update current_mallinfo for malloc_stats and mallinfo() */
@@ -3136,7 +3175,7 @@ static void malloc_update_mallinfo()
}
#endif /* DEBUG */
-
+
/*
@@ -3183,7 +3222,7 @@ struct mallinfo mALLINFo()
#endif /* DEBUG */
-
+
/*
mallopt:
diff --git a/common/env_common.c b/common/env_common.c
index cd7b4cd..af59c72 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -27,12 +27,10 @@ struct hsearch_data env_htab = {
.change_ok = env_flags_validate,
};
-static uchar __env_get_char_spec(int index)
+__weak uchar env_get_char_spec(int index)
{
return *((uchar *)(gd->env_addr + index));
}
-uchar env_get_char_spec(int)
- __attribute__((weak, alias("__env_get_char_spec")));
static uchar env_get_char_init(int index)
{
@@ -120,7 +118,7 @@ void set_default_env(const char *s)
}
if (himport_r(&env_htab, (char *)default_environment,
- sizeof(default_environment), '\0', flags,
+ sizeof(default_environment), '\0', flags, 0,
0, NULL) == 0)
error("Environment import failed: errno = %d\n", errno);
@@ -137,7 +135,7 @@ int set_default_vars(int nvars, char * const vars[])
*/
return himport_r(&env_htab, (const char *)default_environment,
sizeof(default_environment), '\0',
- H_NOCLEAR | H_INTERACTIVE, nvars, vars);
+ H_NOCLEAR | H_INTERACTIVE, 0, nvars, vars);
}
#ifdef CONFIG_ENV_AES
@@ -214,7 +212,7 @@ int env_import(const char *buf, int check)
return ret;
}
- if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0,
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0,
0, NULL)) {
gd->flags |= GD_FLG_ENV_READY;
return 1;
diff --git a/common/lcd.c b/common/lcd.c
index 19b86b7..feb913a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -214,6 +214,11 @@ static inline void console_newline(void)
/*----------------------------------------------------------------------*/
+static void lcd_stub_putc(struct stdio_dev *dev, const char c)
+{
+ lcd_putc(c);
+}
+
void lcd_putc(const char c)
{
if (!lcd_is_enabled) {
@@ -253,6 +258,11 @@ void lcd_putc(const char c)
/*----------------------------------------------------------------------*/
+static void lcd_stub_puts(struct stdio_dev *dev, const char *s)
+{
+ lcd_puts(s);
+}
+
void lcd_puts(const char *s)
{
if (!lcd_is_enabled) {
@@ -426,8 +436,8 @@ int drv_lcd_init(void)
strcpy(lcddev.name, "lcd");
lcddev.ext = 0; /* No extensions */
lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
- lcddev.putc = lcd_putc; /* 'putc' function */
- lcddev.puts = lcd_puts; /* 'puts' function */
+ lcddev.putc = lcd_stub_putc; /* 'putc' function */
+ lcddev.puts = lcd_stub_puts; /* 'puts' function */
rc = stdio_register(&lcddev);
diff --git a/common/main.c b/common/main.c
index 32618f1..2979fbe 100644
--- a/common/main.c
+++ b/common/main.c
@@ -17,8 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
-void inline __show_boot_progress (int val) {}
-void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
+__weak void show_boot_progress(int val) {}
static void modem_init(void)
{
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 062461b..9b200bc 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -44,7 +44,7 @@ void spl_nand_load_image(void)
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
if (header->ih_os == IH_OS_LINUX) {
/* happy - was a linux */
@@ -62,13 +62,13 @@ void spl_nand_load_image(void)
#endif
#ifdef CONFIG_NAND_ENV_DST
nand_spl_load_image(CONFIG_ENV_OFFSET,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
(void *)spl_image.load_addr);
#ifdef CONFIG_ENV_OFFSET_REDUND
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
(void *)spl_image.load_addr);
diff --git a/common/splash.c b/common/splash.c
index 18885f1..144fb10 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -23,15 +23,11 @@
#include <common.h>
#include <splash.h>
-int __splash_screen_prepare(void)
+__weak int splash_screen_prepare(void)
{
return 0;
}
-int splash_screen_prepare(void)
- __attribute__ ((weak, alias("__splash_screen_prepare")));
-
-
#ifdef CONFIG_SPLASH_SCREEN_ALIGN
void splash_get_pos(int *x, int *y)
{
diff --git a/common/stdio.c b/common/stdio.c
index 844f98c..692ca7f 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -11,6 +11,7 @@
#include <config.h>
#include <common.h>
+#include <errno.h>
#include <stdarg.h>
#include <malloc.h>
#include <stdio_dev.h>
@@ -35,23 +36,43 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#ifdef CONFIG_SYS_DEVICE_NULLDEV
-void nulldev_putc(const char c)
+void nulldev_putc(struct stdio_dev *dev, const char c)
{
/* nulldev is empty! */
}
-void nulldev_puts(const char *s)
+void nulldev_puts(struct stdio_dev *dev, const char *s)
{
/* nulldev is empty! */
}
-int nulldev_input(void)
+int nulldev_input(struct stdio_dev *dev)
{
/* nulldev is empty! */
return 0;
}
#endif
+void stdio_serial_putc(struct stdio_dev *dev, const char c)
+{
+ serial_putc(c);
+}
+
+void stdio_serial_puts(struct stdio_dev *dev, const char *s)
+{
+ serial_puts(s);
+}
+
+int stdio_serial_getc(struct stdio_dev *dev)
+{
+ return serial_getc();
+}
+
+int stdio_serial_tstc(struct stdio_dev *dev)
+{
+ return serial_tstc();
+}
+
/**************************************************************************
* SYSTEM DRIVERS
**************************************************************************
@@ -65,10 +86,10 @@ static void drv_system_init (void)
strcpy (dev.name, "serial");
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- dev.putc = serial_putc;
- dev.puts = serial_puts;
- dev.getc = serial_getc;
- dev.tstc = serial_tstc;
+ dev.putc = stdio_serial_putc;
+ dev.puts = stdio_serial_puts;
+ dev.getc = stdio_serial_getc;
+ dev.tstc = stdio_serial_tstc;
stdio_register (&dev);
#ifdef CONFIG_SYS_DEVICE_NULLDEV
@@ -128,32 +149,35 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev)
return _dev;
}
-int stdio_register (struct stdio_dev * dev)
+int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp)
{
struct stdio_dev *_dev;
_dev = stdio_clone(dev);
if(!_dev)
- return -1;
+ return -ENODEV;
list_add_tail(&(_dev->list), &(devs.list));
+ if (devp)
+ *devp = _dev;
+
return 0;
}
+int stdio_register(struct stdio_dev *dev)
+{
+ return stdio_register_dev(dev, NULL);
+}
+
/* deregister the device "devname".
* returns 0 if success, -1 if device is assigned and 1 if devname not found
*/
#ifdef CONFIG_SYS_STDIO_DEREGISTER
-int stdio_deregister(const char *devname)
+int stdio_deregister_dev(struct stdio_dev *dev)
{
int l;
struct list_head *pos;
- struct stdio_dev *dev;
char temp_names[3][16];
- dev = stdio_get_by_name(devname);
-
- if(!dev) /* device not found */
- return -1;
/* get stdio devices (ListRemoveItem changes the dev list) */
for (l=0 ; l< MAX_FILES; l++) {
if (stdio_devices[l] == dev) {
@@ -177,6 +201,18 @@ int stdio_deregister(const char *devname)
}
return 0;
}
+
+int stdio_deregister(const char *devname)
+{
+ struct stdio_dev *dev;
+
+ dev = stdio_get_by_name(devname);
+
+ if (!dev) /* device not found */
+ return -ENODEV;
+
+ return stdio_deregister_dev(dev);
+}
#endif /* CONFIG_SYS_STDIO_DEREGISTER */
int stdio_init (void)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 0b77c16..c34fd5c 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -360,7 +360,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
}
/* test if a character is in the queue */
-static int usb_kbd_testc(void)
+static int usb_kbd_testc(struct stdio_dev *sdev)
{
struct stdio_dev *dev;
struct usb_device *usb_kbd_dev;
@@ -386,7 +386,7 @@ static int usb_kbd_testc(void)
}
/* gets the character from the queue */
-static int usb_kbd_getc(void)
+static int usb_kbd_getc(struct stdio_dev *sdev)
{
struct stdio_dev *dev;
struct usb_device *usb_kbd_dev;
@@ -522,8 +522,6 @@ int drv_usb_kbd_init(void)
memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev));
strcpy(usb_kbd_dev.name, DEVNAME);
usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- usb_kbd_dev.putc = NULL;
- usb_kbd_dev.puts = NULL;
usb_kbd_dev.getc = usb_kbd_getc;
usb_kbd_dev.tstc = usb_kbd_testc;
usb_kbd_dev.priv = (void *)dev;
diff --git a/disk/part.c b/disk/part.c
index baceb19..ecc5e7e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -333,7 +333,7 @@ static void print_part_header (const char *type, block_dev_desc_t * dev_desc)
#endif /* any CONFIG_..._PARTITION */
-void print_part (block_dev_desc_t * dev_desc)
+void print_part(block_dev_desc_t * dev_desc)
{
switch (dev_desc->part_type) {
@@ -381,8 +381,8 @@ void print_part (block_dev_desc_t * dev_desc)
#endif /* HAVE_BLOCK_DEVICE */
-int get_partition_info(block_dev_desc_t *dev_desc, int part
- , disk_partition_t *info)
+int get_partition_info(block_dev_desc_t *dev_desc, int part,
+ disk_partition_t *info)
{
#ifdef HAVE_BLOCK_DEVICE
@@ -511,7 +511,7 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
disk_partition_t tmpinfo;
/*
- * Special-case a psuedo block device "hostfs", to allow access to the
+ * Special-case a pseudo block device "hostfs", to allow access to the
* host's own filesystem.
*/
if (0 == strcmp(ifname, "hostfs")) {
diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index 22c3fcb..f9b68be 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -95,26 +95,37 @@ are provided in test/dm. To run them, try:
You should see something like this:
<...U-Boot banner...>
- Running 12 driver model tests
+ Running 21 driver model tests
Test: dm_test_autobind
Test: dm_test_autoprobe
+ Test: dm_test_bus_children
+ Device 'd-test': seq 3 is in use by 'b-test'
+ Device 'c-test@0': seq 0 is in use by 'a-test'
+ Device 'c-test@1': seq 1 is in use by 'd-test'
+ Test: dm_test_bus_children_funcs
+ Test: dm_test_bus_parent_data
+ Test: dm_test_bus_parent_ops
Test: dm_test_children
Test: dm_test_fdt
+ Device 'd-test': seq 3 is in use by 'b-test'
+ Test: dm_test_fdt_offset
+ Test: dm_test_fdt_pre_reloc
+ Test: dm_test_fdt_uclass_seq
+ Device 'd-test': seq 3 is in use by 'b-test'
+ Device 'a-test': seq 0 is in use by 'd-test'
Test: dm_test_gpio
sandbox_gpio: sb_gpio_get_value: error: offset 4 not reserved
Test: dm_test_leak
- Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c
- Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c
Test: dm_test_lifecycle
Test: dm_test_operations
Test: dm_test_ordering
Test: dm_test_platdata
+ Test: dm_test_pre_reloc
Test: dm_test_remove
Test: dm_test_uclass
+ Test: dm_test_uclass_before_ready
Failures: 0
-(You can add '#define DEBUG' as suggested to check for memory leaks)
-
What is going on?
-----------------
@@ -341,6 +352,145 @@ numbering comes from include/dm/uclass.h. To add a new uclass, add to the
end of the enum there, then declare your uclass as above.
+Device Sequence Numbers
+-----------------------
+
+U-Boot numbers devices from 0 in many situations, such as in the command
+line for I2C and SPI buses, and the device names for serial ports (serial0,
+serial1, ...). Driver model supports this numbering and permits devices
+to be locating by their 'sequence'.
+
+Sequence numbers start from 0 but gaps are permitted. For example, a board
+may have I2C buses 0, 1, 4, 5 but no 2 or 3. The choice of how devices are
+numbered is up to a particular board, and may be set by the SoC in some
+cases. While it might be tempting to automatically renumber the devices
+where there are gaps in the sequence, this can lead to confusion and is
+not the way that U-Boot works.
+
+Each device can request a sequence number. If none is required then the
+device will be automatically allocated the next available sequence number.
+
+To specify the sequence number in the device tree an alias is typically
+used.
+
+aliases {
+ serial2 = "/serial@22230000";
+};
+
+This indicates that in the uclass called "serial", the named node
+("/serial@22230000") will be given sequence number 2. Any command or driver
+which requests serial device 2 will obtain this device.
+
+Some devices represent buses where the devices on the bus are numbered or
+addressed. For example, SPI typically numbers its slaves from 0, and I2C
+uses a 7-bit address. In these cases the 'reg' property of the subnode is
+used, for example:
+
+{
+ aliases {
+ spi2 = "/spi@22300000";
+ };
+
+ spi@22300000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ spi-flash@0 {
+ reg = <0>;
+ ...
+ }
+ eeprom@1 {
+ reg = <1>;
+ };
+ };
+
+In this case we have a SPI bus with two slaves at 0 and 1. The SPI bus
+itself is numbered 2. So we might access the SPI flash with:
+
+ sf probe 2:0
+
+and the eeprom with
+
+ sspi 2:1 32 ef
+
+These commands simply need to look up the 2nd device in the SPI uclass to
+find the right SPI bus. Then, they look at the children of that bus for the
+right sequence number (0 or 1 in this case).
+
+Typically the alias method is used for top-level nodes and the 'reg' method
+is used only for buses.
+
+Device sequence numbers are resolved when a device is probed. Before then
+the sequence number is only a request which may or may not be honoured,
+depending on what other devices have been probed. However the numbering is
+entirely under the control of the board author so a conflict is generally
+an error.
+
+
+Bus Drivers
+-----------
+
+A common use of driver model is to implement a bus, a device which provides
+access to other devices. Example of buses include SPI and I2C. Typically
+the bus provides some sort of transport or translation that makes it
+possible to talk to the devices on the bus.
+
+Driver model provides a few useful features to help with implementing
+buses. Firstly, a bus can request that its children store some 'parent
+data' which can be used to keep track of child state. Secondly, the bus can
+define methods which are called when a child is probed or removed. This is
+similar to the methods the uclass driver provides.
+
+Here an explanation of how a bus fits with a uclass may be useful. Consider
+a USB bus with several devices attached to it, each from a different (made
+up) uclass:
+
+ xhci_usb (UCLASS_USB)
+ eth (UCLASS_ETHERNET)
+ camera (UCLASS_CAMERA)
+ flash (UCLASS_FLASH_STORAGE)
+
+Each of the devices is connected to a different address on the USB bus.
+The bus device wants to store this address and some other information such
+as the bus speed for each device.
+
+To achieve this, the bus device can use dev->parent_priv in each of its
+three children. This can be auto-allocated if the bus driver has a non-zero
+value for per_child_auto_alloc_size. If not, then the bus device can
+allocate the space itself before the child device is probed.
+
+Also the bus driver can define the child_pre_probe() and child_post_remove()
+methods to allow it to do some processing before the child is activated or
+after it is deactivated.
+
+Note that the information that controls this behaviour is in the bus's
+driver, not the child's. In fact it is possible that child has no knowledge
+that it is connected to a bus. The same child device may even be used on two
+different bus types. As an example. the 'flash' device shown above may also
+be connected on a SATA bus or standalone with no bus:
+
+ xhci_usb (UCLASS_USB)
+ flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by USB bus
+
+ sata (UCLASS_SATA)
+ flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by SATA bus
+
+ flash (UCLASS_FLASH_STORAGE) - no parent data/methods (not on a bus)
+
+Above you can see that the driver for xhci_usb/sata controls the child's
+bus methods. In the third example the device is not on a bus, and therefore
+will not have these methods at all. Consider the case where the flash
+device defines child methods. These would be used for *its* children, and
+would be quite separate from the methods defined by the driver for the bus
+that the flash device is connetced to. The act of attaching a device to a
+parent device which is a bus, causes the device to start behaving like a
+bus device, regardless of its own views on the matter.
+
+The uclass for the device can also contain data private to that uclass.
+But note that each device on the bus may be a memeber of a different
+uclass, and this data has nothing to do with the child data for each child
+on the bus.
+
+
Driver Lifecycle
----------------
@@ -406,12 +556,23 @@ steps (see device_probe()):
stored in the device, but it is uclass data. owned by the uclass driver.
It is possible for the device to access it.
- d. All parent devices are probed. It is not possible to activate a device
+ d. If the device's immediate parent specifies a per_child_auto_alloc_size
+ then this space is allocated. This is intended for use by the parent
+ device to keep track of things related to the child. For example a USB
+ flash stick attached to a USB host controller would likely use this
+ space. The controller can hold information about the USB state of each
+ of its children.
+
+ e. All parent devices are probed. It is not possible to activate a device
unless its predecessors (all the way up to the root device) are activated.
This means (for example) that an I2C driver will require that its bus
be activated.
- e. If the driver provides an ofdata_to_platdata() method, then this is
+ f. The device's sequence number is assigned, either the requested one
+ (assuming no conflicts) or the next available one if there is a conflict
+ or nothing particular is requested.
+
+ g. If the driver provides an ofdata_to_platdata() method, then this is
called to convert the device tree data into platform data. This should
do various calls like fdtdec_get_int(gd->fdt_blob, dev->of_offset, ...)
to access the node and store the resulting information into dev->platdata.
@@ -427,7 +588,7 @@ steps (see device_probe()):
data, one day it is possible that U-Boot will cache platformat data for
devices which are regularly de/activated).
- f. The device's probe() method is called. This should do anything that
+ h. The device's probe() method is called. This should do anything that
is required by the device to get it going. This could include checking
that the hardware is actually present, setting up clocks for the
hardware and setting up hardware registers to initial values. The code
@@ -442,9 +603,9 @@ steps (see device_probe()):
allocate the priv space here yourself. The same applies also to
platdata_auto_alloc_size. Remember to free them in the remove() method.
- g. The device is marked 'activated'
+ i. The device is marked 'activated'
- h. The uclass's post_probe() method is called, if one exists. This may
+ j. The uclass's post_probe() method is called, if one exists. This may
cause the uclass to do some housekeeping to record the device as
activated and 'known' by the uclass.
@@ -475,7 +636,8 @@ remove it. This performs the probe steps in reverse:
to be sure that no hardware is running, it should be enough to remove
all devices.
- d. The device memory is freed (platform data, private data, uclass data).
+ d. The device memory is freed (platform data, private data, uclass data,
+ parent data).
Note: Because the platform data for a U_BOOT_DEVICE() is defined with a
static pointer, it is not de-allocated during the remove() method. For
@@ -490,7 +652,14 @@ remove it. This performs the probe steps in reverse:
or preferably ofdata_to_platdata()) and the deallocation in remove()
are the responsibility of the driver author.
- e. The device is marked inactive. Note that it is still bound, so the
+ e. The device sequence number is set to -1, meaning that it no longer
+ has an allocated sequence. If the device is later reactivated and that
+ sequence number is still free, it may well receive the name sequence
+ number again. But from this point, the sequence number previously used
+ by this device will no longer exist (think of SPI bus 2 being removed
+ and bus 2 is no longer available for use).
+
+ f. The device is marked inactive. Note that it is still bound, so the
device structure itself is not freed at this point. Should the device be
activated again, then the cycle starts again at step 2 above.
@@ -538,26 +707,35 @@ dealing with this might not be worth it.
- Implemented a GPIO system, trying to keep it simple
+Pre-Relocation Support
+----------------------
+
+For pre-relocation we simply call the driver model init function. Only
+drivers marked with DM_FLAG_PRE_RELOC or the device tree
+'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
+to reduce the driver model overhead.
+
+Then post relocation we throw that away and re-init driver model again.
+For drivers which require some sort of continuity between pre- and
+post-relocation devices, we can provide access to the pre-relocation
+device pointers, but this is not currently implemented (the root device
+pointer is saved but not made available through the driver model API).
+
+
Things to punt for later
------------------------
- SPL support - this will have to be present before many drivers can be
converted, but it seems like we can add it once we are happy with the
core implementation.
-- Pre-relocation support - similar story
-That is not to say that no thinking has gone into these - in fact there
+That is not to say that no thinking has gone into this - in fact there
is quite a lot there. However, getting these right is non-trivial and
there is a high cost associated with going down the wrong path.
For SPL, it may be possible to fit in a simplified driver model with only
bind and probe methods, to reduce size.
-For pre-relocation we can simply call the driver model init function. Then
-post relocation we throw that away and re-init driver model again. For drivers
-which require some sort of continuity between pre- and post-relocation
-devices, we can provide access to the pre-relocation device pointers.
-
Uclasses are statically numbered at compile time. It would be possible to
change this to dynamic numbering, but then we would require some sort of
lookup service, perhaps searching by name. This is slightly less efficient
diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index c8f6573..4df8046 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -41,7 +41,7 @@ u16 *ataid[AHCI_MAX_PORTS];
#define WAIT_MS_SPINUP 20000
#define WAIT_MS_DATAIO 5000
#define WAIT_MS_FLUSH 5000
-#define WAIT_MS_LINKUP 40
+#define WAIT_MS_LINKUP 200
static inline u32 ahci_port_base(u32 base, u32 port)
{
diff --git a/drivers/core/device.c b/drivers/core/device.c
index c73c339..166b073 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <fdtdec.h>
#include <malloc.h>
#include <dm/device.h>
#include <dm/device-internal.h>
@@ -21,6 +22,8 @@
#include <linux/err.h>
#include <linux/list.h>
+DECLARE_GLOBAL_DATA_PTR;
+
/**
* device_chld_unbind() - Unbind all device's children from the device
*
@@ -95,6 +98,21 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
dev->parent = parent;
dev->driver = drv;
dev->uclass = uc;
+
+ /*
+ * For some devices, such as a SPI or I2C bus, the 'reg' property
+ * is a reasonable indicator of the sequence number. But if there is
+ * an alias, we use that in preference. In any case, this is just
+ * a 'requested' sequence, and will be resolved (and ->seq updated)
+ * when the device is probed.
+ */
+ dev->req_seq = fdtdec_get_int(gd->fdt_blob, of_offset, "reg", -1);
+ dev->seq = -1;
+ if (uc->uc_drv->name && of_offset != -1) {
+ fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name, of_offset,
+ &dev->req_seq);
+ }
+
if (!dev->platdata && drv->platdata_auto_alloc_size)
dev->flags |= DM_FLAG_ALLOC_PDATA;
@@ -129,14 +147,16 @@ fail_bind:
return ret;
}
-int device_bind_by_name(struct udevice *parent, const struct driver_info *info,
- struct udevice **devp)
+int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
+ const struct driver_info *info, struct udevice **devp)
{
struct driver *drv;
drv = lists_driver_lookup_name(info->name);
if (!drv)
return -ENOENT;
+ if (pre_reloc_only && !(drv->flags & DM_FLAG_PRE_RELOC))
+ return -EPERM;
return device_bind(parent, drv, info->name, (void *)info->platdata,
-1, devp);
@@ -198,6 +218,13 @@ static void device_free(struct udevice *dev)
free(dev->uclass_priv);
dev->uclass_priv = NULL;
}
+ if (dev->parent) {
+ size = dev->parent->driver->per_child_auto_alloc_size;
+ if (size) {
+ free(dev->parent_priv);
+ dev->parent_priv = NULL;
+ }
+ }
}
int device_probe(struct udevice *dev)
@@ -205,6 +232,7 @@ int device_probe(struct udevice *dev)
struct driver *drv;
int size = 0;
int ret;
+ int seq;
if (!dev)
return -EINVAL;
@@ -242,11 +270,33 @@ int device_probe(struct udevice *dev)
/* Ensure all parents are probed */
if (dev->parent) {
+ size = dev->parent->driver->per_child_auto_alloc_size;
+ if (size) {
+ dev->parent_priv = calloc(1, size);
+ if (!dev->parent_priv) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+ }
+
ret = device_probe(dev->parent);
if (ret)
goto fail;
}
+ seq = uclass_resolve_seq(dev);
+ if (seq < 0) {
+ ret = seq;
+ goto fail;
+ }
+ dev->seq = seq;
+
+ if (dev->parent && dev->parent->driver->child_pre_probe) {
+ ret = dev->parent->driver->child_pre_probe(dev);
+ if (ret)
+ goto fail;
+ }
+
if (drv->ofdata_to_platdata && dev->of_offset >= 0) {
ret = drv->ofdata_to_platdata(dev);
if (ret)
@@ -274,6 +324,7 @@ fail_uclass:
__func__, dev->name);
}
fail:
+ dev->seq = -1;
device_free(dev);
return ret;
@@ -307,11 +358,20 @@ int device_remove(struct udevice *dev)
goto err_remove;
}
+ if (dev->parent && dev->parent->driver->child_post_remove) {
+ ret = dev->parent->driver->child_post_remove(dev);
+ if (ret) {
+ dm_warn("%s: Device '%s' failed child_post_remove()",
+ __func__, dev->name);
+ }
+ }
+
device_free(dev);
+ dev->seq = -1;
dev->flags &= ~DM_FLAG_ACTIVATED;
- return 0;
+ return ret;
err_remove:
/* We can't put the children back */
@@ -346,3 +406,106 @@ void *dev_get_priv(struct udevice *dev)
return dev->priv;
}
+
+void *dev_get_parentdata(struct udevice *dev)
+{
+ if (!dev) {
+ dm_warn("%s: null device", __func__);
+ return NULL;
+ }
+
+ return dev->parent_priv;
+}
+
+static int device_get_device_tail(struct udevice *dev, int ret,
+ struct udevice **devp)
+{
+ if (ret)
+ return ret;
+
+ ret = device_probe(dev);
+ if (ret)
+ return ret;
+
+ *devp = dev;
+
+ return 0;
+}
+
+int device_get_child(struct udevice *parent, int index, struct udevice **devp)
+{
+ struct udevice *dev;
+
+ list_for_each_entry(dev, &parent->child_head, sibling_node) {
+ if (!index--)
+ return device_get_device_tail(dev, 0, devp);
+ }
+
+ return -ENODEV;
+}
+
+int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,
+ bool find_req_seq, struct udevice **devp)
+{
+ struct udevice *dev;
+
+ *devp = NULL;
+ if (seq_or_req_seq == -1)
+ return -ENODEV;
+
+ list_for_each_entry(dev, &parent->child_head, sibling_node) {
+ if ((find_req_seq ? dev->req_seq : dev->seq) ==
+ seq_or_req_seq) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
+int device_get_child_by_seq(struct udevice *parent, int seq,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = device_find_child_by_seq(parent, seq, false, &dev);
+ if (ret == -ENODEV) {
+ /*
+ * We didn't find it in probed devices. See if there is one
+ * that will request this seq if probed.
+ */
+ ret = device_find_child_by_seq(parent, seq, true, &dev);
+ }
+ return device_get_device_tail(dev, ret, devp);
+}
+
+int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+
+ *devp = NULL;
+
+ list_for_each_entry(dev, &parent->child_head, sibling_node) {
+ if (dev->of_offset == of_offset) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
+int device_get_child_by_of_offset(struct udevice *parent, int seq,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = device_find_child_by_of_offset(parent, seq, &dev);
+ return device_get_device_tail(dev, ret, devp);
+}
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index afb59d1..0f08bfd 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -11,6 +11,7 @@
#include <errno.h>
#include <dm/device.h>
#include <dm/device-internal.h>
+#include <dm/lists.h>
#include <dm/platdata.h>
#include <dm/uclass.h>
#include <dm/util.h>
@@ -61,7 +62,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id)
return NULL;
}
-int lists_bind_drivers(struct udevice *parent)
+int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
{
struct driver_info *info =
ll_entry_start(struct driver_info, driver_info);
@@ -72,8 +73,8 @@ int lists_bind_drivers(struct udevice *parent)
int ret;
for (entry = info; entry != info + n_ents; entry++) {
- ret = device_bind_by_name(parent, entry, &dev);
- if (ret) {
+ ret = device_bind_by_name(parent, pre_reloc_only, entry, &dev);
+ if (ret && ret != -EPERM) {
dm_warn("No match for driver '%s'\n", entry->name);
if (!result || ret != -ENOENT)
result = ret;
@@ -123,16 +124,19 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
const int n_ents = ll_entry_count(struct driver, driver);
struct driver *entry;
struct udevice *dev;
+ bool found = false;
const char *name;
int result = 0;
- int ret;
+ int ret = 0;
dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL));
for (entry = driver; entry != driver + n_ents; entry++) {
ret = driver_check_compatible(blob, offset, entry->of_match);
+ name = fdt_get_name(blob, offset, NULL);
if (ret == -ENOENT) {
continue;
} else if (ret == -ENODEV) {
+ dm_dbg("Device '%s' has no compatible string\n", name);
break;
} else if (ret) {
dm_warn("Device tree error at offset %d\n", offset);
@@ -141,14 +145,21 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
break;
}
- name = fdt_get_name(blob, offset, NULL);
dm_dbg(" - found match at '%s'\n", entry->name);
ret = device_bind(parent, entry, name, NULL, offset, &dev);
if (ret) {
- dm_warn("No match for driver '%s'\n", entry->name);
+ dm_warn("Error binding driver '%s'\n", entry->name);
if (!result || ret != -ENOENT)
result = ret;
+ } else {
+ found = true;
}
+ break;
+ }
+
+ if (!found && !result && ret != -ENODEV) {
+ dm_dbg("No match for node '%s'\n",
+ fdt_get_name(blob, offset, NULL));
}
return result;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 1cbb096..393dd98 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -15,6 +15,7 @@
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/platdata.h>
+#include <dm/root.h>
#include <dm/uclass.h>
#include <dm/util.h>
#include <linux/list.h>
@@ -45,18 +46,29 @@ int dm_init(void)
}
INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
- ret = device_bind_by_name(NULL, &root_info, &DM_ROOT_NON_CONST);
+ ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
if (ret)
return ret;
+ ret = device_probe(DM_ROOT_NON_CONST);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+int dm_uninit(void)
+{
+ device_remove(dm_root());
+ device_unbind(dm_root());
return 0;
}
-int dm_scan_platdata(void)
+int dm_scan_platdata(bool pre_reloc_only)
{
int ret;
- ret = lists_bind_drivers(DM_ROOT_NON_CONST);
+ ret = lists_bind_drivers(DM_ROOT_NON_CONST, pre_reloc_only);
if (ret == -ENOENT) {
dm_warn("Some drivers were not found\n");
ret = 0;
@@ -68,27 +80,66 @@ int dm_scan_platdata(void)
}
#ifdef CONFIG_OF_CONTROL
-int dm_scan_fdt(const void *blob)
+int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
+ bool pre_reloc_only)
{
- int offset = 0;
int ret = 0, err;
- int depth = 0;
- do {
- offset = fdt_next_node(blob, offset, &depth);
- if (offset > 0 && depth == 1) {
- err = lists_bind_fdt(gd->dm_root, blob, offset);
- if (err && !ret)
- ret = err;
- }
- } while (offset > 0);
+ for (offset = fdt_first_subnode(blob, offset);
+ offset > 0;
+ offset = fdt_next_subnode(blob, offset)) {
+ if (pre_reloc_only &&
+ !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
+ continue;
+ err = lists_bind_fdt(parent, blob, offset);
+ if (err && !ret)
+ ret = err;
+ }
if (ret)
dm_warn("Some drivers failed to bind\n");
return ret;
}
+
+int dm_scan_fdt(const void *blob, bool pre_reloc_only)
+{
+ return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
+}
+#endif
+
+__weak int dm_scan_other(bool pre_reloc_only)
+{
+ return 0;
+}
+
+int dm_init_and_scan(bool pre_reloc_only)
+{
+ int ret;
+
+ ret = dm_init();
+ if (ret) {
+ debug("dm_init() failed: %d\n", ret);
+ return ret;
+ }
+ ret = dm_scan_platdata(pre_reloc_only);
+ if (ret) {
+ debug("dm_scan_platdata() failed: %d\n", ret);
+ return ret;
+ }
+#ifdef CONFIG_OF_CONTROL
+ ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
+ if (ret) {
+ debug("dm_scan_fdt() failed: %d\n", ret);
+ return ret;
+ }
#endif
+ ret = dm_scan_other(pre_reloc_only);
+ if (ret)
+ return ret;
+
+ return 0;
+}
/* This is the root driver - all drivers are children of this */
U_BOOT_DRIVER(root_driver) = {
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 34723ec..61ca17e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -23,6 +23,8 @@ struct uclass *uclass_find(enum uclass_id key)
{
struct uclass *uc;
+ if (!gd->dm_root)
+ return NULL;
/*
* TODO(sjg@chromium.org): Optimise this, perhaps moving the found
* node to the start of the list, or creating a linear array mapping
@@ -158,13 +160,72 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
return -ENODEV;
}
-int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
+int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
+ bool find_req_seq, struct udevice **devp)
{
+ struct uclass *uc;
struct udevice *dev;
int ret;
*devp = NULL;
- ret = uclass_find_device(id, index, &dev);
+ debug("%s: %d %d\n", __func__, find_req_seq, seq_or_req_seq);
+ if (seq_or_req_seq == -1)
+ return -ENODEV;
+ ret = uclass_get(id, &uc);
+ if (ret)
+ return ret;
+
+ list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+ debug(" - %d %d\n", dev->req_seq, dev->seq);
+ if ((find_req_seq ? dev->req_seq : dev->seq) ==
+ seq_or_req_seq) {
+ *devp = dev;
+ debug(" - found\n");
+ return 0;
+ }
+ }
+ debug(" - not found\n");
+
+ return -ENODEV;
+}
+
+static int uclass_find_device_by_of_offset(enum uclass_id id, int node,
+ struct udevice **devp)
+{
+ struct uclass *uc;
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ if (node < 0)
+ return -ENODEV;
+ ret = uclass_get(id, &uc);
+ if (ret)
+ return ret;
+
+ list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+ if (dev->of_offset == node) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
+/**
+ * uclass_get_device_tail() - handle the end of a get_device call
+ *
+ * This handles returning an error or probing a device as needed.
+ *
+ * @dev: Device that needs to be probed
+ * @ret: Error to return. If non-zero then the device is not probed
+ * @devp: Returns the value of 'dev' if there is no error
+ * @return ret, if non-zero, else the result of the device_probe() call
+ */
+static int uclass_get_device_tail(struct udevice *dev, int ret,
+ struct udevice **devp)
+{
if (ret)
return ret;
@@ -177,6 +238,44 @@ int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
return 0;
}
+int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_find_device(id, index, &dev);
+ return uclass_get_device_tail(dev, ret, devp);
+}
+
+int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_find_device_by_seq(id, seq, false, &dev);
+ if (ret == -ENODEV) {
+ /*
+ * We didn't find it in probed devices. See if there is one
+ * that will request this seq if probed.
+ */
+ ret = uclass_find_device_by_seq(id, seq, true, &dev);
+ }
+ return uclass_get_device_tail(dev, ret, devp);
+}
+
+int uclass_get_device_by_of_offset(enum uclass_id id, int node,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_find_device_by_of_offset(id, node, &dev);
+ return uclass_get_device_tail(dev, ret, devp);
+}
+
int uclass_first_device(enum uclass_id id, struct udevice **devp)
{
struct uclass *uc;
@@ -254,6 +353,37 @@ int uclass_unbind_device(struct udevice *dev)
return 0;
}
+int uclass_resolve_seq(struct udevice *dev)
+{
+ struct udevice *dup;
+ int seq;
+ int ret;
+
+ assert(dev->seq == -1);
+ ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq,
+ false, &dup);
+ if (!ret) {
+ dm_warn("Device '%s': seq %d is in use by '%s'\n",
+ dev->name, dev->req_seq, dup->name);
+ } else if (ret == -ENODEV) {
+ /* Our requested sequence number is available */
+ if (dev->req_seq != -1)
+ return dev->req_seq;
+ } else {
+ return ret;
+ }
+
+ for (seq = 0; seq < DM_MAX_SEQ; seq++) {
+ ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq,
+ false, &dup);
+ if (ret == -ENODEV)
+ break;
+ if (ret)
+ return ret;
+ }
+ return seq;
+}
+
int uclass_post_probe_device(struct udevice *dev)
{
struct uclass_driver *uc_drv = dev->uclass->uc_drv;
@@ -281,6 +411,7 @@ int uclass_pre_remove_device(struct udevice *dev)
free(dev->uclass_priv);
dev->uclass_priv = NULL;
}
+ dev->seq = -1;
return 0;
}
diff --git a/drivers/demo/demo-uclass.c b/drivers/demo/demo-uclass.c
index 636fd88..f6510d6 100644
--- a/drivers/demo/demo-uclass.c
+++ b/drivers/demo/demo-uclass.c
@@ -19,6 +19,7 @@
DECLARE_GLOBAL_DATA_PTR;
UCLASS_DRIVER(demo) = {
+ .name = "demo",
.id = UCLASS_DEMO,
};
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 4e001e1..fb8dcd9 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,7 +5,9 @@
# SPDX-License-Identifier: GPL-2.0+
#
+ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_DM_GPIO) += gpio-uclass.o
+endif
obj-$(CONFIG_AT91_GPIO) += at91_gpio.o
obj-$(CONFIG_INTEL_ICH6_GPIO) += intel_ich6_gpio.o
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index aa159f8..811033b 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -46,10 +46,16 @@
DECLARE_GLOBAL_DATA_PTR;
-static const struct fsl_i2c *i2c_dev[2] = {
+static const struct fsl_i2c *i2c_dev[4] = {
(struct fsl_i2c *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
- (struct fsl_i2c *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
+ (struct fsl_i2c *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET),
+#endif
+#ifdef CONFIG_SYS_FSL_I2C3_OFFSET
+ (struct fsl_i2c *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C3_OFFSET),
+#endif
+#ifdef CONFIG_SYS_FSL_I2C4_OFFSET
+ (struct fsl_i2c *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C4_OFFSET)
#endif
};
@@ -539,3 +545,15 @@ U_BOOT_I2C_ADAP_COMPLETE(fsl_1, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
CONFIG_SYS_FSL_I2C2_SPEED, CONFIG_SYS_FSL_I2C2_SLAVE,
1)
#endif
+#ifdef CONFIG_SYS_FSL_I2C3_OFFSET
+U_BOOT_I2C_ADAP_COMPLETE(fsl_2, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
+ fsl_i2c_write, fsl_i2c_set_bus_speed,
+ CONFIG_SYS_FSL_I2C3_SPEED, CONFIG_SYS_FSL_I2C3_SLAVE,
+ 2)
+#endif
+#ifdef CONFIG_SYS_FSL_I2C4_OFFSET
+U_BOOT_I2C_ADAP_COMPLETE(fsl_3, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
+ fsl_i2c_write, fsl_i2c_set_bus_speed,
+ CONFIG_SYS_FSL_I2C4_SPEED, CONFIG_SYS_FSL_I2C4_SLAVE,
+ 3)
+#endif
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index a39b591..0f1e35c 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -153,11 +153,60 @@ static uint omap24_i2c_setspeed(struct i2c_adapter *adap, uint speed)
return 0;
}
+
+static void omap24_i2c_deblock(struct i2c_adapter *adap)
+{
+ struct i2c *i2c_base = omap24_get_base(adap);
+ int i;
+ u16 systest;
+ u16 orgsystest;
+
+ /* set test mode ST_EN = 1 */
+ orgsystest = readw(&i2c_base->systest);
+ systest = orgsystest;
+ /* enable testmode */
+ systest |= I2C_SYSTEST_ST_EN;
+ writew(systest, &i2c_base->systest);
+ systest &= ~I2C_SYSTEST_TMODE_MASK;
+ systest |= 3 << I2C_SYSTEST_TMODE_SHIFT;
+ writew(systest, &i2c_base->systest);
+
+ /* set SCL, SDA = 1 */
+ systest |= I2C_SYSTEST_SCL_O | I2C_SYSTEST_SDA_O;
+ writew(systest, &i2c_base->systest);
+ udelay(10);
+
+ /* toggle scl 9 clocks */
+ for (i = 0; i < 9; i++) {
+ /* SCL = 0 */
+ systest &= ~I2C_SYSTEST_SCL_O;
+ writew(systest, &i2c_base->systest);
+ udelay(10);
+ /* SCL = 1 */
+ systest |= I2C_SYSTEST_SCL_O;
+ writew(systest, &i2c_base->systest);
+ udelay(10);
+ }
+
+ /* send stop */
+ systest &= ~I2C_SYSTEST_SDA_O;
+ writew(systest, &i2c_base->systest);
+ udelay(10);
+ systest |= I2C_SYSTEST_SCL_O | I2C_SYSTEST_SDA_O;
+ writew(systest, &i2c_base->systest);
+ udelay(10);
+
+ /* restore original mode */
+ writew(orgsystest, &i2c_base->systest);
+}
+
static void omap24_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
{
struct i2c *i2c_base = omap24_get_base(adap);
int timeout = I2C_TIMEOUT;
+ int deblock = 1;
+retry:
if (readw(&i2c_base->con) & I2C_CON_EN) {
writew(0, &i2c_base->con);
udelay(50000);
@@ -194,6 +243,14 @@ static void omap24_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
udelay(1000);
flush_fifo(adap);
writew(0xFFFF, &i2c_base->stat);
+
+ /* Handle possible failed I2C state */
+ if (wait_for_bb(adap))
+ if (deblock == 1) {
+ omap24_i2c_deblock(adap);
+ deblock = 0;
+ goto retry;
+ }
}
static void flush_fifo(struct i2c_adapter *adap)
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index a2501e0..47502b1 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -93,7 +93,7 @@ static int check_for_keys(struct keyb *config,
*
* @return 0 if no keys available, 1 if keys are available
*/
-static int kbd_tstc(void)
+static int kbd_tstc(struct stdio_dev *dev)
{
/* Just get input to do this for us */
return config.inited ? input_tstc(&config.input) : 0;
@@ -104,7 +104,7 @@ static int kbd_tstc(void)
*
* @return ASCII key code, or 0 if no key, or -1 if error
*/
-static int kbd_getc(void)
+static int kbd_getc(struct stdio_dev *dev)
{
/* Just get input to do this for us */
return config.inited ? input_getc(&config.input) : 0;
@@ -214,7 +214,7 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node,
*
* @return 0 if ok, -1 on error
*/
-static int cros_ec_init_keyboard(void)
+static int cros_ec_init_keyboard(struct stdio_dev *dev)
{
const void *blob = gd->fdt_blob;
int node;
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 35fa0bb..ca1604c 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -398,7 +398,7 @@ int i8042_kbd_init(void)
* i8042_tstc - test if keyboard input is available
* option: cursor blinking if called in a loop
*/
-int i8042_tstc(void)
+int i8042_tstc(struct stdio_dev *dev)
{
unsigned char scan_code = 0;
@@ -432,7 +432,7 @@ int i8042_tstc(void)
* i8042_getc - wait till keyboard input is available
* option: turn on/off cursor while waiting
*/
-int i8042_getc(void)
+int i8042_getc(struct stdio_dev *dev)
{
int ret_chr;
unsigned char scan_code;
diff --git a/drivers/input/keyboard.c b/drivers/input/keyboard.c
index 614592e..be0f333 100644
--- a/drivers/input/keyboard.c
+++ b/drivers/input/keyboard.c
@@ -70,7 +70,7 @@ static void kbd_put_queue(char data)
}
/* test if a character is in the queue */
-static int kbd_testc(void)
+static int kbd_testc(struct stdio_dev *dev)
{
#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
/* no ISR is used, so received chars must be polled */
@@ -83,7 +83,7 @@ static int kbd_testc(void)
}
/* gets the character from the queue */
-static int kbd_getc(void)
+static int kbd_getc(struct stdio_dev *dev)
{
char c;
while(in_pointer==out_pointer) {
@@ -275,8 +275,6 @@ int kbd_init (void)
memset (&kbddev, 0, sizeof(kbddev));
strcpy(kbddev.name, DEVNAME);
kbddev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- kbddev.putc = NULL ;
- kbddev.puts = NULL ;
kbddev.getc = kbd_getc ;
kbddev.tstc = kbd_testc ;
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index f137f93..7e36db0 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -194,7 +194,7 @@ int tegra_kbc_check(struct input_config *input)
*
* @return 0 if no keys available, 1 if keys are available
*/
-static int kbd_tstc(void)
+static int kbd_tstc(struct stdio_dev *dev)
{
/* Just get input to do this for us */
return input_tstc(&config.input);
@@ -207,7 +207,7 @@ static int kbd_tstc(void)
*
* @return ASCII key code, or 0 if no key, or -1 if error
*/
-static int kbd_getc(void)
+static int kbd_getc(struct stdio_dev *dev)
{
/* Just get input to do this for us */
return input_getc(&config.input);
@@ -289,7 +289,7 @@ static void tegra_kbc_open(void)
*
* @return 0 if ok, -ve on error
*/
-static int init_tegra_keyboard(void)
+static int init_tegra_keyboard(struct stdio_dev *dev)
{
/* check if already created */
if (config.created)
diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c
index 80a84fd..5f85ccf 100644
--- a/drivers/misc/cbmem_console.c
+++ b/drivers/misc/cbmem_console.c
@@ -31,7 +31,7 @@ struct cbmem_console {
static struct cbmem_console *cbmem_console_p;
-void cbmemc_putc(char data)
+void cbmemc_putc(struct stdio_dev *dev, char data)
{
int cursor;
@@ -40,12 +40,12 @@ void cbmemc_putc(char data)
cbmem_console_p->buffer_body[cursor] = data;
}
-void cbmemc_puts(const char *str)
+void cbmemc_puts(struct stdio_dev *dev, const char *str)
{
char c;
while ((c = *str++) != 0)
- cbmemc_putc(c);
+ cbmemc_putc(dev, c);
}
int cbmemc_init(void)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b5477b1..a26f3ce 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -21,7 +21,7 @@
static struct list_head mmc_devices;
static int cur_dev_num = -1;
-int __weak board_mmc_getwp(struct mmc *mmc)
+__weak int board_mmc_getwp(struct mmc *mmc)
{
return -1;
}
@@ -42,13 +42,11 @@ int mmc_getwp(struct mmc *mmc)
return wp;
}
-int __board_mmc_getcd(struct mmc *mmc) {
+__weak int board_mmc_getcd(struct mmc *mmc)
+{
return -1;
}
-int board_mmc_getcd(struct mmc *mmc)__attribute__((weak,
- alias("__board_mmc_getcd")));
-
int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
{
int ret;
@@ -377,7 +375,7 @@ static int mmc_send_op_cond_iter(struct mmc *mmc, struct mmc_cmd *cmd,
return 0;
}
-int mmc_send_op_cond(struct mmc *mmc)
+static int mmc_send_op_cond(struct mmc *mmc)
{
struct mmc_cmd cmd;
int err, i;
@@ -399,7 +397,7 @@ int mmc_send_op_cond(struct mmc *mmc)
return IN_PROGRESS;
}
-int mmc_complete_op_cond(struct mmc *mmc)
+static int mmc_complete_op_cond(struct mmc *mmc)
{
struct mmc_cmd cmd;
int timeout = 1000;
@@ -1371,17 +1369,17 @@ int mmc_set_dsr(struct mmc *mmc, u16 val)
return 0;
}
-/*
- * CPU and board-specific MMC initializations. Aliased function
- * signals caller to move on
- */
-static int __def_mmc_init(bd_t *bis)
+/* CPU-specific MMC initializations */
+__weak int cpu_mmc_init(bd_t *bis)
{
return -1;
}
-int cpu_mmc_init(bd_t *bis) __attribute__((weak, alias("__def_mmc_init")));
-int board_mmc_init(bd_t *bis) __attribute__((weak, alias("__def_mmc_init")));
+/* board-specific MMC initializations. */
+__weak int board_mmc_init(bd_t *bis)
+{
+ return -1;
+}
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 17cbb09..5b0c302 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -120,7 +120,7 @@ static void omap5_pbias_config(struct mmc *mmc)
}
#endif
-unsigned char mmc_board_init(struct mmc *mmc)
+static unsigned char mmc_board_init(struct mmc *mmc)
{
#if defined(CONFIG_OMAP34XX)
t2_t *t2_base = (t2_t *)T2_BASE;
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index a389cd1..c4b5bc1 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2360,7 +2360,7 @@ unsigned long flash_init (void)
#endif /* CONFIG_SYS_FLASH_QUIET_TEST */
}
#ifdef CONFIG_SYS_FLASH_PROTECTION
- else if ((s != NULL) && (strcmp(s, "yes") == 0)) {
+ else if (strcmp(s, "yes") == 0) {
/*
* Only the U-Boot image and it's environment
* is protected, all other sectors are
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 65c747e..623f749 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -215,7 +215,7 @@ static void nc_send_packet(const char *buf, int len)
}
}
-static int nc_start(void)
+static int nc_start(struct stdio_dev *dev)
{
int retval;
@@ -235,7 +235,7 @@ static int nc_start(void)
return 0;
}
-static void nc_putc(char c)
+static void nc_putc(struct stdio_dev *dev, char c)
{
if (output_recursion)
return;
@@ -246,7 +246,7 @@ static void nc_putc(char c)
output_recursion = 0;
}
-static void nc_puts(const char *s)
+static void nc_puts(struct stdio_dev *dev, const char *s)
{
int len;
@@ -265,7 +265,7 @@ static void nc_puts(const char *s)
output_recursion = 0;
}
-static int nc_getc(void)
+static int nc_getc(struct stdio_dev *dev)
{
uchar c;
@@ -286,7 +286,7 @@ static int nc_getc(void)
return c;
}
-static int nc_tstc(void)
+static int nc_tstc(struct stdio_dev *dev)
{
struct eth_device *eth;
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index fd61a5e..d2eb752 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -254,6 +254,48 @@ void serial_initialize(void)
serial_assign(default_serial_console()->name);
}
+int serial_stub_start(struct stdio_dev *sdev)
+{
+ struct serial_device *dev = sdev->priv;
+
+ return dev->start();
+}
+
+int serial_stub_stop(struct stdio_dev *sdev)
+{
+ struct serial_device *dev = sdev->priv;
+
+ return dev->stop();
+}
+
+void serial_stub_putc(struct stdio_dev *sdev, const char ch)
+{
+ struct serial_device *dev = sdev->priv;
+
+ dev->putc(ch);
+}
+
+void serial_stub_puts(struct stdio_dev *sdev, const char *str)
+{
+ struct serial_device *dev = sdev->priv;
+
+ dev->puts(str);
+}
+
+int serial_stub_getc(struct stdio_dev *sdev)
+{
+ struct serial_device *dev = sdev->priv;
+
+ return dev->getc();
+}
+
+int serial_stub_tstc(struct stdio_dev *sdev)
+{
+ struct serial_device *dev = sdev->priv;
+
+ return dev->tstc();
+}
+
/**
* serial_stdio_init() - Register serial ports with STDIO core
*
@@ -272,12 +314,12 @@ void serial_stdio_init(void)
strcpy(dev.name, s->name);
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
- dev.start = s->start;
- dev.stop = s->stop;
- dev.putc = s->putc;
- dev.puts = s->puts;
- dev.getc = s->getc;
- dev.tstc = s->tstc;
+ dev.start = serial_stub_start;
+ dev.stop = serial_stub_stop;
+ dev.putc = serial_stub_putc;
+ dev.puts = serial_stub_puts;
+ dev.getc = serial_stub_getc;
+ dev.tstc = serial_stub_tstc;
stdio_register(&dev);
@@ -376,6 +418,7 @@ static struct serial_device *get_current(void)
*/
int serial_init(void)
{
+ gd->flags |= GD_FLG_SERIAL_READY;
return get_current()->start();
}
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index ba68d46..4413e69 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -120,6 +120,8 @@ static NS16550_t serial_ports[6] = {
static int calc_divisor (NS16550_t port)
{
+ const unsigned int mode_x_div = 16;
+
#ifdef CONFIG_OMAP1510
/* If can't cleanly clock 115200 set div to 1 */
if ((CONFIG_SYS_NS16550_CLK == 12000000) && (gd->baudrate == 115200)) {
@@ -128,21 +130,9 @@ static int calc_divisor (NS16550_t port)
}
port->osc_12m_sel = 0; /* clear if previsouly set */
#endif
-#ifdef CONFIG_OMAP1610
- /* If can't cleanly clock 115200 set div to 1 */
- if ((CONFIG_SYS_NS16550_CLK == 48000000) && (gd->baudrate == 115200)) {
- return (26); /* return 26 for base divisor */
- }
-#endif
-#define MODE_X_DIV 16
- /* Compute divisor value. Normally, we should simply return:
- * CONFIG_SYS_NS16550_CLK) / MODE_X_DIV / gd->baudrate
- * but we need to round that value by adding 0.5.
- * Rounding is especially important at high baud rates.
- */
- return (CONFIG_SYS_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
- (MODE_X_DIV * gd->baudrate);
+ return DIV_ROUND_CLOSEST(CONFIG_SYS_NS16550_CLK,
+ mode_x_div * gd->baudrate);
}
void
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 6b912ef..b030526 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -389,7 +389,7 @@ static void str2wide (char *str, u16 * wide)
* Test whether a character is in the RX buffer
*/
-int usbtty_tstc (void)
+int usbtty_tstc(struct stdio_dev *dev)
{
struct usb_endpoint_instance *endpoint =
&endpoint_instance[rx_endpoint];
@@ -409,7 +409,7 @@ int usbtty_tstc (void)
* written into its argument c.
*/
-int usbtty_getc (void)
+int usbtty_getc(struct stdio_dev *dev)
{
char c;
struct usb_endpoint_instance *endpoint =
@@ -429,7 +429,7 @@ int usbtty_getc (void)
/*
* Output a single byte to the usb client port.
*/
-void usbtty_putc (const char c)
+void usbtty_putc(struct stdio_dev *dev, const char c)
{
if (!usbtty_configured ())
return;
@@ -484,7 +484,7 @@ static void __usbtty_puts (const char *str, int len)
}
}
-void usbtty_puts (const char *str)
+void usbtty_puts(struct stdio_dev *dev, const char *str)
{
int n;
int len;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index ceb1573..6685ed2 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -20,9 +20,7 @@
#include <asm/cache.h>
#include <asm/io.h>
#include <linux/list.h>
-
-#define upper_32_bits(n) (u32)((n) >> 32)
-#define lower_32_bits(n) (u32)(n)
+#include <linux/compat.h>
#define MAX_EP_CTX_NUM 31
#define XHCI_ALIGNMENT 64
@@ -1121,7 +1119,7 @@ static inline void xhci_writeq(__le64 volatile *regs, const u64 val)
__u32 *ptr = (__u32 *)regs;
u32 val_lo = lower_32_bits(val);
/* FIXME */
- u32 val_hi = 0;
+ u32 val_hi = upper_32_bits(val);
writel(val_lo, ptr);
writel(val_hi, ptr + 1);
}
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index b52e9ed..9231927 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -944,7 +944,7 @@ static void parse_putc(const char c)
CURSOR_SET;
}
-void video_putc(const char c)
+void video_putc(struct stdio_dev *dev, const char c)
{
#ifdef CONFIG_CFB_CONSOLE_ANSI
int i;
@@ -1158,12 +1158,12 @@ void video_putc(const char c)
flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
}
-void video_puts(const char *s)
+void video_puts(struct stdio_dev *dev, const char *s)
{
int count = strlen(s);
while (count--)
- video_putc(*s++);
+ video_putc(dev, *s++);
}
/*
@@ -2279,8 +2279,6 @@ int drv_video_init(void)
console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
console_dev.putc = video_putc; /* 'putc' function */
console_dev.puts = video_puts; /* 'puts' function */
- console_dev.tstc = NULL; /* 'tstc' function */
- console_dev.getc = NULL; /* 'getc' function */
#if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
/* Also init console device */
diff --git a/fs/fs.c b/fs/fs.c
index 79d432d..ea15c5f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -276,6 +276,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
unsigned long pos;
int len_read;
unsigned long time;
+ char *ep;
if (argc < 2)
return CMD_RET_USAGE;
@@ -286,7 +287,9 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
return 1;
if (argc >= 4) {
- addr = simple_strtoul(argv[3], NULL, 16);
+ addr = simple_strtoul(argv[3], &ep, 16);
+ if (ep == argv[3] || *ep != '\0')
+ return CMD_RET_USAGE;
} else {
addr_str = getenv("loadaddr");
if (addr_str != NULL)
diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index 21441fd..32e6ff2 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -219,18 +219,11 @@ static void yaffs_handle_chunk_wr_ok(struct yaffs_dev *dev, int nand_chunk,
const u8 *data,
const struct yaffs_ext_tags *tags)
{
- dev = dev;
- nand_chunk = nand_chunk;
- data = data;
- tags = tags;
}
static void yaffs_handle_chunk_update(struct yaffs_dev *dev, int nand_chunk,
const struct yaffs_ext_tags *tags)
{
- dev = dev;
- nand_chunk = nand_chunk;
- tags = tags;
}
void yaffs_handle_chunk_error(struct yaffs_dev *dev,
@@ -814,8 +807,6 @@ struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev,
int required_depth;
int level = file_struct->top_level;
- dev = dev;
-
/* Check sane level and chunk Id */
if (level < 0 || level > YAFFS_TNODES_MAX_LEVEL)
return NULL;
@@ -3212,20 +3203,18 @@ static void yaffs_load_name_from_oh(struct yaffs_dev *dev, YCHAR *name,
} else {
yaffs_strncpy(name, oh_name + 1, buff_size - 1);
}
- } else {
-#else
- dev = dev;
- {
-#endif
- yaffs_strncpy(name, oh_name, buff_size - 1);
+
+ return;
}
+#endif
+
+ yaffs_strncpy(name, oh_name, buff_size - 1);
}
static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
const YCHAR *name)
{
#ifdef CONFIG_YAFFS_AUTO_UNICODE
-
int is_ascii;
YCHAR *w;
@@ -3256,13 +3245,12 @@ static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
*oh_name = 0;
yaffs_strncpy(oh_name + 1, name, YAFFS_MAX_NAME_LENGTH - 2);
}
- } else {
-#else
- dev = dev;
- {
-#endif
- yaffs_strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
+
+ return;
}
+#endif
+
+ yaffs_strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
}
/* UpdateObjectHeader updates the header on NAND for an object.
diff --git a/fs/yaffs2/yaffs_verify.c b/fs/yaffs2/yaffs_verify.c
index 97734a9..3fef28b 100644
--- a/fs/yaffs2/yaffs_verify.c
+++ b/fs/yaffs2/yaffs_verify.c
@@ -19,20 +19,17 @@
int yaffs_skip_verification(struct yaffs_dev *dev)
{
- dev = dev;
return !(yaffs_trace_mask &
(YAFFS_TRACE_VERIFY | YAFFS_TRACE_VERIFY_FULL));
}
static int yaffs_skip_full_verification(struct yaffs_dev *dev)
{
- dev = dev;
return !(yaffs_trace_mask & (YAFFS_TRACE_VERIFY_FULL));
}
static int yaffs_skip_nand_verification(struct yaffs_dev *dev)
{
- dev = dev;
return !(yaffs_trace_mask & (YAFFS_TRACE_VERIFY_NAND));
}
@@ -521,6 +518,5 @@ void yaffs_verify_free_chunks(struct yaffs_dev *dev)
int yaffs_verify_file_sane(struct yaffs_obj *in)
{
- in = in;
return YAFFS_OK;
}
diff --git a/fs/yaffs2/yaffsfs.c b/fs/yaffs2/yaffsfs.c
index 334598e..41e5f01 100644
--- a/fs/yaffs2/yaffsfs.c
+++ b/fs/yaffs2/yaffsfs.c
@@ -3136,10 +3136,6 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath)
int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
{
- pathname = pathname;
- mode = mode;
- dev = dev;
-
yaffsfs_SetError(-EINVAL);
return -1;
}
@@ -3187,9 +3183,7 @@ int yaffs_set_error(int error)
int yaffs_dump_dev(const YCHAR *path)
{
-#if 1
- path = path;
-#else
+#if 0
YCHAR *rest;
struct yaffs_obj *obj = yaffsfs_FindRoot(path, &rest);
diff --git a/include/altera.h b/include/altera.h
index 0327a1b..ae5f7ee 100644
--- a/include/altera.h
+++ b/include/altera.h
@@ -26,7 +26,7 @@ typedef enum { /* typedef Altera_Family */
min_altera_type, /* insert all new types after this */
Altera_ACEX1K, /* ACEX1K Family */
Altera_CYC2, /* CYCLONII Family */
- Altera_StratixII, /* StratixII Familiy */
+ Altera_StratixII, /* StratixII Family */
/* Add new models here */
max_altera_type /* insert all new types before this */
} Altera_Family; /* end, typedef Altera_Family */
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 2850ed8..74df210 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -65,7 +65,8 @@ typedef struct global_data {
struct global_data *new_gd; /* relocated global data */
#ifdef CONFIG_DM
- struct udevice *dm_root;/* Root instance for Driver Model */
+ struct udevice *dm_root; /* Root instance for Driver Model */
+ struct udevice *dm_root_f; /* Pre-relocation root instance */
struct list_head uclass_root; /* Head of core tree */
#endif
@@ -85,6 +86,11 @@ typedef struct global_data {
#endif
unsigned long timebase_h;
unsigned long timebase_l;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ unsigned long malloc_base; /* base address of early malloc() */
+ unsigned long malloc_limit; /* limit address */
+ unsigned long malloc_ptr; /* current address */
+#endif
struct arch_global_data arch; /* architecture-specific data */
} gd_t;
#endif
@@ -100,5 +106,6 @@ typedef struct global_data {
#define GD_FLG_LOGINIT 0x00020 /* Log Buffer has been initialized */
#define GD_FLG_DISABLE_CONSOLE 0x00040 /* Disable console (in & out) */
#define GD_FLG_ENV_READY 0x00080 /* Env. imported into hash table */
+#define GD_FLG_SERIAL_READY 0x00100 /* Pre-reloc serial console ready */
#endif /* __ASM_GENERIC_GBL_DATA_H */
diff --git a/include/common.h b/include/common.h
index 82c0a5a..a75fc25 100644
--- a/include/common.h
+++ b/include/common.h
@@ -639,6 +639,11 @@ void serial_puts (const char *);
int serial_getc (void);
int serial_tstc (void);
+/* These versions take a stdio_dev pointer */
+struct stdio_dev;
+int serial_stub_getc(struct stdio_dev *sdev);
+int serial_stub_tstc(struct stdio_dev *sdev);
+
void _serial_setbrg (const int);
void _serial_putc (const char, const int);
void _serial_putc_raw(const char, const int);
diff --git a/include/compiler.h b/include/compiler.h
index 0734ed4..9afc11b 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -48,6 +48,7 @@
# include <machine/endian.h>
typedef unsigned long ulong;
#endif
+#include <time.h>
typedef uint8_t __u8;
typedef uint16_t __u16;
diff --git a/include/configs/ELPPC.h b/include/configs/ELPPC.h
index 0ffbd41..debfc36 100644
--- a/include/configs/ELPPC.h
+++ b/include/configs/ELPPC.h
@@ -234,8 +234,8 @@
#define CONFIG_VIDEO
#define CONFIG_CFB_CONSOLE
#define VIDEO_KBD_INIT_FCT (simple_strtol (getenv("console"), NULL, 10))
-#define VIDEO_TSTC_FCT serial_tstc
-#define VIDEO_GETC_FCT serial_getc
+#define VIDEO_TSTC_FCT serial_stub_tstc
+#define VIDEO_GETC_FCT serial_stub_getc
#define CONFIG_VIDEO_SMI_LYNXEM
#define CONFIG_VIDEO_LOGO
diff --git a/include/configs/MHPC.h b/include/configs/MHPC.h
index 6314b53..d45be0f 100644
--- a/include/configs/MHPC.h
+++ b/include/configs/MHPC.h
@@ -96,8 +96,8 @@
#define CONFIG_VIDEO_LOGO
#define VIDEO_KBD_INIT_FCT 0 /* no KBD dev on MHPC - use serial */
-#define VIDEO_TSTC_FCT serial_tstc
-#define VIDEO_GETC_FCT serial_getc
+#define VIDEO_TSTC_FCT serial_stub_tstc
+#define VIDEO_GETC_FCT serial_stub_getc
#define CONFIG_BR0_WORKAROUND 1
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index a48b386..34d27c6 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -117,7 +117,7 @@
"bootenv=uEnv.txt\0" \
"loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
- "env import -t $loadaddr $filesize\0" \
+ "env import -t -r $loadaddr $filesize\0" \
"ramargs=setenv bootargs console=${console} " \
"${optargs} " \
"root=${ramroot} " \
diff --git a/include/configs/h2200.h b/include/configs/h2200.h
index 5d0b85e..9470ad6 100644
--- a/include/configs/h2200.h
+++ b/include/configs/h2200.h
@@ -123,6 +123,7 @@
#define CONFIG_CMD_IMI
#define CONFIG_FIT
+#define CONFIG_FIT_DISABLE_SHA256
#define CONFIG_SETUP_MEMORY_TAGS
#define CONFIG_CMDLINE_TAG
#define CONFIG_INITRD_TAG
diff --git a/include/configs/jadecpu.h b/include/configs/jadecpu.h
index b34e342..759e112 100644
--- a/include/configs/jadecpu.h
+++ b/include/configs/jadecpu.h
@@ -87,8 +87,8 @@
#define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE (800*480 + 256*4 + 10*1024)
#define VIDEO_FB_16BPP_WORD_SWAP
#define VIDEO_KBD_INIT_FCT 0
-#define VIDEO_TSTC_FCT serial_tstc
-#define VIDEO_GETC_FCT serial_getc
+#define VIDEO_TSTC_FCT serial_stub_tstc
+#define VIDEO_GETC_FCT serial_stub_getc
/*
* BOOTP options
diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index e0c0fac..53cb390 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -263,9 +263,10 @@
#define VIDEO_TSTC_FCT rx51_kp_tstc
#define VIDEO_GETC_FCT rx51_kp_getc
#ifndef __ASSEMBLY__
+struct stdio_dev;
int rx51_kp_init(void);
-int rx51_kp_tstc(void);
-int rx51_kp_getc(void);
+int rx51_kp_tstc(struct stdio_dev *sdev);
+int rx51_kp_getc(struct stdio_dev *sdev);
#endif
#ifndef MTDPARTS_DEFAULT
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 3782049..9ba031d 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -195,7 +195,7 @@
"bootenv=uEnv.txt\0" \
"loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
- "env import -t $loadaddr $filesize\0" \
+ "env import -t -r $loadaddr $filesize\0" \
"ramargs=setenv bootargs console=${console} " \
"${optargs} " \
"mpurate=${mpurate} " \
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index ff48598..60f2489 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -98,7 +98,7 @@
#define CONFIG_SYS_CONSOLE_IS_IN_ENV
#define CONFIG_PREBOOT \
"if load mmc 0:1 ${loadaddr} /uEnv.txt; then " \
- "env import -t ${loadaddr} ${filesize}; " \
+ "env import -t -r ${loadaddr} ${filesize}; " \
"fi"
#define ENV_DEVICE_SETTINGS \
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 12b69d9..bf2d25c 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -68,8 +68,10 @@
#define CONFIG_EFI_PARTITION
/*
- * Size of malloc() pool, although we don't actually use this yet.
+ * Size of malloc() pool, before and after relocation
*/
+#define CONFIG_SYS_MALLOC_F_LEN (1 << 10)
+#define CONFIG_MALLOC_F_ADDR 0x0010000
#define CONFIG_SYS_MALLOC_LEN (32 << 20) /* 32MB */
#define CONFIG_SYS_HUSH_PARSER
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 26e5cf5..7005d03 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -45,12 +45,14 @@ int device_bind(struct udevice *parent, struct driver *drv,
* tree.
*
* @parent: Pointer to device's parent
+ * @pre_reloc_only: If true, bind the driver only if its DM_INIT_F flag is set.
+ * If false bind the driver always.
* @info: Name and platdata for this device
* @devp: Returns a pointer to the bound device
* @return 0 if OK, -ve on error
*/
-int device_bind_by_name(struct udevice *parent, const struct driver_info *info,
- struct udevice **devp);
+int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
+ const struct driver_info *info, struct udevice **devp);
/**
* device_probe() - Probe a device, activating it
diff --git a/include/dm/device.h b/include/dm/device.h
index ae75a3f..c8a4072 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -23,6 +23,9 @@ struct driver_info;
/* DM is responsible for allocating and freeing platdata */
#define DM_FLAG_ALLOC_PDATA (1 << 1)
+/* DM should init this device prior to relocation */
+#define DM_FLAG_PRE_RELOC (1 << 2)
+
/**
* struct udevice - An instance of a driver
*
@@ -48,10 +51,13 @@ struct driver_info;
* @priv: Private data for this device
* @uclass: Pointer to uclass for this device
* @uclass_priv: The uclass's private data for this device
+ * @parent_priv: The parent's private data for this device
* @uclass_node: Used by uclass to link its devices
* @child_head: List of children of this device
* @sibling_node: Next device in list of all devices
* @flags: Flags for this device DM_FLAG_...
+ * @req_seq: Requested sequence number for this device (-1 = any)
+ * @seq: Allocated sequence number for this device (-1 = none)
*/
struct udevice {
struct driver *driver;
@@ -62,12 +68,18 @@ struct udevice {
void *priv;
struct uclass *uclass;
void *uclass_priv;
+ void *parent_priv;
struct list_head uclass_node;
struct list_head child_head;
struct list_head sibling_node;
uint32_t flags;
+ int req_seq;
+ int seq;
};
+/* Maximum sequence number supported */
+#define DM_MAX_SEQ 999
+
/* Returns the operations for a device */
#define device_get_ops(dev) (dev->driver->ops)
@@ -106,6 +118,10 @@ struct udevice_id {
* @remove: Called to remove a device, i.e. de-activate it
* @unbind: Called to unbind a device from its driver
* @ofdata_to_platdata: Called before probe to decode device tree data
+ * @child_pre_probe: Called before a child device is probed. The device has
+ * memory allocated but it has not yet been probed.
+ * @child_post_remove: Called after a child device is removed. The device
+ * has memory allocated but its device_remove() method has been called.
* @priv_auto_alloc_size: If non-zero this is the size of the private data
* to be allocated in the device's ->priv pointer. If zero, then the driver
* is responsible for allocating any data required.
@@ -114,9 +130,13 @@ struct udevice_id {
* This is typically only useful for device-tree-aware drivers (those with
* an of_match), since drivers which use platdata will have the data
* provided in the U_BOOT_DEVICE() instantiation.
- * ops: Driver-specific operations. This is typically a list of function
+ * @per_child_auto_alloc_size: Each device can hold private data owned by
+ * its parent. If required this will be automatically allocated if this
+ * value is non-zero.
+ * @ops: Driver-specific operations. This is typically a list of function
* pointers defined by the driver, to implement driver functions required by
* the uclass.
+ * @flags: driver flags - see DM_FLAGS_...
*/
struct driver {
char *name;
@@ -127,9 +147,13 @@ struct driver {
int (*remove)(struct udevice *dev);
int (*unbind)(struct udevice *dev);
int (*ofdata_to_platdata)(struct udevice *dev);
+ int (*child_pre_probe)(struct udevice *dev);
+ int (*child_post_remove)(struct udevice *dev);
int priv_auto_alloc_size;
int platdata_auto_alloc_size;
+ int per_child_auto_alloc_size;
const void *ops; /* driver-specific operations */
+ uint32_t flags;
};
/* Declare a new U-Boot driver */
@@ -147,6 +171,20 @@ struct driver {
void *dev_get_platdata(struct udevice *dev);
/**
+ * dev_get_parentdata() - Get the parent data for a device
+ *
+ * The parent data is data stored in the device but owned by the parent.
+ * For example, a USB device may have parent data which contains information
+ * about how to talk to the device over USB.
+ *
+ * This checks that dev is not NULL, but no other checks for now
+ *
+ * @dev Device to check
+ * @return parent data, or NULL if none
+ */
+void *dev_get_parentdata(struct udevice *dev);
+
+/**
* dev_get_priv() - Get the private data for a device
*
* This checks that dev is not NULL, but no other checks for now
@@ -156,4 +194,84 @@ void *dev_get_platdata(struct udevice *dev);
*/
void *dev_get_priv(struct udevice *dev);
+/**
+ * device_get_child() - Get the child of a device by index
+ *
+ * Returns the numbered child, 0 being the first. This does not use
+ * sequence numbers, only the natural order.
+ *
+ * @dev: Parent device to check
+ * @index: Child index
+ * @devp: Returns pointer to device
+ */
+int device_get_child(struct udevice *parent, int index, struct udevice **devp);
+
+/**
+ * device_find_child_by_seq() - Find a child device based on a sequence
+ *
+ * This searches for a device with the given seq or req_seq.
+ *
+ * For seq, if an active device has this sequence it will be returned.
+ * If there is no such device then this will return -ENODEV.
+ *
+ * For req_seq, if a device (whether activated or not) has this req_seq
+ * value, that device will be returned. This is a strong indication that
+ * the device will receive that sequence when activated.
+ *
+ * @parent: Parent device
+ * @seq_or_req_seq: Sequence number to find (0=first)
+ * @find_req_seq: true to find req_seq, false to find seq
+ * @devp: Returns pointer to device (there is only one per for each seq).
+ * Set to NULL if none is found
+ * @return 0 if OK, -ve on error
+ */
+int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,
+ bool find_req_seq, struct udevice **devp);
+
+/**
+ * device_get_child_by_seq() - Get a child device based on a sequence
+ *
+ * If an active device has this sequence it will be returned. If there is no
+ * such device then this will check for a device that is requesting this
+ * sequence.
+ *
+ * The device is probed to activate it ready for use.
+ *
+ * @parent: Parent device
+ * @seq: Sequence number to find (0=first)
+ * @devp: Returns pointer to device (there is only one per for each seq)
+ * Set to NULL if none is found
+ * @return 0 if OK, -ve on error
+ */
+int device_get_child_by_seq(struct udevice *parent, int seq,
+ struct udevice **devp);
+
+/**
+ * device_find_child_by_of_offset() - Find a child device based on FDT offset
+ *
+ * Locates a child device by its device tree offset.
+ *
+ * @parent: Parent device
+ * @of_offset: Device tree offset to find
+ * @devp: Returns pointer to device if found, otherwise this is set to NULL
+ * @return 0 if OK, -ve on error
+ */
+int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
+ struct udevice **devp);
+
+/**
+ * device_get_child_by_of_offset() - Get a child device based on FDT offset
+ *
+ * Locates a child device by its device tree offset.
+ *
+ * The device is probed to activate it ready for use.
+ *
+ * @parent: Parent device
+ * @of_offset: Device tree offset to find
+ * @devp: Returns pointer to device if found, otherwise this is set to NULL
+ * @return 0 if OK, -ve on error
+ */
+int device_get_child_by_of_offset(struct udevice *parent, int seq,
+ struct udevice **devp);
+
#endif
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 49d87e6..87a3af5 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -42,7 +42,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
* @early_only: If true, bind only drivers with the DM_INIT_F flag. If false
* bind all drivers.
*/
-int lists_bind_drivers(struct udevice *parent);
+int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
/**
* lists_bind_fdt() - bind a device tree node
diff --git a/include/dm/platdata.h b/include/dm/platdata.h
index 0ef3353..2bc8b14 100644
--- a/include/dm/platdata.h
+++ b/include/dm/platdata.h
@@ -11,9 +11,15 @@
#ifndef _DM_PLATDATA_H
#define _DM_PLATDATA_H
+/**
+ * struct driver_info - Information required to instantiate a device
+ *
+ * @name: Device name
+ * @platdata: Driver-specific platform data
+ */
struct driver_info {
- const char *name;
- const void *platdata;
+ const char *name;
+ const void *platdata;
};
#define U_BOOT_DEVICE(__name) \
diff --git a/include/dm/root.h b/include/dm/root.h
index a4826a6..c7f0c1d 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -26,19 +26,66 @@ struct udevice *dm_root(void);
*
* This scans all available platdata and creates drivers for each
*
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
* @return 0 if OK, -ve on error
*/
-int dm_scan_platdata(void);
+int dm_scan_platdata(bool pre_reloc_only);
/**
* dm_scan_fdt() - Scan the device tree and bind drivers
*
- * This scans the device tree and creates a driver for each node
+ * This scans the device tree and creates a driver for each node. Only
+ * the top-level subnodes are examined.
*
* @blob: Pointer to device tree blob
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
* @return 0 if OK, -ve on error
*/
-int dm_scan_fdt(const void *blob);
+int dm_scan_fdt(const void *blob, bool pre_reloc_only);
+
+/**
+ * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
+ *
+ * This scans the subnodes of a device tree node and and creates a driver
+ * for each one.
+ *
+ * @parent: Parent device for the devices that will be created
+ * @blob: Pointer to device tree blob
+ * @offset: Offset of node to scan
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
+ * @return 0 if OK, -ve on error
+ */
+int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
+ bool pre_reloc_only);
+
+/**
+ * dm_scan_other() - Scan for other devices
+ *
+ * Some devices may not be visible to Driver Model. This weak function can
+ * be provided by boards which wish to create their own devices
+ * programmaticaly. They should do this by calling device_bind() on each
+ * device.
+ *
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
+ */
+int dm_scan_other(bool pre_reloc_only);
+
+/**
+ * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
+ *
+ * This function initialises the roots of the driver tree and uclass trees,
+ * then scans and binds available devices from platform data and the FDT.
+ * This calls dm_init() to set up Driver Model structures.
+ *
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
+ * @return 0 if OK, -ve on error
+ */
+int dm_init_and_scan(bool pre_reloc_only);
/**
* dm_init() - Initialise Driver Model structures
@@ -50,4 +97,12 @@ int dm_scan_fdt(const void *blob);
*/
int dm_init(void);
+/**
+ * dm_uninit - Uninitialise Driver Model structures
+ *
+ * All devices will be removed and unbound
+ * @return 0 if OK, -ve on error
+ */
+int dm_uninit(void);
+
#endif
diff --git a/include/dm/test.h b/include/dm/test.h
index 409f1a3..235d728 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -82,6 +82,17 @@ struct dm_test_uclass_priv {
int total_add;
};
+/**
+ * struct dm_test_parent_data - parent's information on each child
+ *
+ * @sum: Test value used to check parent data works correctly
+ * @flag: Used to track calling of parent operations
+ */
+struct dm_test_parent_data {
+ int sum;
+ int flag;
+};
+
/*
* Operation counts for the test driver, used to check that each method is
* called correctly
@@ -100,6 +111,7 @@ extern struct dm_test_state global_test_state;
* @fail_count: Number of tests that failed
* @force_fail_alloc: Force all memory allocs to fail
* @skip_post_probe: Skip uclass post-probe processing
+ * @removed: Used to keep track of a device that was removed
*/
struct dm_test_state {
struct udevice *root;
@@ -107,6 +119,7 @@ struct dm_test_state {
int fail_count;
int force_fail_alloc;
int skip_post_probe;
+ struct udevice *removed;
};
/* Test flags for each test */
@@ -156,6 +169,15 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
uint32_t base, struct dm_test_priv *priv);
/**
+ * dm_check_devices() - check the devices respond to operations correctly
+ *
+ * @dms: Overall test state
+ * @num_devices: Number of test devices to check
+ * @return 0 if OK, -ve on error
+ */
+int dm_check_devices(struct dm_test_state *dms, int num_devices);
+
+/**
* dm_test_main() - Run all the tests
*
* This runs all available driver model tests
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index f0e691c..dd95fca 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -17,9 +17,10 @@ enum uclass_id {
UCLASS_DEMO,
UCLASS_TEST,
UCLASS_TEST_FDT,
+ UCLASS_TEST_BUS,
/* U-Boot uclasses start here */
- UCLASS_GPIO,
+ UCLASS_GPIO, /* Bank of general-purpose I/O pins */
UCLASS_COUNT,
UCLASS_INVALID = -1,
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index 1434db3..f718f37 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -82,4 +82,27 @@ struct uclass *uclass_find(enum uclass_id key);
*/
int uclass_destroy(struct uclass *uc);
+/**
+ * uclass_find_device_by_seq() - Find uclass device based on ID and sequence
+ *
+ * This searches for a device with the given seq or req_seq.
+ *
+ * For seq, if an active device has this sequence it will be returned.
+ * If there is no such device then this will return -ENODEV.
+ *
+ * For req_seq, if a device (whether activated or not) has this req_seq
+ * value, that device will be returned. This is a strong indication that
+ * the device will receive that sequence when activated.
+ *
+ * The device is NOT probed, it is merely returned.
+ *
+ * @id: ID to look up
+ * @seq_or_req_seq: Sequence number to find (0=first)
+ * @find_req_seq: true to find req_seq, false to find seq
+ * @devp: Returns pointer to device (there is only one per for each seq)
+ * @return 0 if OK, -ve on error
+ */
+int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
+ bool find_req_seq, struct udevice **devp);
+
#endif
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index afd9923..8d09ecf 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -98,7 +98,7 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
*
* The device is probed to activate it ready for use.
*
- * id: ID to look up
+ * @id: ID to look up
* @index: Device number within that uclass (0=first)
* @devp: Returns pointer to device (there is only one per for each ID)
* @return 0 if OK, -ve on error
@@ -106,6 +106,38 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
int uclass_get_device(enum uclass_id id, int index, struct udevice **devp);
/**
+ * uclass_get_device_by_seq() - Get a uclass device based on an ID and sequence
+ *
+ * If an active device has this sequence it will be returned. If there is no
+ * such device then this will check for a device that is requesting this
+ * sequence.
+ *
+ * The device is probed to activate it ready for use.
+ *
+ * @id: ID to look up
+ * @seq: Sequence number to find (0=first)
+ * @devp: Returns pointer to device (there is only one for each seq)
+ * @return 0 if OK, -ve on error
+ */
+int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp);
+
+/**
+ * uclass_get_device_by_of_offset() - Get a uclass device by device tree node
+ *
+ * This searches the devices in the uclass for one attached to the given
+ * device tree node.
+ *
+ * The device is probed to activate it ready for use.
+ *
+ * @id: ID to look up
+ * @node: Device tree offset to search for (if -ve then -ENODEV is returned)
+ * @devp: Returns pointer to device (there is only one for each node)
+ * @return 0 if OK, -ve on error
+ */
+int uclass_get_device_by_of_offset(enum uclass_id id, int node,
+ struct udevice **devp);
+
+/**
* uclass_first_device() - Get the first device in a uclass
*
* @id: Uclass ID to look up
@@ -124,6 +156,21 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp);
int uclass_next_device(struct udevice **devp);
/**
+ * uclass_resolve_seq() - Resolve a device's sequence number
+ *
+ * On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a
+ * sequence number automatically, or >= 0 to select a particular number.
+ * If the requested sequence number is in use, then this device will
+ * be allocated another one.
+ *
+ * Note that the device's seq value is not changed by this function.
+ *
+ * @dev: Device for which to allocate sequence number
+ * @return sequence number allocated, or -ve on error
+ */
+int uclass_resolve_seq(struct udevice *dev);
+
+/**
* uclass_foreach_dev() - Helper function to iteration through devices
*
* This creates a for() loop which works through the available devices in
diff --git a/include/env_callback.h b/include/env_callback.h
index f90a7fa..ab4e115 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -60,7 +60,7 @@ void env_callback_init(ENTRY *var_entry);
*/
#ifdef CONFIG_SPL_BUILD
#define U_BOOT_ENV_CALLBACK(name, callback) \
- static inline void _u_boot_env_noop_##name(void) \
+ static inline __maybe_unused void _u_boot_env_noop_##name(void) \
{ \
(void)callback; \
}
diff --git a/include/fdtdec.h b/include/fdtdec.h
index a7e6ee7..856e6cf 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -345,6 +345,35 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
int fdtdec_add_aliases_for_id(const void *blob, const char *name,
enum fdt_compat_id id, int *node_list, int maxcount);
+/**
+ * Get the alias sequence number of a node
+ *
+ * This works out whether a node is pointed to by an alias, and if so, the
+ * sequence number of that alias. Aliases are of the form <base><num> where
+ * <num> is the sequence number. For example spi2 would be sequence number
+ * 2.
+ *
+ * @param blob Device tree blob (if NULL, then error is returned)
+ * @param base Base name for alias (before the underscore)
+ * @param node Node to look up
+ * @param seqp This is set to the sequence number if one is found,
+ * but otherwise the value is left alone
+ * @return 0 if a sequence was found, -ve if not
+ */
+int fdtdec_get_alias_seq(const void *blob, const char *base, int node,
+ int *seqp);
+
+/**
+ * Get the offset of the given alias node
+ *
+ * This looks up an alias in /aliases then finds the offset of that node.
+ *
+ * @param blob Device tree blob (if NULL, then error is returned)
+ * @param name Alias name, e.g. "console"
+ * @return Node offset referred to by that alias, or -ve FDT_ERR_...
+ */
+int fdtdec_get_alias_node(const void *blob, const char *name);
+
/*
* Get the name for a compatible ID
*
diff --git a/include/i8042.h b/include/i8042.h
index 9630619..58c85ec 100644
--- a/include/i8042.h
+++ b/include/i8042.h
@@ -72,8 +72,10 @@ void i8042_flush(void);
*/
int i8042_disable(void);
+struct stdio_dev;
+
int i8042_kbd_init(void);
-int i8042_tstc(void);
-int i8042_getc(void);
+int i8042_tstc(struct stdio_dev *dev);
+int i8042_getc(struct stdio_dev *dev);
#endif /* _I8042_H_ */
diff --git a/include/ide.h b/include/ide.h
index 0424d04..c2a48e0 100644
--- a/include/ide.h
+++ b/include/ide.h
@@ -66,12 +66,16 @@ void ide_write_data(int dev, const ulong *sect_buf, int words);
/*
* I/O function overrides
*/
+unsigned char ide_inb(int dev, int port);
+void ide_outb(int dev, int port, unsigned char val);
void ide_input_swap_data(int dev, ulong *sect_buf, int words);
void ide_input_data(int dev, ulong *sect_buf, int words);
void ide_output_data(int dev, const ulong *sect_buf, int words);
void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts);
void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts);
+void ide_led(uchar led, uchar status);
+
/**
* board_start_ide() - Start up the board IDE interfac
*
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3fdfb39..35e216e 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -57,4 +57,23 @@
, __FILE__, __LINE__); }
#define PAGE_SIZE 4096
+
+/**
+ * upper_32_bits - return MSB bits 32-63 of a number if little endian, or
+ * return MSB bits 0-31 of a number if big endian.
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return LSB bits 0-31 of a number if little endian, or
+ * return LSB bits 32-63 of a number if big endian.
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
#endif
diff --git a/include/mmc.h b/include/mmc.h
index f46572e..7f5f9bc 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -327,10 +327,11 @@ struct mmc *find_mmc_device(int dev_num);
int mmc_set_dev(int dev_num);
void print_mmc_devices(char separator);
int get_mmc_num(void);
-int board_mmc_getcd(struct mmc *mmc);
int mmc_switch_part(int dev_num, unsigned int part_num);
int mmc_getcd(struct mmc *mmc);
+int board_mmc_getcd(struct mmc *mmc);
int mmc_getwp(struct mmc *mmc);
+int board_mmc_getwp(struct mmc *mmc);
int mmc_set_dsr(struct mmc *mmc, u16 val);
/* Function to change the size of boot partition and rpmb partitions */
int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
@@ -385,6 +386,7 @@ int mmc_legacy_init(int verbose);
#endif
int board_mmc_init(bd_t *bis);
+int cpu_mmc_init(bd_t *bis);
/* Set block count limit because of 16 bit register limit on some hardware*/
#ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
diff --git a/include/search.h b/include/search.h
index ae3efc4..9701efb 100644
--- a/include/search.h
+++ b/include/search.h
@@ -102,7 +102,8 @@ extern ssize_t hexport_r(struct hsearch_data *__htab,
*/
extern int himport_r(struct hsearch_data *__htab,
const char *__env, size_t __size, const char __sep,
- int __flag, int nvars, char * const vars[]);
+ int __flag, int __crlf_is_lf, int nvars,
+ char * const vars[]);
/* Walk the whole table calling the callback on each element */
extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *));
diff --git a/include/status_led.h b/include/status_led.h
index 0eb91b8..b8aaaf7 100644
--- a/include/status_led.h
+++ b/include/status_led.h
@@ -272,19 +272,21 @@ extern void __led_set (led_id_t mask, int state);
# include <asm/status_led.h>
#endif
+#endif /* CONFIG_STATUS_LED */
+
/*
* Coloured LEDs API
*/
#ifndef __ASSEMBLY__
-extern void coloured_LED_init (void);
-extern void red_led_on(void);
-extern void red_led_off(void);
-extern void green_led_on(void);
-extern void green_led_off(void);
-extern void yellow_led_on(void);
-extern void yellow_led_off(void);
-extern void blue_led_on(void);
-extern void blue_led_off(void);
+void coloured_LED_init(void);
+void red_led_on(void);
+void red_led_off(void);
+void green_led_on(void);
+void green_led_off(void);
+void yellow_led_on(void);
+void yellow_led_off(void);
+void blue_led_on(void);
+void blue_led_off(void);
#else
.extern LED_init
.extern red_led_on
@@ -297,6 +299,4 @@ extern void blue_led_off(void);
.extern blue_led_off
#endif
-#endif /* CONFIG_STATUS_LED */
-
#endif /* _STATUS_LED_H_ */
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index e6dc12a..a7d0825 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -27,18 +27,21 @@ struct stdio_dev {
/* GENERAL functions */
- int (*start) (void); /* To start the device */
- int (*stop) (void); /* To stop the device */
+ int (*start)(struct stdio_dev *dev); /* To start the device */
+ int (*stop)(struct stdio_dev *dev); /* To stop the device */
/* OUTPUT functions */
- void (*putc) (const char c); /* To put a char */
- void (*puts) (const char *s); /* To put a string (accelerator) */
+ /* To put a char */
+ void (*putc)(struct stdio_dev *dev, const char c);
+ /* To put a string (accelerator) */
+ void (*puts)(struct stdio_dev *dev, const char *s);
/* INPUT functions */
- int (*tstc) (void); /* To test if a char is ready... */
- int (*getc) (void); /* To get that char */
+ /* To test if a char is ready... */
+ int (*tstc)(struct stdio_dev *dev);
+ int (*getc)(struct stdio_dev *dev); /* To get that char */
/* Other functions */
@@ -74,10 +77,12 @@ extern char *stdio_names[MAX_FILES];
* PROTOTYPES
*/
int stdio_register (struct stdio_dev * dev);
+int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp);
int stdio_init (void);
void stdio_print_current_devices(void);
#ifdef CONFIG_SYS_STDIO_DEREGISTER
int stdio_deregister(const char *devname);
+int stdio_deregister_dev(struct stdio_dev *dev);
#endif
struct list_head* stdio_get_list(void);
struct stdio_dev* stdio_get_by_name(const char* name);
diff --git a/include/video.h b/include/video.h
index 0ff857b..673aa2e 100644
--- a/include/video.h
+++ b/include/video.h
@@ -11,9 +11,11 @@
/* Video functions */
-int video_init (void *videobase);
-void video_putc (const char c);
-void video_puts (const char *s);
+struct stdio_dev;
+
+int video_init(void *videobase);
+void video_putc(struct stdio_dev *dev, const char c);
+void video_puts(struct stdio_dev *dev, const char *s);
/**
* Display a BMP format bitmap on the screen
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c
index 6ea7b03..129bc3e 100644
--- a/lib/asm-offsets.c
+++ b/lib/asm-offsets.c
@@ -28,6 +28,9 @@ int main(void)
DEFINE(GD_SIZE, sizeof(struct global_data));
DEFINE(GD_BD, offsetof(struct global_data, bd));
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
+#endif
#if defined(CONFIG_ARM)
diff --git a/lib/div64.c b/lib/div64.c
index e688a91..795ef0e 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -16,6 +16,7 @@
* assembly versions such as arch/powerpc/lib/div64.S and arch/sh/lib/div64.S.
*/
+#include <div64.h>
#include <linux/types.h>
uint32_t __div64_32(uint64_t *n, uint32_t base)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index aaa6620..eb5aa20 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -5,9 +5,11 @@
#ifndef USE_HOSTCC
#include <common.h>
+#include <errno.h>
#include <serial.h>
#include <libfdt.h>
#include <fdtdec.h>
+#include <linux/ctype.h>
#include <asm/gpio.h>
@@ -319,6 +321,65 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
return num_found;
}
+int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
+ int *seqp)
+{
+ int base_len = strlen(base);
+ const char *find_name;
+ int find_namelen;
+ int prop_offset;
+ int aliases;
+
+ find_name = fdt_get_name(blob, offset, &find_namelen);
+ debug("Looking for '%s' at %d, name %s\n", base, offset, find_name);
+
+ aliases = fdt_path_offset(blob, "/aliases");
+ for (prop_offset = fdt_first_property_offset(blob, aliases);
+ prop_offset > 0;
+ prop_offset = fdt_next_property_offset(blob, prop_offset)) {
+ const char *prop;
+ const char *name;
+ const char *slash;
+ const char *p;
+ int len;
+
+ prop = fdt_getprop_by_offset(blob, prop_offset, &name, &len);
+ debug(" - %s, %s\n", name, prop);
+ if (len < find_namelen || *prop != '/' || prop[len - 1] ||
+ strncmp(name, base, base_len))
+ continue;
+
+ slash = strrchr(prop, '/');
+ if (strcmp(slash + 1, find_name))
+ continue;
+ for (p = name; *p; p++) {
+ if (isdigit(*p)) {
+ *seqp = simple_strtoul(p, NULL, 10);
+ debug("Found seq %d\n", *seqp);
+ return 0;
+ }
+ }
+ }
+
+ debug("Not found\n");
+ return -ENOENT;
+}
+
+int fdtdec_get_alias_node(const void *blob, const char *name)
+{
+ const char *prop;
+ int alias_node;
+ int len;
+
+ if (!blob)
+ return -FDT_ERR_NOTFOUND;
+ alias_node = fdt_path_offset(blob, "/aliases");
+ prop = fdt_getprop(blob, alias_node, name, &len);
+ if (!prop)
+ return -FDT_ERR_NOTFOUND;
+ return fdt_path_offset(blob, prop);
+}
+
int fdtdec_check_fdt(void)
{
/*
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4356b23..18ed590 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -776,7 +776,7 @@ static int drop_var_from_set(const char *name, int nvars, char * vars[])
int himport_r(struct hsearch_data *htab,
const char *env, size_t size, const char sep, int flag,
- int nvars, char * const vars[])
+ int crlf_is_lf, int nvars, char * const vars[])
{
char *data, *sp, *dp, *name, *value;
char *localvars[nvars];
@@ -841,6 +841,21 @@ int himport_r(struct hsearch_data *htab,
}
}
+ if(!size)
+ return 1; /* everything OK */
+ if(crlf_is_lf) {
+ /* Remove Carriage Returns in front of Line Feeds */
+ unsigned ignored_crs = 0;
+ for(;dp < data + size && *dp; ++dp) {
+ if(*dp == '\r' &&
+ dp < data + size - 1 && *(dp+1) == '\n')
+ ++ignored_crs;
+ else
+ *(dp-ignored_crs) = *dp;
+ }
+ size -= ignored_crs;
+ dp = data;
+ }
/* Parse environment; allow for '\0' and 'sep' as separators */
do {
ENTRY e, *rv;
diff --git a/lib/lmb.c b/lib/lmb.c
index 081e418..49a3c9e 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -332,14 +332,12 @@ int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr)
return 0;
}
-void __board_lmb_reserve(struct lmb *lmb)
+__weak void board_lmb_reserve(struct lmb *lmb)
{
/* please define platform specific board_lmb_reserve() */
}
-void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve")));
-void __arch_lmb_reserve(struct lmb *lmb)
+__weak 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")));
diff --git a/lib/sha1.c b/lib/sha1.c
index 0a5f688..05b17a2 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -389,8 +389,6 @@ void sha1_hmac(const unsigned char *key, int keylen,
memset (&ctx, 0, sizeof (sha1_context));
}
-static const char _sha1_src[] = "_sha1_src";
-
#ifdef SELF_TEST
/*
* FIPS-180-1 test vectors
diff --git a/lib/time.c b/lib/time.c
index 73c3b6a..c7b0264 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -15,12 +15,13 @@
#endif
#ifndef CONFIG_WD_PERIOD
-# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default*/
+# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default */
#endif
DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_SYS_TIMER_RATE
+/* Returns tick rate in ticks per second */
ulong notrace get_tbclk(void)
{
return CONFIG_SYS_TIMER_RATE;
@@ -51,9 +52,10 @@ unsigned long long __weak notrace get_ticks(void)
return ((unsigned long long)gd->timebase_h << 32) | gd->timebase_l;
}
-static unsigned long long notrace tick_to_time(uint64_t tick)
+/* Returns time in milliseconds */
+static unsigned long long notrace tick_to_time(unsigned long long tick)
{
- unsigned int div = get_tbclk();
+ ulong div = get_tbclk();
tick *= CONFIG_SYS_HZ;
do_div(tick, div);
@@ -65,6 +67,7 @@ int __weak timer_init(void)
return 0;
}
+/* Returns time in milliseconds */
ulong __weak get_timer(ulong base)
{
return tick_to_time(get_ticks()) - base;
@@ -74,9 +77,10 @@ unsigned long __weak notrace timer_get_us(void)
{
return tick_to_time(get_ticks() * 1000);
}
+
static unsigned long long usec_to_tick(unsigned long usec)
{
- uint64_t tick = usec;
+ unsigned long long tick = usec;
tick *= get_tbclk();
do_div(tick, 1000000);
return tick;
@@ -85,12 +89,10 @@ static unsigned long long usec_to_tick(unsigned long usec)
void __weak __udelay(unsigned long usec)
{
unsigned long long tmp;
- ulong tmo;
- tmo = usec_to_tick(usec);
- tmp = get_ticks() + tmo; /* get current timestamp */
+ tmp = get_ticks() + usec_to_tick(usec); /* get current timestamp */
- while (get_ticks() < tmp) /* loop till event */
+ while (get_ticks() < tmp+1) /* loop till event */
/*NOP*/;
}
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 60874da..7ec758e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -28,17 +28,6 @@
/* some reluctance to put this into a new limits.h, so it is here */
#define INT_MAX ((int)(~0U>>1))
-static const char hex_asc[] = "0123456789abcdef";
-#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
-#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
-
-static inline char *pack_hex_byte(char *buf, u8 byte)
-{
- *buf++ = hex_asc_hi(byte);
- *buf++ = hex_asc_lo(byte);
- return buf;
-}
-
unsigned long simple_strtoul(const char *cp, char **endp,
unsigned int base)
{
@@ -434,6 +423,17 @@ static char *string(char *buf, char *end, char *s, int field_width,
}
#ifdef CONFIG_CMD_NET
+static const char hex_asc[] = "0123456789abcdef";
+#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
+#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
+
+static inline char *pack_hex_byte(char *buf, u8 byte)
+{
+ *buf++ = hex_asc_hi(byte);
+ *buf++ = hex_asc_lo(byte);
+ return buf;
+}
+
static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
int precision, int flags)
{
diff --git a/net/bootp.c b/net/bootp.c
index 189a003..fdb97cb 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -605,7 +605,7 @@ BootpRequest(void)
int extlen, pktlen, iplen;
int eth_hdr_size;
#ifdef CONFIG_BOOTP_RANDOM_DELAY
- ulong i, rand_ms;
+ ulong rand_ms;
#endif
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start");
@@ -623,8 +623,7 @@ BootpRequest(void)
rand_ms = rand() >> 19;
printf("Random delay: %ld ms...\n", rand_ms);
- for (i = 0; i < rand_ms; i++)
- udelay(1000); /*Wait 1ms*/
+ mdelay(rand_ms);
#endif /* CONFIG_BOOTP_RANDOM_DELAY */
diff --git a/net/eth.c b/net/eth.c
index 99386e3..76ffa05 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -10,6 +10,7 @@
#include <net.h>
#include <miiphy.h>
#include <phy.h>
+#include <asm/errno.h>
void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
{
@@ -152,6 +153,11 @@ static void eth_current_changed(void)
setenv("ethact", NULL);
}
+int eth_address_set(unsigned char *addr)
+{
+ return memcmp(addr, "\0\0\0\0\0\0", 6);
+}
+
int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
int eth_number)
{
@@ -160,8 +166,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
- if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
- if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
+ if (eth_address_set(env_enetaddr)) {
+ if (eth_address_set(dev->enetaddr) &&
memcmp(dev->enetaddr, env_enetaddr, 6)) {
printf("\nWarning: %s MAC addresses don't match:\n",
dev->name);
@@ -177,14 +183,22 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
dev->enetaddr);
printf("\nWarning: %s using MAC address from net device\n",
dev->name);
+ } else if (!(eth_address_set(dev->enetaddr))) {
+ printf("\nError: %s address not set.\n",
+ dev->name);
+ return -EINVAL;
}
- if (dev->write_hwaddr &&
- !eth_mac_skip(eth_number)) {
- if (!is_valid_ether_addr(dev->enetaddr))
- return -1;
+ if (dev->write_hwaddr && !eth_mac_skip(eth_number)) {
+ if (!is_valid_ether_addr(dev->enetaddr)) {
+ printf("\nError: %s address %pM illegal value\n",
+ dev->name, dev->enetaddr);
+ return -EINVAL;
+ }
ret = dev->write_hwaddr(dev);
+ if (ret)
+ printf("\nWarning: %s failed to set MAC address\n", dev->name);
}
return ret;
@@ -303,8 +317,7 @@ int eth_initialize(bd_t *bis)
puts("\nWarning: eth device name has a space!"
"\n");
- if (eth_write_hwaddr(dev, "eth", dev->index))
- puts("\nWarning: failed to set MAC address\n");
+ eth_write_hwaddr(dev, "eth", dev->index);
dev = dev->next;
num_devices++;
diff --git a/scripts/mailmapper b/scripts/mailmapper
new file mode 100755
index 0000000..dd1ddf6
--- /dev/null
+++ b/scripts/mailmapper
@@ -0,0 +1,160 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+'''
+A tool to create/update the mailmap file
+
+The command 'git shortlog' summarizes git log output in a format suitable
+for inclusion in release announcements. Each commit will be grouped by
+author and title.
+
+One problem is that the authors' name and/or email address is sometimes
+spelled differently. The .mailmap feature can be used to coalesce together
+commits by the same persion.
+(See 'man git-shortlog' for furthur information of this feature.)
+
+This tool helps to create/update the mailmap file.
+
+It runs 'git shortlog' internally and searches differently spelled author
+names which share the same email address. The author name with the most
+commits is asuumed to be a canonical real name. If the number of commits
+from the cananonical name is equal to or greater than 'MIN_COMMITS',
+the entry for the cananical name will be output. ('MIN_COMMITS' is used
+here because we do not want to create a fat mailmap by adding every author
+with only a few commits.)
+
+If there exists a mailmap file specified by the mailmap.file configuration
+options or '.mailmap' at the toplevel of the repository, it is used as
+a base file. (The mailmap.file configuration takes precedence over the
+'.mailmap' file if both exist.)
+
+The base file and the newly added entries are merged together and sorted
+alphabetically (but the comment block is kept untouched), and then printed
+to standard output.
+
+Usage
+-----
+
+ scripts/mailmapper
+
+prints the mailmapping to standard output.
+
+ scripts/mailmapper > tmp; mv tmp .mailmap
+
+will be useful for updating '.mailmap' file.
+'''
+
+import sys
+import os
+import subprocess
+
+# The entries only for the canonical names with MIN_COMMITS or more commits.
+# This limitation is used so as not to create a too big mailmap file.
+MIN_COMMITS = 50
+
+try:
+ toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
+except subprocess.CalledProcessError:
+ print >> sys.stderr, 'Please run in a git repository.'
+ sys.exit(1)
+
+# strip '\n'
+toplevel = toplevel.rstrip()
+
+# Change the current working directory to the toplevel of the respository
+# for our easier life.
+os.chdir(toplevel)
+
+# First, create 'auther name' vs 'number of commits' database.
+# We assume the name with the most commits as the canonical real name.
+shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n'])
+
+commits_per_name = {}
+
+for line in shortlog.splitlines():
+ try:
+ commits, name = line.split(None, 1)
+ except ValueError:
+ # ignore lines with an empty author name
+ pass
+ commits_per_name[name] = int(commits)
+
+# Next, coalesce the auther names with the same email address
+shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n', '-e'])
+
+mail_vs_name = {}
+output = {}
+
+for line in shortlog.splitlines():
+ # tmp, mail = line.rsplit(None, 1) is not safe
+ # because weird email addresses might include whitespaces
+ tmp, mail = line.split('<')
+ mail = '<' + mail.rstrip()
+ try:
+ _, name = tmp.rstrip().split(None, 1)
+ except ValueError:
+ # author name is empty
+ name = ''
+ if mail in mail_vs_name:
+ # another name for the same email address
+ prev_name = mail_vs_name[mail]
+ # Take the name with more commits
+ major_name = sorted([prev_name, name],
+ key=lambda x: commits_per_name[x] if x else 0)[1]
+ mail_vs_name[mail] = major_name
+ if commits_per_name[major_name] > MIN_COMMITS:
+ output[mail] = major_name
+ else:
+ mail_vs_name[mail] = name
+
+# [1] If there exists a mailmap file at the location pointed to
+# by the mailmap.file configuration option, update it.
+# [2] If the file .mailmap exists at the toplevel of the repository, update it.
+# [3] Otherwise, create a new mailmap file.
+mailmap_files = []
+
+try:
+ config_mailmap = subprocess.check_output(['git', 'config', 'mailmap.file'])
+except subprocess.CalledProcessError:
+ config_mailmap = ''
+
+config_mailmap = config_mailmap.rstrip()
+if config_mailmap:
+ mailmap_files.append(config_mailmap)
+
+mailmap_files.append('.mailmap')
+
+infile = None
+
+for map_file in mailmap_files:
+ try:
+ infile = open(map_file)
+ except:
+ # Failed to open. Try next.
+ continue
+ break
+
+comment_block = []
+output_lines = []
+
+if infile:
+ for line in infile:
+ if line[0] == '#' or line[0] == '\n':
+ comment_block.append(line)
+ else:
+ output_lines.append(line)
+ break
+ for line in infile:
+ output_lines.append(line)
+ infile.close()
+
+for mail, name in output.items():
+ output_lines.append(name + ' ' + mail + '\n')
+
+output_lines.sort()
+
+sys.stdout.write(''.join(comment_block + output_lines))
diff --git a/test/dm/Makefile b/test/dm/Makefile
index c0f2135..5c2415e 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -5,6 +5,7 @@
#
obj-$(CONFIG_CMD_DM) += cmd_dm.o
+obj-$(CONFIG_DM_TEST) += bus.o
obj-$(CONFIG_DM_TEST) += test-driver.o
obj-$(CONFIG_DM_TEST) += test-fdt.o
obj-$(CONFIG_DM_TEST) += test-main.o
diff --git a/test/dm/bus.c b/test/dm/bus.c
new file mode 100644
index 0000000..873d64e
--- /dev/null
+++ b/test/dm/bus.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/root.h>
+#include <dm/test.h>
+#include <dm/ut.h>
+#include <dm/util.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum {
+ FLAG_CHILD_PROBED = 10,
+ FLAG_CHILD_REMOVED = -7,
+};
+
+static struct dm_test_state *test_state;
+
+static int testbus_drv_probe(struct udevice *dev)
+{
+ return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+}
+
+static int testbus_child_pre_probe(struct udevice *dev)
+{
+ struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
+
+ parent_data->flag += FLAG_CHILD_PROBED;
+
+ return 0;
+}
+
+static int testbus_child_post_remove(struct udevice *dev)
+{
+ struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
+ struct dm_test_state *dms = test_state;
+
+ parent_data->flag += FLAG_CHILD_REMOVED;
+ if (dms)
+ dms->removed = dev;
+
+ return 0;
+}
+
+static const struct udevice_id testbus_ids[] = {
+ {
+ .compatible = "denx,u-boot-test-bus",
+ .data = DM_TEST_TYPE_FIRST },
+ { }
+};
+
+U_BOOT_DRIVER(testbus_drv) = {
+ .name = "testbus_drv",
+ .of_match = testbus_ids,
+ .id = UCLASS_TEST_BUS,
+ .probe = testbus_drv_probe,
+ .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+ .platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
+ .per_child_auto_alloc_size = sizeof(struct dm_test_parent_data),
+ .child_pre_probe = testbus_child_pre_probe,
+ .child_post_remove = testbus_child_post_remove,
+};
+
+UCLASS_DRIVER(testbus) = {
+ .name = "testbus",
+ .id = UCLASS_TEST_BUS,
+};
+
+/* Test that we can probe for children */
+static int dm_test_bus_children(struct dm_test_state *dms)
+{
+ int num_devices = 4;
+ struct udevice *bus;
+ struct uclass *uc;
+
+ ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
+ ut_asserteq(num_devices, list_count_items(&uc->dev_head));
+
+ /* Probe the bus, which should yield 3 more devices */
+ ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+ num_devices += 3;
+
+ ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
+ ut_asserteq(num_devices, list_count_items(&uc->dev_head));
+
+ ut_assert(!dm_check_devices(dms, num_devices));
+
+ return 0;
+}
+DM_TEST(dm_test_bus_children, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test our functions for accessing children */
+static int dm_test_bus_children_funcs(struct dm_test_state *dms)
+{
+ const void *blob = gd->fdt_blob;
+ struct udevice *bus, *dev;
+ int node;
+
+ ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+
+ /* device_get_child() */
+ ut_assertok(device_get_child(bus, 0, &dev));
+ ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev));
+ ut_assertok(device_get_child_by_seq(bus, 5, &dev));
+ ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+ ut_asserteq_str("c-test@5", dev->name);
+
+ /* Device with sequence number 0 should be accessible */
+ ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, true, &dev));
+ ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
+ ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+ ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 0, false, &dev));
+ ut_assertok(device_get_child_by_seq(bus, 0, &dev));
+ ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+
+ /* There is no device with sequence number 2 */
+ ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, false, &dev));
+ ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, true, &dev));
+ ut_asserteq(-ENODEV, device_get_child_by_seq(bus, 2, &dev));
+
+ /* Looking for something that is not a child */
+ node = fdt_path_offset(blob, "/junk");
+ ut_asserteq(-ENODEV, device_find_child_by_of_offset(bus, node, &dev));
+ node = fdt_path_offset(blob, "/d-test");
+ ut_asserteq(-ENODEV, device_find_child_by_of_offset(bus, node, &dev));
+
+ /* Find a valid child */
+ node = fdt_path_offset(blob, "/some-bus/c-test@1");
+ ut_assertok(device_find_child_by_of_offset(bus, node, &dev));
+ ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+ ut_assertok(device_get_child_by_of_offset(bus, node, &dev));
+ ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+
+ return 0;
+}
+DM_TEST(dm_test_bus_children_funcs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that the bus can store data about each child */
+static int dm_test_bus_parent_data(struct dm_test_state *dms)
+{
+ struct dm_test_parent_data *parent_data;
+ struct udevice *bus, *dev;
+ struct uclass *uc;
+ int value;
+
+ ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+
+ /* Check that parent data is allocated */
+ ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
+ ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
+ ut_assertok(device_get_child_by_seq(bus, 0, &dev));
+ parent_data = dev_get_parentdata(dev);
+ ut_assert(NULL != parent_data);
+
+ /* Check that it starts at 0 and goes away when device is removed */
+ parent_data->sum += 5;
+ ut_asserteq(5, parent_data->sum);
+ device_remove(dev);
+ ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
+
+ /* Check that we can do this twice */
+ ut_assertok(device_get_child_by_seq(bus, 0, &dev));
+ parent_data = dev_get_parentdata(dev);
+ ut_assert(NULL != parent_data);
+ parent_data->sum += 5;
+ ut_asserteq(5, parent_data->sum);
+
+ /* Add parent data to all children */
+ ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
+ value = 5;
+ uclass_foreach_dev(dev, uc) {
+ /* Ignore these if they are not on this bus */
+ if (dev->parent != bus) {
+ ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
+ continue;
+ }
+ ut_assertok(device_probe(dev));
+ parent_data = dev_get_parentdata(dev);
+
+ parent_data->sum = value;
+ value += 5;
+ }
+
+ /* Check it is still there */
+ value = 5;
+ uclass_foreach_dev(dev, uc) {
+ /* Ignore these if they are not on this bus */
+ if (dev->parent != bus)
+ continue;
+ parent_data = dev_get_parentdata(dev);
+
+ ut_asserteq(value, parent_data->sum);
+ value += 5;
+ }
+
+ return 0;
+}
+
+DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that the bus ops are called when a child is probed/removed */
+static int dm_test_bus_parent_ops(struct dm_test_state *dms)
+{
+ struct dm_test_parent_data *parent_data;
+ struct udevice *bus, *dev;
+ struct uclass *uc;
+
+ test_state = dms;
+ ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+ ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
+
+ uclass_foreach_dev(dev, uc) {
+ /* Ignore these if they are not on this bus */
+ if (dev->parent != bus)
+ continue;
+ ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
+
+ ut_assertok(device_probe(dev));
+ parent_data = dev_get_parentdata(dev);
+ ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+ }
+
+ uclass_foreach_dev(dev, uc) {
+ /* Ignore these if they are not on this bus */
+ if (dev->parent != bus)
+ continue;
+ parent_data = dev_get_parentdata(dev);
+ ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+ ut_assertok(device_remove(dev));
+ ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
+ ut_asserteq_ptr(dms->removed, dev);
+ }
+ test_state = NULL;
+
+ return 0;
+}
+DM_TEST(dm_test_bus_parent_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c
index 96f10f3..26980d2 100644
--- a/test/dm/cmd_dm.c
+++ b/test/dm/cmd_dm.c
@@ -16,6 +16,24 @@
#include <dm/test.h>
#include <dm/uclass-internal.h>
+/**
+ * dm_display_line() - Display information about a single device
+ *
+ * Displays a single line of information with an option prefix
+ *
+ * @dev: Device to display
+ * @buf: Prefix to display at the start of the line
+ */
+static void dm_display_line(struct udevice *dev, char *buf)
+{
+ printf("%s- %c %s @ %08lx", buf,
+ dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+ dev->name, (ulong)map_to_sysmem(dev));
+ if (dev->req_seq != -1)
+ printf(", %d", dev->req_seq);
+ puts("\n");
+}
+
static int display_succ(struct udevice *in, char *buf)
{
int len;
@@ -23,10 +41,7 @@ static int display_succ(struct udevice *in, char *buf)
char local[16];
struct udevice *pos, *n, *prev = NULL;
- printf("%s- %c %s @ %08lx", buf,
- in->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
- in->name, (ulong)map_to_sysmem(in));
- puts("\n");
+ dm_display_line(in, buf);
if (list_empty(&in->child_head))
return 0;
@@ -81,12 +96,10 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
continue;
printf("uclass %d: %s\n", id, uc->uc_drv->name);
- for (ret = uclass_first_device(id, &dev);
- dev;
- ret = uclass_next_device(&dev)) {
- printf(" %c %s @ %08lx:\n",
- dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
- dev->name, (ulong)map_to_sysmem(dev));
+ if (list_empty(&uc->dev_head))
+ continue;
+ list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+ dm_display_line(dev, "");
}
puts("\n");
}
@@ -135,7 +148,7 @@ static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
dm, 2, 1, do_dm,
"Driver model low level access",
- "tree Dump driver model tree\n"
+ "tree Dump driver model tree ('*' = activated)\n"
"dm uclass Dump list of instances for each uclass"
TEST_HELP
);
diff --git a/test/dm/core.c b/test/dm/core.c
index be3646b..b0cfb42 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -25,6 +25,7 @@ enum {
TEST_INTVAL2 = 3,
TEST_INTVAL3 = 6,
TEST_INTVAL_MANUAL = 101112,
+ TEST_INTVAL_PRE_RELOC = 7,
};
static const struct dm_test_pdata test_pdata[] = {
@@ -37,6 +38,10 @@ static const struct dm_test_pdata test_pdata_manual = {
.ping_add = TEST_INTVAL_MANUAL,
};
+static const struct dm_test_pdata test_pdata_pre_reloc = {
+ .ping_add = TEST_INTVAL_PRE_RELOC,
+};
+
U_BOOT_DEVICE(dm_test_info1) = {
.name = "test_drv",
.platdata = &test_pdata[0],
@@ -57,6 +62,11 @@ static struct driver_info driver_info_manual = {
.platdata = &test_pdata_manual,
};
+static struct driver_info driver_info_pre_reloc = {
+ .name = "test_pre_reloc_drv",
+ .platdata = &test_pdata_manual,
+};
+
/* Test that binding with platdata occurs correctly */
static int dm_test_autobind(struct dm_test_state *dms)
{
@@ -71,7 +81,7 @@ static int dm_test_autobind(struct dm_test_state *dms)
ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
- ut_assertok(dm_scan_platdata());
+ ut_assertok(dm_scan_platdata(false));
/* We should have our test class now at least, plus more children */
ut_assert(1 < list_count_items(&gd->uclass_root));
@@ -106,7 +116,7 @@ static int dm_test_autoprobe(struct dm_test_state *dms)
ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
/* The root device should not be activated until needed */
- ut_assert(!(dms->root->flags & DM_FLAG_ACTIVATED));
+ ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
/*
* We should be able to find the three test devices, and they should
@@ -181,7 +191,7 @@ static int dm_test_lifecycle(struct dm_test_state *dms)
memcpy(op_count, dm_testdrv_op_count, sizeof(op_count));
- ut_assertok(device_bind_by_name(dms->root, &driver_info_manual,
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
&dev));
ut_assert(dev);
ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND]
@@ -232,15 +242,15 @@ static int dm_test_ordering(struct dm_test_state *dms)
struct udevice *dev, *dev_penultimate, *dev_last, *test_dev;
int pingret;
- ut_assertok(device_bind_by_name(dms->root, &driver_info_manual,
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
&dev));
ut_assert(dev);
/* Bind two new devices (numbers 4 and 5) */
- ut_assertok(device_bind_by_name(dms->root, &driver_info_manual,
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
&dev_penultimate));
ut_assert(dev_penultimate);
- ut_assertok(device_bind_by_name(dms->root, &driver_info_manual,
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
&dev_last));
ut_assert(dev_last);
@@ -255,7 +265,8 @@ static int dm_test_ordering(struct dm_test_state *dms)
ut_assert(dev_last == test_dev);
/* Add back the original device 3, now in position 5 */
- ut_assertok(device_bind_by_name(dms->root, &driver_info_manual, &dev));
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
+ &dev));
ut_assert(dev);
/* Try ping */
@@ -375,8 +386,8 @@ static int dm_test_leak(struct dm_test_state *dms)
if (!start.uordblks)
puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n");
- ut_assertok(dm_scan_platdata());
- ut_assertok(dm_scan_fdt(gd->fdt_blob));
+ ut_assertok(dm_scan_platdata(false));
+ ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
/* Scanning the uclass is enough to probe all the devices */
for (id = UCLASS_ROOT; id < UCLASS_COUNT; id++) {
@@ -444,8 +455,8 @@ static int create_children(struct dm_test_state *dms, struct udevice *parent,
for (i = 0; i < count; i++) {
struct dm_test_pdata *pdata;
- ut_assertok(device_bind_by_name(parent, &driver_info_manual,
- &dev));
+ ut_assertok(device_bind_by_name(parent, false,
+ &driver_info_manual, &dev));
pdata = calloc(1, sizeof(*pdata));
pdata->ping_add = key + i;
dev->platdata = pdata;
@@ -542,3 +553,34 @@ static int dm_test_children(struct dm_test_state *dms)
return 0;
}
DM_TEST(dm_test_children, 0);
+
+/* Test that pre-relocation devices work as expected */
+static int dm_test_pre_reloc(struct dm_test_state *dms)
+{
+ struct udevice *dev;
+
+ /* The normal driver should refuse to bind before relocation */
+ ut_asserteq(-EPERM, device_bind_by_name(dms->root, true,
+ &driver_info_manual, &dev));
+
+ /* But this one is marked pre-reloc */
+ ut_assertok(device_bind_by_name(dms->root, true,
+ &driver_info_pre_reloc, &dev));
+
+ return 0;
+}
+DM_TEST(dm_test_pre_reloc, 0);
+
+static int dm_test_uclass_before_ready(struct dm_test_state *dms)
+{
+ struct uclass *uc;
+
+ ut_assertok(uclass_get(UCLASS_TEST, &uc));
+
+ memset(gd, '\0', sizeof(*gd));
+ ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
+
+ return 0;
+}
+
+DM_TEST(dm_test_uclass_before_ready, 0);
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index 0f1a37b..bc6a6e7 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -144,3 +144,14 @@ U_BOOT_DRIVER(test_manual_drv) = {
.remove = test_manual_remove,
.unbind = test_manual_unbind,
};
+
+U_BOOT_DRIVER(test_pre_reloc_drv) = {
+ .name = "test_pre_reloc_drv",
+ .id = UCLASS_TEST,
+ .ops = &test_manual_ops,
+ .bind = test_manual_bind,
+ .probe = test_manual_probe,
+ .remove = test_manual_remove,
+ .unbind = test_manual_unbind,
+ .flags = DM_FLAG_PRE_RELOC,
+};
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 98e3936..cd2c389 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -39,7 +39,8 @@ static int testfdt_ofdata_to_platdata(struct udevice *dev)
pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
"ping-add", -1);
- pdata->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+ pdata->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+ "ping-expect");
return 0;
}
@@ -90,55 +91,170 @@ UCLASS_DRIVER(testfdt) = {
.id = UCLASS_TEST_FDT,
};
+int dm_check_devices(struct dm_test_state *dms, int num_devices)
+{
+ struct udevice *dev;
+ int ret;
+ int i;
+
+ /*
+ * Now check that the ping adds are what we expect. This is using the
+ * ping-add property in each node.
+ */
+ for (i = 0; i < num_devices; i++) {
+ uint32_t base;
+
+ ret = uclass_get_device(UCLASS_TEST_FDT, i, &dev);
+ ut_assert(!ret);
+
+ /*
+ * Get the 'ping-expect' property, which tells us what the
+ * ping add should be. We don't use the platdata because we
+ * want to test the code that sets that up
+ * (testfdt_drv_probe()).
+ */
+ base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+ "ping-expect");
+ debug("dev=%d, base=%d: %s\n", i, base,
+ fdt_get_name(gd->fdt_blob, dev->of_offset, NULL));
+
+ ut_assert(!dm_check_operations(dms, dev, base,
+ dev_get_priv(dev)));
+ }
+
+ return 0;
+}
+
/* Test that FDT-based binding works correctly */
static int dm_test_fdt(struct dm_test_state *dms)
{
- const int num_drivers = 3;
+ const int num_devices = 4;
struct udevice *dev;
struct uclass *uc;
int ret;
int i;
- ret = dm_scan_fdt(gd->fdt_blob);
+ ret = dm_scan_fdt(gd->fdt_blob, false);
ut_assert(!ret);
ret = uclass_get(UCLASS_TEST_FDT, &uc);
ut_assert(!ret);
- /* These are num_drivers compatible root-level device tree nodes */
- ut_asserteq(num_drivers, list_count_items(&uc->dev_head));
+ /* These are num_devices compatible root-level device tree nodes */
+ ut_asserteq(num_devices, list_count_items(&uc->dev_head));
/* Each should have no platdata / priv */
- for (i = 0; i < num_drivers; i++) {
+ for (i = 0; i < num_devices; i++) {
ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev);
ut_assert(!ret);
ut_assert(!dev_get_priv(dev));
ut_assert(!dev->platdata);
}
+ ut_assertok(dm_check_devices(dms, num_devices));
+
+ return 0;
+}
+DM_TEST(dm_test_fdt, 0);
+
+static int dm_test_fdt_pre_reloc(struct dm_test_state *dms)
+{
+ struct uclass *uc;
+ int ret;
+
+ ret = dm_scan_fdt(gd->fdt_blob, true);
+ ut_assert(!ret);
+
+ ret = uclass_get(UCLASS_TEST_FDT, &uc);
+ ut_assert(!ret);
+
+ /* These is only one pre-reloc device */
+ ut_asserteq(1, list_count_items(&uc->dev_head));
+
+ return 0;
+}
+DM_TEST(dm_test_fdt_pre_reloc, 0);
+
+/* Test that sequence numbers are allocated properly */
+static int dm_test_fdt_uclass_seq(struct dm_test_state *dms)
+{
+ struct udevice *dev;
+
+ /* A few basic santiy tests */
+ ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev));
+ ut_asserteq_str("b-test", dev->name);
+
+ ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 0, true, &dev));
+ ut_asserteq_str("a-test", dev->name);
+
+ ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5,
+ true, &dev));
+ ut_asserteq_ptr(NULL, dev);
+
+ /* Test aliases */
+ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 6, &dev));
+ ut_asserteq_str("e-test", dev->name);
+
+ ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7,
+ true, &dev));
+
/*
- * Now check that the ping adds are what we expect. This is using the
- * ping-add property in each node.
+ * Note that c-test nodes are not probed since it is not a top-level
+ * node
*/
- for (i = 0; i < num_drivers; i++) {
- uint32_t base;
+ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 3, &dev));
+ ut_asserteq_str("b-test", dev->name);
- ret = uclass_get_device(UCLASS_TEST_FDT, i, &dev);
- ut_assert(!ret);
+ /*
+ * d-test wants sequence number 3 also, but it can't have it because
+ * b-test gets it first.
+ */
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev));
+ ut_asserteq_str("d-test", dev->name);
- /*
- * Get the 'reg' property, which tells us what the ping add
- * should be. We don't use the platdata because we want
- * to test the code that sets that up (testfdt_drv_probe()).
- */
- base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
- debug("dev=%d, base=%d: %s\n", i, base,
- fdt_get_name(gd->fdt_blob, dev->of_offset, NULL));
+ /* d-test actually gets 0 */
+ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev));
+ ut_asserteq_str("d-test", dev->name);
- ut_assert(!dm_check_operations(dms, dev, base,
- dev_get_priv(dev)));
- }
+ /* initially no one wants seq 1 */
+ ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
+ &dev));
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 1, &dev));
+
+ /* But now that it is probed, we can find it */
+ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
+ ut_asserteq_str("a-test", dev->name);
return 0;
}
-DM_TEST(dm_test_fdt, 0);
+DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can find a device by device tree offset */
+static int dm_test_fdt_offset(struct dm_test_state *dms)
+{
+ const void *blob = gd->fdt_blob;
+ struct udevice *dev;
+ int node;
+
+ node = fdt_path_offset(blob, "/e-test");
+ ut_assert(node > 0);
+ ut_assertok(uclass_get_device_by_of_offset(UCLASS_TEST_FDT, node,
+ &dev));
+ ut_asserteq_str("e-test", dev->name);
+
+ /* This node should not be bound */
+ node = fdt_path_offset(blob, "/junk");
+ ut_assert(node > 0);
+ ut_asserteq(-ENODEV, uclass_get_device_by_of_offset(UCLASS_TEST_FDT,
+ node, &dev));
+
+ /* This is not a top level node so should not be probed */
+ node = fdt_path_offset(blob, "/some-bus/c-test@5");
+ ut_assert(node > 0);
+ ut_asserteq(-ENODEV, uclass_get_device_by_of_offset(UCLASS_TEST_FDT,
+ node, &dev));
+
+ return 0;
+}
+DM_TEST(dm_test_fdt_offset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index fbdae68..94ce72a 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -89,11 +89,11 @@ int dm_test_main(void)
ut_assertok(dm_test_init(dms));
if (test->flags & DM_TESTF_SCAN_PDATA)
- ut_assertok(dm_scan_platdata());
+ ut_assertok(dm_scan_platdata(false));
if (test->flags & DM_TESTF_PROBE_TEST)
ut_assertok(do_autoprobe(dms));
if (test->flags & DM_TESTF_SCAN_FDT)
- ut_assertok(dm_scan_fdt(gd->fdt_blob));
+ ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
if (test->func(dms))
break;
diff --git a/test/dm/test.dts b/test/dm/test.dts
index ec5364f..8489595 100644
--- a/test/dm/test.dts
+++ b/test/dm/test.dts
@@ -6,10 +6,22 @@
#address-cells = <1>;
#size-cells = <0>;
+ aliases {
+ console = &uart0;
+ testfdt6 = "/e-test";
+ };
+
+ uart0: serial {
+ compatible = "sandbox,serial";
+ u-boot,dm-pre-reloc;
+ };
+
a-test {
reg = <0>;
compatible = "denx,u-boot-fdt-test";
+ ping-expect = <0>;
ping-add = <0>;
+ u-boot,dm-pre-reloc;
};
junk {
@@ -24,23 +36,47 @@
b-test {
reg = <3>;
compatible = "denx,u-boot-fdt-test";
+ ping-expect = <3>;
ping-add = <3>;
};
some-bus {
#address-cells = <1>;
#size-cells = <0>;
- reg = <4>;
+ compatible = "denx,u-boot-test-bus";
+ reg = <3>;
+ ping-expect = <4>;
ping-add = <4>;
- c-test {
+ c-test@5 {
compatible = "denx,u-boot-fdt-test";
reg = <5>;
+ ping-expect = <5>;
ping-add = <5>;
};
+ c-test@0 {
+ compatible = "denx,u-boot-fdt-test";
+ reg = <0>;
+ ping-expect = <6>;
+ ping-add = <6>;
+ };
+ c-test@1 {
+ compatible = "denx,u-boot-fdt-test";
+ reg = <1>;
+ ping-expect = <7>;
+ ping-add = <7>;
+ };
};
d-test {
- reg = <6>;
+ reg = <3>;
+ ping-expect = <6>;
+ ping-add = <6>;
+ compatible = "google,another-fdt-test";
+ };
+
+ e-test {
+ reg = <3>;
+ ping-expect = <6>;
ping-add = <6>;
compatible = "google,another-fdt-test";
};
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 4a2d753..39a6e8a 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -188,7 +188,8 @@ class BuilderThread(threading.Thread):
return self.builder.do_make(commit, brd, stage, cwd, *args,
**kwargs)
- def RunCommit(self, commit_upto, brd, work_dir, do_config, force_build):
+ def RunCommit(self, commit_upto, brd, work_dir, do_config, force_build,
+ force_build_failures):
"""Build a particular commit.
If the build is already done, and we are not forcing a build, we skip
@@ -200,6 +201,8 @@ class BuilderThread(threading.Thread):
work_dir: Directory to which the source will be checked out
do_config: True to run a make <board>_config on the source
force_build: Force a build even if one was previously done
+ force_build_failures: Force a bulid if the previous result showed
+ failure
Returns:
tuple containing:
@@ -215,14 +218,20 @@ class BuilderThread(threading.Thread):
# Check if the job was already completed last time
done_file = self.builder.GetDoneFile(commit_upto, brd.target)
result.already_done = os.path.exists(done_file)
- if result.already_done and not force_build:
+ will_build = (force_build or force_build_failures or
+ not result.already_done)
+ if result.already_done and will_build:
# Get the return code from that build and use it
with open(done_file, 'r') as fd:
result.return_code = int(fd.readline())
err_file = self.builder.GetErrFile(commit_upto, brd.target)
if os.path.exists(err_file) and os.stat(err_file).st_size:
result.stderr = 'bad'
- else:
+ elif not force_build:
+ # The build passed, so no need to build it again
+ will_build = False
+
+ if will_build:
# We are going to have to build it. First, get a toolchain
if not self.toolchain:
try:
@@ -411,14 +420,17 @@ class BuilderThread(threading.Thread):
for commit_upto in range(0, len(job.commits), job.step):
result, request_config = self.RunCommit(commit_upto, brd,
work_dir, do_config,
- force_build or self.builder.force_build)
+ force_build or self.builder.force_build,
+ self.builder.force_build_failures)
failed = result.return_code or result.stderr
+ did_config = do_config
if failed and not do_config:
# If our incremental build failed, try building again
# with a reconfig.
if self.builder.force_config_on_failure:
result, request_config = self.RunCommit(commit_upto,
- brd, work_dir, True, True)
+ brd, work_dir, True, True, False)
+ did_config = True
do_config = request_config
# If we built that commit, then config is done. But if we got
@@ -435,7 +447,7 @@ class BuilderThread(threading.Thread):
# Of course this is substantially slower if there are build
# errors/warnings (e.g. 2-3x slower even if only 10% of builds
# have problems).
- if (failed and not result.already_done and not do_config and
+ if (failed and not result.already_done and not did_config and
self.builder.force_config_on_failure):
# If this build failed, try the next one with a
# reconfigure.
@@ -498,6 +510,8 @@ class Builder:
force_config_on_failure: If a commit fails for a board, disable
incremental building for the next commit we build for that
board, so that we will see all warnings/errors again.
+ force_build_failures: If a previously-built build (i.e. built on
+ a previous run of buildman) is marked as failed, rebuild it.
git_dir: Git directory containing source repository
last_line_len: Length of the last line we printed (used for erasing
it with new progress information)
@@ -578,6 +592,7 @@ class Builder:
self._complete_delay = None
self._next_delay_update = datetime.now()
self.force_config_on_failure = True
+ self.force_build_failures = False
self._step = step
self.col = terminal.Color()
diff --git a/tools/buildman/buildman.py b/tools/buildman/buildman.py
index 73a5483..0da6797 100755
--- a/tools/buildman/buildman.py
+++ b/tools/buildman/buildman.py
@@ -72,6 +72,9 @@ parser.add_option('-e', '--show_errors', action='store_true',
parser.add_option('-f', '--force-build', dest='force_build',
action='store_true', default=False,
help='Force build of boards even if already built')
+parser.add_option('-F', '--force-build-failures', dest='force_build_failures',
+ action='store_true', default=False,
+ help='Force build of previously-failed build')
parser.add_option('-d', '--detail', dest='show_detail',
action='store_true', default=False,
help='Show detailed information for each board in summary')
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index d2f4102..cfad535 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -156,6 +156,7 @@ def DoBuildman(options, args):
ShowActions(series, why_selected, selected, builder, options)
else:
builder.force_build = options.force_build
+ builder.force_build_failures = options.force_build_failures
# Work out which boards to build
board_selected = boards.GetSelectedDict()