blob: 0e33f6af0b7645040fde7e888745b846464623cf [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek952d5142007-03-11 13:42:58 +01002/*
Michal Simek4e39ea82018-07-13 08:26:28 +02003 * (C) Copyright 2007-2018 Michal Simek
Michal Simek952d5142007-03-11 13:42:58 +01004 *
Michal Simek4e39ea82018-07-13 08:26:28 +02005 * Michal SIMEK <monstr@monstr.eu>
Michal Simek952d5142007-03-11 13:42:58 +01006 */
7
Shreenidhi Shediffced402018-07-15 02:34:35 +05308/*
9 * This is a board specific file. It's OK to include board specific
10 * header files
11 */
Michal Simek952d5142007-03-11 13:42:58 +010012
13#include <common.h>
Michal Simekdda9bd82007-03-30 22:52:09 +020014#include <config.h>
Simon Glassa7b51302019-11-14 12:57:46 -070015#include <init.h>
Michal Simek4e39ea82018-07-13 08:26:28 +020016#include <dm/lists.h>
Michal Simek65e915c2014-05-08 16:08:44 +020017#include <fdtdec.h>
Michal Simek360da4b2019-09-25 11:00:17 +020018#include <linux/sizes.h>
Michal Simek23ccda02013-04-24 10:01:20 +020019
Michal Simek65e915c2014-05-08 16:08:44 +020020DECLARE_GLOBAL_DATA_PTR;
21
Simon Glass2f949c32017-03-31 08:40:32 -060022int dram_init_banksize(void)
Michal Simek65e915c2014-05-08 16:08:44 +020023{
Michal Simekfdf3d802018-11-22 12:39:18 +010024 return fdtdec_setup_memory_banksize();
Michal Simek65e915c2014-05-08 16:08:44 +020025}
26
27int dram_init(void)
28{
Michal Simekfdf3d802018-11-22 12:39:18 +010029 if (fdtdec_setup_mem_size_base() != 0)
30 return -EINVAL;
Michal Simek65e915c2014-05-08 16:08:44 +020031
32 return 0;
33};
Michal Simek65e915c2014-05-08 16:08:44 +020034
Michal Simek01525242015-12-11 15:01:28 +010035int board_late_init(void)
Michal Simek9cabb362012-07-04 13:12:37 +020036{
Michal Simek360da4b2019-09-25 11:00:17 +020037 ulong max_size, lowmem_size;
38
Michal Simek4e39ea82018-07-13 08:26:28 +020039#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
40 int ret;
Shreenidhi Shedi1f8fcbb2018-07-15 02:05:40 +053041
Michal Simek4e39ea82018-07-13 08:26:28 +020042 ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
43 "reset_soft", NULL);
44 if (ret)
45 printf("Warning: No reset driver: ret=%d\n", ret);
46#endif
Michal Simek360da4b2019-09-25 11:00:17 +020047
48 if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
49 debug("Saved variables - Skipping\n");
50 return 0;
51 }
52
53 max_size = gd->start_addr_sp - CONFIG_STACK_SIZE;
54 max_size = round_down(max_size, SZ_16M);
55
56 /* Linux default LOWMEM_SIZE is 0x30000000 = 768MB */
57 lowmem_size = gd->ram_base + 768 * 1024 * 1024;
58
59 env_set_addr("initrd_high", (void *)min_t(ulong, max_size,
60 lowmem_size));
61 env_set_addr("fdt_high", (void *)min_t(ulong, max_size, lowmem_size));
62
Michal Simek01525242015-12-11 15:01:28 +010063 return 0;
Michal Simek9cabb362012-07-04 13:12:37 +020064}