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