]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - arch/x86/cpu/queensbay/tnc_dram.c
omap5: Add netargs and netboot option
[karo-tx-uboot.git] / arch / x86 / cpu / queensbay / tnc_dram.c
1 /*
2  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <asm/arch/fsp/fsp_support.h>
9 #include <asm/e820.h>
10 #include <asm/post.h>
11
12 DECLARE_GLOBAL_DATA_PTR;
13
14 int dram_init(void)
15 {
16         phys_size_t ram_size = 0;
17         union hob_pointers hob;
18
19         hob.raw = gd->arch.hob_list;
20         while (!end_of_hob(hob)) {
21                 if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
22                         if (hob.res_desc->type == RES_SYS_MEM ||
23                             hob.res_desc->type == RES_MEM_RESERVED) {
24                                 ram_size += hob.res_desc->len;
25                         }
26                 }
27                 hob.raw = get_next_hob(hob);
28         }
29
30         gd->ram_size = ram_size;
31         post_code(POST_DRAM);
32
33         return 0;
34 }
35
36 void dram_init_banksize(void)
37 {
38         gd->bd->bi_dram[0].start = 0;
39         gd->bd->bi_dram[0].size = gd->ram_size;
40 }
41
42 /*
43  * This function looks for the highest region of memory lower than 4GB which
44  * has enough space for U-Boot where U-Boot is aligned on a page boundary.
45  * It overrides the default implementation found elsewhere which simply
46  * picks the end of ram, wherever that may be. The location of the stack,
47  * the relocation address, and how far U-Boot is moved by relocation are
48  * set in the global data structure.
49  */
50 ulong board_get_usable_ram_top(ulong total_size)
51 {
52         return fsp_get_usable_lowmem_top(gd->arch.hob_list);
53 }
54
55 unsigned install_e820_map(unsigned max_entries, struct e820entry *entries)
56 {
57         unsigned num_entries = 0;
58
59         union hob_pointers hob;
60
61         hob.raw = gd->arch.hob_list;
62
63         while (!end_of_hob(hob)) {
64                 if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
65                         entries[num_entries].addr = hob.res_desc->phys_start;
66                         entries[num_entries].size = hob.res_desc->len;
67
68                         if (hob.res_desc->type == RES_SYS_MEM)
69                                 entries[num_entries].type = E820_RAM;
70                         else if (hob.res_desc->type == RES_MEM_RESERVED)
71                                 entries[num_entries].type = E820_RESERVED;
72                 }
73                 hob.raw = get_next_hob(hob);
74                 num_entries++;
75         }
76
77         return num_entries;
78 }