Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vladimir Zapolskiy | cdbb0cf | 2016-11-28 00:15:31 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Vladimir Zapolskiy <vz@mleia.com> |
Vladimir Zapolskiy | cdbb0cf | 2016-11-28 00:15:31 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9413387 | 2019-12-28 10:44:45 -0700 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 8 | #include <asm/global_data.h> |
Vladimir Zapolskiy | cdbb0cf | 2016-11-28 00:15:31 +0200 | [diff] [blame] | 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | int dram_init(void) |
| 13 | { |
| 14 | gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, |
| 15 | CONFIG_SYS_SDRAM_SIZE); |
| 16 | |
| 17 | return 0; |
| 18 | } |
Vladimir Zapolskiy | bccf09e | 2016-11-28 00:15:32 +0200 | [diff] [blame] | 19 | |
| 20 | void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaddr) |
| 21 | { |
| 22 | void (*reloc_board_init_r)(gd_t *gd, ulong dest) = board_init_r; |
| 23 | |
| 24 | if (new_gd->reloc_off) { |
| 25 | memcpy((void *)new_gd->relocaddr, |
| 26 | (void *)(new_gd->relocaddr - new_gd->reloc_off), |
| 27 | new_gd->mon_len); |
| 28 | |
| 29 | reloc_board_init_r += new_gd->reloc_off; |
| 30 | } |
| 31 | |
| 32 | __asm__ __volatile__("mov.l %0, r15\n" : : "m" (new_gd->start_addr_sp)); |
| 33 | |
| 34 | while (1) |
| 35 | reloc_board_init_r(new_gd, 0x0); |
| 36 | } |