blob: b31fa6d70311c523075a58d5be1c7bba29858768 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vladimir Zapolskiy22d75602016-11-28 00:15:31 +02002/*
3 * Copyright (C) 2016 Vladimir Zapolskiy <vz@mleia.com>
Vladimir Zapolskiy22d75602016-11-28 00:15:31 +02004 */
5
6#include <common.h>
Simon Glass284f71b2019-12-28 10:44:45 -07007#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06008#include <asm/global_data.h>
Vladimir Zapolskiy22d75602016-11-28 00:15:31 +02009
10DECLARE_GLOBAL_DATA_PTR;
11
12int dram_init(void)
13{
Tom Rinibb4dd962022-11-16 13:10:37 -050014 gd->ram_size = get_ram_size((long *)CFG_SYS_SDRAM_BASE,
15 CFG_SYS_SDRAM_SIZE);
Vladimir Zapolskiy22d75602016-11-28 00:15:31 +020016
17 return 0;
18}
Vladimir Zapolskiy16179742016-11-28 00:15:32 +020019
20void 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}