#include <console.h>
#include <cpu.h>
#include <cpu_func.h>
+#include <cyclic.h>
+#include <display_options.h>
#include <dm.h>
#include <env.h>
#include <env_internal.h>
#include <i2c.h>
#include <init.h>
#include <initcall.h>
-#include <lcd.h>
#include <log.h>
#include <malloc.h>
#include <mapmem.h>
#include <post.h>
#include <relocate.h>
#include <serial.h>
-#ifdef CONFIG_SPL
#include <spl.h>
-#endif
#include <status_led.h>
#include <sysreset.h>
#include <timer.h>
#include <video.h>
#include <watchdog.h>
#include <asm/cache.h>
-#ifdef CONFIG_MACH_TYPE
-#include <asm/mach-types.h>
-#endif
-#if defined(CONFIG_MP) && defined(CONFIG_PPC)
-#include <asm/mp.h>
-#endif
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/sections.h>
#include <dm/root.h>
#include <linux/errno.h>
+#include <linux/log2.h>
-/*
- * Pointer to initial global data area
- *
- * Here we initialize it if needed.
- */
-#ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
-#undef XTRN_DECLARE_GLOBAL_DATA_PTR
-#define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
-DECLARE_GLOBAL_DATA_PTR = (gd_t *)(CONFIG_SYS_INIT_GD_ADDR);
-#else
DECLARE_GLOBAL_DATA_PTR;
-#endif
/*
* TODO(sjg@chromium.org): IMO this code should be
hw_watchdog_init();
puts(" Watchdog enabled\n");
# endif
- WATCHDOG_RESET();
+ schedule();
return 0;
}
int init_func_watchdog_reset(void)
{
- WATCHDOG_RESET();
+ schedule();
return 0;
}
bss_start = (ulong)&__bss_start;
bss_end = (ulong)&__bss_end;
-#ifdef CONFIG_SYS_TEXT_BASE
- text_base = CONFIG_SYS_TEXT_BASE;
+#ifdef CONFIG_TEXT_BASE
+ text_base = CONFIG_TEXT_BASE;
#else
text_base = CONFIG_SYS_MONITOR_BASE;
#endif
{
struct udevice *dev;
char status[256];
+ bool status_printed = false;
int ret;
- ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
- if (ret) {
- debug("%s: No sysreset device found (error: %d)\n",
- __func__, ret);
- /* Not all boards have sysreset drivers available during early
- * boot, so don't fail if one can't be found.
- */
- return 0;
- }
+ /* Not all boards have sysreset drivers available during early
+ * boot, so don't fail if one can't be found.
+ */
+ for (ret = uclass_first_device_check(UCLASS_SYSRESET, &dev); dev;
+ ret = uclass_next_device_check(&dev)) {
+ if (ret) {
+ debug("%s: %s sysreset device (error: %d)\n",
+ __func__, dev->name, ret);
+ continue;
+ }
- if (!sysreset_get_status(dev, status, sizeof(status)))
- printf("%s", status);
+ if (!sysreset_get_status(dev, status, sizeof(status))) {
+ printf("%s%s", status_printed ? " " : "", status);
+ status_printed = true;
+ }
+ }
+ if (status_printed)
+ printf("\n");
return 0;
}
return 0;
}
+/*
+ * From input size calculate its nearest rounded unit scale (multiply of 2^10)
+ * and value in calculated unit scale multiplied by 10 (as fractional fixed
+ * point number with one decimal digit), which is human natural format,
+ * same what uses print_size() function for displaying. Mathematically it is:
+ * round_nearest(val * 2^scale) = size * 10; where: 10 <= val < 10240.
+ *
+ * For example for size=87654321 we calculate scale=20 and val=836 which means
+ * that input has natural human format 83.6 M (mega = 2^20).
+ */
+#define compute_size_scale_val(size, scale, val) do { \
+ scale = ilog2(size) / 10 * 10; \
+ val = (10 * size + ((1ULL << scale) >> 1)) >> scale; \
+ if (val == 10240) { val = 10; scale += 10; } \
+} while (0)
+
+/*
+ * Check if the sizes in their natural units written in decimal format with
+ * one fraction number are same.
+ */
+static int sizes_near(unsigned long long size1, unsigned long long size2)
+{
+ unsigned int size1_scale, size1_val, size2_scale, size2_val;
+
+ compute_size_scale_val(size1, size1_scale, size1_val);
+ compute_size_scale_val(size2, size2_scale, size2_val);
+
+ return size1_scale == size2_scale && size1_val == size2_val;
+}
+
static int show_dram_config(void)
{
unsigned long long size;
}
debug("\nDRAM: ");
- print_size(size, "");
+ print_size(gd->ram_size, "");
+ if (!sizes_near(gd->ram_size, size)) {
+ printf(" (effective ");
+ print_size(size, ")");
+ }
board_add_ram_info(0);
putc('\n');
gd->mon_len = (ulong)&_end - (ulong)_init;
#elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
gd->mon_len = CONFIG_SYS_MONITOR_LEN;
-#elif defined(CONFIG_NDS32) || defined(CONFIG_SH) || defined(CONFIG_RISCV)
+#elif defined(CONFIG_SH) || defined(CONFIG_RISCV)
gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
#elif defined(CONFIG_SYS_MONITOR_BASE)
/* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
}
/* Get the top of usable RAM */
-__weak ulong board_get_usable_ram_top(ulong total_size)
+__weak phys_size_t board_get_usable_ram_top(phys_size_t total_size)
{
-#if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
+#if defined(CFG_SYS_SDRAM_BASE) && CFG_SYS_SDRAM_BASE > 0
/*
* Detect whether we have so much RAM that it goes past the end of our
* 32-bit address space. If so, clip the usable RAM so it doesn't.
*/
- if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
+ if (gd->ram_top < CFG_SYS_SDRAM_BASE)
/*
* Will wrap back to top of 32-bit space when reservations
* are made.
return gd->ram_top;
}
+__weak int arch_setup_dest_addr(void)
+{
+ return 0;
+}
+
static int setup_dest_addr(void)
{
debug("Monitor len: %08lX\n", gd->mon_len);
/*
* Ram is setup, size stored in gd !!
*/
- debug("Ram size: %08lX\n", (ulong)gd->ram_size);
+ debug("Ram size: %08llX\n", (unsigned long long)gd->ram_size);
#if CONFIG_VAL(SYS_MEM_TOP_HIDE)
/*
* Subtract specified amount of memory to hide so that it won't
*/
gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
#endif
-#ifdef CONFIG_SYS_SDRAM_BASE
- gd->ram_base = CONFIG_SYS_SDRAM_BASE;
+#ifdef CFG_SYS_SDRAM_BASE
+ gd->ram_base = CFG_SYS_SDRAM_BASE;
#endif
gd->ram_top = gd->ram_base + get_effective_memsize();
gd->ram_top = board_get_usable_ram_top(gd->mon_len);
gd->relocaddr = gd->ram_top;
- debug("Ram top: %08lX\n", (ulong)gd->ram_top);
-#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
- /*
- * We need to make sure the location we intend to put secondary core
- * boot code is reserved and not used by any part of u-boot
- */
- if (gd->relocaddr > determine_mp_bootpg(NULL)) {
- gd->relocaddr = determine_mp_bootpg(NULL);
- debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
- }
-#endif
- return 0;
+ debug("Ram top: %08llX\n", (unsigned long long)gd->ram_top);
+
+ return arch_setup_dest_addr();
}
-#ifdef CONFIG_PRAM
+#ifdef CFG_PRAM
/* reserve protected RAM */
static int reserve_pram(void)
{
ulong reg;
- reg = env_get_ulong("pram", 10, CONFIG_PRAM);
+ reg = env_get_ulong("pram", 10, CFG_PRAM);
gd->relocaddr -= (reg << 10); /* size is in kB */
debug("Reserving %ldk for protected RAM at %08lx\n", reg,
gd->relocaddr);
return 0;
}
-#endif /* CONFIG_PRAM */
+#endif /* CFG_PRAM */
/* Round memory pointer down to next 4 kB limit */
static int reserve_round_4k(void)
static int reserve_video(void)
{
-#ifdef CONFIG_DM_VIDEO
- ulong addr;
- int ret;
+ if (IS_ENABLED(CONFIG_VIDEO)) {
+ ulong addr;
+ int ret;
- addr = gd->relocaddr;
- ret = video_reserve(&addr);
- if (ret)
- return ret;
- debug("Reserving %luk for video at: %08lx\n",
- ((unsigned long)gd->relocaddr - addr) >> 10, addr);
- gd->relocaddr = addr;
-#elif defined(CONFIG_LCD)
-# ifdef CONFIG_FB_ADDR
- gd->fb_base = CONFIG_FB_ADDR;
-# else
- /* reserve memory for LCD display (always full pages) */
- gd->relocaddr = lcd_setmem(gd->relocaddr);
- gd->fb_base = gd->relocaddr;
-# endif /* CONFIG_FB_ADDR */
-#endif
+ addr = gd->relocaddr;
+ ret = video_reserve(&addr);
+ if (ret)
+ return ret;
+ debug("Reserving %luk for video at: %08lx\n",
+ ((unsigned long)gd->relocaddr - addr) >> 10, addr);
+ gd->relocaddr = addr;
+ }
return 0;
}
{
/*
* The value of gd->start_addr_sp must match the value of malloc_start
- * calculated in boatrd_f.c:initr_malloc(), which is passed to
- * board_r.c:mem_malloc_init() and then used by
+ * calculated in board_r.c:initr_malloc(), which is passed to
+ * dlmalloc.c:mem_malloc_init() and then used by
* cache.c:noncached_init()
*
* These calculations must match the code in cache.c:noncached_init()
bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
}
-#ifdef CONFIG_MACH_TYPE
- bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
return arch_setup_bdinfo();
}
static int setup_reloc(void)
{
if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
-#ifdef CONFIG_SYS_TEXT_BASE
+#ifdef CONFIG_TEXT_BASE
#ifdef ARM
gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
+#elif defined(CONFIG_MICROBLAZE)
+ gd->reloc_off = gd->relocaddr - (u32)_start;
#elif defined(CONFIG_M68K)
/*
* On all ColdFire arch cpu, monitor code starts always
* just after the default vector table location, so at 0x400
*/
- gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
+ gd->reloc_off = gd->relocaddr - (CONFIG_TEXT_BASE + 0x400);
#elif !defined(CONFIG_SANDBOX)
- gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
+ gd->reloc_off = gd->relocaddr - CONFIG_TEXT_BASE;
#endif
#endif
}
post_init_f,
#endif
INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_SYS_DRAM_TEST)
+#if defined(CFG_SYS_DRAM_TEST)
testdram,
-#endif /* CONFIG_SYS_DRAM_TEST */
+#endif /* CFG_SYS_DRAM_TEST */
INIT_FUNC_WATCHDOG_RESET
#ifdef CONFIG_POST
#ifdef CONFIG_OF_BOARD_FIXUP
fix_fdt,
#endif
-#ifdef CONFIG_PRAM
+#ifdef CFG_PRAM
reserve_pram,
#endif
reserve_round_4k,
do_elf_reloc_fixups,
#endif
clear_bss,
+ /*
+ * Deregister all cyclic functions before relocation, so that
+ * gd->cyclic_list does not contain any references to pre-relocation
+ * devices. Drivers will register their cyclic functions anew when the
+ * devices are probed again.
+ *
+ * This should happen as late as possible so that the window where a
+ * watchdog device is not serviced is as small as possible.
+ */
+ cyclic_unregister_all,
#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
!CONFIG_IS_ENABLED(X86_64)
jump_to_copy,