blob: 6fc0512ce53f58a67064fe1ca570ececfbaf7cba [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek76316a32007-03-11 13:42:58 +01002/*
Michal Simek4a693662018-07-13 08:26:28 +02003 * (C) Copyright 2007-2018 Michal Simek
Michal Simek76316a32007-03-11 13:42:58 +01004 *
Michal Simek4a693662018-07-13 08:26:28 +02005 * Michal SIMEK <monstr@monstr.eu>
Michal Simek76316a32007-03-11 13:42:58 +01006 */
7
Shreenidhi Shedi359125282018-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 Simek76316a32007-03-11 13:42:58 +010012
Michal Simek342cd092007-03-30 22:52:09 +020013#include <config.h>
Simon Glass09140112020-05-10 11:40:03 -060014#include <env.h>
Simon Glass52559322019-11-14 12:57:46 -070015#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060016#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060017#include <asm/global_data.h>
Michal Simek4a693662018-07-13 08:26:28 +020018#include <dm/lists.h>
Michal Simeke945f6d2014-05-08 16:08:44 +020019#include <fdtdec.h>
Michal Simeke0418342019-09-25 11:00:17 +020020#include <linux/sizes.h>
Michal Simek12305822020-10-23 07:54:18 +020021#include "../common/board.h"
Michal Simek4e779ad2013-04-24 10:01:20 +020022
Michal Simeke945f6d2014-05-08 16:08:44 +020023DECLARE_GLOBAL_DATA_PTR;
24
Simon Glass76b00ac2017-03-31 08:40:32 -060025int dram_init_banksize(void)
Michal Simeke945f6d2014-05-08 16:08:44 +020026{
Michal Simek656185a2018-11-22 12:39:18 +010027 return fdtdec_setup_memory_banksize();
Michal Simeke945f6d2014-05-08 16:08:44 +020028}
29
30int dram_init(void)
31{
Michal Simek656185a2018-11-22 12:39:18 +010032 if (fdtdec_setup_mem_size_base() != 0)
33 return -EINVAL;
Michal Simeke945f6d2014-05-08 16:08:44 +020034
35 return 0;
36};
Michal Simeke945f6d2014-05-08 16:08:44 +020037
Michal Simek38c47612015-12-11 15:01:28 +010038int board_late_init(void)
Michal Simek2380b8f2012-07-04 13:12:37 +020039{
Michal Simek12305822020-10-23 07:54:18 +020040 ulong max_size;
T Karthik Reddyd6242ed2020-09-22 05:18:53 -060041 u32 status = 0;
Michal Simeke0418342019-09-25 11:00:17 +020042
Simon Glassdac3ce92024-09-29 19:49:47 -060043#if !defined(CONFIG_XPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
Michal Simek4a693662018-07-13 08:26:28 +020044 int ret;
Shreenidhi Shedi6ec6f582018-07-15 02:05:40 +053045
Michal Simek4a693662018-07-13 08:26:28 +020046 ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
47 "reset_soft", NULL);
48 if (ret)
49 printf("Warning: No reset driver: ret=%d\n", ret);
50#endif
Michal Simeke0418342019-09-25 11:00:17 +020051
52 if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
53 debug("Saved variables - Skipping\n");
54 return 0;
55 }
56
57 max_size = gd->start_addr_sp - CONFIG_STACK_SIZE;
58 max_size = round_down(max_size, SZ_16M);
59
Padmarao Begari5550a152024-10-01 13:55:37 +053060 status |= env_set_hex("scriptaddr", (max_size - gd->ram_base) + SZ_2M);
T Karthik Reddyed0842d2020-09-22 05:18:54 -060061
62 status |= env_set_hex("pxefile_addr_r", max_size + SZ_1M);
63
64 status |= env_set_hex("kernel_addr_r", gd->ram_base + SZ_32M);
65
66 status |= env_set_hex("fdt_addr_r", gd->ram_base + SZ_32M - SZ_1M);
67
68 status |= env_set_hex("ramdisk_addr_r",
69 gd->ram_base + SZ_32M + SZ_4M + SZ_2M);
T Karthik Reddy57664292020-12-17 03:15:55 -070070 if (IS_ENABLED(CONFIG_MTD_NOR_FLASH))
71 status |= env_set_hex("script_offset_nor",
72 gd->bd->bi_flashstart +
73 CONFIG_BOOT_SCRIPT_OFFSET);
T Karthik Reddyd6242ed2020-09-22 05:18:53 -060074 if (status)
75 printf("%s: Saving run time variables FAILED\n", __func__);
Michal Simeke0418342019-09-25 11:00:17 +020076
Michal Simek12305822020-10-23 07:54:18 +020077 return board_late_init_xilinx();
Michal Simek2380b8f2012-07-04 13:12:37 +020078}