Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 2 | /* |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 3 | * (C) Copyright 2007-2018 Michal Simek |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 4 | * |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 5 | * Michal SIMEK <monstr@monstr.eu> |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 8 | /* |
| 9 | * This is a board specific file. It's OK to include board specific |
| 10 | * header files |
| 11 | */ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 12 | |
Michal Simek | dda9bd8 | 2007-03-30 22:52:09 +0200 | [diff] [blame] | 13 | #include <config.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 14 | #include <env.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 15 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 16 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 17 | #include <asm/global_data.h> |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 18 | #include <dm/lists.h> |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 19 | #include <fdtdec.h> |
Michal Simek | 360da4b | 2019-09-25 11:00:17 +0200 | [diff] [blame] | 20 | #include <linux/sizes.h> |
Michal Simek | 9ccfcae | 2020-10-23 07:54:18 +0200 | [diff] [blame] | 21 | #include "../common/board.h" |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 22 | |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 25 | int dram_init_banksize(void) |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 26 | { |
Michal Simek | fdf3d80 | 2018-11-22 12:39:18 +0100 | [diff] [blame] | 27 | return fdtdec_setup_memory_banksize(); |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | int dram_init(void) |
| 31 | { |
Michal Simek | fdf3d80 | 2018-11-22 12:39:18 +0100 | [diff] [blame] | 32 | if (fdtdec_setup_mem_size_base() != 0) |
| 33 | return -EINVAL; |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 34 | |
| 35 | return 0; |
| 36 | }; |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 37 | |
Michal Simek | 0152524 | 2015-12-11 15:01:28 +0100 | [diff] [blame] | 38 | int board_late_init(void) |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 39 | { |
Michal Simek | 9ccfcae | 2020-10-23 07:54:18 +0200 | [diff] [blame] | 40 | ulong max_size; |
T Karthik Reddy | 51d7815 | 2020-09-22 05:18:53 -0600 | [diff] [blame] | 41 | u32 status = 0; |
Michal Simek | 360da4b | 2019-09-25 11:00:17 +0200 | [diff] [blame] | 42 | |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 43 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE) |
| 44 | int ret; |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 45 | |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 46 | 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 Simek | 360da4b | 2019-09-25 11:00:17 +0200 | [diff] [blame] | 51 | |
| 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 | |
T Karthik Reddy | a95a5bc | 2020-09-22 05:18:54 -0600 | [diff] [blame] | 60 | status |= env_set_hex("scriptaddr", max_size + SZ_2M); |
| 61 | |
| 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 Reddy | 78aae96 | 2020-12-17 03:15:55 -0700 | [diff] [blame] | 70 | 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 Reddy | 51d7815 | 2020-09-22 05:18:53 -0600 | [diff] [blame] | 74 | if (status) |
| 75 | printf("%s: Saving run time variables FAILED\n", __func__); |
Michal Simek | 360da4b | 2019-09-25 11:00:17 +0200 | [diff] [blame] | 76 | |
Michal Simek | 9ccfcae | 2020-10-23 07:54:18 +0200 | [diff] [blame] | 77 | return board_late_init_xilinx(); |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 78 | } |