blob: 9d84af5ef2ba20b691b32a159aacc90bf14b6249 [file] [log] [blame]
Bin Meng2229c4c2015-05-07 21:34:08 +08001/*
2 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <asm/post.h>
9#include <asm/arch/qemu.h>
10
11DECLARE_GLOBAL_DATA_PTR;
12
13int dram_init(void)
14{
15 u32 ram;
16
17 outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT);
18 ram = ((u32)inb(CMOS_DATA_PORT)) << 14;
19 outb(LOW_RAM_ADDR, CMOS_ADDR_PORT);
20 ram |= ((u32)inb(CMOS_DATA_PORT)) << 6;
21 ram += 16 * 1024;
22
23 gd->ram_size = ram * 1024;
24 post_code(POST_DRAM);
25
26 return 0;
27}
28
Simon Glass2f949c32017-03-31 08:40:32 -060029int dram_init_banksize(void)
Bin Meng2229c4c2015-05-07 21:34:08 +080030{
31 gd->bd->bi_dram[0].start = 0;
32 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060033
34 return 0;
Bin Meng2229c4c2015-05-07 21:34:08 +080035}
36
37/*
38 * This function looks for the highest region of memory lower than 4GB which
39 * has enough space for U-Boot where U-Boot is aligned on a page boundary.
40 * It overrides the default implementation found elsewhere which simply
41 * picks the end of ram, wherever that may be. The location of the stack,
42 * the relocation address, and how far U-Boot is moved by relocation are
43 * set in the global data structure.
44 */
45ulong board_get_usable_ram_top(ulong total_size)
46{
47 return gd->ram_size;
48}