Merge tag 'xilinx-for-v2020.01' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/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 <dm/lists.h>
16 #include <fdtdec.h>
17 #include <linux/sizes.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 int dram_init_banksize(void)
22 {
23         return fdtdec_setup_memory_banksize();
24 }
25
26 int dram_init(void)
27 {
28         if (fdtdec_setup_mem_size_base() != 0)
29                 return -EINVAL;
30
31         return 0;
32 };
33
34 int board_late_init(void)
35 {
36         ulong max_size, lowmem_size;
37
38 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
39         int ret;
40
41         ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
42                                  "reset_soft", NULL);
43         if (ret)
44                 printf("Warning: No reset driver: ret=%d\n", ret);
45 #endif
46
47         if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
48                 debug("Saved variables - Skipping\n");
49                 return 0;
50         }
51
52         max_size = gd->start_addr_sp - CONFIG_STACK_SIZE;
53         max_size = round_down(max_size, SZ_16M);
54
55         /* Linux default LOWMEM_SIZE is 0x30000000 = 768MB */
56         lowmem_size = gd->ram_base + 768 * 1024 * 1024;
57
58         env_set_addr("initrd_high", (void *)min_t(ulong, max_size,
59                                                   lowmem_size));
60         env_set_addr("fdt_high", (void *)min_t(ulong, max_size, lowmem_size));
61
62         return 0;
63 }