common: Drop log.h from common header
[pandora-u-boot.git] / board / xilinx / microblaze-generic / microblaze-generic.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2007-2018 Michal Simek
4  *
5  * Michal SIMEK <monstr@monstr.eu>
6  */
7
8 /*
9  * This is a board specific file.  It's OK to include board specific
10  * header files
11  */
12
13 #include <common.h>
14 #include <config.h>
15 #include <env.h>
16 #include <init.h>
17 #include <log.h>
18 #include <dm/lists.h>
19 #include <fdtdec.h>
20 #include <linux/sizes.h>
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 int dram_init_banksize(void)
25 {
26         return fdtdec_setup_memory_banksize();
27 }
28
29 int dram_init(void)
30 {
31         if (fdtdec_setup_mem_size_base() != 0)
32                 return -EINVAL;
33
34         return 0;
35 };
36
37 int board_late_init(void)
38 {
39         ulong max_size, lowmem_size;
40
41 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
42         int ret;
43
44         ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
45                                  "reset_soft", NULL);
46         if (ret)
47                 printf("Warning: No reset driver: ret=%d\n", ret);
48 #endif
49
50         if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
51                 debug("Saved variables - Skipping\n");
52                 return 0;
53         }
54
55         max_size = gd->start_addr_sp - CONFIG_STACK_SIZE;
56         max_size = round_down(max_size, SZ_16M);
57
58         /* Linux default LOWMEM_SIZE is 0x30000000 = 768MB */
59         lowmem_size = gd->ram_base + 768 * 1024 * 1024;
60
61         env_set_addr("initrd_high", (void *)min_t(ulong, max_size,
62                                                   lowmem_size));
63         env_set_addr("fdt_high", (void *)min_t(ulong, max_size, lowmem_size));
64
65         return 0;
66 }