hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * (C) Copyright 2020 Rockchip Electronics Co., Ltd.
 *
 * SPDX-License-Identifier:     GPL-2.0+
 */
 
#include <common.h>
#include <mapmem.h>
#include <malloc.h>
#include <dm/root.h>
 
DECLARE_GLOBAL_DATA_PTR;
 
static void initr_reloc(void)
{
   /* tell others: relocation done */
   gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
}
 
#ifdef CONFIG_ARM
static void initr_caches(void)
{
   icache_enable();
   dcache_enable();
}
#endif
 
static void initr_malloc(void)
{
   ulong malloc_start;
 
   /* The malloc area is immediately below the monitor copy in DRAM */
   malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
   mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
           TOTAL_MALLOC_LEN);
}
 
#ifdef CONFIG_DM
static int initr_dm(void)
{
   /* Save the pre-reloc driver model and start a new one */
   gd->dm_root_f = gd->dm_root;
   gd->dm_root = NULL;
 
   return dm_init_and_scan(false);
}
#endif
 
/*
 * The below functions are all __weak declared.
 */
int dram_init(void)
{
#if CONFIG_SYS_MALLOC_LEN > SZ_64M
   "CONFIG_SYS_MALLOC_LEN is over 64MB"
#endif
   gd->ram_size = SZ_64M; /* default */
 
   gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
   gd->bd->bi_dram[0].size  = gd->ram_size;
 
   return 0;
}
 
/* Refers to common/board_r.c */
void board_init_r(gd_t *new_gd, ulong dest_addr)
{
   initr_reloc();
#ifdef CONFIG_ARM
   initr_caches();
#endif
   initr_malloc();
#ifdef CONFIG_DM
   initr_dm();
#endif
   /* Setup chipselects, entering usb-plug mode */
   board_init();
 
   hang();
}